Author: arty
Date: Wed Jan 23 05:47:22 2008
New Revision: 31956
URL:
http://svn.reactos.org/svn/reactos?rev=31956&view=rev
Log:
Unhack freeldr.c a bit by applying some adjustment macros.
Fix slow bitscanreverse and make LARGE_INTEGER and kin bi-endian.
Modified:
trunk/reactos/include/psdk/winnt.h
trunk/reactos/ntoskrnl/ke/freeldr.c
Modified: trunk/reactos/include/psdk/winnt.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winnt.h?rev=3…
==============================================================================
--- trunk/reactos/include/psdk/winnt.h (original)
+++ trunk/reactos/include/psdk/winnt.h Wed Jan 23 05:47:22 2008
@@ -2561,35 +2561,37 @@
PEXCEPTION_RECORD ExceptionRecord;
PCONTEXT ContextRecord;
} EXCEPTION_POINTERS,*PEXCEPTION_POINTERS,*LPEXCEPTION_POINTERS;
+
+#ifdef _M_PPC
+#define LARGE_INTEGER_ORDER(x) x HighPart; DWORD LowPart;
+#else
+#define LARGE_INTEGER_ORDER(x) DWORD LowPart; x HighPart;
+#endif
+
typedef union _LARGE_INTEGER {
#if ! defined(NONAMELESSUNION) || defined(__cplusplus)
_ANONYMOUS_STRUCT struct {
- DWORD LowPart;
- LONG HighPart;
+ LARGE_INTEGER_ORDER(LONG)
};
#endif /* NONAMELESSUNION */
struct {
- DWORD LowPart;
- LONG HighPart;
+ LARGE_INTEGER_ORDER(LONG)
} u;
LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
typedef union _ULARGE_INTEGER {
#if ! defined(NONAMELESSUNION) || defined(__cplusplus)
_ANONYMOUS_STRUCT struct {
- DWORD LowPart;
- DWORD HighPart;
+ LARGE_INTEGER_ORDER(DWORD)
};
#endif /* NONAMELESSUNION */
struct {
- DWORD LowPart;
- DWORD HighPart;
+ LARGE_INTEGER_ORDER(DWORD)
} u;
ULONGLONG QuadPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
typedef struct _LUID {
- DWORD LowPart;
- LONG HighPart;
+ LARGE_INTEGER_ORDER(LONG)
} LUID, *PLUID;
#pragma pack(push,4)
typedef struct _LUID_AND_ATTRIBUTES {
@@ -4215,7 +4217,7 @@
return BitPosition;
#else
/* Slow implementation for now */
- for( *Index = 31; *Index; *Index-- ) {
+ for( *Index = 31; *Index; (*Index)-- ) {
if( (1<<*Index) & Mask ) {
return TRUE;
}
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/freeldr.c (original)
+++ trunk/reactos/ntoskrnl/ke/freeldr.c Wed Jan 23 05:47:22 2008
@@ -9,11 +9,16 @@
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
-#define NDEBUG
+//#define NDEBUG
#include <debug.h>
#ifdef _M_PPC
#include <ppcmmu/mmu.h>
+#define KERNEL_RVA(x) RVA(x,0x80800000)
+#define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x + KernelBase) >> PAGE_SHIFT)
+#else
+#define KERNEL_RVA(x) RVA(x,KSEG0_BASE)
+#define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x &~ KSEG0_BASE) >> PAGE_SHIFT)
#endif
typedef struct _BIOS_MEMORY_DESCRIPTOR
@@ -126,8 +131,8 @@
NTAPI
KiRosBuildBiosMemoryMap(VOID)
{
+ ULONG BlockBegin, BlockEnd;
ULONG j;
- ULONG BlockBegin, BlockEnd;
/* Loop the BIOS Memory Map */
for (j = 0; j < KeMemoryMapRangeCount; j++)
@@ -967,17 +972,19 @@
ModStart = (PVOID)RosEntry->ModStart;
ModSize = RosEntry->ModEnd - (ULONG_PTR)ModStart;
+#ifdef _M_PPC
+ ModStart -= KernelBase;
+#endif
+
/* Check if this is any of the NLS files */
if (!_stricmp(DriverName, "ansi.nls"))
{
/* ANSI Code page */
- ModStart = RVA(ModStart, KSEG0_BASE);
- LoaderBlock->NlsData->AnsiCodePageData = ModStart;
+ LoaderBlock->NlsData->AnsiCodePageData = KERNEL_RVA(ModStart);
/* Create an MD for it */
KiRosAllocateNtDescriptor(LoaderNlsData,
- ((ULONG_PTR)ModStart &~ KSEG0_BASE) >>
- PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
@@ -986,13 +993,11 @@
else if (!_stricmp(DriverName, "oem.nls"))
{
/* OEM Code page */
- ModStart = RVA(ModStart, KSEG0_BASE);
- LoaderBlock->NlsData->OemCodePageData = ModStart;
+ LoaderBlock->NlsData->OemCodePageData = KERNEL_RVA(ModStart);
/* Create an MD for it */
KiRosAllocateNtDescriptor(LoaderNlsData,
- ((ULONG_PTR)ModStart &~ KSEG0_BASE) >>
- PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
@@ -1001,13 +1006,11 @@
else if (!_stricmp(DriverName, "casemap.nls"))
{
/* Unicode Code page */
- ModStart = RVA(ModStart, KSEG0_BASE);
- LoaderBlock->NlsData->UnicodeCodePageData = ModStart;
+ LoaderBlock->NlsData->UnicodeCodePageData = KERNEL_RVA(ModStart);
/* Create an MD for it */
KiRosAllocateNtDescriptor(LoaderNlsData,
- ((ULONG_PTR)ModStart &~ KSEG0_BASE) >>
- PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
@@ -1019,8 +1022,7 @@
!(_stricmp(DriverName, "system.hiv")))
{
/* Save registry data */
- ModStart = RVA(ModStart, KSEG0_BASE);
- LoaderBlock->RegistryBase = ModStart;
+ LoaderBlock->RegistryBase = KERNEL_RVA(ModStart);
LoaderBlock->RegistryLength = ModSize;
/* Disable setup mode */
@@ -1028,8 +1030,7 @@
/* Create an MD for it */
KiRosAllocateNtDescriptor(LoaderRegistryData,
- ((ULONG_PTR)ModStart &~ KSEG0_BASE) >>
- PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
@@ -1042,7 +1043,7 @@
{
/* Create an MD for it */
KiRosAllocateNtDescriptor(LoaderRegistryData,
- (ULONG_PTR)ModStart >> PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
@@ -1054,8 +1055,7 @@
{
/* Create an MD for it */
KiRosAllocateNtDescriptor(LoaderSystemCode,
- ((ULONG_PTR)ModStart &~ KSEG0_BASE) >>
- PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
@@ -1064,8 +1064,7 @@
{
/* Create an MD for the HAL */
KiRosAllocateNtDescriptor(LoaderHalCode,
- ((ULONG_PTR)ModStart &~ KSEG0_BASE) >>
- PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
@@ -1074,15 +1073,14 @@
{
/* Create an MD for any driver */
KiRosAllocateNtDescriptor(LoaderBootDriver,
- ((ULONG_PTR)ModStart &~ KSEG0_BASE) >>
- PAGE_SHIFT,
+ KERNEL_DESCRIPTOR_PAGE(ModStart),
(ModSize + PAGE_SIZE - 1)>> PAGE_SHIFT,
0,
&Base);
}
#ifdef _M_PPC
- ModStart = (PVOID)((ULONG)ModStart + 0x80800000 - KernelBase);
+ ModStart += 0x80800000;
#endif
/* Lowercase the drivername so we can check its extension later */
@@ -1291,6 +1289,7 @@
#if defined(_M_PPC)
MmFreeLdrFirstKrnlPhysAddr = KeRosLoaderBlock->ModsAddr[0].ModStart;
MmFreeLdrLastKrnlPhysAddr = MmFreeLdrLastKernelAddress;
+ MmFreeLdrLastKernelAddress = 0x80800000 +
KeRosLoaderBlock->ModsAddr[KeRosLoaderBlock->ModsCount - 1].ModEnd -
MmFreeLdrFirstKrnlPhysAddr;
DbgPrint("kernel phys = %08x-%08x\n",
MmFreeLdrFirstKrnlPhysAddr,
MmFreeLdrLastKrnlPhysAddr);