diff --git a/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c b/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c index 26dae964913..9bf55b2a39c 100644 --- a/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c +++ b/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c @@ -127,8 +127,6 @@ VOID NTAPI FrLdrStartup(ULONG Magic) { - KernelEntryFn KernelEntryAddress = - (KernelEntryFn)(KernelEntryPoint + KernelBase); ULONG_PTR i, j, page, count; PCHAR ModHeader; boot_infos_t *LocalBootInfo = &BootInfo; @@ -136,6 +134,8 @@ FrLdrStartup(ULONG Magic) LoaderBlock.ArchExtra = (ULONG)LocalBootInfo; ppc_map_info_t *info = MmAllocateMemory(0x80 * sizeof(*info)); + printf("FrLdrStartup(KernelEntry = %x)\n", KernelEntryPoint); + for(i = 0; i < LoaderBlock.ModsCount; i++) { ModHeader = ((PCHAR)reactos_modules[i].ModStart); @@ -145,19 +145,28 @@ FrLdrStartup(ULONG Magic) (PCHAR)reactos_modules[i].String); } + printf("PpcInitializeMmu\n"); PpcInitializeMmu(0); + printf("PpcInitializeMmu done\n"); /* We'll use vsid 1 for freeldr (expendable) */ MmuAllocVsid(1, 0xff); + printf("(1)\n"); MmuSetVsid(0, 8, 1); + printf("(2)\n"); MmuAllocVsid(0, 0xff00); + printf("(3)\n"); MmuSetVsid(8, 16, 0); + printf("(4)\n"); + printf("MmuSetTrapHandler\n"); MmuSetTrapHandler(3, MmuPageMiss); MmuSetTrapHandler(4, MmuPageMiss); + printf("MmuSetTrapHandler done\n"); info = MmAllocateMemory((KernelMemorySize >> PAGE_SHIFT) * sizeof(*info)); + printf("page info at %x\n", info); /* Map kernel space 0x80000000 ... */ for( i = (ULONG)KernelMemory, page = 0; @@ -169,11 +178,14 @@ FrLdrStartup(ULONG Magic) info[page].flags = MMU_ALL_RW; } + printf("Adding page info (%d pages)\n", page); MmuMapPage(info, page); + printf("Adding page info (%d pages) ... done\n", page); /* Map module name strings */ for( count = 0, i = 0; i < LoaderBlock.ModsCount; i++ ) { + printf("Checking string %s\n", reactos_modules[i].String); page = ROUND_DOWN(((ULONG)reactos_modules[i].String), (1<OptionalHeader.SizeOfImage); - KernelEntryPoint = SWAPD(NtHeader->OptionalHeader.AddressOfEntryPoint); printf("Total image size is %x\n", ImageSize); /* Handle relocation sections */ @@ -689,17 +707,21 @@ PVOID NTAPI FrLdrMapImage(IN FILE *Image, IN PCHAR ShortName, IN ULONG ImageType) { - PVOID Result; + PVOID Result = NULL; + + printf("Loading image %s (type %d)\n", ShortName, ImageType); if (ImageType == 1) { if(FrLdrMapKernel(Image)) - return (PVOID)KernelMemory; - else - return NULL; + Result = (PVOID)KernelMemory; } else - Result = (PVOID)FrLdrLoadModule(Image, ShortName, NULL); + { + PVOID ModuleBase = (PVOID)NextModuleBase; + if(FrLdrMapModule(Image, ShortName, 0, 0)) + Result = ModuleBase; + } return Result; } diff --git a/reactos/lib/ppcmmu/mmuobject.c b/reactos/lib/ppcmmu/mmuobject.c index e01fc80edee..35d928d913d 100644 --- a/reactos/lib/ppcmmu/mmuobject.c +++ b/reactos/lib/ppcmmu/mmuobject.c @@ -73,7 +73,6 @@ void TakeException(int n, ppc_trap_frame_t *tf); int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf) { - void (*fun)(void *) = arg1; ppc_trap_frame_t *trap_frame = (action >= 0x100) ? tf : arg1; int ret = 0; @@ -84,14 +83,14 @@ int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf) if(!ptegreload(trap_frame, trap_frame->dar)) { __asm__("mfmsr 3\n\tori 3,3,0x30\n\tmtmsr 3\n\t"); - if (!callback[action](action,trap_frame)) hang(action, trap_frame); + if (!callback[action](action,trap_frame)) TakeException(action, trap_frame); } break; case 4: if(!ptegreload(trap_frame, trap_frame->srr0)) { __asm__("mfmsr 3\n\tori 3,3,0x30\n\tmtmsr 3\n\t"); - if (!callback[action](action,trap_frame)) hang(action, trap_frame); + if (!callback[action](action,trap_frame)) TakeException(action, trap_frame); } break; @@ -141,16 +140,7 @@ int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf) ret = mmunitest(); break; case 0x107: - __asm__("mfmsr 3\n\t" - "ori 3,3,0x30\n\t" - "mtmsr 3\n\t" - "mtsdr1 %0\n\t" - "mr 0,%2\n\t" - "mtctr 0\n\t" - "mr 3,%1\n\t" - "bctrl\n\t" - : : "r" (HTABORG), "r" (arg2), "r" (fun)); - /* BYE ! */ + callkernel(arg1, arg2); break; case 0x108: mmusetramsize((paddr_t)arg1); @@ -423,7 +413,7 @@ void mmufreevsid(int vsid, int mask) for(i = 0; i < 16; i++) { if(mask & (1 << i)) - allocvsid((vsid << 4) + i); + freevsid((vsid << 4) + i); } } @@ -602,3 +592,18 @@ int ptegreload(ppc_trap_frame_t *frame, vaddr_t addr) __asm__("tlbie %0\n\tsync\n\tisync" : : "r" (addr)); return 1; } + +void callkernel(void *fun_ptr, void *arg) +{ + void (*fun)(void *) = fun_ptr; + __asm__("mfmsr 3\n\t" + "ori 3,3,0x30\n\t" + "mtmsr 3\n\t" + "mtsdr1 %0\n\t" + "mr 0,%2\n\t" + "mtctr 0\n\t" + "mr 3,%1\n\t" + "bctrl\n\t" + : : "r" (HTABORG), "r" (arg), "r" (fun)); + /* BYE ! */ +} diff --git a/reactos/lib/ppcmmu/mmuobject.h b/reactos/lib/ppcmmu/mmuobject.h index 6a82edc4013..9689746ff0a 100644 --- a/reactos/lib/ppcmmu/mmuobject.h +++ b/reactos/lib/ppcmmu/mmuobject.h @@ -12,5 +12,6 @@ void mmuallocvsid(int vsid, int mask); void freevsid(int); void mmufreevsid(int vsid, int mask); int mmunitest(); +void callkernel(void *fun_ptr, void *arg); #endif/*_LIBMMU_MMUOBJECT_H*/