root/kernel/main.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 #include "types.h"
   2 #include "param.h"
   3 #include "memlayout.h"
   4 #include "riscv.h"
   5 #include "defs.h"
   6 
   7 volatile static int started = 0;
   8 
   9 // start() jumps here in supervisor mode on all CPUs.
  10 void
  11 main()
  12 {
  13   if(cpuid() == 0){
  14     consoleinit();
  15     printfinit();
  16     printf("\n");
  17     printf("xv6 kernel is booting\n");
  18     printf("\n");
  19     kinit();         // physical page allocator
  20     kvminit();       // create kernel page table
  21     kvminithart();   // turn on paging
  22     procinit();      // process table
  23     trapinit();      // trap vectors
  24     trapinithart();  // install kernel trap vector
  25     plicinit();      // set up interrupt controller
  26     plicinithart();  // ask PLIC for device interrupts
  27     binit();         // buffer cache
  28     iinit();         // inode table
  29     fileinit();      // file table
  30     virtio_disk_init(); // emulated hard disk
  31     userinit();      // first user process
  32     __sync_synchronize();
  33     started = 1;
  34   } else {
  35     while(started == 0)
  36       ;
  37     __sync_synchronize();
  38     printf("hart %d starting\n", cpuid());
  39     kvminithart();    // turn on paging
  40     trapinithart();   // install kernel trap vector
  41     plicinithart();   // ask PLIC for device interrupts
  42   }
  43 
  44   scheduler();        
  45 }

/* [<][>][^][v][top][bottom][index][help] */