Changeset 538 for Whitix/branches/hybrid/kernel/module.c
- Timestamp:
- 05/24/08 09:54:46 (6 months ago)
- Files:
-
- 1 modified
-
Whitix/branches/hybrid/kernel/module.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/hybrid/kernel/module.c
r490 r538 29 29 #include <sys.h> 30 30 #include <task.h> 31 #include <imports.h> 31 32 32 33 LIST_HEAD(moduleList); 34 35 static struct Module bootModules[20]; 36 int bootIndex=0; 33 37 34 38 #define MODULE_START 0xD8000000 … … 83 87 84 88 if (name) 85 printf("%s+%#X/%#X\n", name, offset, size);89 KePrint("%s+%#X/%#X\n", name, offset, size); 86 90 else 87 printf("%#X\n", address);91 KePrint("%#X\n", address); 88 92 }else 89 printf("%#X\n", address);93 KePrint("%#X\n", address); 90 94 } 91 95 … … 106 110 void ModuleSymbolPrint(DWORD address) 107 111 { 108 printf("%#X\n", address);112 KePrint("%#X\n", address); 109 113 } 110 114 … … 148 152 } 149 153 150 printf("Could not resolve %s\n", name);154 KePrint("Could not resolve %s\n", name); 151 155 152 156 return 0; … … 191 195 break; 192 196 193 printf("Could not resolve %s\n", symName);197 KePrint("Could not resolve %s\n", symName); 194 198 return -ENOENT; 195 199 … … 200 204 /* Common symbols aren't supported by the module loading code. */ 201 205 case STN_COMMON: 202 printf("Please recompile the module with -fno-common.\n");206 KePrint("Please recompile the module with -fno-common.\n"); 203 207 return -ENOENT; 204 208 … … 240 244 241 245 default: 242 printf("ModuleSymbolResolve: type = %u, %u\n", ELF_R_TYPE(reloc->info), symbol->symIndex);246 KePrint("ModuleSymbolResolve: type = %u, %u\n", ELF_R_TYPE(reloc->info), symbol->symIndex); 243 247 } 244 248 } … … 286 290 287 291 /* Get basic information about the module. */ 288 module=(struct Module*)malloc(sizeof(struct Module)); 292 if (MemAlloc) 293 module=(struct Module*)MemAlloc(sizeof(struct Module)); 294 else 295 module=&bootModules[bootIndex++]; 296 289 297 module->loadAddr=loadAddr; 290 298 module->sectionHeaders=sectionHeaders; … … 362 370 } 363 371 372 #define SYS_MODULE_BASE 51 373 374 int SysModuleAdd(void* data, unsigned long length); 375 int SysModuleRemove(const char* name); 376 377 struct SysCall moduleSysCalls[]={ 378 { SysModuleAdd, 8 }, 379 { SysModuleRemove, 4}, 380 { 0, 0 } 381 }; 382 383 void ModulesBootLoad() 384 { 385 /* The modules are located above the kernel in memory. */ 386 BYTE* numModules=(BYTE*)0x2FFFF; 387 int i=0; 388 DWORD* length=(DWORD*)0x40000; 389 char* names=(char*)0x30000; 390 391 for (i=0; i<*numModules; i++) 392 { 393 /* Load each module, one at a time. */ 394 BYTE* data=(BYTE*)(length+1); 395 void* kData=(void*)VirtMapPhysRange(MODULE_START, MODULE_END, PAGE_ALIGN_UP(*length) >> PAGE_SHIFT, 3); 396 char buf[32]; 397 398 int j=0; 399 400 while (names[j] != '\n') 401 j++; 402 403 names[j]='\0'; 404 405 strcpy(buf, names); 406 strcat(buf, ".sys"); 407 408 if (ModuleAdd(data, kData, *length, 0)) 409 KernelPanic("Could not initialize the kernel"); 410 411 KePrint("MODULES: Loaded %s, %dkb\n", buf, (*length)/1024); 412 413 names+=strlen(names)+1; 414 415 length+=(*length/4)+1; 416 } 417 418 /* Free the low pages. */ 419 420 /* Add the calls to the system table. */ 421 SysRegisterRange(SYS_MODULE_BASE, moduleSysCalls); 422 } 423 364 424 int SysModuleAdd(void* data, unsigned long length) 365 425 { … … 374 434 int SysModuleRemove(const char* name) 375 435 { 376 printf("SysModuleRemove\n");436 KePrint("SysModuleRemove\n"); 377 437 return 0; 378 438 }