Author: fireball
Date: Sun Jan 27 20:22:57 2008
New Revision: 32030
URL:
http://svn.reactos.org/svn/reactos?rev=32030&view=rev
Log:
- Map APIC pages, if they are present.
- Set the size of the memory new MM uses to 24Mb.
- Set heap size to 4Mb.
- Misc code cleanup.
Modified:
trunk/reactos/boot/freeldr/freeldr/include/mm.h
trunk/reactos/boot/freeldr/freeldr/include/reactos.h
trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c
Modified: trunk/reactos/boot/freeldr/freeldr/include/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/mm.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/mm.h Sun Jan 27 20:22:57 2008
@@ -50,10 +50,10 @@
//
// This is the zone which is used by the OS loader
//
-#define LOADER_HIGH_ZONE ((16*1024*1024) >> MM_PAGE_SHIFT) //16Mb page
+#define LOADER_HIGH_ZONE ((24*1024*1024) >> MM_PAGE_SHIFT) // 24Mb
// HEAP and STACK size
-#define HEAP_PAGES 0x100//0x18
+#define HEAP_PAGES 0x400
#define STACK_PAGES 0x00
typedef struct
Modified: trunk/reactos/boot/freeldr/freeldr/include/reactos.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/reactos.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/reactos.h Sun Jan 27 20:22:57 2008
@@ -41,6 +41,7 @@
#define STARTUP_BASE 0xC0000000
#define HYPERSPACE_BASE 0xC0400000
#define HAL_BASE 0xFFC00000
+#define APIC_BASE 0xFFFE0000
#define LowMemPageTableIndex 0
#define StartupPageTableIndex (STARTUP_BASE >> 22)
Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c Sun Jan 27 20:22:57 2008
@@ -100,7 +100,7 @@
/* GLOBALS ***************************************************************/
PHARDWARE_PTE PDE;
-PHARDWARE_PTE HalPT;
+PHARDWARE_PTE HalPageTable;
PUCHAR PhysicalPageTablesBuffer;
PUCHAR KernelPageTablesBuffer;
@@ -151,10 +151,10 @@
PDE[HYPER_SPACE_ENTRY].Write = 1;
// The last PDE slot is allocated for HAL's memory mapping (Virtual Addresses
0xFFC00000 - 0xFFFFFFFF)
- HalPT = (PHARDWARE_PTE)&Buffer[MM_PAGE_SIZE*1];
+ HalPageTable = (PHARDWARE_PTE)&Buffer[MM_PAGE_SIZE*1];
// Map it
- PDE[1023].PageFrameNumber = (ULONG)HalPT >> MM_PAGE_SHIFT;
+ PDE[1023].PageFrameNumber = (ULONG)HalPageTable >> MM_PAGE_SHIFT;
PDE[1023].Valid = 1;
PDE[1023].Write = 1;
@@ -387,6 +387,52 @@
}
}
}
+
+#ifdef _M_IX86
+
+BOOLEAN LocalAPIC = FALSE;
+ULONG_PTR APICAddress = 0;
+
+VOID
+WinLdrpMapApic()
+{
+ /* Check if we have a local APIC */
+ asm(".intel_syntax noprefix\n");
+ asm("mov eax, 1\n");
+ asm("cpuid\n");
+ asm("shr edx, 9\n");
+ asm("and edx, 0x1\n");
+ asm("mov _LocalAPIC, edx\n");
+ asm(".att_syntax\n");
+
+ /* If there is no APIC, just return */
+ if (!LocalAPIC)
+ return;
+
+ asm(".intel_syntax noprefix\n");
+ asm("mov ecx, 0x1B\n");
+ asm("rdmsr\n");
+ asm("mov edx, eax\n");
+ asm("and edx, 0xFFFFF000\n");
+ asm("mov _APICAddress, edx");
+ asm(".att_syntax\n");
+
+ DbgPrint((DPRINT_WINDOWS, "Local APIC detected at address 0x%x\n",
+ APICAddress));
+
+ /* Map it */
+ HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber
+ = APICAddress >> MM_PAGE_SHIFT;
+ HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
+ HalPageTable[(APIC_BASE - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
+}
+#else
+VOID
+WinLdrpMapApic()
+{
+ /* Implement it for another arch */
+}
+#endif
BOOLEAN
WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
@@ -525,17 +571,20 @@
}*/
//VideoDisplayString(L"Hello from VGA, going into the kernel\n");
- DbgPrint((DPRINT_WINDOWS, "HalPT: 0x%X\n", HalPT));
+ DbgPrint((DPRINT_WINDOWS, "HalPageTable: 0x%X\n", HalPageTable));
// Page Tables have been setup, make special handling for PCR and TSS
// (which is done in BlSetupFotNt in usual ntldr)
- HalPT[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber =
PcrBasePage+1;
- HalPT[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
- HalPT[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
-
- HalPT[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber =
PcrBasePage;
- HalPT[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
- HalPT[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
+ HalPageTable[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber
= PcrBasePage+1;
+ HalPageTable[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
+ HalPageTable[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
+
+ HalPageTable[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber =
PcrBasePage;
+ HalPageTable[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1;
+ HalPageTable[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1;
+
+ // Map APIC
+ WinLdrpMapApic();
// Map VGA memory
//VideoMemoryBase = MmMapIoSpace(0xb8000, 4000, MmNonCached);
@@ -775,7 +824,7 @@
pGdt[7].HighWord.Bytes.BaseHi = 0;
//
- // Some BIOS fuck (0x40)
+ // Some BIOS stuff (0x40)
//
pGdt[8].LimitLow = 0xFFFF;
pGdt[8].BaseLow = 0x400;
@@ -828,7 +877,7 @@
// Video buffer Selector (0x68)
//
pGdt[13].LimitLow = 0x3FFF;
- pGdt[13].BaseLow = 0x8000; //FIXME: I guess not correct for UGA
+ pGdt[13].BaseLow = 0x8000;
pGdt[13].HighWord.Bytes.BaseMid = 0x0B;
pGdt[13].HighWord.Bytes.Flags1 = 0x92;
pGdt[13].HighWord.Bytes.Flags2 = 0;
@@ -846,7 +895,7 @@
//
// Some unused descriptors should go here
- // ...
+ //
// Copy the old IDT
RtlCopyMemory(pIdt, (PVOID)OldIdt.Base, OldIdt.Limit);