aboutsummaryrefslogtreecommitdiff
path: root/kernel.c
blob: fc629e1f4a6916341ae4ab34638c908b15ca7452 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "uart.h"
#include "demo_functionality.h"
#include "paging.h"

void kernel_main(uint32_t r0, uint32_t r1, uint32_t atags)
{
  // Declare as unused
  (void) r0;
  (void) r1;
  (void) atags;

  uart_init();

  // When we attach screen session after loading kernel with socat
  // we miss kernel's greeting... So we'll make the kernel wait for
  // one char we're going to send from within screen
  uart_getc();
  
  uart_puts("Hello, kernel World!\r\n");

  // prints some info
  demo_paging_support();

  // prints some info
  demo_current_mode();

  // prints some info and sets upp translation table, turns on MMU
  setup_flat_map();

  demo_setup_libkernel();

  demo_setup_PL0();

  demo_setup_interrupts();
  
  // prints some info and sets up a section for PL0 code, loads a blob
  // there and jumps to it... never, ever, ever returns
  demo_go_unprivileged();
  
  while(1);
  
  while (1)
    {
      char c = uart_getc();

      uart_putc(c);
      
      if (c == '\r')
	uart_putc('\n');
    }
}