Remaining fixes from branch transition. MmuTurnOn, now with GDB stub.

svn path=/trunk/; revision=29894
This commit is contained in:
Art Yerkes 2007-10-26 06:37:52 +00:00
parent e40b261ed9
commit f6640c9b72
3 changed files with 51 additions and 23 deletions

View file

@ -127,8 +127,6 @@ VOID
NTAPI NTAPI
FrLdrStartup(ULONG Magic) FrLdrStartup(ULONG Magic)
{ {
KernelEntryFn KernelEntryAddress =
(KernelEntryFn)(KernelEntryPoint + KernelBase);
ULONG_PTR i, j, page, count; ULONG_PTR i, j, page, count;
PCHAR ModHeader; PCHAR ModHeader;
boot_infos_t *LocalBootInfo = &BootInfo; boot_infos_t *LocalBootInfo = &BootInfo;
@ -136,6 +134,8 @@ FrLdrStartup(ULONG Magic)
LoaderBlock.ArchExtra = (ULONG)LocalBootInfo; LoaderBlock.ArchExtra = (ULONG)LocalBootInfo;
ppc_map_info_t *info = MmAllocateMemory(0x80 * sizeof(*info)); ppc_map_info_t *info = MmAllocateMemory(0x80 * sizeof(*info));
printf("FrLdrStartup(KernelEntry = %x)\n", KernelEntryPoint);
for(i = 0; i < LoaderBlock.ModsCount; i++) for(i = 0; i < LoaderBlock.ModsCount; i++)
{ {
ModHeader = ((PCHAR)reactos_modules[i].ModStart); ModHeader = ((PCHAR)reactos_modules[i].ModStart);
@ -145,19 +145,28 @@ FrLdrStartup(ULONG Magic)
(PCHAR)reactos_modules[i].String); (PCHAR)reactos_modules[i].String);
} }
printf("PpcInitializeMmu\n");
PpcInitializeMmu(0); PpcInitializeMmu(0);
printf("PpcInitializeMmu done\n");
/* We'll use vsid 1 for freeldr (expendable) */ /* We'll use vsid 1 for freeldr (expendable) */
MmuAllocVsid(1, 0xff); MmuAllocVsid(1, 0xff);
printf("(1)\n");
MmuSetVsid(0, 8, 1); MmuSetVsid(0, 8, 1);
printf("(2)\n");
MmuAllocVsid(0, 0xff00); MmuAllocVsid(0, 0xff00);
printf("(3)\n");
MmuSetVsid(8, 16, 0); MmuSetVsid(8, 16, 0);
printf("(4)\n");
printf("MmuSetTrapHandler\n");
MmuSetTrapHandler(3, MmuPageMiss); MmuSetTrapHandler(3, MmuPageMiss);
MmuSetTrapHandler(4, MmuPageMiss); MmuSetTrapHandler(4, MmuPageMiss);
printf("MmuSetTrapHandler done\n");
info = MmAllocateMemory((KernelMemorySize >> PAGE_SHIFT) * sizeof(*info)); info = MmAllocateMemory((KernelMemorySize >> PAGE_SHIFT) * sizeof(*info));
printf("page info at %x\n", info);
/* Map kernel space 0x80000000 ... */ /* Map kernel space 0x80000000 ... */
for( i = (ULONG)KernelMemory, page = 0; for( i = (ULONG)KernelMemory, page = 0;
@ -169,11 +178,14 @@ FrLdrStartup(ULONG Magic)
info[page].flags = MMU_ALL_RW; info[page].flags = MMU_ALL_RW;
} }
printf("Adding page info (%d pages)\n", page);
MmuMapPage(info, page); MmuMapPage(info, page);
printf("Adding page info (%d pages) ... done\n", page);
/* Map module name strings */ /* Map module name strings */
for( count = 0, i = 0; i < LoaderBlock.ModsCount; i++ ) 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<<PFN_SHIFT)); page = ROUND_DOWN(((ULONG)reactos_modules[i].String), (1<<PFN_SHIFT));
for( j = 0; j < count; j++ ) for( j = 0; j < count; j++ )
{ {
@ -181,6 +193,8 @@ FrLdrStartup(ULONG Magic)
} }
if( j != count ) if( j != count )
{ {
printf("Mapping page %x containing string %s\n",
page, reactos_modules[i].String);
info[count].flags = MMU_ALL_RW; info[count].flags = MMU_ALL_RW;
info[count].proc = 1; info[count].proc = 1;
info[count].addr = page; info[count].addr = page;
@ -194,6 +208,7 @@ FrLdrStartup(ULONG Magic)
{ {
if(info[j].addr == page) break; if(info[j].addr == page) break;
} }
if( j != count ) if( j != count )
{ {
info[count].flags = MMU_ALL_RW; info[count].flags = MMU_ALL_RW;
@ -202,9 +217,13 @@ FrLdrStartup(ULONG Magic)
info[count].phys = page; // PpcVirt2phys(page, 0); info[count].phys = page; // PpcVirt2phys(page, 0);
count++; count++;
} }
printf("Mapping module name strings\n");
MmuMapPage(info, count); MmuMapPage(info, count);
printf("Module name strings mapped\n");
MmuTurnOn(KernelEntryAddress, (void*)&LoaderBlock); printf("MmuTurnOn(KernelEntry = %x)\n", KernelEntryPoint);
MmuTurnOn((KernelEntryFn)KernelEntryPoint, (void*)&LoaderBlock);
printf("MAED OF FALE!!1\n");
/* Nothing more */ /* Nothing more */
while(1); while(1);
@ -467,7 +486,6 @@ FrLdrMapModule(FILE *KernelImage, PCHAR ImageName, PCHAR MemLoadAddr, ULONG Kern
} }
ImageSize = SWAPD(NtHeader->OptionalHeader.SizeOfImage); ImageSize = SWAPD(NtHeader->OptionalHeader.SizeOfImage);
KernelEntryPoint = SWAPD(NtHeader->OptionalHeader.AddressOfEntryPoint);
printf("Total image size is %x\n", ImageSize); printf("Total image size is %x\n", ImageSize);
/* Handle relocation sections */ /* Handle relocation sections */
@ -689,17 +707,21 @@ PVOID
NTAPI NTAPI
FrLdrMapImage(IN FILE *Image, IN PCHAR ShortName, IN ULONG ImageType) 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 (ImageType == 1)
{ {
if(FrLdrMapKernel(Image)) if(FrLdrMapKernel(Image))
return (PVOID)KernelMemory; Result = (PVOID)KernelMemory;
else
return NULL;
} }
else else
Result = (PVOID)FrLdrLoadModule(Image, ShortName, NULL); {
PVOID ModuleBase = (PVOID)NextModuleBase;
if(FrLdrMapModule(Image, ShortName, 0, 0))
Result = ModuleBase;
}
return Result; return Result;
} }

View file

@ -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) 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; ppc_trap_frame_t *trap_frame = (action >= 0x100) ? tf : arg1;
int ret = 0; 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)) if(!ptegreload(trap_frame, trap_frame->dar))
{ {
__asm__("mfmsr 3\n\tori 3,3,0x30\n\tmtmsr 3\n\t"); __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; break;
case 4: case 4:
if(!ptegreload(trap_frame, trap_frame->srr0)) if(!ptegreload(trap_frame, trap_frame->srr0))
{ {
__asm__("mfmsr 3\n\tori 3,3,0x30\n\tmtmsr 3\n\t"); __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; break;
@ -141,16 +140,7 @@ int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf)
ret = mmunitest(); ret = mmunitest();
break; break;
case 0x107: case 0x107:
__asm__("mfmsr 3\n\t" callkernel(arg1, arg2);
"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 ! */
break; break;
case 0x108: case 0x108:
mmusetramsize((paddr_t)arg1); mmusetramsize((paddr_t)arg1);
@ -423,7 +413,7 @@ void mmufreevsid(int vsid, int mask)
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
{ {
if(mask & (1 << 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)); __asm__("tlbie %0\n\tsync\n\tisync" : : "r" (addr));
return 1; 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 ! */
}

View file

@ -12,5 +12,6 @@ void mmuallocvsid(int vsid, int mask);
void freevsid(int); void freevsid(int);
void mmufreevsid(int vsid, int mask); void mmufreevsid(int vsid, int mask);
int mmunitest(); int mmunitest();
void callkernel(void *fun_ptr, void *arg);
#endif/*_LIBMMU_MMUOBJECT_H*/ #endif/*_LIBMMU_MMUOBJECT_H*/