《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1020 B

  1. #include <defs.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <console.h>
  5. #include <kdebug.h>
  6. #include <picirq.h>
  7. #include <trap.h>
  8. #include <clock.h>
  9. #include <intr.h>
  10. #include <pmm.h>
  11. #include <proc.h>
  12. #include <kmonitor.h>
  13. int kern_init(void) __attribute__((noreturn));
  14. void grade_backtrace(void);
  15. int
  16. kern_init(void) {
  17. extern char edata[], end[];
  18. memset(edata, 0, end - edata);
  19. cons_init(); // init the console
  20. const char *message = "(THU.CST) os is loading ...";
  21. cprintf("%s\n\n", message);
  22. print_kerninfo();
  23. pmm_init(); // init physical memory management
  24. pic_init(); // init interrupt controller
  25. idt_init(); // init interrupt descriptor table
  26. proc_init(); // init process table
  27. clock_init(); // init clock interrupt
  28. intr_enable(); // enable irq interrupt
  29. schedule(); //let init proc run
  30. while (do_wait(1, NULL) == 0) {
  31. schedule();
  32. }
  33. }