You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			74 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
| #include "startup.h"
 | |
| 
 | |
| #include "../arch/acpi.h"
 | |
| #include "../arch/apic.h"
 | |
| #include "../arch/core.h"
 | |
| #include "../arch/idt.h"
 | |
| #include "../arch/pic.h"
 | |
| #include "../compiler/libc.h"
 | |
| #include "../debug/output.h"
 | |
| #include "../interrupt/handlers.h"
 | |
| 
 | |
| /*! \brief The first processor is the Bootstrap Processor (BSP)
 | |
|  */
 | |
| static bool isBootstrapProcessor = true;
 | |
| 
 | |
| extern "C" [[noreturn]] void kernel_init() {
 | |
|   if (isBootstrapProcessor) {
 | |
|     isBootstrapProcessor = false;
 | |
|     // Setup and load Interrupt Description Table (IDT)
 | |
|     initInterruptHandlers();
 | |
| 
 | |
|     // Initialize PICs
 | |
|     PIC::initialize();
 | |
| 
 | |
|     // Call global constructors
 | |
|     CSU::initializer();
 | |
| 
 | |
|     // Initialize ACPI
 | |
|     if (!ACPI::init()) {
 | |
|       DBG_VERBOSE << "No ACPI!";
 | |
|       Core::die();
 | |
|     }
 | |
|     // Initialize APIC (using ACPI)
 | |
|     if (!APIC::init()) {
 | |
|       DBG_VERBOSE << "APIC Initialization failed";
 | |
|       Core::die();
 | |
|     }
 | |
| 
 | |
|     // Initialize the Bootstrap Processor
 | |
|     Core::init();
 | |
| 
 | |
|     // Go to main function
 | |
|     main();
 | |
| 
 | |
|     // Exit CPU
 | |
|     DBG_VERBOSE << "CPU core " << Core::getID() << " (BSP) shutdown." << endl;
 | |
|     Core::exit();
 | |
|   } else {
 | |
|     // Load Interrupt Description Table (IDT)
 | |
|     IDT::load();
 | |
| 
 | |
|     // Initialize this application processor
 | |
|     Core::init();
 | |
| 
 | |
|     // And call the AP main
 | |
|     main_ap();
 | |
| 
 | |
|     // Exit CPU
 | |
|     DBG_VERBOSE << "CPU core " << Core::getID() << " (AP) shutdown." << endl;
 | |
|     Core::exit();
 | |
|   }
 | |
| 
 | |
|   // Only on last core
 | |
|   if (Core::countOnline() == 1) {
 | |
|     // Call global destructors
 | |
|     CSU::finalizer();
 | |
|   }
 | |
| 
 | |
|   // wait forever
 | |
|   while (true) {
 | |
|     Core::die();
 | |
|   }
 | |
| }
 |