예제 #1
0
파일: Kernel.c 프로젝트: Astaelan/SEMOS
void Kernel(UINT32 pMBootMagic,
            PVOID pMBoot)
{
	COMPortLogger_Initialize();
	COMPortLogger_WriteLine("See? It works!");

	VGAText_Clear(VGATEXT_ATTRIBUTES(VGATEXT_ATTRIBUTE_LIGHT_WHITE, VGATEXT_ATTRIBUTE_DARK_BLACK));
	if (!MBoot_Initialize(pMBootMagic, pMBoot)) Panic("PANIC: Bootloader did not pass valid multiboot data");

    FileSystem_Initialize();

    printf("Booting SEMOS...\n");

	GDT_Initialize();
	IDT_Initialize();
	PIC_Initialize();
	PIT_Initialize(1000);
	RTC_Initialize();

	time_t startupTime = time(NULL);
	printf("Startup @ %s\n", ctime(&startupTime));

	SystemPartition_Initialize();

    printf("CLR Runtime Initializing\n");
	logLevel = 0;

    JIT_Execute_Init();
    printf("CLR JIT Initialized\n");
	MetaData_Init();
    printf("CLR MetaData Initialized\n");
	Type_Init();
    printf("CLR Types Initialized\n");
	Heap_Init();
    printf("CLR Heap Initialized\n");
	Finalizer_Init();
    printf("CLR Finalizer Initialized\n");

	tCLIFile *cliFile = CLIFile_Load("/SYSTEM/KERNEL.EXE");
    if (cliFile) printf("Loaded Kernel.exe\n");
	INT32 retValue = CLIFile_Execute(cliFile, 0, NULL);
    printf("Executed Kernel.exe: %d\n", retValue);
    if (retValue) { }
    while (TRUE);
}
예제 #2
0
tMetaData* CLIFile_GetMetaDataForAssembly(unsigned char *pAssemblyName) {
	tFilesLoaded *pFiles;

	// Convert "mscorlib" to "corlib"
	if (strcmp(pAssemblyName, "mscorlib") == 0) {
		pAssemblyName = "corlib";
	}

	// Look in already-loaded files first
	pFiles = pFilesLoaded;
	while (pFiles != NULL) {
		tCLIFile *pCLIFile;
		tMD_Assembly *pThisAssembly;

		pCLIFile = pFiles->pCLIFile;
		// Get the assembly info - there is only ever one of these in the each file's metadata
		pThisAssembly = MetaData_GetTableRow(pCLIFile->pMetaData, MAKE_TABLE_INDEX(0x20, 1));
		if (strcmp(pAssemblyName, pThisAssembly->name) == 0) {
			// Found the correct assembly, so return its meta-data
			return pCLIFile->pMetaData;
		}
		pFiles = pFiles->pNext;
	}

	// Assembly not loaded, so load it if possible
	{
		tCLIFile *pCLIFile;
		unsigned char fileName[128];
		sprintf(fileName, "%s.dll", pAssemblyName);
		pCLIFile = CLIFile_Load(fileName);
		if (pCLIFile == NULL) {
			Crash("Cannot load required assembly file: %s", fileName);
		}
		return pCLIFile->pMetaData;
	}
}