kernel.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2011-2017 Richard Braun.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <kern/init.h>
  18. #include <kern/kernel.h>
  19. #include <kern/log.h>
  20. #include <kern/thread.h>
  21. #include <machine/cpu.h>
  22. #include <test/test.h>
  23. #include <vm/page.h>
  24. void __init
  25. kernel_main (void)
  26. {
  27. assert (!cpu_intr_enabled ());
  28. init_setup ();
  29. vm_page_info (log_stream_info ());
  30. #ifdef CONFIG_RUN_TEST
  31. test_setup ();
  32. #endif
  33. /*
  34. * Enabling application processors is done late in the boot process for
  35. * two reasons :
  36. * - It's much simpler to bootstrap with interrupts disabled on all
  37. * processors, enabling them only when necessary on the BSP.
  38. * - Depending on the architecture, the pmap module could create per
  39. * processor page tables. Once done, keeping the kernel page tables
  40. * synchronized requires interrupts (and potentially scheduling)
  41. * enabled on all processors.
  42. *
  43. * It is highly recommended not to do anything else than starting the
  44. * scheduler right after this call.
  45. */
  46. cpu_mp_setup ();
  47. thread_run_scheduler ();
  48. __builtin_unreachable ();
  49. }
  50. void __init
  51. kernel_ap_main (void)
  52. {
  53. assert (!cpu_intr_enabled ());
  54. thread_run_scheduler ();
  55. }