96 #include "pedigree/kernel/Archive.h" 97 #include "pedigree/kernel/BootstrapInfo.h" 98 #include "pedigree/kernel/Log.h" 99 #include "pedigree/kernel/Version.h" 100 #include "pedigree/kernel/compiler.h" 101 #include "pedigree/kernel/core/BootIO.h" 102 #include "pedigree/kernel/core/SlamAllocator.h" 103 #include "pedigree/kernel/core/cppsupport.h" 105 #include "pedigree/kernel/linker/KernelElf.h" 106 #include "pedigree/kernel/machine/InputManager.h" 107 #include "pedigree/kernel/machine/Machine.h" 108 #include "pedigree/kernel/machine/Trace.h" 109 #include "pedigree/kernel/panic.h" 110 #include "pedigree/kernel/process/InfoBlock.h" 111 #include "pedigree/kernel/process/MemoryPressureKiller.h" 112 #include "pedigree/kernel/process/MemoryPressureManager.h" 113 #include "pedigree/kernel/process/PerProcessorScheduler.h" 114 #include "pedigree/kernel/process/Scheduler.h" 115 #include "pedigree/kernel/process/Thread.h" 116 #include "pedigree/kernel/processor/KernelCoreSyscallManager.h" 117 #include "pedigree/kernel/processor/Processor.h" 118 #include "pedigree/kernel/processor/ProcessorInformation.h" 119 #include "pedigree/kernel/processor/types.h" 120 #include "pedigree/kernel/utilities/Cache.h" 121 #include "pedigree/kernel/utilities/StaticString.h" 122 #include "pedigree/kernel/utilities/String.h" 123 #include "pedigree/kernel/utilities/new" 126 #include "pedigree/kernel/debugger/Debugger.h" 127 #include "pedigree/kernel/debugger/commands/LocksCommand.h" 131 #include "pedigree/kernel/machine/openfirmware/Device.h" 135 #include "pedigree/kernel/utilities/ZombieQueue.h" 156 virtual const String getMemoryPressureDescription();
157 virtual bool compact();
160 #ifdef MULTIPROCESSOR 185 #ifdef STATIC_DRIVERS 186 extern uintptr_t start_modinfo;
187 extern uintptr_t end_modinfo;
189 extern uintptr_t start_module_ctors;
190 extern uintptr_t end_module_ctors;
194 static int loadModules(
void *inf)
196 #ifdef STATIC_DRIVERS 197 ModuleInfo *tags =
reinterpret_cast<ModuleInfo *
>(&start_modinfo);
198 ModuleInfo *lasttag =
reinterpret_cast<ModuleInfo *
>(&end_modinfo);
202 uintptr_t *iterator = &start_module_ctors;
203 while (iterator < &end_module_ctors)
205 void (*fp)(void) =
reinterpret_cast<void (*)(
void)
>(*iterator);
211 while (tags < lasttag)
213 if (tags->tag == MODULE_TAG)
228 Archive initrd(bsInf.getInitrdAddress(), bsInf.getInitrdSize());
231 g_BootProgressTotal =
233 for (
size_t i = 0; i < nFiles; i++)
237 reinterpret_cast<uint8_t *>(initrd.getFile(i)),
238 initrd.getFileSize(i));
240 WARNING(
"A loaded module disabled interrupts.");
258 FATAL(
"At least one module's dependencies were never met.");
262 fprintf(stderr,
"Pedigree has started: all modules have been loaded.\n");
272 TRACE(
"constructors");
275 initialiseConstructors();
277 g_pBootstrapInfo = &bsInf;
280 g_LocksCommand.setReady();
283 TRACE(
"Processor init");
293 TRACE(
"Machine init");
296 Machine &machine = Machine::instance();
301 #if defined(DEBUGGER) 302 TRACE(
"Debugger init");
306 TRACE(
"Machine init2");
315 TRACE(
"Processor init2");
321 TRACE(
"Machine init3");
325 TRACE(
"KernelElf init");
329 panic(
"KernelElf::initialise() failed");
331 #ifndef STATIC_DRIVERS // initrd needed if drivers aren't statically linked. 332 if (bsInf.isInitrdLoaded() ==
false)
333 panic(
"Initrd module not loaded!");
336 TRACE(
"kernel syscall init");
340 TRACE(
"initial init done, enabling interrupts");
344 TRACE(
"bootIO init");
351 str +=
"Pedigree - revision ";
352 str += g_pBuildRevision;
353 #ifndef DONT_LOG_TO_SERIAL 354 str +=
"\r\n=======================\r\n";
356 str +=
"\n=======================\n";
358 bootIO.
write(str, BootIO::White, BootIO::Black);
366 str += g_pBuildMachine;
367 #ifndef DONT_LOG_TO_SERIAL 372 bootIO.
write(str, BootIO::LightGrey, BootIO::Black);
375 str +=
"Build flags: ";
376 str += g_pBuildFlags;
377 #ifndef DONT_LOG_TO_SERIAL 382 bootIO.
write(str, BootIO::LightGrey, BootIO::Black);
385 str +=
"Processor information: ";
388 #ifndef DONT_LOG_TO_SERIAL 393 bootIO.
write(str, BootIO::LightGrey, BootIO::Black);
395 TRACE(
"creating graphics service");
404 String(
"graphics"), pService, pFeatures);
407 TRACE(
"creating memory pressure handlers");
412 MemoryPressureManager::HighestPriority, &recovery);
417 MemoryPressureManager::LowestPriority, &killer);
420 TRACE(
"InfoBlockManager init");
421 InfoBlockManager::instance().initialise();
424 TRACE(
"CacheManager init");
428 TRACE(
"InputManager init");
432 TRACE(
"ZombieQueue init");
438 TRACE(
"starting module load thread");
443 static_cast<void *>(&bsInf), 0);
449 #ifdef DEBUGGER_RUN_AT_START 453 TRACE(
"becoming idle");
480 #ifdef MULTIPROCESSOR 481 Machine::instance().stopAllOtherProcessors();
490 NOTICE(
"All modules unloaded. Running destructors and terminating...");
491 runKernelDestructors();
497 Machine::instance().deinitialise();
508 const String SlamRecovery::getMemoryPressureDescription()
510 return String(
"SLAM recovery; freeing unused slabs.");
515 return SlamAllocator::instance().recovery(5) != 0;
Bootstrap structure passed to the kernel entry point.
static bool getInterrupts()
EXPORTED_PUBLIC void write(T &str, Colour foreColour, Colour backColour)
static void initialise2(const BootstrapStruct_t &Info) INITIALISATION_ONLY
second/last stage in the initialisation of the processor-specific interface
static Debugger & instance()
Module * loadModule(uint8_t *pModule, size_t len, bool silent=false)
virtual void initialiseDeviceTree()
static void initialisationDone()
void waitForModulesToLoad()
static ProcessorInformation & information()
static KernelElf & instance()
static void initialise1(const BootstrapStruct_t &Info) INITIALISATION_ONLY
first stage in the initialisation of the processor-specific interface
virtual void initialise2()
Called after debugger startup.
static Scheduler & instance()
static KernelCoreSyscallManager & instance()
static void haltUntilInterrupt()
static void deinitialise()
static void setInterrupts(bool bEnable)
static void identify(HugeStaticString &str)
virtual void initialise3()
Called after processor startup - for thread creation etc.
static EXPORTED_PUBLIC Log & instance()
virtual void initialise()
void addService(const String &serviceName, Service *s, ServiceFeatures *feats)
void EXPORTED_PUBLIC panic(const char *msg) NORETURN
void executeModules(bool silent=false, bool progress=true)
virtual void initialise()=0
void registerHandler(size_t prio, MemoryPressureHandler *pHandler)