Author: arty
Date: Fri Oct 26 10:37:52 2007
New Revision: 29894
URL: 
http://svn.reactos.org/svn/reactos?rev=29894&view=rev
Log:
Remaining fixes from branch transition.  MmuTurnOn, now with GDB stub.
Modified:
    trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c
    trunk/reactos/lib/ppcmmu/mmuobject.c
    trunk/reactos/lib/ppcmmu/mmuobject.h
Modified: trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c Fri Oct 26 10:37:52 2007
@@ -127,8 +127,6 @@
 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 @@
     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 @@
                 (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 @@
        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<<PFN_SHIFT));
        for( j = 0; j < count; j++ )
        {
@@ -181,6 +193,8 @@
        }
        if( j != count )
        {
+            printf("Mapping page %x containing string %s\n",
+                   page, reactos_modules[i].String);
            info[count].flags = MMU_ALL_RW;
            info[count].proc = 1;
            info[count].addr = page;
@@ -194,6 +208,7 @@
     {
        if(info[j].addr == page) break;
     }
+
     if( j != count )
     {
        info[count].flags = MMU_ALL_RW;
@@ -202,9 +217,13 @@
        info[count].phys = page; // PpcVirt2phys(page, 0);
        count++;
     }
+    printf("Mapping module name strings\n");
     MmuMapPage(info, count);
-
-    MmuTurnOn(KernelEntryAddress, (void*)&LoaderBlock);
+    printf("Module name strings mapped\n");
+
+    printf("MmuTurnOn(KernelEntry = %x)\n", KernelEntryPoint);
+    MmuTurnOn((KernelEntryFn)KernelEntryPoint, (void*)&LoaderBlock);
+    printf("MAED OF FALE!!1\n");
     /* Nothing more */
     while(1);
@@ -467,7 +486,6 @@
     }
     ImageSize = SWAPD(NtHeader->OptionalHeader.SizeOfImage);
-    KernelEntryPoint = SWAPD(NtHeader->OptionalHeader.AddressOfEntryPoint);
     printf("Total image size is %x\n", ImageSize);
     /* Handle relocation sections */
@@ -689,17 +707,21 @@
 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;
 }
Modified: trunk/reactos/lib/ppcmmu/mmuobject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/ppcmmu/mmuobject.c?rev…
==============================================================================
--- trunk/reactos/lib/ppcmmu/mmuobject.c (original)
+++ trunk/reactos/lib/ppcmmu/mmuobject.c Fri Oct 26 10:37:52 2007
@@ -73,7 +73,6 @@
 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 @@
        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 @@
        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 @@
     for(i = 0; i < 16; i++)
     {
        if(mask & (1 << i))
-           allocvsid((vsid << 4) + i);
+           freevsid((vsid << 4) + i);
     }
 }
@@ -602,3 +592,18 @@
     __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 ! */
+}
Modified: trunk/reactos/lib/ppcmmu/mmuobject.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/ppcmmu/mmuobject.h?rev…
==============================================================================
--- trunk/reactos/lib/ppcmmu/mmuobject.h (original)
+++ trunk/reactos/lib/ppcmmu/mmuobject.h Fri Oct 26 10:37:52 2007
@@ -12,5 +12,6 @@
 void freevsid(int);
 void mmufreevsid(int vsid, int mask);
 int mmunitest();
+void callkernel(void *fun_ptr, void *arg);
 #endif/*_LIBMMU_MMUOBJECT_H*/