mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:35:47 +00:00
Unhack freeldr.c a bit by applying some adjustment macros.
Fix slow bitscanreverse and make LARGE_INTEGER and kin bi-endian. svn path=/trunk/; revision=31956
This commit is contained in:
parent
56a886e58d
commit
9ebb58eb88
2 changed files with 38 additions and 37 deletions
|
@ -2561,35 +2561,37 @@ typedef struct _EXCEPTION_POINTERS {
|
|||
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 @@ BitScanReverse(OUT ULONG *Index,
|
|||
return BitPosition;
|
||||
#else
|
||||
/* Slow implementation for now */
|
||||
for( *Index = 31; *Index; *Index-- ) {
|
||||
for( *Index = 31; *Index; (*Index)-- ) {
|
||||
if( (1<<*Index) & Mask ) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -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 @@ VOID
|
|||
NTAPI
|
||||
KiRosBuildBiosMemoryMap(VOID)
|
||||
{
|
||||
ULONG j;
|
||||
ULONG BlockBegin, BlockEnd;
|
||||
ULONG j;
|
||||
|
||||
/* Loop the BIOS Memory Map */
|
||||
for (j = 0; j < KeMemoryMapRangeCount; j++)
|
||||
|
@ -967,17 +972,19 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
!(_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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
|
||||
/* 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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
{
|
||||
/* 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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
{
|
||||
/* 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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
{
|
||||
/* 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 @@ KiRosFrldrLpbToNtLpb(IN PROS_LOADER_PARAMETER_BLOCK RosLoaderBlock,
|
|||
{
|
||||
/* 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 @@ KiRosPrepareForSystemStartup(IN ULONG Dummy,
|
|||
#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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue