Author: ros-arm-bringup
Date: Mon Jun 30 03:40:54 2008
New Revision: 34210
URL:
http://svn.reactos.org/svn/reactos?rev=34210&view=rev
Log:
- Add driver database code to FreeLDR (using ReactOS-style LoadOrderListHead instead of
BootDriversListHead, oh well!).
- This means we actually load and parse drivers now!!! Some Mm work was required to
support unloading and remapping: MmDeleteVirtualMapping is now implemented.
- We can now see scsiport.sys and atapi.sys strings displayed on the LCD.
- Implemented HalQuery/SetDisplayParameters, HalQuery/ReleaseDisplayOwnership and
HalDisplayString just like on x86.
- Since we now load symbols for the drivers (or at least try to), stubbed DebugService2,
which also shows us what's being loaded.
- Extended the Loader MemoryType array to include XIP/RAM Disk Memory.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c
trunk/reactos/boot/freeldr/freeldr/reactos/imageldr.c
trunk/reactos/hal/halarm/generic/hal.c
trunk/reactos/ntoskrnl/ke/arm/kiinit.c
trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
trunk/reactos/ntoskrnl/mm/arm/stubs.c
trunk/reactos/ntoskrnl/mm/mminit.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/loader.c [iso-8859-1] Mon Jun 30 03:40:54
2008
@@ -30,7 +30,6 @@
CHAR ArmArcHalPath[64];
CHAR ArmNtHalPath[64];
CHAR ArmNtBootPath[64];
-WCHAR ArmModuleName[64];
PNLS_DATA_BLOCK ArmNlsDataBlock;
PLOADER_PARAMETER_EXTENSION ArmExtension;
BIOS_MEMORY_DESCRIPTOR ArmBoardMemoryDescriptors[16] = {{0}};
@@ -48,6 +47,7 @@
extern ULONG_PTR KernelBase;
extern ULONG_PTR AnsiData, OemData, UnicodeData, RegistryData, KernelData, HalData,
DriverData[16];
extern ULONG RegistrySize, AnsiSize, OemSize, UnicodeSize, KernelSize, HalSize,
DriverSize[16];
+extern PCHAR DriverName[16];
extern ULONG Drivers;
extern ULONG BootStack, TranslationTableStart, TranslationTableEnd;
@@ -1061,6 +1061,7 @@
ULONG ArcDiskCount = 0, Checksum = 0;
PMASTER_BOOT_RECORD Mbr;
PULONG Buffer;
+ PWCHAR ArmModuleName;
//
// Allocate the ARM Shared Heap
@@ -1231,6 +1232,7 @@
//
// Setup loader entry for the kernel
//
+ ArmModuleName = ArmAllocateFromSharedHeap(64 * sizeof(WCHAR));
wcscpy(ArmModuleName, L"ntoskrnl.exe");
LdrEntry = ArmAllocateFromSharedHeap(sizeof(LDR_DATA_TABLE_ENTRY));
RtlZeroMemory(LdrEntry, sizeof(LDR_DATA_TABLE_ENTRY));
@@ -1244,12 +1246,55 @@
LdrEntry->FullDllName.Buffer = (PVOID)((ULONG_PTR)LdrEntry->FullDllName.Buffer
| KSEG0_BASE);
LdrEntry->BaseDllName.Buffer = (PVOID)((ULONG_PTR)LdrEntry->BaseDllName.Buffer
| KSEG0_BASE);
InsertTailList(&ArmLoaderBlock->LoadOrderListHead,
&LdrEntry->InLoadOrderLinks);
+
+ //
+ // Setup loader entry for the HAL
+ //
+ ArmModuleName = ArmAllocateFromSharedHeap(64 * sizeof(WCHAR));
+ wcscpy(ArmModuleName, L"hal.dll");
+ LdrEntry = ArmAllocateFromSharedHeap(sizeof(LDR_DATA_TABLE_ENTRY));
+ RtlZeroMemory(LdrEntry, sizeof(LDR_DATA_TABLE_ENTRY));
+ LdrEntry->DllBase = (PVOID)(HalData | KSEG0_BASE);
+ LdrEntry->SizeOfImage = HalSize;
+ LdrEntry->EntryPoint = (PVOID)RtlImageNtHeader((PVOID)HalData)->
+ OptionalHeader.AddressOfEntryPoint;
+ LdrEntry->EntryPoint = (PVOID)((ULONG_PTR)LdrEntry->EntryPoint | KSEG0_BASE);
+ LdrEntry->LoadCount = 1;
+ LdrEntry->Flags = LDRP_IMAGE_DLL | LDRP_ENTRY_PROCESSED;
+ RtlInitUnicodeString(&LdrEntry->FullDllName, ArmModuleName);
+ RtlInitUnicodeString(&LdrEntry->BaseDllName, ArmModuleName);
+ LdrEntry->FullDllName.Buffer = (PVOID)((ULONG_PTR)LdrEntry->FullDllName.Buffer
| KSEG0_BASE);
+ LdrEntry->BaseDllName.Buffer = (PVOID)((ULONG_PTR)LdrEntry->BaseDllName.Buffer
| KSEG0_BASE);
+ InsertTailList(&ArmLoaderBlock->LoadOrderListHead,
&LdrEntry->InLoadOrderLinks);
//
// Build descriptors for the drivers loaded
//
for (i = 0; i < Drivers; i++)
{
+ //
+ // Setup loader entry for the driver
+ //
+ LdrEntry = ArmAllocateFromSharedHeap(sizeof(LDR_DATA_TABLE_ENTRY));
+ RtlZeroMemory(LdrEntry, sizeof(LDR_DATA_TABLE_ENTRY));
+ LdrEntry->DllBase = (PVOID)(DriverData[i] | KSEG0_BASE);
+ LdrEntry->SizeOfImage = DriverSize[i];
+ LdrEntry->EntryPoint = (PVOID)RtlImageNtHeader((PVOID)DriverData[i])->
+ OptionalHeader.AddressOfEntryPoint;
+ LdrEntry->EntryPoint = (PVOID)((ULONG_PTR)LdrEntry->EntryPoint |
KSEG0_BASE);
+ LdrEntry->LoadCount = 1;
+ LdrEntry->Flags = LDRP_IMAGE_DLL | LDRP_ENTRY_PROCESSED;
+ ArmModuleName = ArmAllocateFromSharedHeap(64 * sizeof(WCHAR));
+ RtlZeroMemory(ArmModuleName, 64 * sizeof(WCHAR));
+ LdrEntry->FullDllName.Length = strlen(DriverName[i]) * sizeof(WCHAR);
+ LdrEntry->FullDllName.MaximumLength = LdrEntry->FullDllName.Length;
+ LdrEntry->FullDllName.Buffer = ArmModuleName;
+ LdrEntry->BaseDllName = LdrEntry->FullDllName;
+ while (*DriverName[i]) *ArmModuleName++ = *DriverName[i]++;
+ LdrEntry->FullDllName.Buffer =
(PVOID)((ULONG_PTR)LdrEntry->FullDllName.Buffer | KSEG0_BASE);
+ LdrEntry->BaseDllName.Buffer =
(PVOID)((ULONG_PTR)LdrEntry->BaseDllName.Buffer | KSEG0_BASE);
+ InsertTailList(&ArmLoaderBlock->LoadOrderListHead,
&LdrEntry->InLoadOrderLinks);
+
//
// Build a descriptor for the driver
//
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/imageldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/imageldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/imageldr.c [iso-8859-1] Mon Jun 30 03:40:54
2008
@@ -19,6 +19,7 @@
ULONG Drivers;
PVOID AnsiData, OemData, UnicodeData, RegistryData, KernelData, HalData, DriverData[16];
ULONG RegistrySize, AnsiSize, OemSize, UnicodeSize, KernelSize, HalSize, DriverSize[16];
+PCHAR DriverName[16];
/* MODULE MANAGEMENT **********************************************************/
@@ -568,6 +569,7 @@
}
else
{
+ DriverName[Drivers] = reactos_module_strings[ImageId];
DriverData[Drivers] = (PVOID)NextModuleBase;
DriverSize[Drivers] = ImageSize;
Drivers++;
Modified: trunk/reactos/hal/halarm/generic/hal.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halarm/generic/hal.c?r…
==============================================================================
--- trunk/reactos/hal/halarm/generic/hal.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halarm/generic/hal.c [iso-8859-1] Mon Jun 30 03:40:54 2008
@@ -11,6 +11,7 @@
#include <hal.h>
#define NDEBUG
#include <debug.h>
+#include <ndk/inbvfuncs.h>
#undef ExAcquireFastMutex
#undef ExReleaseFastMutex
@@ -173,15 +174,6 @@
}
-VOID
-NTAPI
-HalAcquireDisplayOwnership(
- PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
-{
- UNIMPLEMENTED;
-}
-
-
NTSTATUS
NTAPI
HalAdjustResourceList(
@@ -295,15 +287,49 @@
return TRUE;
}
-
-VOID
-NTAPI
-HalDisplayString(
- PCH String)
-{
- UNIMPLEMENTED;
-}
-
+VOID
+NTAPI
+HalAcquireDisplayOwnership(IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters)
+{
+ //
+ // Stub since Windows XP implemented Inbv
+ //
+ return;
+}
+
+VOID
+NTAPI
+HalDisplayString(IN PCH String)
+{
+ //
+ // Call the Inbv driver
+ //
+ InbvDisplayString(String);
+}
+
+VOID
+NTAPI
+HalQueryDisplayParameters(OUT PULONG DispSizeX,
+ OUT PULONG DispSizeY,
+ OUT PULONG CursorPosX,
+ OUT PULONG CursorPosY)
+{
+ //
+ // Stub since Windows XP implemented Inbv
+ //
+ return;
+}
+
+VOID
+NTAPI
+HalSetDisplayParameters(IN ULONG CursorPosX,
+ IN ULONG CursorPosY)
+{
+ //
+ // Stub since Windows XP implemented Inbv
+ //
+ return;
+}
BOOLEAN
NTAPI
@@ -672,27 +698,6 @@
}
-BOOLEAN
-NTAPI
-HalQueryDisplayOwnership(VOID)
-{
- UNIMPLEMENTED;
-
- return FALSE;
-}
-
-
-VOID
-NTAPI
-HalQueryDisplayParameters(
- OUT PULONG DispSizeX,
- OUT PULONG DispSizeY,
- OUT PULONG CursorPosX,
- OUT PULONG CursorPosY)
-{
- UNIMPLEMENTED;
-}
-
#define RTC_DATA (PVOID)0xE00E8000
BOOLEAN
@@ -729,13 +734,6 @@
return 0;
}
-
-VOID
-NTAPI
-HalReleaseDisplayOwnership(VOID)
-{
- UNIMPLEMENTED;
-}
VOID
NTAPI
@@ -816,16 +814,6 @@
}
-VOID
-NTAPI
-HalSetDisplayParameters(
- ULONG CursorPosX,
- ULONG CursorPosY)
-{
- UNIMPLEMENTED;
-}
-
-
ARC_STATUS
NTAPI
HalSetEnvironmentVariable(
Modified: trunk/reactos/ntoskrnl/ke/arm/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/kiinit.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/kiinit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/kiinit.c [iso-8859-1] Mon Jun 30 03:40:54 2008
@@ -43,6 +43,18 @@
//
void arm_kprintf(const char *fmt, ...);
arm_kprintf("%s", Buffer);
+}
+
+VOID
+DebugService2(IN ULONG Arg1,
+ IN ULONG Arg2,
+ IN ULONG Service)
+{
+ //
+ // FIXME: ARM Bring-up Hack
+ //
+ void arm_kprintf(const char *fmt, ...);
+ arm_kprintf("Loading symbols for %Z...\n", (PCHAR)Arg1);
}
VOID
Modified: trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/stubs_asm.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] Mon Jun 30 03:40:54 2008
@@ -53,7 +53,6 @@
GENERATE_ARM_STUB RtlUnwind
GENERATE_ARM_STUB RtlpGetExceptionAddress
GENERATE_ARM_STUB RtlDispatchException
-GENERATE_ARM_STUB DebugService2
GENERATE_ARM_STUB RtlpGetStackLimits
GENERATE_ARM_STUB KdpGdbStubInit
Modified: trunk/reactos/ntoskrnl/mm/arm/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/arm/stubs.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/arm/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/arm/stubs.c [iso-8859-1] Mon Jun 30 03:40:54 2008
@@ -240,10 +240,91 @@
OUT PBOOLEAN WasDirty,
OUT PPFN_TYPE Page)
{
- //
- // TODO
- //
- UNIMPLEMENTED;
+ PMMPTE PointerPte, PointerPde;
+ MMPTE Pte;
+
+ //
+ // Check if this is for a different process
+ //
+ if ((Process) && (Process != PsGetCurrentProcess()))
+ {
+ //
+ // TODO
+ //
+ UNIMPLEMENTED;
+ return;
+ }
+
+ //
+ // Get the PDE
+ //
+ PointerPde = MiGetPdeAddress(Address);
+ if (PointerPde->u.Hard.L1.Fault.Type == FaultPte)
+ {
+ //
+ // Invalid PDE
+ //
+ if (WasDirty) *WasDirty = FALSE;
+ if (Page) *Page = 0;
+ return;
+ }
+
+ //
+ // Get the PTE
+ //
+ PointerPte = MiGetPteAddress(Address);
+ ASSERT(PointerPte->u.Hard.L2.Small.Type == SmallPte);
+
+ //
+ // Save the PTE
+ //
+ Pte = *PointerPte;
+
+ //
+ // Destroy the PTE
+ //
+ PointerPte->u.Hard.AsUlong = 0;
+ ASSERT(PointerPte->u.Hard.L2.Fault.Type == FaultPte);
+
+ //
+ // Flush the TLB
+ //
+ KiFlushSingleTb(TRUE, Address);
+
+ //
+ // Check if the PTE was valid
+ //
+ if (Pte.u.Hard.L2.Fault.Type != FaultPte)
+ {
+ //
+ // Mark the page as unmapped
+ //
+ MmMarkPageUnmapped(Pte.u.Hard.L2.Small.BaseAddress);
+ }
+ else
+ {
+ //
+ // Make it sane
+ //
+ Pte.u.Hard.L2.Small.BaseAddress = 0;
+ }
+
+ //
+ // Check if this was our page, and valid
+ //
+ if ((FreePage) && (Pte.u.Hard.L2.Fault.Type != FaultPte))
+ {
+ //
+ // Release it
+ //
+ MmReleasePageMemoryConsumer(MC_NPPOOL, Pte.u.Hard.L2.Small.BaseAddress);
+ }
+
+ //
+ // Return if the page was dirty
+ //
+ if (WasDirty) *WasDirty = TRUE; // LIE!!!
+ if (Page) *Page = Pte.u.Hard.L2.Small.BaseAddress;
}
VOID
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c [iso-8859-1] Mon Jun 30 03:40:54 2008
@@ -41,7 +41,8 @@
"NlsData ",
"SpecialMemory ",
"BBTMemory ",
- "LoaderReserve "
+ "LoaderReserve ",
+ "LoaderXIPRom "
};
BOOLEAN IsThisAnNtAsSystem = FALSE;