FreeLdr Patch. Now fully loads ntoskrnl using a PE Loader, supports /3gb dynamically but this is NOT enabled yet, so please continue using the 3GB entry in config until r2 is ready which will support relocation and remove the config entry. You must also supply /3GB to the commandline if you're using 3GB, just like since the previous patch. Also freeldr now uses w32api headers. Janitors will clean the dupes up. Thank you: Mike, Royce, Hartmut, Blight, Filip and everyone who reviewed. Hartmut, if anything is missing from the patch you sent me, feel free to add it. More info at http://blogs.reactos.com/Alex_Ionescu.

svn path=/trunk/; revision=13462
This commit is contained in:
Alex Ionescu 2005-02-08 01:46:01 +00:00
parent f390d143d5
commit 518763e600
113 changed files with 3822 additions and 3649 deletions

View file

@ -83,7 +83,7 @@ setup_loader : setupldr.sys
$(CP) setupldr.sys $(BOOTCD_DIR)/disk/loader/setupldr.sys
COMPILER_OPTIONS = -Wall -Werror -nostdlib -nostdinc -ffreestanding -fno-builtin -fno-inline \
COMPILER_OPTIONS = -Wall -Werror -nostdlib -ffreestanding -fno-builtin -fno-inline \
-fno-zero-initialized-in-bss -O1 -MD
# FreeLoader does not use any of the standard libraries, includes, or built-in functions
@ -95,7 +95,7 @@ endif
COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES)
COMPILER_INCLUDES = -I$(SRCDIR)/include -I$(PATH_TO_TOP)/include
COMPILER_INCLUDES = -I$(SRCDIR)/include -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/ntoskrnl/include
CFLAGS = $(COMPILER_OPTIONS) \
$(COMPILER_DEFINES) \

View file

@ -29,14 +29,14 @@
VOID
MachInit(VOID)
{
U32 PciId;
ULONG PciId;
memset(&MachVtbl, 0, sizeof(MACHVTBL));
/* Check for Xbox by identifying device at PCI 0:0:0, if it's
* 0x10de/0x02a5 then we're running on an Xbox */
WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0));
PciId = READ_PORT_ULONG((U32*) 0xcfc);
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0));
PciId = READ_PORT_ULONG((ULONG*) 0xcfc);
if (0x02a510de == PciId)
{
XboxMachInit();

File diff suppressed because it is too large Load diff

View file

@ -25,91 +25,6 @@
#include "../../reactos/registry.h"
#endif
typedef enum
{
InterfaceTypeUndefined = -1,
Internal,
Isa,
Eisa,
MicroChannel,
TurboChannel,
PCIBus,
VMEBus,
NuBus,
PCMCIABus,
CBus,
MPIBus,
MPSABus,
ProcessorInternal,
InternalPowerBus,
PNPISABus,
MaximumInterfaceType
} INTERFACE_TYPE, *PINTERFACE_TYPE;
typedef enum _CM_RESOURCE_TYPE
{
CmResourceTypeNull = 0,
CmResourceTypePort,
CmResourceTypeInterrupt,
CmResourceTypeMemory,
CmResourceTypeDma,
CmResourceTypeDeviceSpecific,
CmResourceTypeMaximum
} CM_RESOURCE_TYPE;
typedef enum _CM_SHARE_DISPOSITION
{
CmResourceShareUndetermined = 0,
CmResourceShareDeviceExclusive,
CmResourceShareDriverExclusive,
CmResourceShareShared
} CM_SHARE_DISPOSITION;
typedef U64 PHYSICAL_ADDRESS;
typedef struct
{
U8 Type;
U8 ShareDisposition;
U16 Flags;
union
{
struct
{
PHYSICAL_ADDRESS Start;
U32 Length;
} __attribute__((packed)) Port;
struct
{
U32 Level;
U32 Vector;
U32 Affinity;
} __attribute__((packed)) Interrupt;
struct
{
PHYSICAL_ADDRESS Start;
U32 Length;
} __attribute__((packed)) Memory;
struct
{
U32 Channel;
U32 Port;
U32 Reserved1;
} __attribute__((packed)) Dma;
struct
{
U32 DataSize;
U32 Reserved1;
U32 Reserved2;
} __attribute__((packed)) DeviceSpecificData;
} __attribute__((packed)) u;
} __attribute__((packed)) CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags */
#define CM_RESOURCE_PORT_MEMORY 0x0000
#define CM_RESOURCE_PORT_IO 0x0001
@ -117,30 +32,12 @@ typedef struct
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
#define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
typedef struct
{
U16 Version;
U16 Revision;
U32 Count;
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
} __attribute__((packed))CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
typedef struct
{
INTERFACE_TYPE InterfaceType;
U32 BusNumber;
CM_PARTIAL_RESOURCE_LIST PartialResourceList;
} __attribute__((packed)) CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
typedef struct _CM_COMPONENT_INFORMATION
{
U32 Flags;
U32 Version;
U32 Key;
U32 Affinity;
ULONG Flags;
ULONG Version;
ULONG Key;
ULONG Affinity;
} __attribute__((packed)) CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
@ -154,46 +51,48 @@ typedef struct _CM_COMPONENT_INFORMATION
#define Output 0x00000040
#define CONFIG_CMD(bus, dev_fn, where) \
(0x80000000 | (((U32)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
/* PROTOTYPES ***************************************************************/
/* hardware.c */
VOID HalpCalibrateStallExecution(VOID);
VOID KeStallExecutionProcessor(U32 Microseconds);
VOID SetComponentInformation(HKEY ComponentKey,
U32 Flags,
U32 Key,
U32 Affinity);
VOID StallExecutionProcessor(ULONG Microseconds);
VOID HalpCalibrateStallExecution(VOID);
VOID SetComponentInformation(FRLDRHKEY ComponentKey,
ULONG Flags,
ULONG Key,
ULONG Affinity);
/* hwacpi.c */
VOID DetectAcpiBios(HKEY SystemKey, U32 *BusNumber);
VOID DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber);
/* hwapm.c */
VOID DetectApmBios(HKEY SystemKey, U32 *BusNumber);
VOID DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber);
/* hwcpu.c */
VOID DetectCPUs(HKEY SystemKey);
VOID DetectCPUs(FRLDRHKEY SystemKey);
/* hwpci.c */
VOID DetectPciBios(HKEY SystemKey, U32 *BusNumber);
VOID DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber);
/* i386cpu.S */
U32 CpuidSupported(VOID);
VOID GetCpuid(U32 Level,
U32 *eax,
U32 *ebx,
U32 *ecx,
U32 *edx);
U64 RDTSC(VOID);
ULONG CpuidSupported(VOID);
VOID GetCpuid(ULONG Level,
ULONG *eax,
ULONG *ebx,
ULONG *ecx,
ULONG *edx);
ULONGLONG RDTSC(VOID);
/* i386pnp.S */
U32 PnpBiosSupported(VOID);
U32 PnpBiosGetDeviceNodeCount(U32 *NodeSize,
U32 *NodeCount);
U32 PnpBiosGetDeviceNode(U8 *NodeId,
U8 *NodeBuffer);
ULONG PnpBiosSupported(VOID);
ULONG PnpBiosGetDeviceNodeCount(ULONG *NodeSize,
ULONG *NodeCount);
ULONG PnpBiosGetDeviceNode(UCHAR *NodeId,
UCHAR *NodeBuffer);
#endif /* __I386_HARDWARE_H_ */

View file

@ -32,11 +32,11 @@
static BOOL
FindAcpiBios(VOID)
{
PU8 Ptr;
PUCHAR Ptr;
/* Find the 'Root System Descriptor Table Pointer' */
Ptr = (PU8)0xE0000;
while ((U32)Ptr < 0x100000)
Ptr = (PUCHAR)0xE0000;
while ((ULONG)Ptr < 0x100000)
{
if (!memcmp(Ptr, "RSD PTR ", 8))
{
@ -45,7 +45,7 @@ FindAcpiBios(VOID)
return TRUE;
}
Ptr = (PU8)((U32)Ptr + 0x10);
Ptr = (PUCHAR)((ULONG)Ptr + 0x10);
}
DbgPrint((DPRINT_HWDETECT, "ACPI not supported\n"));
@ -55,11 +55,11 @@ FindAcpiBios(VOID)
VOID
DetectAcpiBios(HKEY SystemKey, U32 *BusNumber)
DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
char Buffer[80];
HKEY BiosKey;
S32 Error;
FRLDRHKEY BiosKey;
LONG Error;
if (FindAcpiBios())
{
@ -90,7 +90,7 @@ DetectAcpiBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Identifier",
REG_SZ,
(PU8)"ACPI BIOS",
(PUCHAR)"ACPI BIOS",
10);
if (Error != ERROR_SUCCESS)
{

View file

@ -60,11 +60,11 @@ FindApmBios(VOID)
VOID
DetectApmBios(HKEY SystemKey, U32 *BusNumber)
DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
char Buffer[80];
HKEY BiosKey;
S32 Error;
FRLDRHKEY BiosKey;
LONG Error;
if (FindApmBios())
{
@ -95,7 +95,7 @@ DetectApmBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Identifier",
REG_SZ,
(PU8)"APM",
(PUCHAR)"APM",
4);
if (Error != ERROR_SUCCESS)
{

View file

@ -35,60 +35,60 @@
typedef struct _MP_FLOATING_POINT_TABLE
{
U32 Signature; /* "_MP_" */
U32 PhysicalAddressPointer;
U8 Length;
U8 SpecRev;
U8 Checksum;
U8 FeatureByte[5];
ULONG Signature; /* "_MP_" */
ULONG PhysicalAddressPointer;
UCHAR Length;
UCHAR SpecRev;
UCHAR Checksum;
UCHAR FeatureByte[5];
} PACKED MP_FLOATING_POINT_TABLE, *PMP_FLOATING_POINT_TABLE;
typedef struct _MPS_CONFIG_TABLE_HEADER
{
U32 Signature; /* "PCMP" */
U16 BaseTableLength;
U8 SpecRev;
U8 Checksum;
U8 OemIdString[8];
U8 ProductIdString[12];
U32 OemTablePointer;
U16 OemTableLength;
U16 EntryCount;
U32 AddressOfLocalAPIC;
U16 ExtendedTableLength;
U8 ExtendedTableChecksum;
U8 Reserved;
ULONG Signature; /* "PCMP" */
USHORT BaseTableLength;
UCHAR SpecRev;
UCHAR Checksum;
UCHAR OemIdString[8];
UCHAR ProductIdString[12];
ULONG OemTablePointer;
USHORT OemTableLength;
USHORT EntryCount;
ULONG AddressOfLocalAPIC;
USHORT ExtendedTableLength;
UCHAR ExtendedTableChecksum;
UCHAR Reserved;
} PACKED MP_CONFIGURATION_TABLE, *PMP_CONFIGURATION_TABLE;
typedef struct _MP_PROCESSOR_ENTRY
{
U8 EntryType;
U8 LocalApicId;
U8 LocalApicVersion;
U8 CpuFlags;
U32 CpuSignature;
U32 FeatureFlags;
U32 Reserved1;
U32 Reserved2;
UCHAR EntryType;
UCHAR LocalApicId;
UCHAR LocalApicVersion;
UCHAR CpuFlags;
ULONG CpuSignature;
ULONG FeatureFlags;
ULONG Reserved1;
ULONG Reserved2;
} PACKED MP_PROCESSOR_ENTRY, *PMP_PROCESSOR_ENTRY;
/* FUNCTIONS ****************************************************************/
static U32
static ULONG
GetCpuSpeed(VOID)
{
U64 Timestamp1;
U64 Timestamp2;
U64 Diff;
ULONGLONG Timestamp1;
ULONGLONG Timestamp2;
ULONGLONG Diff;
/* Read TSC (Time Stamp Counter) */
Timestamp1 = RDTSC();
/* Wait for 0.1 seconds (= 100 milliseconds = 100000 microseconds)*/
KeStallExecutionProcessor(100000);
StallExecutionProcessor(100000);
/* Read TSC (Time Stamp Counter) again */
Timestamp2 = RDTSC();
@ -100,30 +100,30 @@ GetCpuSpeed(VOID)
}
else
{
Diff = Timestamp2 + (((U64)-1) - Timestamp1);
Diff = Timestamp2 + (((ULONGLONG)-1) - Timestamp1);
}
return (U32)(Diff / 100000);
return (ULONG)(Diff / 100000);
}
static VOID
DetectCPU(HKEY CpuKey,
HKEY FpuKey)
DetectCPU(FRLDRHKEY CpuKey,
FRLDRHKEY FpuKey)
{
char VendorIdentifier[13];
char Identifier[64];
U32 FeatureSet;
HKEY CpuInstKey;
HKEY FpuInstKey;
U32 eax = 0;
U32 ebx = 0;
U32 ecx = 0;
U32 edx = 0;
U32 *Ptr;
S32 Error;
ULONG FeatureSet;
FRLDRHKEY CpuInstKey;
FRLDRHKEY FpuInstKey;
ULONG eax = 0;
ULONG ebx = 0;
ULONG ecx = 0;
ULONG edx = 0;
ULONG *Ptr;
LONG Error;
BOOL SupportTSC = FALSE;
U32 CpuSpeed;
ULONG CpuSpeed;
/* Create the CPU instance key */
@ -154,7 +154,7 @@ DetectCPU(HKEY CpuKey,
/* Get vendor identifier */
GetCpuid(0, &eax, &ebx, &ecx, &edx);
VendorIdentifier[12] = 0;
Ptr = (U32*)&VendorIdentifier[0];
Ptr = (ULONG*)&VendorIdentifier[0];
*Ptr = ebx;
Ptr++;
*Ptr = edx;
@ -195,8 +195,8 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"FeatureSet",
REG_DWORD,
(PU8)&FeatureSet,
sizeof(U32));
(PUCHAR)&FeatureSet,
sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@ -208,7 +208,7 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"Identifier",
REG_SZ,
(PU8)Identifier,
(PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@ -218,7 +218,7 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(FpuInstKey,
"Identifier",
REG_SZ,
(PU8)Identifier,
(PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@ -231,7 +231,7 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"VendorIdentifier",
REG_SZ,
(PU8)VendorIdentifier,
(PUCHAR)VendorIdentifier,
strlen(VendorIdentifier) + 1);
if (Error != ERROR_SUCCESS)
{
@ -250,8 +250,8 @@ DetectCPU(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"~MHz",
REG_DWORD,
(PU8)&CpuSpeed,
sizeof(U32));
(PUCHAR)&CpuSpeed,
sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@ -261,23 +261,23 @@ DetectCPU(HKEY CpuKey,
static VOID
SetMpsProcessor(HKEY CpuKey,
HKEY FpuKey,
SetMpsProcessor(FRLDRHKEY CpuKey,
FRLDRHKEY FpuKey,
PMP_PROCESSOR_ENTRY CpuEntry)
{
char VendorIdentifier[13];
char Identifier[64];
char Buffer[8];
U32 FeatureSet;
HKEY CpuInstKey;
HKEY FpuInstKey;
U32 eax = 0;
U32 ebx = 0;
U32 ecx = 0;
U32 edx = 0;
U32 *Ptr;
S32 Error;
U32 CpuSpeed;
ULONG FeatureSet;
FRLDRHKEY CpuInstKey;
FRLDRHKEY FpuInstKey;
ULONG eax = 0;
ULONG ebx = 0;
ULONG ecx = 0;
ULONG edx = 0;
ULONG *Ptr;
LONG Error;
ULONG CpuSpeed;
/* Get processor instance number */
sprintf(Buffer, "%u", CpuEntry->LocalApicId);
@ -305,7 +305,7 @@ SetMpsProcessor(HKEY CpuKey,
/* Get 'VendorIdentifier' */
GetCpuid(0, &eax, &ebx, &ecx, &edx);
VendorIdentifier[12] = 0;
Ptr = (U32*)&VendorIdentifier[0];
Ptr = (ULONG*)&VendorIdentifier[0];
*Ptr = ebx;
Ptr++;
*Ptr = edx;
@ -315,9 +315,9 @@ SetMpsProcessor(HKEY CpuKey,
/* Get 'Identifier' */
sprintf(Identifier,
"x86 Family %u Model %u Stepping %u",
(U32)((CpuEntry->CpuSignature >> 8) & 0x0F),
(U32)((CpuEntry->CpuSignature >> 4) & 0x0F),
(U32)(CpuEntry->CpuSignature & 0x0F));
(ULONG)((CpuEntry->CpuSignature >> 8) & 0x0F),
(ULONG)((CpuEntry->CpuSignature >> 4) & 0x0F),
(ULONG)(CpuEntry->CpuSignature & 0x0F));
/* Get FeatureSet */
FeatureSet = CpuEntry->FeatureFlags;
@ -339,8 +339,8 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"FeatureSet",
REG_DWORD,
(PU8)&FeatureSet,
sizeof(U32));
(PUCHAR)&FeatureSet,
sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@ -352,7 +352,7 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"Identifier",
REG_SZ,
(PU8)Identifier,
(PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@ -362,7 +362,7 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(FpuInstKey,
"Identifier",
REG_SZ,
(PU8)Identifier,
(PUCHAR)Identifier,
strlen(Identifier) + 1);
if (Error != ERROR_SUCCESS)
{
@ -375,7 +375,7 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"VendorIdentifier",
REG_SZ,
(PU8)VendorIdentifier,
(PUCHAR)VendorIdentifier,
strlen(VendorIdentifier) + 1);
if (Error != ERROR_SUCCESS)
{
@ -394,8 +394,8 @@ SetMpsProcessor(HKEY CpuKey,
Error = RegSetValue(CpuInstKey,
"~MHz",
REG_DWORD,
(PU8)&CpuSpeed,
sizeof(U32));
(PUCHAR)&CpuSpeed,
sizeof(ULONG));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@ -409,12 +409,12 @@ GetMpFloatingPointTable(VOID)
{
PMP_FLOATING_POINT_TABLE FpTable;
char *Ptr;
U8 Sum;
U32 Length;
U32 i;
UCHAR Sum;
ULONG Length;
ULONG i;
FpTable = (PMP_FLOATING_POINT_TABLE)0xF0000;
while ((U32)FpTable < 0x100000)
while ((ULONG)FpTable < 0x100000)
{
if (FpTable->Signature == MP_FP_SIGNATURE)
{
@ -440,7 +440,7 @@ GetMpFloatingPointTable(VOID)
return FpTable;
}
FpTable = (PMP_FLOATING_POINT_TABLE)((U32)FpTable + 0x10);
FpTable = (PMP_FLOATING_POINT_TABLE)((ULONG)FpTable + 0x10);
}
return NULL;
@ -452,9 +452,9 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
{
PMP_CONFIGURATION_TABLE ConfigTable;
char *Ptr;
U8 Sum;
U32 Length;
U32 i;
UCHAR Sum;
ULONG Length;
ULONG i;
if (FpTable->FeatureByte[0] != 0 ||
FpTable->PhysicalAddressPointer == 0)
@ -466,7 +466,7 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
DbgPrint((DPRINT_HWDETECT,
"MP Configuration Table at: %x\n",
(U32)ConfigTable));
(ULONG)ConfigTable));
/* Calculate base table checksum */
Length = ConfigTable->BaseTableLength;
@ -498,14 +498,14 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
static BOOL
DetectMps(HKEY CpuKey,
HKEY FpuKey)
DetectMps(FRLDRHKEY CpuKey,
FRLDRHKEY FpuKey)
{
PMP_FLOATING_POINT_TABLE FpTable;
PMP_CONFIGURATION_TABLE ConfigTable;
PMP_PROCESSOR_ENTRY CpuEntry;
char *Ptr;
U32 Offset;
ULONG Offset;
/* Get floating point table */
FpTable = GetMpFloatingPointTable();
@ -514,7 +514,7 @@ DetectMps(HKEY CpuKey,
DbgPrint((DPRINT_HWDETECT,
"MP Floating Point Table at: %x\n",
(U32)FpTable));
(ULONG)FpTable));
if (FpTable->FeatureByte[0] == 0)
{
@ -530,7 +530,7 @@ DetectMps(HKEY CpuKey,
Offset = sizeof(MP_CONFIGURATION_TABLE);
while (Offset < ConfigTable->BaseTableLength)
{
Ptr = (char*)((U32)ConfigTable + Offset);
Ptr = (char*)((ULONG)ConfigTable + Offset);
switch (*Ptr)
{
@ -548,9 +548,9 @@ DetectMps(HKEY CpuKey,
DbgPrint((DPRINT_HWDETECT,
"Processor %u: x86 Family %u Model %u Stepping %u\n",
CpuEntry->LocalApicId,
(U32)((CpuEntry->CpuSignature >> 8) & 0x0F),
(U32)((CpuEntry->CpuSignature >> 4) & 0x0F),
(U32)(CpuEntry->CpuSignature & 0x0F)));
(ULONG)((CpuEntry->CpuSignature >> 8) & 0x0F),
(ULONG)((CpuEntry->CpuSignature >> 4) & 0x0F),
(ULONG)(CpuEntry->CpuSignature & 0x0F)));
SetMpsProcessor(CpuKey, FpuKey, CpuEntry);
Offset += 0x14;
@ -577,7 +577,7 @@ DetectMps(HKEY CpuKey,
break;
default:
DbgPrint((DPRINT_HWDETECT, "Unknown Entry %u\n",(U32)*Ptr));
DbgPrint((DPRINT_HWDETECT, "Unknown Entry %u\n",(ULONG)*Ptr));
return FALSE;
}
}
@ -599,11 +599,11 @@ DetectMps(HKEY CpuKey,
VOID
DetectCPUs(HKEY SystemKey)
DetectCPUs(FRLDRHKEY SystemKey)
{
HKEY CpuKey;
HKEY FpuKey;
S32 Error;
FRLDRHKEY CpuKey;
FRLDRHKEY FpuKey;
LONG Error;
/* Create the 'CentralProcessor' key */
Error = RegCreateKey(SystemKey,

View file

@ -30,40 +30,40 @@
typedef struct _ROUTING_SLOT
{
U8 BusNumber;
U8 DeviceNumber;
U8 LinkA;
U16 BitmapA;
U8 LinkB;
U16 BitmapB;
U8 LinkC;
U16 BitmapC;
U8 LinkD;
U16 BitmapD;
U8 SlotNumber;
U8 Reserved;
UCHAR BusNumber;
UCHAR DeviceNumber;
UCHAR LinkA;
USHORT BitmapA;
UCHAR LinkB;
USHORT BitmapB;
UCHAR LinkC;
USHORT BitmapC;
UCHAR LinkD;
USHORT BitmapD;
UCHAR SlotNumber;
UCHAR Reserved;
} __attribute__((packed)) ROUTING_SLOT, *PROUTING_SLOT;
typedef struct _PCI_IRQ_ROUTING_TABLE
{
U32 Signature;
U16 Version;
U16 Size;
U8 RouterBus;
U8 RouterSlot;
U16 ExclusiveIRQs;
U32 CompatibleRouter;
U32 MiniportData;
U8 Reserved[11];
U8 Checksum;
ULONG Signature;
USHORT Version;
USHORT Size;
UCHAR RouterBus;
UCHAR RouterSlot;
USHORT ExclusiveIRQs;
ULONG CompatibleRouter;
ULONG MiniportData;
UCHAR Reserved[11];
UCHAR Checksum;
ROUTING_SLOT Slot[1];
} __attribute__((packed)) PCI_IRQ_ROUTING_TABLE, *PPCI_IRQ_ROUTING_TABLE;
typedef struct _CM_PCI_BUS_DATA
{
U8 BusCount;
U16 PciVersion;
U8 HardwareMechanism;
UCHAR BusCount;
USHORT PciVersion;
UCHAR HardwareMechanism;
} __attribute__((packed)) CM_PCI_BUS_DATA, *PCM_PCI_BUS_DATA;
@ -71,19 +71,19 @@ static PPCI_IRQ_ROUTING_TABLE
GetPciIrqRoutingTable(VOID)
{
PPCI_IRQ_ROUTING_TABLE Table;
PU8 Ptr;
U32 Sum;
U32 i;
PUCHAR Ptr;
ULONG Sum;
ULONG i;
Table = (PPCI_IRQ_ROUTING_TABLE)0xF0000;
while ((U32)Table < 0x100000)
while ((ULONG)Table < 0x100000)
{
if (Table->Signature == 0x52495024)
{
DbgPrint((DPRINT_HWDETECT,
"Found signature\n"));
Ptr = (PU8)Table;
Ptr = (PUCHAR)Table;
Sum = 0;
for (i = 0; i < Table->Size; i++)
{
@ -103,7 +103,7 @@ GetPciIrqRoutingTable(VOID)
return Table;
}
Table = (PPCI_IRQ_ROUTING_TABLE)((U32)Table + 0x10);
Table = (PPCI_IRQ_ROUTING_TABLE)((ULONG)Table + 0x10);
}
return NULL;
@ -145,14 +145,14 @@ FindPciBios(PCM_PCI_BUS_DATA BusData)
static VOID
DetectPciIrqRoutingTable(HKEY BusKey)
DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PPCI_IRQ_ROUTING_TABLE Table;
HKEY TableKey;
U32 Size;
S32 Error;
FRLDRHKEY TableKey;
ULONG Size;
LONG Error;
Table = GetPciIrqRoutingTable();
if (Table != NULL)
@ -178,7 +178,7 @@ DetectPciIrqRoutingTable(HKEY BusKey)
Error = RegSetValue(TableKey,
"Identifier",
REG_SZ,
(PU8)"PCI Real-mode IRQ Routing Table",
(PUCHAR)"PCI Real-mode IRQ Routing Table",
32);
if (Error != ERROR_SUCCESS)
{
@ -216,7 +216,7 @@ DetectPciIrqRoutingTable(HKEY BusKey)
Error = RegSetValue(TableKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PU8) FullResourceDescriptor,
(PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@ -231,17 +231,17 @@ DetectPciIrqRoutingTable(HKEY BusKey)
VOID
DetectPciBios(HKEY SystemKey, U32 *BusNumber)
DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
CM_PCI_BUS_DATA BusData;
char Buffer[80];
HKEY BiosKey;
U32 Size;
S32 Error;
FRLDRHKEY BiosKey;
ULONG Size;
LONG Error;
#if 0
HKEY BusKey;
U32 i;
FRLDRHKEY BusKey;
ULONG i;
#endif
/* Report the PCI BIOS */
@ -272,7 +272,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Identifier",
REG_SZ,
(PU8)"PCI BIOS",
(PUCHAR)"PCI BIOS",
9);
if (Error != ERROR_SUCCESS)
{
@ -301,7 +301,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BiosKey,
"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PU8) FullResourceDescriptor,
(PUCHAR) FullResourceDescriptor,
Size);
MmFreeMemory(FullResourceDescriptor);
if (Error != ERROR_SUCCESS)
@ -322,7 +322,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
*/
/* Report PCI buses */
for (i = 0; i < (U32)BusData.BusCount; i++)
for (i = 0; i < (ULONG)BusData.BusCount; i++)
{
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
@ -350,7 +350,7 @@ DetectPciBios(HKEY SystemKey, U32 *BusNumber)
Error = RegSetValue(BusKey,
"Identifier",
REG_SZ,
(PU8)"PCI",
(PUCHAR)"PCI",
4);
if (Error != ERROR_SUCCESS)
{

View file

@ -18,13 +18,7 @@
*/
#include "freeldr.h"
#include "disk.h"
#include "rtl.h"
#include "arch.h"
#include "debug.h"
#include "portio.h"
#include "machine.h"
/////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
@ -32,7 +26,7 @@
#ifdef __i386__
BOOL DiskResetController(U32 DriveNumber)
BOOL DiskResetController(ULONG DriveNumber)
{
REGS RegsIn;
REGS RegsOut;
@ -55,7 +49,7 @@ BOOL DiskResetController(U32 DriveNumber)
return INT386_SUCCESS(RegsOut);
}
BOOL DiskInt13ExtensionsSupported(U32 DriveNumber)
BOOL DiskInt13ExtensionsSupported(ULONG DriveNumber)
{
REGS RegsIn;
REGS RegsOut;
@ -133,11 +127,11 @@ VOID DiskStopFloppyMotor(VOID)
WRITE_PORT_UCHAR((PUCHAR)0x3F2, 0);
}
BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSize)
BOOL DiskGetExtendedDriveParameters(ULONG DriveNumber, PVOID Buffer, USHORT BufferSize)
{
REGS RegsIn;
REGS RegsOut;
PU16 Ptr = (PU16)(BIOSCALLBUFFER);
PUSHORT Ptr = (PUSHORT)(BIOSCALLBUFFER);
DbgPrint((DPRINT_DISK, "DiskGetExtendedDriveParameters()\n"));

View file

@ -18,9 +18,6 @@
*/
#include <freeldr.h>
#include <arch.h>
#include <rtl.h>
#include <portio.h>
void beep(void)
{

View file

@ -30,31 +30,31 @@
typedef struct
{
U8 Signature[4]; // (ret) signature ("VESA")
UCHAR Signature[4]; // (ret) signature ("VESA")
// (call) VESA 2.0 request signature ("VBE2"), required to receive
// version 2.0 info
U16 VesaVersion; // VESA version number (one-digit minor version -- 0102h = v1.2)
U32 OemNamePtr; // pointer to OEM name
USHORT VesaVersion; // VESA version number (one-digit minor version -- 0102h = v1.2)
ULONG OemNamePtr; // pointer to OEM name
// "761295520" for ATI
U32 Capabilities; // capabilities flags (see #00078)
U32 SupportedModeListPtr; // pointer to list of supported VESA and OEM video modes
ULONG Capabilities; // capabilities flags (see #00078)
ULONG SupportedModeListPtr; // pointer to list of supported VESA and OEM video modes
// (list of words terminated with FFFFh)
U16 TotalVideoMemory; // total amount of video memory in 64K blocks
USHORT TotalVideoMemory; // total amount of video memory in 64K blocks
// ---VBE v1.x ---
//U8 Reserved[236];
//UCHAR Reserved[236];
// ---VBE v2.0 ---
U16 OemSoftwareVersion; // OEM software version (BCD, high byte = major, low byte = minor)
U32 VendorNamePtr; // pointer to vendor name
U32 ProductNamePtr; // pointer to product name
U32 ProductRevisionStringPtr; // pointer to product revision string
U16 VBE_AF_Version; // (if capabilities bit 3 set) VBE/AF version (BCD)
USHORT OemSoftwareVersion; // OEM software version (BCD, high byte = major, low byte = minor)
ULONG VendorNamePtr; // pointer to vendor name
ULONG ProductNamePtr; // pointer to product name
ULONG ProductRevisionStringPtr; // pointer to product revision string
USHORT VBE_AF_Version; // (if capabilities bit 3 set) VBE/AF version (BCD)
// 0100h for v1.0P
U32 AcceleratedModeListPtr; // (if capabilities bit 3 set) pointer to list of supported
ULONG AcceleratedModeListPtr; // (if capabilities bit 3 set) pointer to list of supported
// accelerated video modes (list of words terminated with FFFFh)
U8 Reserved[216]; // reserved for VBE implementation
U8 ScratchPad[256]; // OEM scratchpad (for OEM strings, etc.)
UCHAR Reserved[216]; // reserved for VBE implementation
UCHAR ScratchPad[256]; // OEM scratchpad (for OEM strings, etc.)
} PACKED VESA_SVGA_INFO, *PVESA_SVGA_INFO;
// Bitfields for VESA capabilities:
@ -106,11 +106,11 @@ VOID BiosSetVideoFont8x16(VOID)
Int386(0x10, &Regs, &Regs);
}
VOID VideoSetTextCursorPosition(U32 X, U32 Y)
VOID VideoSetTextCursorPosition(ULONG X, ULONG Y)
{
}
U32 VideoGetTextCursorPositionX(VOID)
ULONG VideoGetTextCursorPositionX(VOID)
{
REGS Regs;
@ -135,7 +135,7 @@ U32 VideoGetTextCursorPositionX(VOID)
return Regs.b.dl;
}
U32 VideoGetTextCursorPositionY(VOID)
ULONG VideoGetTextCursorPositionY(VOID)
{
REGS Regs;
@ -160,13 +160,13 @@ U32 VideoGetTextCursorPositionY(VOID)
return Regs.b.dh;
}
U16 BiosIsVesaSupported(VOID)
USHORT BiosIsVesaSupported(VOID)
{
REGS Regs;
PVESA_SVGA_INFO SvgaInfo = (PVESA_SVGA_INFO)BIOSCALLBUFFER;
#ifdef DEBUG
//U16* VideoModes;
//U16 Index;
//USHORT* VideoModes;
//USHORT Index;
#endif // defined DEBUG
DbgPrint((DPRINT_UI, "BiosIsVesaSupported()\n"));
@ -227,7 +227,7 @@ U16 BiosIsVesaSupported(VOID)
DbgPrint((DPRINT_UI, "SvgaInfo->VBE/AF Version = 0x%x (BCD WORD)\n", SvgaInfo->VBE_AF_Version));
//DbgPrint((DPRINT_UI, "\nSupported VESA and OEM video modes:\n"));
//VideoModes = (U16*)SvgaInfo->SupportedModeListPtr;
//VideoModes = (USHORT*)SvgaInfo->SupportedModeListPtr;
//for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
//{
// DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));
@ -236,7 +236,7 @@ U16 BiosIsVesaSupported(VOID)
//if (SvgaInfo->VesaVersion >= 0x0200)
//{
// DbgPrint((DPRINT_UI, "\nSupported accelerated video modes (VESA v2.0):\n"));
// VideoModes = (U16*)SvgaInfo->AcceleratedModeListPtr;
// VideoModes = (USHORT*)SvgaInfo->AcceleratedModeListPtr;
// for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
// {
// DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));

View file

@ -32,28 +32,28 @@ VOID PcConsPutChar(int Ch);
BOOL PcConsKbHit();
int PcConsGetCh();
VOID PcVideoClearScreen(U8 Attr);
VOID PcVideoClearScreen(UCHAR Attr);
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayMode, BOOL Init);
VOID PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
U32 PcVideoGetBufferSize(VOID);
VOID PcVideoSetTextCursorPosition(U32 X, U32 Y);
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);
ULONG PcVideoGetBufferSize(VOID);
VOID PcVideoSetTextCursorPosition(ULONG X, ULONG Y);
VOID PcVideoHideShowTextCursor(BOOL Show);
VOID PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y);
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
BOOL PcVideoIsPaletteFixed(VOID);
VOID PcVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
VOID PcVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
VOID PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
VOID PcVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
VOID PcVideoSync(VOID);
VOID PcVideoPrepareForReactOS(VOID);
U32 PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
ULONG PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
BOOL PcDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
U32 PcDiskGetCacheableBlockCount(U32 DriveNumber);
BOOL PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOL PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG PcDiskGetCacheableBlockCount(ULONG DriveNumber);
VOID PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
VOID PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second);
VOID PcHwDetect(VOID);

View file

@ -24,7 +24,7 @@
#include "mm.h"
#endif
U8 XboxFont8x16[256 * 16];
UCHAR XboxFont8x16[256 * 16];
VOID XboxMachInit(VOID);
@ -33,30 +33,30 @@ BOOL XboxConsKbHit();
int XboxConsGetCh();
VOID XboxVideoInit(VOID);
VOID XboxVideoClearScreen(U8 Attr);
VOID XboxVideoClearScreen(UCHAR Attr);
VIDEODISPLAYMODE XboxVideoSetDisplayMode(char *DisplayModem, BOOL Init);
VOID XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
U32 XboxVideoGetBufferSize(VOID);
VOID XboxVideoSetTextCursorPosition(U32 X, U32 Y);
VOID XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);
ULONG XboxVideoGetBufferSize(VOID);
VOID XboxVideoSetTextCursorPosition(ULONG X, ULONG Y);
VOID XboxVideoHideShowTextCursor(BOOL Show);
VOID XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y);
VOID XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
BOOL XboxVideoIsPaletteFixed(VOID);
VOID XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
VOID XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
VOID XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
VOID XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
VOID XboxVideoSync(VOID);
VOID XboxVideoPrepareForReactOS(VOID);
VOID XboxMemInit(VOID);
PVOID XboxMemReserveMemory(U32 MbToReserve);
U32 XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
PVOID XboxMemReserveMemory(ULONG MbToReserve);
ULONG XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
BOOL XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
BOOL XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
U32 XboxDiskGetCacheableBlockCount(U32 DriveNumber);
BOOL XboxDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOL XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG XboxDiskGetCacheableBlockCount(ULONG DriveNumber);
VOID XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
VOID XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second);
VOID XboxHwDetect(VOID);

View file

@ -29,116 +29,29 @@
* This boots the kernel
*/
.code32
EXTERN(_boot_reactos)
call _MachVideoPrepareForReactOS
.globl _PageDirectoryStart
.globl _startup_pagedirectory
.globl _lowmem_pagetable
.globl _kernel_pagetable
.globl _hyperspace_pagetable
.globl _apic_pagetable
.globl _kpcr_pagetable
call _multi_boot
// Should never get here
cli
bootloop:
hlt
jmp bootloop
/*
* After you have setup the _mb_header and _mb_info structures
* then call this routine to transfer control to the kernel.
*/
EXTERN(_multi_boot)
cli
/*
* Load the absolute address of the multiboot information structure
*/
movl $_mb_info,%ebx
/*
* Initalize eflags
*/
pushl $0
popfl
/*
* Load the multiboot magic value into eax
*/
movl $0x2badb002,%eax
/*
* Jump to start of 32 bit code at 0xc0000000 + 0x1000
*/
pushl $KERNEL_CS
pushl _mb_entry_addr
lretl
EXTERN(_mb_header)
_mb_magic:
.long 0 // unsigned long magic;
_mb_flags:
.long 0 // unsigned long flags;
_mb_checksum:
.long 0 // unsigned long checksum;
_mb_header_addr:
.long 0 // unsigned long header_addr;
_mb_load_addr:
.long 0 // unsigned long load_addr;
_mb_load_end_addr:
.long 0 // unsigned long load_end_addr;
_mb_bss_end_addr:
.long 0 // unsigned long bss_end_addr;
_mb_entry_addr:
.long 0 // unsigned long entry_addr;
.globl _startup_pagedirectorytable_pae
.globl _startup_pagedirectory_pae
.globl _lowmem_pagetable_pae
.globl _kernel_pagetable_pae
.globl _hyperspace_pagetable_pae
.globl _apic_pagetable_pae
.globl _kpcr_pagetable_pae
.globl _PageDirectoryEnd
//
// Boot information structure
//
EXTERN(_mb_info)
_multiboot_flags:
.long 0
_multiboot_mem_lower:
.long 0
_multiboot_mem_upper:
.long 0
_multiboot_boot_device:
.long 0
_multiboot_cmdline:
.long 0
_multiboot_mods_count:
.long 0
_multiboot_mods_addr:
.long 0
_multiboot_syms:
.rept 12
.byte 0
.endr
_multiboot_mmap_length:
.long 0
_multiboot_mmap_addr:
.long 0
_multiboot_drives_count:
.long 0
_multiboot_drives_addr:
.long 0
_multiboot_config_table:
.long 0
_multiboot_boot_loader_name:
.long 0
_multiboot_apm_table:
.long 0
EXTERN(_multiboot_modules)
.rept (64 * /*multiboot_module_size*/ 16)
.byte 0
.endr
EXTERN(_multiboot_module_strings)
.rept (64*256)
.byte 0
.endr
EXTERN(_multiboot_memory_map_descriptor_size)
.long 0
@ -147,7 +60,44 @@ EXTERN(_multiboot_memory_map)
.byte 0
.endr
EXTERN(_multiboot_kernel_cmdline)
.rept 255
.byte 0
.endr
.bss
_PageDirectoryStart:
_startup_pagedirectory:
.fill 4096, 1, 0
_lowmem_pagetable:
.fill 4096, 1, 0
_kernel_pagetable:
.fill 2*4096, 1, 0
_hyperspace_pagetable:
.fill 4096, 1, 0
_apic_pagetable:
.fill 4096, 1, 0
_kpcr_pagetable:
.fill 4096, 1, 0
_startup_pagedirectory_pae:
.fill 4 * 4096, 1, 0
_lowmem_pagetable_pae:
.fill 2 * 4096, 1, 0
_kernel_pagetable_pae:
.fill 3*4096, 1, 0
_hyperspace_pagetable_pae:
.fill 2*4096, 1, 0
_apic_pagetable_pae:
.fill 2*4096, 1, 0
_kpcr_pagetable_pae:
.fill 4*4096, 1, 0
_startup_pagedirectorytable_pae:
.fill 4096, 1, 0
_PageDirectoryEnd:

View file

@ -29,13 +29,13 @@
typedef struct
{
U8 PacketSize; // 00h - Size of packet (10h or 18h)
U8 Reserved; // 01h - Reserved (0)
U16 LBABlockCount; // 02h - Number of blocks to transfer (max 007Fh for Phoenix EDD)
U16 TransferBufferOffset; // 04h - Transfer buffer offset (seg:off)
U16 TransferBufferSegment; // Transfer buffer segment (seg:off)
U64 LBAStartBlock; // 08h - Starting absolute block number
U64 TransferBuffer64; // 10h - (EDD-3.0, optional) 64-bit flat address of transfer buffer
UCHAR PacketSize; // 00h - Size of packet (10h or 18h)
UCHAR Reserved; // 01h - Reserved (0)
USHORT LBABlockCount; // 02h - Number of blocks to transfer (max 007Fh for Phoenix EDD)
USHORT TransferBufferOffset; // 04h - Transfer buffer offset (seg:off)
USHORT TransferBufferSegment; // Transfer buffer segment (seg:off)
ULONGLONG LBAStartBlock; // 08h - Starting absolute block number
ULONGLONG TransferBuffer64; // 10h - (EDD-3.0, optional) 64-bit flat address of transfer buffer
// used if DWORD at 04h is FFFFh:FFFFh
} PACKED I386_DISK_ADDRESS_PACKET, *PI386_DISK_ADDRESS_PACKET;
@ -43,7 +43,7 @@ typedef struct
// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////////////////////
static BOOL PcDiskResetController(U32 DriveNumber)
static BOOL PcDiskResetController(ULONG DriveNumber)
{
REGS RegsIn;
REGS RegsOut;
@ -66,11 +66,11 @@ static BOOL PcDiskResetController(U32 DriveNumber)
return INT386_SUCCESS(RegsOut);
}
static BOOL PcDiskReadLogicalSectorsLBA(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
static BOOL PcDiskReadLogicalSectorsLBA(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
REGS RegsIn;
REGS RegsOut;
U32 RetryCount;
ULONG RetryCount;
PI386_DISK_ADDRESS_PACKET Packet = (PI386_DISK_ADDRESS_PACKET)(BIOSCALLBUFFER);
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectorsLBA() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer));
@ -86,8 +86,8 @@ static BOOL PcDiskReadLogicalSectorsLBA(U32 DriveNumber, U64 SectorNumber, U32 S
Packet->PacketSize = sizeof(I386_DISK_ADDRESS_PACKET);
Packet->Reserved = 0;
Packet->LBABlockCount = SectorCount;
Packet->TransferBufferOffset = ((U32)Buffer) & 0x0F;
Packet->TransferBufferSegment = ((U32)Buffer) >> 4;
Packet->TransferBufferOffset = ((ULONG)Buffer) & 0x0F;
Packet->TransferBufferSegment = ((ULONG)Buffer) >> 4;
Packet->LBAStartBlock = SectorNumber;
Packet->TransferBuffer64 = 0;
@ -130,16 +130,16 @@ static BOOL PcDiskReadLogicalSectorsLBA(U32 DriveNumber, U64 SectorNumber, U32 S
return FALSE;
}
static BOOL PcDiskReadLogicalSectorsCHS(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
static BOOL PcDiskReadLogicalSectorsCHS(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
U32 PhysicalSector;
U32 PhysicalHead;
U32 PhysicalTrack;
ULONG PhysicalSector;
ULONG PhysicalHead;
ULONG PhysicalTrack;
GEOMETRY DriveGeometry;
U32 NumberOfSectorsToRead;
ULONG NumberOfSectorsToRead;
REGS RegsIn;
REGS RegsOut;
U32 RetryCount;
ULONG RetryCount;
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectorsCHS()\n"));
@ -215,8 +215,8 @@ static BOOL PcDiskReadLogicalSectorsCHS(U32 DriveNumber, U64 SectorNumber, U32 S
RegsIn.b.cl = (PhysicalSector + ((PhysicalTrack & 0x300) >> 2));
RegsIn.b.dh = PhysicalHead;
RegsIn.b.dl = DriveNumber;
RegsIn.w.es = ((U32)Buffer) >> 4;
RegsIn.w.bx = ((U32)Buffer) & 0x0F;
RegsIn.w.es = ((ULONG)Buffer) >> 4;
RegsIn.w.bx = ((ULONG)Buffer) & 0x0F;
//
// Perform the read
@ -266,9 +266,9 @@ static BOOL PcDiskReadLogicalSectorsCHS(U32 DriveNumber, U64 SectorNumber, U32 S
return TRUE;
}
static BOOL PcDiskInt13ExtensionsSupported(U32 DriveNumber)
static BOOL PcDiskInt13ExtensionsSupported(ULONG DriveNumber)
{
static U32 LastDriveNumber = 0xffffffff;
static ULONG LastDriveNumber = 0xffffffff;
static BOOL LastSupported;
REGS RegsIn;
REGS RegsOut;
@ -355,7 +355,7 @@ static BOOL PcDiskInt13ExtensionsSupported(U32 DriveNumber)
return TRUE;
}
BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
BOOL PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer));
@ -385,18 +385,18 @@ BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount
}
BOOL
PcDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
/* Just use the standard routine */
return DiskGetPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
}
BOOL
PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
{
REGS RegsIn;
REGS RegsOut;
U32 Cylinders;
ULONG Cylinders;
DbgPrint((DPRINT_DISK, "DiskGetDriveGeometry()\n"));
@ -442,8 +442,8 @@ PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
return TRUE;
}
U32
PcDiskGetCacheableBlockCount(U32 DriveNumber)
ULONG
PcDiskGetCacheableBlockCount(ULONG DriveNumber)
{
GEOMETRY Geometry;

View file

@ -28,12 +28,12 @@
#include "portio.h"
#include "rtl.h"
static U32
static ULONG
PcMemGetExtendedMemorySize(VOID)
{
REGS RegsIn;
REGS RegsOut;
U32 MemorySize;
ULONG MemorySize;
DbgPrint((DPRINT_MEMORY, "GetExtendedMemorySize()\n"));
@ -119,7 +119,7 @@ PcMemGetExtendedMemorySize(VOID)
return MemorySize;
}
static U32
static ULONG
PcMemGetConventionalMemorySize(VOID)
{
REGS Regs;
@ -141,14 +141,14 @@ PcMemGetConventionalMemorySize(VOID)
DbgPrint((DPRINT_MEMORY, "Int12h\n"));
DbgPrint((DPRINT_MEMORY, "AX = 0x%x\n\n", Regs.w.ax));
return (U32)Regs.w.ax;
return (ULONG)Regs.w.ax;
}
static U32
PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
static ULONG
PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
REGS Regs;
U32 MapCount;
ULONG MapCount;
DbgPrint((DPRINT_MEMORY, "GetBiosMemoryMap()\n"));
@ -225,10 +225,10 @@ PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
return MapCount;
}
U32
PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
ULONG
PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
U32 EntryCount;
ULONG EntryCount;
EntryCount = PcMemGetBiosMemoryMap(BiosMemoryMap, MaxMemoryMapSize);

View file

@ -25,7 +25,7 @@
#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
VOID
PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
{
REGS Regs;

View file

@ -56,69 +56,69 @@
typedef struct
{
U16 ModeAttributes; /* mode attributes (see #00080) */
U8 WindowAttributesA; /* window attributes, window A (see #00081) */
U8 WindowsAttributesB; /* window attributes, window B (see #00081) */
U16 WindowGranularity; /* window granularity in KB */
U16 WindowSize; /* window size in KB */
U16 WindowAStartSegment; /* start segment of window A (0000h if not supported) */
U16 WindowBStartSegment; /* start segment of window B (0000h if not supported) */
U32 WindowPositioningFunction; /* -> FAR window positioning function (equivalent to AX=4F05h) */
U16 BytesPerScanLine; /* bytes per scan line */
USHORT ModeAttributes; /* mode attributes (see #00080) */
UCHAR WindowAttributesA; /* window attributes, window A (see #00081) */
UCHAR WindowsAttributesB; /* window attributes, window B (see #00081) */
USHORT WindowGranularity; /* window granularity in KB */
USHORT WindowSize; /* window size in KB */
USHORT WindowAStartSegment; /* start segment of window A (0000h if not supported) */
USHORT WindowBStartSegment; /* start segment of window B (0000h if not supported) */
ULONG WindowPositioningFunction; /* -> FAR window positioning function (equivalent to AX=4F05h) */
USHORT BytesPerScanLine; /* bytes per scan line */
/* ---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes--- */
U16 WidthInPixels; /* width in pixels (graphics) or characters (text) */
U16 HeightInPixels; /* height in pixels (graphics) or characters (text) */
U8 CharacterWidthInPixels; /* width of character cell in pixels */
U8 CharacterHeightInPixels; /* height of character cell in pixels */
U8 NumberOfMemoryPlanes; /* number of memory planes */
U8 BitsPerPixel; /* number of bits per pixel */
U8 NumberOfBanks; /* number of banks */
U8 MemoryModel; /* memory model type (see #00082) */
U8 BankSize; /* size of bank in KB */
U8 NumberOfImagePanes; /* number of image pages (less one) that will fit in video RAM */
U8 Reserved1; /* reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0) */
USHORT WidthInPixels; /* width in pixels (graphics) or characters (text) */
USHORT HeightInPixels; /* height in pixels (graphics) or characters (text) */
UCHAR CharacterWidthInPixels; /* width of character cell in pixels */
UCHAR CharacterHeightInPixels; /* height of character cell in pixels */
UCHAR NumberOfMemoryPlanes; /* number of memory planes */
UCHAR BitsPerPixel; /* number of bits per pixel */
UCHAR NumberOfBanks; /* number of banks */
UCHAR MemoryModel; /* memory model type (see #00082) */
UCHAR BankSize; /* size of bank in KB */
UCHAR NumberOfImagePanes; /* number of image pages (less one) that will fit in video RAM */
UCHAR Reserved1; /* reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0) */
/* ---VBE v1.2+ --- */
U8 RedMaskSize; /* red mask size */
U8 RedMaskPosition; /* red field position */
U8 GreenMaskSize; /* green mask size */
U8 GreenMaskPosition; /* green field size */
U8 BlueMaskSize; /* blue mask size */
U8 BlueMaskPosition; /* blue field size */
U8 ReservedMaskSize; /* reserved mask size */
U8 ReservedMaskPosition; /* reserved mask position */
U8 DirectColorModeInfo; /* direct color mode info */
UCHAR RedMaskSize; /* red mask size */
UCHAR RedMaskPosition; /* red field position */
UCHAR GreenMaskSize; /* green mask size */
UCHAR GreenMaskPosition; /* green field size */
UCHAR BlueMaskSize; /* blue mask size */
UCHAR BlueMaskPosition; /* blue field size */
UCHAR ReservedMaskSize; /* reserved mask size */
UCHAR ReservedMaskPosition; /* reserved mask position */
UCHAR DirectColorModeInfo; /* direct color mode info */
/* bit 0:Color ramp is programmable */
/* bit 1:Bytes in reserved field may be used by application */
/* ---VBE v2.0+ --- */
U32 LinearVideoBufferAddress; /* physical address of linear video buffer */
U32 OffscreenMemoryPointer; /* pointer to start of offscreen memory */
U16 OffscreenMemorySize; /* KB of offscreen memory */
ULONG LinearVideoBufferAddress; /* physical address of linear video buffer */
ULONG OffscreenMemoryPointer; /* pointer to start of offscreen memory */
USHORT OffscreenMemorySize; /* KB of offscreen memory */
/* ---VBE v3.0 --- */
U16 LinearBytesPerScanLine; /* bytes per scan line in linear modes */
U8 BankedNumberOfImages; /* number of images (less one) for banked video modes */
U8 LinearNumberOfImages; /* number of images (less one) for linear video modes */
U8 LinearRedMaskSize; /* linear modes:Size of direct color red mask (in bits) */
U8 LinearRedMaskPosition; /* linear modes:Bit position of red mask LSB (e.g. shift count) */
U8 LinearGreenMaskSize; /* linear modes:Size of direct color green mask (in bits) */
U8 LinearGreenMaskPosition; /* linear modes:Bit position of green mask LSB (e.g. shift count) */
U8 LinearBlueMaskSize; /* linear modes:Size of direct color blue mask (in bits) */
U8 LinearBlueMaskPosition; /* linear modes:Bit position of blue mask LSB (e.g. shift count) */
U8 LinearReservedMaskSize; /* linear modes:Size of direct color reserved mask (in bits) */
U8 LinearReservedMaskPosition; /* linear modes:Bit position of reserved mask LSB */
U32 MaximumPixelClock; /* maximum pixel clock for graphics video mode, in Hz */
U8 Reserved2[190]; /* 190 BYTEs reserved (0) */
USHORT LinearBytesPerScanLine; /* bytes per scan line in linear modes */
UCHAR BankedNumberOfImages; /* number of images (less one) for banked video modes */
UCHAR LinearNumberOfImages; /* number of images (less one) for linear video modes */
UCHAR LinearRedMaskSize; /* linear modes:Size of direct color red mask (in bits) */
UCHAR LinearRedMaskPosition; /* linear modes:Bit position of red mask LSB (e.g. shift count) */
UCHAR LinearGreenMaskSize; /* linear modes:Size of direct color green mask (in bits) */
UCHAR LinearGreenMaskPosition; /* linear modes:Bit position of green mask LSB (e.g. shift count) */
UCHAR LinearBlueMaskSize; /* linear modes:Size of direct color blue mask (in bits) */
UCHAR LinearBlueMaskPosition; /* linear modes:Bit position of blue mask LSB (e.g. shift count) */
UCHAR LinearReservedMaskSize; /* linear modes:Size of direct color reserved mask (in bits) */
UCHAR LinearReservedMaskPosition; /* linear modes:Bit position of reserved mask LSB */
ULONG MaximumPixelClock; /* maximum pixel clock for graphics video mode, in Hz */
UCHAR Reserved2[190]; /* 190 BYTEs reserved (0) */
} PACKED SVGA_MODE_INFORMATION, *PSVGA_MODE_INFORMATION;
static U32 BiosVideoMode; /* Current video mode as known by BIOS */
static U32 ScreenWidth = 80; /* Screen Width in characters */
static U32 ScreenHeight = 25; /* Screen Height in characters */
static U32 BytesPerScanLine = 160; /* Number of bytes per scanline (delta) */
static ULONG BiosVideoMode; /* Current video mode as known by BIOS */
static ULONG ScreenWidth = 80; /* Screen Width in characters */
static ULONG ScreenHeight = 25; /* Screen Height in characters */
static ULONG BytesPerScanLine = 160; /* Number of bytes per scanline (delta) */
static VIDEODISPLAYMODE DisplayMode = VideoTextMode; /* Current display mode */
static BOOL VesaVideoMode = FALSE; /* Are we using a VESA mode? */
static SVGA_MODE_INFORMATION VesaVideoModeInformation; /* Only valid when in VESA mode */
static U32 CurrentMemoryBank = 0; /* Currently selected VESA bank */
static ULONG CurrentMemoryBank = 0; /* Currently selected VESA bank */
static U32
static ULONG
PcVideoDetectVideoCard(VOID)
{
REGS Regs;
@ -192,7 +192,7 @@ PcVideoDetectVideoCard(VOID)
}
}
static VOID PcVideoSetBiosMode(U32 VideoMode)
static VOID PcVideoSetBiosMode(ULONG VideoMode)
{
REGS Regs;
@ -297,7 +297,7 @@ VOID PcVideoDisableCursorEmulation(VOID)
}
static VOID
PcVideoDefineCursor(U32 StartScanLine, U32 EndScanLine)
PcVideoDefineCursor(ULONG StartScanLine, ULONG EndScanLine)
{
REGS Regs;
@ -333,7 +333,7 @@ PcVideoDefineCursor(U32 StartScanLine, U32 EndScanLine)
}
static VOID
PcVideoSetVerticalResolution(U32 ScanLines)
PcVideoSetVerticalResolution(ULONG ScanLines)
{
REGS Regs;
@ -439,7 +439,7 @@ PcVideoSetDisplayEnd(VOID)
}
static BOOL
PcVideoVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformation)
PcVideoVesaGetSVGAModeInformation(USHORT Mode, PSVGA_MODE_INFORMATION ModeInformation)
{
REGS Regs;
@ -511,7 +511,7 @@ PcVideoVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformati
}
static BOOL
PcVideoSetBiosVesaMode(U16 Mode)
PcVideoSetBiosVesaMode(USHORT Mode)
{
REGS Regs;
@ -697,7 +697,7 @@ PcVideoSetMode80x60(VOID)
}
static BOOL
PcVideoSetMode(U32 NewMode)
PcVideoSetMode(ULONG NewMode)
{
CurrentMemoryBank = 0;
@ -735,7 +735,7 @@ PcVideoSetMode(U32 NewMode)
{
/* 640x480x16 */
PcVideoSetBiosMode(NewMode);
WRITE_PORT_USHORT((U16*)0x03CE, 0x0F01); /* For some reason this is necessary? */
WRITE_PORT_USHORT((USHORT*)0x03CE, 0x0F01); /* For some reason this is necessary? */
ScreenWidth = 640;
ScreenHeight = 480;
BytesPerScanLine = 80;
@ -830,7 +830,7 @@ PcVideoSetBlinkBit(BOOL Enable)
}
static VOID
PcVideoSetMemoryBank(U16 BankNumber)
PcVideoSetMemoryBank(USHORT BankNumber)
{
REGS Regs;
@ -870,7 +870,7 @@ PcVideoSetMemoryBank(U16 BankNumber)
VIDEODISPLAYMODE
PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
{
U32 VideoMode = VIDEOMODE_NORMAL_TEXT;
ULONG VideoMode = VIDEOMODE_NORMAL_TEXT;
if (NULL == DisplayModeName || '\0' == *DisplayModeName)
{
@ -927,7 +927,7 @@ PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
}
VOID
PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
{
*Width = ScreenWidth;
*Height = ScreenHeight;
@ -950,14 +950,14 @@ PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
}
}
U32
ULONG
PcVideoGetBufferSize(VOID)
{
return ScreenHeight * BytesPerScanLine;
}
VOID
PcVideoSetTextCursorPosition(U32 X, U32 Y)
PcVideoSetTextCursorPosition(ULONG X, ULONG Y)
{
REGS Regs;
@ -997,10 +997,10 @@ PcVideoHideShowTextCursor(BOOL Show)
VOID
PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
{
U32 BanksToCopy;
U32 BytesInLastBank;
U32 CurrentBank;
U32 BankSize;
ULONG BanksToCopy;
ULONG BytesInLastBank;
ULONG CurrentBank;
ULONG BankSize;
/* PcVideoWaitForVerticalRetrace(); */
@ -1036,14 +1036,14 @@ PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
}
VOID
PcVideoClearScreen(U8 Attr)
PcVideoClearScreen(UCHAR Attr)
{
U16 AttrChar;
U16 *BufPtr;
USHORT AttrChar;
USHORT *BufPtr;
AttrChar = ((U16) Attr << 8) | ' ';
for (BufPtr = (U16 *) VIDEOTEXT_MEM_ADDRESS;
BufPtr < (U16 *) (VIDEOTEXT_MEM_ADDRESS + VIDEOTEXT_MEM_SIZE);
AttrChar = ((USHORT) Attr << 8) | ' ';
for (BufPtr = (USHORT *) VIDEOTEXT_MEM_ADDRESS;
BufPtr < (USHORT *) (VIDEOTEXT_MEM_ADDRESS + VIDEOTEXT_MEM_SIZE);
BufPtr++)
{
*BufPtr = AttrChar;
@ -1051,12 +1051,12 @@ PcVideoClearScreen(U8 Attr)
}
VOID
PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
{
U16 *BufPtr;
USHORT *BufPtr;
BufPtr = (U16 *) (VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
*BufPtr = ((U16) Attr << 8) | (Ch & 0xff);
BufPtr = (USHORT *) (VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
*BufPtr = ((USHORT) Attr << 8) | (Ch & 0xff);
}
BOOL
@ -1066,27 +1066,27 @@ PcVideoIsPaletteFixed(VOID)
}
VOID
PcVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
{
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_WRITE, Color);
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Red);
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Green);
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Blue);
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_WRITE, Color);
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Red);
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Green);
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Blue);
}
VOID
PcVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
PcVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue)
{
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_READ, Color);
*Red = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
*Green = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
*Blue = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_READ, Color);
*Red = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
*Green = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
*Blue = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
}
VOID
PcVideoSync(VOID)
{
while (1 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
while (1 == (READ_PORT_UCHAR((UCHAR*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
{
/*
* Keep reading the port until bit 3 is clear
@ -1096,7 +1096,7 @@ PcVideoSync(VOID)
*/
}
while (0 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
while (0 == (READ_PORT_UCHAR((UCHAR*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
{
/*
* Keep reading the port until bit 3 is set

View file

@ -51,37 +51,45 @@
#define SLOW_DOWN_IO __SLOW_DOWN_IO
#endif
VOID /*STDCALL*/
#undef READ_PORT_BUFFER_UCHAR
VOID
STDCALL
READ_PORT_BUFFER_UCHAR (PUCHAR Port,
PUCHAR Buffer,
U32 Count)
ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; insb\n\t"
: "=D" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
VOID /*STDCALL*/
READ_PORT_BUFFER_USHORT (U16* Port,
U16* Buffer,
U32 Count)
#undef READ_PORT_BUFFER_USHORT
VOID
STDCALL
READ_PORT_BUFFER_USHORT (USHORT* Port,
USHORT* Buffer,
ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; insw"
: "=D" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
VOID /*STDCALL*/
READ_PORT_BUFFER_ULONG (U32* Port,
U32* Buffer,
U32 Count)
#undef READ_PORT_BUFFER_ULONG
VOID
STDCALL
READ_PORT_BUFFER_ULONG (ULONG* Port,
ULONG* Buffer,
ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; insl"
: "=D" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
UCHAR /*STDCALL*/
#undef READ_PORT_UCHAR
UCHAR
STDCALL
READ_PORT_UCHAR (PUCHAR Port)
{
UCHAR Value;
@ -93,10 +101,12 @@ READ_PORT_UCHAR (PUCHAR Port)
return(Value);
}
U16 /*STDCALL*/
READ_PORT_USHORT (U16* Port)
#undef READ_PORT_USHORT
USHORT
STDCALL
READ_PORT_USHORT (USHORT* Port)
{
U16 Value;
USHORT Value;
__asm__("inw %w1, %0\n\t"
: "=a" (Value)
@ -105,10 +115,12 @@ READ_PORT_USHORT (U16* Port)
return(Value);
}
U32 /*STDCALL*/
READ_PORT_ULONG (U32* Port)
#undef READ_PORT_ULONG
ULONG
STDCALL
READ_PORT_ULONG (ULONG* Port)
{
U32 Value;
ULONG Value;
__asm__("inl %w1, %0\n\t"
: "=a" (Value)
@ -117,37 +129,45 @@ READ_PORT_ULONG (U32* Port)
return(Value);
}
VOID /*STDCALL*/
#undef WRITE_PORT_BUFFER_UCHAR
VOID
STDCALL
WRITE_PORT_BUFFER_UCHAR (PUCHAR Port,
PUCHAR Buffer,
U32 Count)
ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; outsb"
: "=S" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
VOID /*STDCALL*/
WRITE_PORT_BUFFER_USHORT (U16* Port,
U16* Buffer,
U32 Count)
#undef WRITE_PORT_BUFFER_USHORT
VOID
STDCALL
WRITE_PORT_BUFFER_USHORT (USHORT* Port,
USHORT* Buffer,
ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; outsw"
: "=S" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
VOID /*STDCALL*/
WRITE_PORT_BUFFER_ULONG (U32* Port,
U32* Buffer,
U32 Count)
#undef WRITE_PORT_BUFFER_ULONG
VOID
STDCALL
WRITE_PORT_BUFFER_ULONG (ULONG* Port,
ULONG* Buffer,
ULONG Count)
{
__asm__ __volatile__ ("cld ; rep ; outsl"
: "=S" (Buffer), "=c" (Count)
: "d" (Port),"0" (Buffer),"1" (Count));
}
VOID /*STDCALL*/
#undef WRITE_PORT_UCHAR
VOID
STDCALL
WRITE_PORT_UCHAR (PUCHAR Port,
UCHAR Value)
{
@ -158,9 +178,11 @@ WRITE_PORT_UCHAR (PUCHAR Port,
SLOW_DOWN_IO;
}
VOID /*STDCALL*/
WRITE_PORT_USHORT (U16* Port,
U16 Value)
#undef WRITE_PORT_USHORT
VOID
STDCALL
WRITE_PORT_USHORT (USHORT* Port,
USHORT Value)
{
__asm__("outw %0, %w1\n\t"
:
@ -169,9 +191,11 @@ WRITE_PORT_USHORT (U16* Port,
SLOW_DOWN_IO;
}
VOID /*STDCALL*/
WRITE_PORT_ULONG (U32* Port,
U32 Value)
#undef WRITE_PORT_ULONG
VOID
STDCALL
WRITE_PORT_ULONG (ULONG* Port,
ULONG Value)
{
__asm__("outl %0, %w1\n\t"
:

View file

@ -28,9 +28,9 @@ static unsigned CurrentAttr = 0x0f;
VOID
XboxConsPutChar(int c)
{
U32 Width;
U32 Height;
U32 Depth;
ULONG Width;
ULONG Height;
ULONG Depth;
if ('\r' == c)
{

View file

@ -38,9 +38,9 @@
static struct
{
U32 SectorCountBeforePartition;
U32 PartitionSectorCount;
U8 SystemIndicator;
ULONG SectorCountBeforePartition;
ULONG PartitionSectorCount;
UCHAR SystemIndicator;
} XboxPartitions[] =
{
/* This is in the \Device\Harddisk0\Partition.. order used by the Xbox kernel */
@ -155,17 +155,17 @@ static struct
* Data block read and write commands
*/
#define IDEReadBlock(Address, Buffer, Count) \
(READ_PORT_BUFFER_USHORT((PU16)((Address) + IDE_REG_DATA_PORT), (PU16)(Buffer), (Count) / 2))
(READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
#define IDEWriteBlock(Address, Buffer, Count) \
(WRITE_PORT_BUFFER_USHORT((PU16)((Address) + IDE_REG_DATA_PORT), (PU16)(Buffer), (Count) / 2))
(WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
#define IDEReadBlock32(Address, Buffer, Count) \
(READ_PORT_BUFFER_ULONG((PU32)((Address) + IDE_REG_DATA_PORT), (PU32)(Buffer), (Count) / 4))
(READ_PORT_BUFFER_ULONG((PULONG)((Address) + IDE_REG_DATA_PORT), (PULONG)(Buffer), (Count) / 4))
#define IDEWriteBlock32(Address, Buffer, Count) \
(WRITE_PORT_BUFFER_ULONG((PU32)((Address) + IDE_REG_DATA_PORT), (PU32)(Buffer), (Count) / 4))
(WRITE_PORT_BUFFER_ULONG((PULONG)((Address) + IDE_REG_DATA_PORT), (PULONG)(Buffer), (Count) / 4))
#define IDEReadWord(Address) \
(READ_PORT_USHORT((PU16)((Address) + IDE_REG_DATA_PORT)))
(READ_PORT_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT)))
/*
* Access macros for control registers
@ -180,64 +180,64 @@ static struct
typedef struct _IDE_DRIVE_IDENTIFY
{
U16 ConfigBits; /*00*/
U16 LogicalCyls; /*01*/
U16 Reserved02; /*02*/
U16 LogicalHeads; /*03*/
U16 BytesPerTrack; /*04*/
U16 BytesPerSector; /*05*/
U16 SectorsPerTrack; /*06*/
U8 InterSectorGap; /*07*/
U8 InterSectorGapSize;
U8 Reserved08H; /*08*/
U8 BytesInPLO;
U16 VendorUniqueCnt; /*09*/
USHORT ConfigBits; /*00*/
USHORT LogicalCyls; /*01*/
USHORT Reserved02; /*02*/
USHORT LogicalHeads; /*03*/
USHORT BytesPerTrack; /*04*/
USHORT BytesPerSector; /*05*/
USHORT SectorsPerTrack; /*06*/
UCHAR InterSectorGap; /*07*/
UCHAR InterSectorGapSize;
UCHAR Reserved08H; /*08*/
UCHAR BytesInPLO;
USHORT VendorUniqueCnt; /*09*/
char SerialNumber[20]; /*10*/
U16 ControllerType; /*20*/
U16 BufferSize; /*21*/
U16 ECCByteCnt; /*22*/
USHORT ControllerType; /*20*/
USHORT BufferSize; /*21*/
USHORT ECCByteCnt; /*22*/
char FirmwareRev[8]; /*23*/
char ModelNumber[40]; /*27*/
U16 RWMultImplemented; /*47*/
U16 DWordIo; /*48*/
U16 Capabilities; /*49*/
USHORT RWMultImplemented; /*47*/
USHORT DWordIo; /*48*/
USHORT Capabilities; /*49*/
#define IDE_DRID_STBY_SUPPORTED 0x2000
#define IDE_DRID_IORDY_SUPPORTED 0x0800
#define IDE_DRID_IORDY_DISABLE 0x0400
#define IDE_DRID_LBA_SUPPORTED 0x0200
#define IDE_DRID_DMA_SUPPORTED 0x0100
U16 Reserved50; /*50*/
U16 MinPIOTransTime; /*51*/
U16 MinDMATransTime; /*52*/
U16 TMFieldsValid; /*53*/
U16 TMCylinders; /*54*/
U16 TMHeads; /*55*/
U16 TMSectorsPerTrk; /*56*/
U16 TMCapacityLo; /*57*/
U16 TMCapacityHi; /*58*/
U16 RWMultCurrent; /*59*/
U16 TMSectorCountLo; /*60*/
U16 TMSectorCountHi; /*61*/
U16 DmaModes; /*62*/
U16 MultiDmaModes; /*63*/
U16 Reserved64[5]; /*64*/
U16 Reserved69[2]; /*69*/
U16 Reserved71[4]; /*71*/
U16 MaxQueueDepth; /*75*/
U16 Reserved76[4]; /*76*/
U16 MajorRevision; /*80*/
U16 MinorRevision; /*81*/
U16 SupportedFeatures82; /*82*/
U16 SupportedFeatures83; /*83*/
U16 SupportedFeatures84; /*84*/
U16 EnabledFeatures85; /*85*/
U16 EnabledFeatures86; /*86*/
U16 EnabledFeatures87; /*87*/
U16 UltraDmaModes; /*88*/
U16 Reserved89[11]; /*89*/
U16 Max48BitAddress[4]; /*100*/
U16 Reserved104[151]; /*104*/
U16 Checksum; /*255*/
USHORT Reserved50; /*50*/
USHORT MinPIOTransTime; /*51*/
USHORT MinDMATransTime; /*52*/
USHORT TMFieldsValid; /*53*/
USHORT TMCylinders; /*54*/
USHORT TMHeads; /*55*/
USHORT TMSectorsPerTrk; /*56*/
USHORT TMCapacityLo; /*57*/
USHORT TMCapacityHi; /*58*/
USHORT RWMultCurrent; /*59*/
USHORT TMSectorCountLo; /*60*/
USHORT TMSectorCountHi; /*61*/
USHORT DmaModes; /*62*/
USHORT MultiDmaModes; /*63*/
USHORT Reserved64[5]; /*64*/
USHORT Reserved69[2]; /*69*/
USHORT Reserved71[4]; /*71*/
USHORT MaxQueueDepth; /*75*/
USHORT Reserved76[4]; /*76*/
USHORT MajorRevision; /*80*/
USHORT MinorRevision; /*81*/
USHORT SupportedFeatures82; /*82*/
USHORT SupportedFeatures83; /*83*/
USHORT SupportedFeatures84; /*84*/
USHORT EnabledFeatures85; /*85*/
USHORT EnabledFeatures86; /*86*/
USHORT EnabledFeatures87; /*87*/
USHORT UltraDmaModes; /*88*/
USHORT Reserved89[11]; /*89*/
USHORT Max48BitAddress[4]; /*100*/
USHORT Reserved104[151]; /*104*/
USHORT Checksum; /*255*/
} IDE_DRIVE_IDENTIFY, *PIDE_DRIVE_IDENTIFY;
/* XboxDiskPolledRead
@ -249,15 +249,15 @@ typedef struct _IDE_DRIVE_IDENTIFY
* PASSIVE_LEVEL
*
* ARGUMENTS:
* U32 CommandPort Address of command port for drive
* U32 ControlPort Address of control port for drive
* U8 PreComp Value to write to precomp register
* U8 SectorCnt Value to write to sectorCnt register
* U8 SectorNum Value to write to sectorNum register
* U8 CylinderLow Value to write to CylinderLow register
* U8 CylinderHigh Value to write to CylinderHigh register
* U8 DrvHead Value to write to Drive/Head register
* U8 Command Value to write to Command register
* ULONG CommandPort Address of command port for drive
* ULONG ControlPort Address of control port for drive
* UCHAR PreComp Value to write to precomp register
* UCHAR SectorCnt Value to write to sectorCnt register
* UCHAR SectorNum Value to write to sectorNum register
* UCHAR CylinderLow Value to write to CylinderLow register
* UCHAR CylinderHigh Value to write to CylinderHigh register
* UCHAR DrvHead Value to write to Drive/Head register
* UCHAR Command Value to write to Command register
* PVOID Buffer Buffer for output data
*
* RETURNS:
@ -265,21 +265,21 @@ typedef struct _IDE_DRIVE_IDENTIFY
*/
static BOOL
XboxDiskPolledRead(U32 CommandPort,
U32 ControlPort,
U8 PreComp,
U8 SectorCnt,
U8 SectorNum,
U8 CylinderLow,
U8 CylinderHigh,
U8 DrvHead,
U8 Command,
XboxDiskPolledRead(ULONG CommandPort,
ULONG ControlPort,
UCHAR PreComp,
UCHAR SectorCnt,
UCHAR SectorNum,
UCHAR CylinderLow,
UCHAR CylinderHigh,
UCHAR DrvHead,
UCHAR Command,
PVOID Buffer)
{
U32 SectorCount = 0;
U32 RetryCount;
ULONG SectorCount = 0;
ULONG RetryCount;
BOOL Junk = FALSE;
U8 Status;
UCHAR Status;
/* Wait for BUSY to clear */
for (RetryCount = 0; RetryCount < IDE_MAX_BUSY_RETRIES; RetryCount++)
@ -289,7 +289,7 @@ XboxDiskPolledRead(U32 CommandPort,
{
break;
}
KeStallExecutionProcessor(10);
StallExecutionProcessor(10);
}
DbgPrint((DPRINT_DISK, "status=0x%x\n", Status));
DbgPrint((DPRINT_DISK, "waited %d usecs for busy to clear\n", RetryCount * 10));
@ -301,11 +301,11 @@ XboxDiskPolledRead(U32 CommandPort,
/* Write Drive/Head to select drive */
IDEWriteDriveHead(CommandPort, IDE_DH_FIXED | DrvHead);
KeStallExecutionProcessor(500);
StallExecutionProcessor(500);
/* Disable interrupts */
IDEWriteDriveControl(ControlPort, IDE_DC_nIEN);
KeStallExecutionProcessor(500);
StallExecutionProcessor(500);
/* Issue command to drive */
if (DrvHead & IDE_DH_LBA)
@ -338,7 +338,7 @@ XboxDiskPolledRead(U32 CommandPort,
/* Issue the command */
IDEWriteCommand(CommandPort, Command);
KeStallExecutionProcessor(50);
StallExecutionProcessor(50);
/* wait for DRQ or error */
for (RetryCount = 0; RetryCount < IDE_MAX_POLL_RETRIES; RetryCount++)
@ -349,7 +349,7 @@ XboxDiskPolledRead(U32 CommandPort,
if (Status & IDE_SR_ERR)
{
IDEWriteDriveControl(ControlPort, 0);
KeStallExecutionProcessor(50);
StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
@ -362,20 +362,20 @@ XboxDiskPolledRead(U32 CommandPort,
else
{
IDEWriteDriveControl(ControlPort, 0);
KeStallExecutionProcessor(50);
StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
}
}
KeStallExecutionProcessor(10);
StallExecutionProcessor(10);
}
/* timed out */
if (RetryCount >= IDE_MAX_POLL_RETRIES)
{
IDEWriteDriveControl(ControlPort, 0);
KeStallExecutionProcessor(50);
StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
@ -405,7 +405,7 @@ XboxDiskPolledRead(U32 CommandPort,
if (Status & IDE_SR_ERR)
{
IDEWriteDriveControl(ControlPort, 0);
KeStallExecutionProcessor(50);
StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return FALSE;
@ -427,7 +427,7 @@ XboxDiskPolledRead(U32 CommandPort,
SectorCount - SectorCnt));
}
IDEWriteDriveControl(ControlPort, 0);
KeStallExecutionProcessor(50);
StallExecutionProcessor(50);
IDEReadStatus(CommandPort);
return TRUE;
@ -438,10 +438,10 @@ XboxDiskPolledRead(U32 CommandPort,
}
BOOL
XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
XboxDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
U32 StartSector;
U8 Count;
ULONG StartSector;
UCHAR Count;
if (DriveNumber < 0x80 || 2 <= (DriveNumber & 0x0f))
{
@ -456,7 +456,7 @@ XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, P
return FALSE;
}
StartSector = (U32) SectorNumber;
StartSector = (ULONG) SectorNumber;
while (0 < SectorCount)
{
Count = (SectorCount <= 255 ? SectorCount : 255);
@ -481,9 +481,9 @@ XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, P
}
BOOL
XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
U8 SectorData[IDE_SECTOR_BUF_SZ];
UCHAR SectorData[IDE_SECTOR_BUF_SZ];
/* This is the Xbox, chances are that there is a Xbox-standard partitionless
* disk in it so let's check that first */
@ -491,7 +491,7 @@ XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE
if (1 <= PartitionNumber && PartitionNumber <= sizeof(XboxPartitions) / sizeof(XboxPartitions[0]) &&
MachDiskReadLogicalSectors(DriveNumber, XBOX_SIGNATURE_SECTOR, 1, SectorData))
{
if (*((PU32) SectorData) == XBOX_SIGNATURE)
if (*((PULONG) SectorData) == XBOX_SIGNATURE)
{
memset(PartitionTableEntry, 0, sizeof(PARTITION_TABLE_ENTRY));
PartitionTableEntry->SystemIndicator = XboxPartitions[PartitionNumber - 1].SystemIndicator;
@ -506,10 +506,10 @@ XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE
}
BOOL
XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
{
IDE_DRIVE_IDENTIFY DrvParms;
U32 i;
ULONG i;
BOOL Atapi;
Atapi = FALSE; /* FIXME */
@ -565,8 +565,8 @@ XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
return TRUE;
}
U32
XboxDiskGetCacheableBlockCount(U32 DriveNumber)
ULONG
XboxDiskGetCacheableBlockCount(ULONG DriveNumber)
{
/* 64 seems a nice number, it is used by the machpc code for LBA devices */
return 64;

View file

@ -23,7 +23,7 @@
#include "machine.h"
#include "machxbox.h"
U8 XboxFont8x16[256 * 16] =
UCHAR XboxFont8x16[256 * 16] =
{
0x00,0x00,0x00,0x7c,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c,0x00,0x00,0x00,0x00, /* 0x00 */
0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xa5,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, /* 0x01 */

View file

@ -29,8 +29,8 @@
#include "machxbox.h"
#include "portio.h"
static U32 InstalledMemoryMb = 0;
static U32 AvailableMemoryMb = 0;
static ULONG InstalledMemoryMb = 0;
static ULONG AvailableMemoryMb = 0;
#define TEST_SIZE 0x200
#define TEST_PATTERN1 0xaa
@ -39,15 +39,15 @@ static U32 AvailableMemoryMb = 0;
VOID
XboxMemInit(VOID)
{
U8 ControlRegion[TEST_SIZE];
UCHAR ControlRegion[TEST_SIZE];
PVOID MembaseTop = (PVOID)(64 * 1024 * 1024);
PVOID MembaseLow = (PVOID)0;
(*(PU32)(0xfd000000 + 0x100200)) = 0x03070103 ;
(*(PU32)(0xfd000000 + 0x100204)) = 0x11448000 ;
(*(PULONG)(0xfd000000 + 0x100200)) = 0x03070103 ;
(*(PULONG)(0xfd000000 + 0x100204)) = 0x11448000 ;
WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
WRITE_PORT_ULONG((U32*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
WRITE_PORT_ULONG((ULONG*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */
InstalledMemoryMb = 64;
memset(ControlRegion, TEST_PATTERN1, TEST_SIZE);
@ -76,16 +76,16 @@ XboxMemInit(VOID)
}
/* Set hardware for amount of memory detected */
WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
WRITE_PORT_ULONG((U32*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
WRITE_PORT_ULONG((ULONG*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
AvailableMemoryMb = InstalledMemoryMb;
}
U32
XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
ULONG
XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
U32 EntryCount = 0;
ULONG EntryCount = 0;
/* Synthesize memory map */
if (1 <= MaxMemoryMapSize)
@ -110,7 +110,7 @@ XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
}
PVOID
XboxMemReserveMemory(U32 MbToReserve)
XboxMemReserveMemory(ULONG MbToReserve)
{
if (0 == InstalledMemoryMb)
{

View file

@ -41,7 +41,7 @@ HalpQueryCMOS(UCHAR Reg)
}
VOID
XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
{
while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
{

View file

@ -30,10 +30,10 @@
#define I2C_IO_BASE 0xc000
static PVOID FrameBuffer;
static U32 ScreenWidth;
static U32 ScreenHeight;
static U32 BytesPerPixel;
static U32 Delta;
static ULONG ScreenWidth;
static ULONG ScreenHeight;
static ULONG BytesPerPixel;
static ULONG Delta;
#define CHAR_WIDTH 8
#define CHAR_HEIGHT 16
@ -45,16 +45,16 @@ static U32 Delta;
#define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
static VOID
XboxVideoOutputChar(U8 Char, unsigned X, unsigned Y, U32 FgColor, U32 BgColor)
XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
{
PU8 FontPtr;
PU32 Pixel;
U8 Mask;
PUCHAR FontPtr;
PULONG Pixel;
UCHAR Mask;
unsigned Line;
unsigned Col;
FontPtr = XboxFont8x16 + Char * 16;
Pixel = (PU32) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
Pixel = (PULONG) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
+ X * CHAR_WIDTH * BytesPerPixel);
for (Line = 0; Line < CHAR_HEIGHT; Line++)
{
@ -64,14 +64,14 @@ XboxVideoOutputChar(U8 Char, unsigned X, unsigned Y, U32 FgColor, U32 BgColor)
Pixel[Col] = (0 != (FontPtr[Line] & Mask) ? FgColor : BgColor);
Mask = Mask >> 1;
}
Pixel = (PU32) ((char *) Pixel + Delta);
Pixel = (PULONG) ((char *) Pixel + Delta);
}
}
static U32
XboxVideoAttrToSingleColor(U8 Attr)
static ULONG
XboxVideoAttrToSingleColor(UCHAR Attr)
{
U8 Intensity;
UCHAR Intensity;
Intensity = (0 == (Attr & 0x08) ? 127 : 255);
@ -82,21 +82,21 @@ XboxVideoAttrToSingleColor(U8 Attr)
}
static VOID
XboxVideoAttrToColors(U8 Attr, U32 *FgColor, U32 *BgColor)
XboxVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
{
*FgColor = XboxVideoAttrToSingleColor(Attr & 0xf);
*BgColor = XboxVideoAttrToSingleColor((Attr >> 4) & 0xf);
}
static VOID
XboxVideoClearScreenColor(U32 Color, BOOL FullScreen)
XboxVideoClearScreenColor(ULONG Color, BOOL FullScreen)
{
U32 Line, Col;
PU32 p;
ULONG Line, Col;
PULONG p;
for (Line = 0; Line < ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
{
p = (PU32) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
p = (PULONG) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
for (Col = 0; Col < ScreenWidth; Col++)
{
*p++ = Color;
@ -105,9 +105,9 @@ XboxVideoClearScreenColor(U32 Color, BOOL FullScreen)
}
VOID
XboxVideoClearScreen(U8 Attr)
XboxVideoClearScreen(UCHAR Attr)
{
U32 FgColor, BgColor;
ULONG FgColor, BgColor;
XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
@ -115,9 +115,9 @@ XboxVideoClearScreen(U8 Attr)
}
VOID
XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
{
U32 FgColor, BgColor;
ULONG FgColor, BgColor;
XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
@ -125,11 +125,11 @@ XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
}
static BOOL
ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, ULONG *Data_to_smbus)
{
int nRetriesToLive=50;
while (0 != (READ_PORT_USHORT((PU16) (I2C_IO_BASE + 0)) & 0x0800))
while (0 != (READ_PORT_USHORT((PUSHORT) (I2C_IO_BASE + 0)) & 0x0800))
{
; /* Franz's spin while bus busy with any master traffic */
}
@ -142,8 +142,8 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
WRITE_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 4), (Address << 1) | 1);
WRITE_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 8), bRegister);
temp = READ_PORT_USHORT((U16 *) (I2C_IO_BASE + 0));
WRITE_PORT_USHORT((PU16) (I2C_IO_BASE + 0), temp); /* clear down all preexisting errors */
temp = READ_PORT_USHORT((USHORT *) (I2C_IO_BASE + 0));
WRITE_PORT_USHORT((PUSHORT) (I2C_IO_BASE + 0), temp); /* clear down all preexisting errors */
switch (Size)
{
@ -186,7 +186,7 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
READ_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 9));
break;
case 2:
*Data_to_smbus = READ_PORT_USHORT((U16 *) (I2C_IO_BASE + 6));
*Data_to_smbus = READ_PORT_USHORT((USHORT *) (I2C_IO_BASE + 6));
break;
default:
*Data_to_smbus = READ_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 6));
@ -203,7 +203,7 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
static BOOL
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, U32 *Return)
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, ULONG *Return)
{
return ReadfromSMBus(bPicAddressI2cFormat, bDataToWrite, 1, Return);
}
@ -212,9 +212,9 @@ I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, U32 *Re
VOID
XboxVideoInit(VOID)
{
U32 AvMode;
ULONG AvMode;
FrameBuffer = (PVOID)((U32) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
FrameBuffer = (PVOID)((ULONG) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode))
{
@ -247,7 +247,7 @@ XboxVideoInit(VOID)
XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE);
/* Tell the nVidia controller about the framebuffer */
*((PU32) 0xfd600800) = (U32) FrameBuffer;
*((PULONG) 0xfd600800) = (ULONG) FrameBuffer;
}
VIDEODISPLAYMODE
@ -258,21 +258,21 @@ XboxVideoSetDisplayMode(char *DisplayMode, BOOL Init)
}
VOID
XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
{
*Width = ScreenWidth / CHAR_WIDTH;
*Height = (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT;
*Depth = 0;
}
U32
ULONG
XboxVideoGetBufferSize(VOID)
{
return (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT * (ScreenWidth / CHAR_WIDTH) * 2;
}
VOID
XboxVideoSetTextCursorPosition(U32 X, U32 Y)
XboxVideoSetTextCursorPosition(ULONG X, ULONG Y)
{
/* We don't have a cursor yet */
}
@ -286,8 +286,8 @@ XboxVideoHideShowTextCursor(BOOL Show)
VOID
XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
{
PU8 OffScreenBuffer = (PU8) Buffer;
U32 Col, Line;
PUCHAR OffScreenBuffer = (PUCHAR) Buffer;
ULONG Col, Line;
for (Line = 0; Line < (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT; Line++)
{
@ -306,13 +306,13 @@ XboxVideoIsPaletteFixed(VOID)
}
VOID
XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
{
/* Not supported */
}
VOID
XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue)
{
/* Not supported */
}

View file

@ -41,13 +41,13 @@ VOID RunLoader(VOID)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
U32 SectionId;
U32 OperatingSystemCount;
ULONG SectionId;
ULONG OperatingSystemCount;
PUCHAR *OperatingSystemSectionNames;
PUCHAR *OperatingSystemDisplayNames;
U32 DefaultOperatingSystem;
S32 TimeOut;
U32 SelectedOperatingSystem;
ULONG DefaultOperatingSystem;
LONG TimeOut;
ULONG SelectedOperatingSystem;
if (!IniFileInitialize())
{
@ -159,13 +159,13 @@ reboot:
return;
}
U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSystemCount)
ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount)
{
UCHAR DefaultOSText[80];
char* DefaultOSName;
U32 SectionId;
U32 DefaultOS = 0;
U32 Idx;
ULONG SectionId;
ULONG DefaultOS = 0;
ULONG Idx;
if (!IniOpenSection("FreeLoader", &SectionId))
{
@ -196,11 +196,11 @@ U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSyste
return DefaultOS;
}
S32 GetTimeOut(VOID)
LONG GetTimeOut(VOID)
{
UCHAR TimeOutText[20];
S32 TimeOut;
U32 SectionId;
LONG TimeOut;
ULONG SectionId;
TimeOut = CmdLineGetTimeOut();
if (0 <= TimeOut)
@ -225,7 +225,7 @@ S32 GetTimeOut(VOID)
return TimeOut;
}
BOOL MainBootMenuKeyPressFilter(U32 KeyPress)
BOOL MainBootMenuKeyPressFilter(ULONG KeyPress)
{
if (KeyPress == KEY_F8)
{

View file

@ -30,7 +30,7 @@
// Returns a pointer to a CACHE_BLOCK structure
// Adds the block to the cache manager block list
// in cache memory if it isn't already there
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
{
PCACHE_BLOCK CacheBlock = NULL;
@ -55,7 +55,7 @@ PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumb
return CacheBlock;
}
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
{
PCACHE_BLOCK CacheBlock = NULL;
@ -93,7 +93,7 @@ PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
return NULL;
}
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
{
PCACHE_BLOCK CacheBlock = NULL;
@ -195,7 +195,7 @@ BOOL CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive)
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive)
{
U32 NewCacheSize;
ULONG NewCacheSize;
DbgPrint((DPRINT_CACHE, "CacheInternalCheckCacheSizeLimits()\n"));

View file

@ -34,11 +34,11 @@
CACHE_DRIVE CacheManagerDrive;
BOOL CacheManagerInitialized = FALSE;
BOOL CacheManagerDataInvalid = FALSE;
U32 CacheBlockCount = 0;
U32 CacheSizeLimit = 0;
U32 CacheSizeCurrent = 0;
ULONG CacheBlockCount = 0;
ULONG CacheSizeLimit = 0;
ULONG CacheSizeCurrent = 0;
BOOL CacheInitializeDrive(U32 DriveNumber)
BOOL CacheInitializeDrive(ULONG DriveNumber)
{
PCACHE_BLOCK NextCacheBlock;
GEOMETRY DriveGeometry;
@ -116,16 +116,16 @@ VOID CacheInvalidateCacheData(VOID)
CacheManagerDataInvalid = TRUE;
}
BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOID Buffer)
BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount, PVOID Buffer)
{
PCACHE_BLOCK CacheBlock;
U32 StartBlock;
U32 SectorOffsetInStartBlock;
U32 CopyLengthInStartBlock;
U32 EndBlock;
U32 SectorOffsetInEndBlock;
U32 BlockCount;
U32 Idx;
ULONG StartBlock;
ULONG SectorOffsetInStartBlock;
ULONG CopyLengthInStartBlock;
ULONG EndBlock;
ULONG SectorOffsetInEndBlock;
ULONG BlockCount;
ULONG Idx;
DbgPrint((DPRINT_CACHE, "CacheReadDiskSectors() DiskNumber: 0x%x StartSector: %d SectorCount: %d Buffer: 0x%x\n", DiskNumber, StartSector, SectorCount, Buffer));
@ -248,13 +248,13 @@ BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOI
return TRUE;
}
BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorCount)
BOOL CacheForceDiskSectorsIntoCache(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount)
{
PCACHE_BLOCK CacheBlock;
U32 StartBlock;
U32 EndBlock;
U32 BlockCount;
U32 Idx;
ULONG StartBlock;
ULONG EndBlock;
ULONG BlockCount;
ULONG Idx;
DbgPrint((DPRINT_CACHE, "CacheForceDiskSectorsIntoCache() DiskNumber: 0x%x StartSector: %d SectorCount: %d\n", DiskNumber, StartSector, SectorCount));
@ -294,9 +294,9 @@ BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorC
return TRUE;
}
BOOL CacheReleaseMemory(U32 MinimumAmountToRelease)
BOOL CacheReleaseMemory(ULONG MinimumAmountToRelease)
{
U32 AmountReleased;
ULONG AmountReleased;
DbgPrint((DPRINT_CACHE, "CacheReleaseMemory() MinimumAmountToRelease = %d\n", MinimumAmountToRelease));

View file

@ -38,9 +38,9 @@ typedef struct
{
LIST_ITEM ListEntry; // Doubly linked list synchronization member
U32 BlockNumber; // Track index for CHS, 64k block index for LBA
ULONG BlockNumber; // Track index for CHS, 64k block index for LBA
BOOL LockedInCache; // Indicates that this block is locked in cache memory
U32 AccessCount; // Access count for this block
ULONG AccessCount; // Access count for this block
PVOID BlockData; // Pointer to block data
@ -55,10 +55,10 @@ typedef struct
///////////////////////////////////////////////////////////////////////////////////////
typedef struct
{
U32 DriveNumber;
U32 BytesPerSector;
ULONG DriveNumber;
ULONG BytesPerSector;
U32 BlockSize; // Block size (in sectors)
ULONG BlockSize; // Block size (in sectors)
PCACHE_BLOCK CacheBlockHead;
} CACHE_DRIVE, *PCACHE_DRIVE;
@ -71,18 +71,18 @@ typedef struct
///////////////////////////////////////////////////////////////////////////////////////
extern CACHE_DRIVE CacheManagerDrive;
extern BOOL CacheManagerInitialized;
extern U32 CacheBlockCount;
extern U32 CacheSizeLimit;
extern U32 CacheSizeCurrent;
extern ULONG CacheBlockCount;
extern ULONG CacheSizeLimit;
extern ULONG CacheSizeCurrent;
///////////////////////////////////////////////////////////////////////////////////////
//
// Internal functions
//
///////////////////////////////////////////////////////////////////////////////////////
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Returns a pointer to a CACHE_BLOCK structure given a block number
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Searches the block list for a particular block
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Adds a block to the cache's block list
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Returns a pointer to a CACHE_BLOCK structure given a block number
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Searches the block list for a particular block
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Adds a block to the cache's block list
BOOL CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive); // Removes a block from the cache's block list & frees the memory
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive); // Checks the cache size limits to see if we can add a new block, if not calls CacheInternalFreeBlock()
VOID CacheInternalDumpBlockList(PCACHE_DRIVE CacheDrive); // Dumps the list of cached blocks to the debug output port

View file

@ -112,7 +112,7 @@ CmdLineGetDefaultOS(void)
return CmdLineInfo.DefaultOperatingSystem;
}
S32
LONG
CmdLineGetTimeOut(void)
{
return CmdLineInfo.TimeOut;

View file

@ -61,8 +61,8 @@
/* STATIC VARIABLES *********************************************************/
static U32 Rs232ComPort = 0;
static U32 Rs232BaudRate = 0;
static ULONG Rs232ComPort = 0;
static ULONG Rs232BaudRate = 0;
static PUCHAR Rs232PortBase = (PUCHAR)0;
/* The com port must only be initialized once! */
@ -73,8 +73,8 @@ static BOOLEAN PortInitialized = FALSE;
static BOOL Rs232DoesComPortExist(PUCHAR BaseAddress)
{
BOOLEAN found;
U8 mcr;
U8 msr;
UCHAR mcr;
UCHAR msr;
found = FALSE;
@ -118,12 +118,12 @@ static BOOL Rs232DoesComPortExist(PUCHAR BaseAddress)
/* FUNCTIONS *********************************************************/
BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
{
U32 BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
//char buffer[80];
U32 divisor;
U8 lcr;
ULONG divisor;
UCHAR lcr;
if (PortInitialized == FALSE)
{
@ -146,7 +146,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
sprintf (buffer,
"\nSerial port COM%ld found at 0x%lx\n",
ComPort,
(U32)PortBase);
(ULONG)PortBase);
HalDisplayString (buffer);
#endif*/ /* NDEBUG */
}
@ -158,7 +158,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
sprintf (buffer,
"\nSerial port COM%ld found at 0x%lx\n",
ComPort,
(U32)PortBase);
(ULONG)PortBase);
HalDisplayString (buffer);
#endif*/ /* NDEBUG */
}
@ -180,7 +180,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
sprintf (buffer,
"\nSerial port COM%ld found at 0x%lx\n",
ComPort,
(U32)PortBase);
(ULONG)PortBase);
HalDisplayString (buffer);
#endif*/ /* NDEBUG */
}
@ -222,7 +222,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
/*
* set global info
*/
//KdComPortInUse = (U32)PortBase;
//KdComPortInUse = (ULONG)PortBase;
/*
* print message to blue screen
@ -230,7 +230,7 @@ BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
/*sprintf (buffer,
"\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
ComPort,
(U32)PortBase,
(ULONG)PortBase,
BaudRate);
HalDisplayString (buffer);*/

View file

@ -46,8 +46,8 @@ UCHAR CustomBootPrompt[] = "Press ENTER to boot your custom boot setup.";
VOID OptionMenuCustomBoot(VOID)
{
PUCHAR CustomBootMenuList[] = { "Disk", "Partition", "Boot Sector File", "ReactOS", "Linux" };
U32 CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
U32 SelectedMenuItem;
ULONG CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
ULONG SelectedMenuItem;
if (!UiDisplayMenu(CustomBootMenuList, CustomBootMenuCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
{
@ -79,8 +79,8 @@ VOID OptionMenuCustomBootDisk(VOID)
{
UCHAR SectionName[100];
UCHAR BootDriveString[20];
U32 SectionId;
U32 Year, Month, Day, Hour, Minute, Second;
ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -122,8 +122,8 @@ VOID OptionMenuCustomBootPartition(VOID)
UCHAR SectionName[100];
UCHAR BootDriveString[20];
UCHAR BootPartitionString[20];
U32 SectionId;
U32 Year, Month, Day, Hour, Minute, Second;
ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -178,8 +178,8 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
UCHAR BootDriveString[20];
UCHAR BootPartitionString[20];
UCHAR BootSectorFileString[200];
U32 SectionId;
U32 Year, Month, Day, Hour, Minute, Second;
ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -248,8 +248,8 @@ VOID OptionMenuCustomBootReactOS(VOID)
UCHAR ReactOSSystemPath[200];
UCHAR ReactOSARCPath[200];
UCHAR ReactOSOptions[200];
U32 SectionId;
U32 Year, Month, Day, Hour, Minute, Second;
ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -321,8 +321,8 @@ VOID OptionMenuCustomBootLinux(VOID)
UCHAR LinuxKernelString[200];
UCHAR LinuxInitrdString[200];
UCHAR LinuxCommandLineString[200];
U32 SectionId;
U32 Year, Month, Day, Hour, Minute, Second;
ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second;
RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));

View file

@ -39,7 +39,7 @@ VOID DiskReportError (BOOL bError)
bReportError = bError;
}
VOID DiskError(PUCHAR ErrorString, U32 ErrorCode)
VOID DiskError(PUCHAR ErrorString, ULONG ErrorCode)
{
UCHAR ErrorCodeString[200];
@ -53,7 +53,7 @@ VOID DiskError(PUCHAR ErrorString, U32 ErrorCode)
UiMessageBox(ErrorCodeString);
}
PUCHAR DiskGetErrorCodeString(U32 ErrorCode)
PUCHAR DiskGetErrorCodeString(ULONG ErrorCode)
{
switch (ErrorCode)
{
@ -89,9 +89,9 @@ PUCHAR DiskGetErrorCodeString(U32 ErrorCode)
}
// This function is in arch/i386/i386disk.c
//BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
//BOOL DiskReadLogicalSectors(ULONG DriveNumber, U64 SectorNumber, ULONG SectorCount, PVOID Buffer)
BOOL DiskIsDriveRemovable(U32 DriveNumber)
BOOL DiskIsDriveRemovable(ULONG DriveNumber)
{
// Hard disks use drive numbers >= 0x80
// So if the drive number indicates a hard disk
@ -109,4 +109,4 @@ BOOL DiskIsDriveRemovable(U32 DriveNumber)
//VOID DiskStopFloppyMotor(VOID)
// This function is in arch/i386/i386disk.c
//U32 DiskGetCacheableBlockCount(U32 DriveNumber)
//ULONG DiskGetCacheableBlockCount(ULONG DriveNumber)

View file

@ -26,9 +26,9 @@
#include <machine.h>
BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
U32 BootablePartitionCount = 0;
ULONG BootablePartitionCount = 0;
MASTER_BOOT_RECORD MasterBootRecord;
// Read master boot record
@ -77,13 +77,13 @@ BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY Partiti
return TRUE;
}
BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
MASTER_BOOT_RECORD MasterBootRecord;
PARTITION_TABLE_ENTRY ExtendedPartitionTableEntry;
U32 ExtendedPartitionNumber;
U32 ExtendedPartitionOffset;
U32 Index;
ULONG ExtendedPartitionNumber;
ULONG ExtendedPartitionOffset;
ULONG Index;
// Read master boot record
if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
@ -157,7 +157,7 @@ BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABL
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
U32 Index;
ULONG Index;
for (Index=0; Index<4; Index++)
{
@ -178,7 +178,7 @@ BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
U32 Index;
ULONG Index;
for (Index=0; Index<4; Index++)
{
@ -195,11 +195,11 @@ BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PP
return FALSE;
}
BOOL DiskReadBootRecord(U32 DriveNumber, U64 LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
BOOL DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
{
char ErrMsg[64];
#ifdef DEBUG
U32 Index;
ULONG Index;
#endif
// Read master boot record

View file

@ -26,9 +26,9 @@
#include <debug.h>
BOOL DriveMapInstalled = FALSE; // Tells us if we have already installed our drive map int 13h handler code
U32 OldInt13HandlerAddress = 0; // Address of BIOS int 13h handler
U32 DriveMapHandlerAddress = 0; // Linear address of our drive map handler
U32 DriveMapHandlerSegOff = 0; // Segment:offset style address of our drive map handler
ULONG OldInt13HandlerAddress = 0; // Address of BIOS int 13h handler
ULONG DriveMapHandlerAddress = 0; // Linear address of our drive map handler
ULONG DriveMapHandlerSegOff = 0; // Segment:offset style address of our drive map handler
VOID DriveMapMapDrivesInSection(PUCHAR SectionName)
{
@ -37,10 +37,10 @@ VOID DriveMapMapDrivesInSection(PUCHAR SectionName)
UCHAR ErrorText[260];
UCHAR Drive1[80];
UCHAR Drive2[80];
U32 SectionId;
U32 SectionItemCount;
U32 Index;
U32 Index2;
ULONG SectionId;
ULONG SectionItemCount;
ULONG Index;
ULONG Index2;
DRIVE_MAP_LIST DriveMapList;
RtlZeroMemory(&DriveMapList, sizeof(DRIVE_MAP_LIST));
@ -119,7 +119,7 @@ VOID DriveMapMapDrivesInSection(PUCHAR SectionName)
BOOL DriveMapIsValidDriveString(PUCHAR DriveString)
{
U32 Index;
ULONG Index;
// Now verify that the user has given us appropriate strings
if ((strlen(DriveString) < 3) ||
@ -147,9 +147,9 @@ BOOL DriveMapIsValidDriveString(PUCHAR DriveString)
return TRUE;
}
U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName)
ULONG DriveMapGetBiosDriveNumber(PUCHAR DeviceName)
{
U32 BiosDriveNumber = 0;
ULONG BiosDriveNumber = 0;
// If they passed in a number string then just
// convert it to decimal and return it
@ -174,8 +174,8 @@ U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName)
VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
{
U32* RealModeIVT = (U32*)0x00000000;
U16* BiosLowMemorySize = (U16*)0x00000413;
ULONG* RealModeIVT = (ULONG*)0x00000000;
USHORT* BiosLowMemorySize = (USHORT*)0x00000413;
if (!DriveMapInstalled)
{
@ -186,7 +186,7 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
(*BiosLowMemorySize)--;
// Get linear address for drive map handler
DriveMapHandlerAddress = (U32)(*BiosLowMemorySize) << 10;
DriveMapHandlerAddress = (ULONG)(*BiosLowMemorySize) << 10;
// Convert to segment:offset style address
DriveMapHandlerSegOff = (DriveMapHandlerAddress << 12) & 0xffff0000;
@ -199,7 +199,7 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
DriveMapOldInt13HandlerAddress = OldInt13HandlerAddress;
// Copy the code to our reserved area
RtlCopyMemory((PVOID)DriveMapHandlerAddress, &DriveMapInt13HandlerStart, ((U32)&DriveMapInt13HandlerEnd - (U32)&DriveMapInt13HandlerStart));
RtlCopyMemory((PVOID)DriveMapHandlerAddress, &DriveMapInt13HandlerStart, ((ULONG)&DriveMapInt13HandlerEnd - (ULONG)&DriveMapInt13HandlerStart));
// Update the IVT
RealModeIVT[0x13] = DriveMapHandlerSegOff;
@ -210,8 +210,8 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
VOID DriveMapRemoveInt13Handler(VOID)
{
U32* RealModeIVT = (U32*)0x00000000;
U16* BiosLowMemorySize = (U16*)0x00000413;
ULONG* RealModeIVT = (ULONG*)0x00000000;
USHORT* BiosLowMemorySize = (USHORT*)0x00000413;
if (DriveMapInstalled)
{

View file

@ -35,17 +35,17 @@ GEOMETRY Ext2DiskGeometry; // Ext2 file system disk geometry
PEXT2_SUPER_BLOCK Ext2SuperBlock = NULL; // Ext2 file system super block
PEXT2_GROUP_DESC Ext2GroupDescriptors = NULL; // Ext2 file system group descriptors
U8 Ext2DriveNumber = 0; // Ext2 file system drive number
U64 Ext2VolumeStartSector = 0; // Ext2 file system starting sector
U32 Ext2BlockSizeInBytes = 0; // Block size in bytes
U32 Ext2BlockSizeInSectors = 0; // Block size in sectors
U32 Ext2FragmentSizeInBytes = 0; // Fragment size in bytes
U32 Ext2FragmentSizeInSectors = 0; // Fragment size in sectors
U32 Ext2GroupCount = 0; // Number of groups in this file system
U32 Ext2InodesPerBlock = 0; // Number of inodes in one block
U32 Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
UCHAR Ext2DriveNumber = 0; // Ext2 file system drive number
ULONGLONG Ext2VolumeStartSector = 0; // Ext2 file system starting sector
ULONG Ext2BlockSizeInBytes = 0; // Block size in bytes
ULONG Ext2BlockSizeInSectors = 0; // Block size in sectors
ULONG Ext2FragmentSizeInBytes = 0; // Fragment size in bytes
ULONG Ext2FragmentSizeInSectors = 0; // Fragment size in sectors
ULONG Ext2GroupCount = 0; // Number of groups in this file system
ULONG Ext2InodesPerBlock = 0; // Number of inodes in one block
ULONG Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
BOOL Ext2OpenVolume(U8 DriveNumber, U64 VolumeStartSector)
BOOL Ext2OpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector)
{
DbgPrint((DPRINT_FILESYSTEM, "Ext2OpenVolume() DriveNumber = 0x%x VolumeStartSector = %d\n", DriveNumber, VolumeStartSector));
@ -93,7 +93,7 @@ FILE* Ext2OpenFile(PUCHAR FileName)
PEXT2_FILE_INFO FileHandle;
UCHAR SymLinkPath[EXT3_NAME_LEN];
UCHAR FullPath[EXT3_NAME_LEN * 2];
U32 Index;
ULONG Index;
DbgPrint((DPRINT_FILESYSTEM, "Ext2OpenFile() FileName = %s\n", FileName));
@ -193,10 +193,10 @@ FILE* Ext2OpenFile(PUCHAR FileName)
BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
{
int i;
U32 NumberOfPathParts;
ULONG NumberOfPathParts;
UCHAR PathPart[261];
PVOID DirectoryBuffer;
U32 DirectoryInode = EXT3_ROOT_INO;
ULONG DirectoryInode = EXT3_ROOT_INO;
EXT2_INODE InodeData;
EXT2_DIR_ENTRY DirectoryEntry;
@ -238,7 +238,7 @@ BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
//
// Search for file name in directory
//
if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (U32)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (ULONG)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
{
MmFreeMemory(DirectoryBuffer);
return FALSE;
@ -289,9 +289,9 @@ BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
return TRUE;
}
BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry)
BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry)
{
U32 CurrentOffset;
ULONG CurrentOffset;
PEXT2_DIR_ENTRY CurrentDirectoryEntry;
DbgPrint((DPRINT_FILESYSTEM, "Ext2SearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectorySize = %d FileName = %s\n", DirectoryBuffer, DirectorySize, FileName));
@ -345,16 +345,16 @@ BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize,
* Reads BytesToRead from open file and
* returns the number of bytes read in BytesRead
*/
BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffer)
BOOL Ext2ReadFile(FILE *FileHandle, ULONGLONG BytesToRead, ULONGLONG* BytesRead, PVOID Buffer)
{
PEXT2_FILE_INFO Ext2FileInfo = (PEXT2_FILE_INFO)FileHandle;
U32 BlockNumber;
U32 BlockNumberIndex;
U32 OffsetInBlock;
U32 LengthInBlock;
U32 NumberOfBlocks;
ULONG BlockNumber;
ULONG BlockNumberIndex;
ULONG OffsetInBlock;
ULONG LengthInBlock;
ULONG NumberOfBlocks;
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadFile() BytesToRead = %d Buffer = 0x%x\n", (U32)BytesToRead, Buffer));
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadFile() BytesToRead = %d Buffer = 0x%x\n", (ULONG)BytesToRead, Buffer));
if (BytesRead != NULL)
{
@ -529,7 +529,7 @@ BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffe
return TRUE;
}
U64 Ext2GetFileSize(FILE *FileHandle)
ULONGLONG Ext2GetFileSize(FILE *FileHandle)
{
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
@ -538,7 +538,7 @@ U64 Ext2GetFileSize(FILE *FileHandle)
return Ext2FileHandle->FileSize;
}
VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer)
VOID Ext2SetFilePointer(FILE *FileHandle, ULONGLONG NewFilePointer)
{
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
@ -547,7 +547,7 @@ VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer)
Ext2FileHandle->FilePointer = NewFilePointer;
}
U64 Ext2GetFilePointer(FILE *FileHandle)
ULONGLONG Ext2GetFilePointer(FILE *FileHandle)
{
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
@ -556,7 +556,7 @@ U64 Ext2GetFilePointer(FILE *FileHandle)
return Ext2FileHandle->FilePointer;
}
BOOL Ext2ReadVolumeSectors(U8 DriveNumber, U64 SectorNumber, U64 SectorCount, PVOID Buffer)
BOOL Ext2ReadVolumeSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONGLONG SectorCount, PVOID Buffer)
{
//GEOMETRY DiskGeometry;
//BOOL ReturnValue;
@ -734,8 +734,8 @@ BOOL Ext2ReadSuperBlock(VOID)
BOOL Ext2ReadGroupDescriptors(VOID)
{
U32 GroupDescBlockCount;
U32 CurrentGroupDescBlock;
ULONG GroupDescBlockCount;
ULONG CurrentGroupDescBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadGroupDescriptors()\n"));
@ -778,7 +778,7 @@ BOOL Ext2ReadGroupDescriptors(VOID)
return TRUE;
}
BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer)
BOOL Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer)
{
EXT2_FILE_INFO DirectoryFileInfo;
@ -837,7 +837,7 @@ BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePoint
return TRUE;
}
BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer)
BOOL Ext2ReadBlock(ULONG BlockNumber, PVOID Buffer)
{
UCHAR ErrorString[80];
@ -861,14 +861,14 @@ BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer)
return TRUE;
}
return Ext2ReadVolumeSectors(Ext2DriveNumber, (U64)BlockNumber * Ext2BlockSizeInSectors, Ext2BlockSizeInSectors, Buffer);
return Ext2ReadVolumeSectors(Ext2DriveNumber, (ULONGLONG)BlockNumber * Ext2BlockSizeInSectors, Ext2BlockSizeInSectors, Buffer);
}
/*
* Ext2ReadPartialBlock()
* Reads part of a block into memory
*/
BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID Buffer)
BOOL Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer)
{
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadPartialBlock() BlockNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", BlockNumber, StartingOffset, Length, Buffer));
@ -883,36 +883,36 @@ BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID
return TRUE;
}
U32 Ext2GetGroupDescBlockNumber(U32 Group)
ULONG Ext2GetGroupDescBlockNumber(ULONG Group)
{
return (((Group * sizeof(EXT2_GROUP_DESC)) / Ext2GroupDescPerBlock) + Ext2SuperBlock->s_first_data_block + 1);
}
U32 Ext2GetGroupDescOffsetInBlock(U32 Group)
ULONG Ext2GetGroupDescOffsetInBlock(ULONG Group)
{
return ((Group * sizeof(EXT2_GROUP_DESC)) % Ext2GroupDescPerBlock);
}
U32 Ext2GetInodeGroupNumber(U32 Inode)
ULONG Ext2GetInodeGroupNumber(ULONG Inode)
{
return ((Inode - 1) / Ext2SuperBlock->s_inodes_per_group);
}
U32 Ext2GetInodeBlockNumber(U32 Inode)
ULONG Ext2GetInodeBlockNumber(ULONG Inode)
{
return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) / Ext2InodesPerBlock);
}
U32 Ext2GetInodeOffsetInBlock(U32 Inode)
ULONG Ext2GetInodeOffsetInBlock(ULONG Inode)
{
return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) % Ext2InodesPerBlock);
}
BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer)
BOOL Ext2ReadInode(ULONG Inode, PEXT2_INODE InodeBuffer)
{
U32 InodeGroupNumber;
U32 InodeBlockNumber;
U32 InodeOffsetInBlock;
ULONG InodeGroupNumber;
ULONG InodeBlockNumber;
ULONG InodeOffsetInBlock;
UCHAR ErrorString[80];
EXT2_GROUP_DESC GroupDescriptor;
@ -978,7 +978,7 @@ BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer)
return TRUE;
}
BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer)
BOOL Ext2ReadGroupDescriptor(ULONG Group, PEXT2_GROUP_DESC GroupBuffer)
{
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadGroupDescriptor()\n"));
@ -1002,13 +1002,13 @@ BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer)
return TRUE;
}
U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
{
U64 FileSize;
U32 BlockCount;
U32* BlockList;
U32 CurrentBlockInList;
U32 CurrentBlock;
ULONGLONG FileSize;
ULONG BlockCount;
ULONG* BlockList;
ULONG CurrentBlockInList;
ULONG CurrentBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadBlockPointerList()\n"));
@ -1023,13 +1023,13 @@ U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
BlockCount = (FileSize / Ext2BlockSizeInBytes);
// Allocate the memory for the block list
BlockList = MmAllocateMemory(BlockCount * sizeof(U32));
BlockList = MmAllocateMemory(BlockCount * sizeof(ULONG));
if (BlockList == NULL)
{
return NULL;
}
RtlZeroMemory(BlockList, BlockCount * sizeof(U32));
RtlZeroMemory(BlockList, BlockCount * sizeof(ULONG));
CurrentBlockInList = 0;
// Copy the direct block pointers
@ -1072,27 +1072,27 @@ U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
return BlockList;
}
U64 Ext2GetInodeFileSize(PEXT2_INODE Inode)
ULONGLONG Ext2GetInodeFileSize(PEXT2_INODE Inode)
{
if ((Inode->i_mode & EXT2_S_IFMT) == EXT2_S_IFDIR)
{
return (U64)(Inode->i_size);
return (ULONGLONG)(Inode->i_size);
}
else
{
return ((U64)(Inode->i_size) | ((U64)(Inode->i_dir_acl) << 32));
return ((ULONGLONG)(Inode->i_size) | ((ULONGLONG)(Inode->i_dir_acl) << 32));
}
}
BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 IndirectBlock)
BOOL Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG IndirectBlock)
{
U32* BlockBuffer = (U32*)FILESYSBUFFER;
U32 CurrentBlock;
U32 BlockPointersPerBlock;
ULONG* BlockBuffer = (ULONG*)FILESYSBUFFER;
ULONG CurrentBlock;
ULONG BlockPointersPerBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyIndirectBlockPointers() BlockCount = %d\n", BlockCount));
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
if (!Ext2ReadBlock(IndirectBlock, BlockBuffer))
{
@ -1108,17 +1108,17 @@ BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32
return TRUE;
}
BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 DoubleIndirectBlock)
BOOL Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG DoubleIndirectBlock)
{
U32* BlockBuffer;
U32 CurrentBlock;
U32 BlockPointersPerBlock;
ULONG* BlockBuffer;
ULONG CurrentBlock;
ULONG BlockPointersPerBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyDoubleIndirectBlockPointers() BlockCount = %d\n", BlockCount));
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
BlockBuffer = (U32*)MmAllocateMemory(Ext2BlockSizeInBytes);
BlockBuffer = (ULONG*)MmAllocateMemory(Ext2BlockSizeInBytes);
if (BlockBuffer == NULL)
{
return FALSE;
@ -1143,17 +1143,17 @@ BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList
return TRUE;
}
BOOL Ext2CopyTripleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 TripleIndirectBlock)
BOOL Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG TripleIndirectBlock)
{
U32* BlockBuffer;
U32 CurrentBlock;
U32 BlockPointersPerBlock;
ULONG* BlockBuffer;
ULONG CurrentBlock;
ULONG BlockPointersPerBlock;
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyTripleIndirectBlockPointers() BlockCount = %d\n", BlockCount));
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
BlockBuffer = (U32*)MmAllocateMemory(Ext2BlockSizeInBytes);
BlockBuffer = (ULONG*)MmAllocateMemory(Ext2BlockSizeInBytes);
if (BlockBuffer == NULL)
{
return FALSE;

View file

@ -113,7 +113,7 @@
# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
#endif
#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (ULONG))
#ifdef __KERNEL__
# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
#else
@ -151,20 +151,20 @@
*/
struct ext3_acl_header /* Header of Access Control Lists */
{
__u32 aclh_size;
__u32 aclh_file_count;
__u32 aclh_acle_count;
__u32 aclh_first_acle;
ULONG aclh_size;
ULONG aclh_file_count;
ULONG aclh_acle_count;
ULONG aclh_first_acle;
};
struct ext3_acl_entry /* Access Control List Entry */
{
__u32 acle_size;
__u16 acle_perms; /* Access permissions */
__u16 acle_type; /* Type of entry */
__u16 acle_tag; /* User or group identity */
__u16 acle_pad1;
__u32 acle_next; /* Pointer on next entry for the */
ULONG acle_size;
USHORT acle_perms; /* Access permissions */
USHORT acle_type; /* Type of entry */
USHORT acle_tag; /* User or group identity */
USHORT acle_pad1;
ULONG acle_next; /* Pointer on next entry for the */
/* same inode or on next free entry */
};
@ -173,14 +173,14 @@ struct ext3_acl_entry /* Access Control List Entry */
*/
struct ext3_group_desc
{
__u32 bg_block_bitmap; /* Blocks bitmap block */
__u32 bg_inode_bitmap; /* Inodes bitmap block */
__u32 bg_inode_table; /* Inodes table block */
__u16 bg_free_blocks_count; /* Free blocks count */
__u16 bg_free_inodes_count; /* Free inodes count */
__u16 bg_used_dirs_count; /* Directories count */
__u16 bg_pad;
__u32 bg_reserved[3];
ULONG bg_block_bitmap; /* Blocks bitmap block */
ULONG bg_inode_bitmap; /* Inodes bitmap block */
ULONG bg_inode_table; /* Inodes table block */
USHORT bg_free_blocks_count; /* Free blocks count */
USHORT bg_free_inodes_count; /* Free inodes count */
USHORT bg_used_dirs_count; /* Directories count */
USHORT bg_pad;
ULONG bg_reserved[3];
};
/*
@ -254,55 +254,55 @@ struct ext3_group_desc
* Structure of an inode on the disk
*/
struct ext3_inode {
__u16 i_mode; /* File mode */
__u16 i_uid; /* Low 16 bits of Owner Uid */
__u32 i_size; /* Size in bytes */
__u32 i_atime; /* Access time */
__u32 i_ctime; /* Creation time */
__u32 i_mtime; /* Modification time */
__u32 i_dtime; /* Deletion Time */
__u16 i_gid; /* Low 16 bits of Group Id */
__u16 i_links_count; /* Links count */
__u32 i_blocks; /* Blocks count */
__u32 i_flags; /* File flags */
USHORT i_mode; /* File mode */
USHORT i_uid; /* Low 16 bits of Owner Uid */
ULONG i_size; /* Size in bytes */
ULONG i_atime; /* Access time */
ULONG i_ctime; /* Creation time */
ULONG i_mtime; /* Modification time */
ULONG i_dtime; /* Deletion Time */
USHORT i_gid; /* Low 16 bits of Group Id */
USHORT i_links_count; /* Links count */
ULONG i_blocks; /* Blocks count */
ULONG i_flags; /* File flags */
union {
struct {
__u32 l_i_reserved1;
ULONG l_i_reserved1;
} linux1;
struct {
__u32 h_i_translator;
ULONG h_i_translator;
} hurd1;
struct {
__u32 m_i_reserved1;
ULONG m_i_reserved1;
} masix1;
} osd1; /* OS dependent 1 */
__u32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
__u32 i_generation; /* File version (for NFS) */
__u32 i_file_acl; /* File ACL */
__u32 i_dir_acl; /* Directory ACL */
__u32 i_faddr; /* Fragment address */
ULONG i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
ULONG i_generation; /* File version (for NFS) */
ULONG i_file_acl; /* File ACL */
ULONG i_dir_acl; /* Directory ACL */
ULONG i_faddr; /* Fragment address */
union {
struct {
__u8 l_i_frag; /* Fragment number */
__u8 l_i_fsize; /* Fragment size */
__u16 i_pad1;
__u16 l_i_uid_high; /* these 2 fields */
__u16 l_i_gid_high; /* were reserved2[0] */
__u32 l_i_reserved2;
UCHAR l_i_frag; /* Fragment number */
UCHAR l_i_fsize; /* Fragment size */
USHORT i_pad1;
USHORT l_i_uid_high; /* these 2 fields */
USHORT l_i_gid_high; /* were reserved2[0] */
ULONG l_i_reserved2;
} linux2;
struct {
__u8 h_i_frag; /* Fragment number */
__u8 h_i_fsize; /* Fragment size */
__u16 h_i_mode_high;
__u16 h_i_uid_high;
__u16 h_i_gid_high;
__u32 h_i_author;
UCHAR h_i_frag; /* Fragment number */
UCHAR h_i_fsize; /* Fragment size */
USHORT h_i_mode_high;
USHORT h_i_uid_high;
USHORT h_i_gid_high;
ULONG h_i_author;
} hurd2;
struct {
__u8 m_i_frag; /* Fragment number */
__u8 m_i_fsize; /* Fragment size */
__u16 m_pad1;
__u32 m_i_reserved2[2];
UCHAR m_i_frag; /* Fragment number */
UCHAR m_i_fsize; /* Fragment size */
USHORT m_pad1;
ULONG m_i_reserved2[2];
} masix2;
} osd2; /* OS dependent 2 */
};
@ -398,31 +398,31 @@ struct ext3_inode {
* Structure of the super block
*/
struct ext3_super_block {
/*00*/ __u32 s_inodes_count; /* Inodes count */
__u32 s_blocks_count; /* Blocks count */
__u32 s_r_blocks_count; /* Reserved blocks count */
__u32 s_free_blocks_count; /* Free blocks count */
/*10*/ __u32 s_free_inodes_count; /* Free inodes count */
__u32 s_first_data_block; /* First Data Block */
__u32 s_log_block_size; /* Block size */
__s32 s_log_frag_size; /* Fragment size */
/*20*/ __u32 s_blocks_per_group; /* # Blocks per group */
__u32 s_frags_per_group; /* # Fragments per group */
__u32 s_inodes_per_group; /* # Inodes per group */
__u32 s_mtime; /* Mount time */
/*30*/ __u32 s_wtime; /* Write time */
__u16 s_mnt_count; /* Mount count */
__s16 s_max_mnt_count; /* Maximal mount count */
__u16 s_magic; /* Magic signature */
__u16 s_state; /* File system state */
__u16 s_errors; /* Behaviour when detecting errors */
__u16 s_minor_rev_level; /* minor revision level */
/*40*/ __u32 s_lastcheck; /* time of last check */
__u32 s_checkinterval; /* max. time between checks */
__u32 s_creator_os; /* OS */
__u32 s_rev_level; /* Revision level */
/*50*/ __u16 s_def_resuid; /* Default uid for reserved blocks */
__u16 s_def_resgid; /* Default gid for reserved blocks */
/*00*/ ULONG s_inodes_count; /* Inodes count */
ULONG s_blocks_count; /* Blocks count */
ULONG s_r_blocks_count; /* Reserved blocks count */
ULONG s_free_blocks_count; /* Free blocks count */
/*10*/ ULONG s_free_inodes_count; /* Free inodes count */
ULONG s_first_data_block; /* First Data Block */
ULONG s_log_block_size; /* Block size */
LONG s_log_frag_size; /* Fragment size */
/*20*/ ULONG s_blocks_per_group; /* # Blocks per group */
ULONG s_frags_per_group; /* # Fragments per group */
ULONG s_inodes_per_group; /* # Inodes per group */
ULONG s_mtime; /* Mount time */
/*30*/ ULONG s_wtime; /* Write time */
USHORT s_mnt_count; /* Mount count */
SHORT s_max_mnt_count; /* Maximal mount count */
USHORT s_magic; /* Magic signature */
USHORT s_state; /* File system state */
USHORT s_errors; /* Behaviour when detecting errors */
USHORT s_minor_rev_level; /* minor revision level */
/*40*/ ULONG s_lastcheck; /* time of last check */
ULONG s_checkinterval; /* max. time between checks */
ULONG s_creator_os; /* OS */
ULONG s_rev_level; /* Revision level */
/*50*/ USHORT s_def_resuid; /* Default uid for reserved blocks */
USHORT s_def_resgid; /* Default gid for reserved blocks */
/*
* These fields are for EXT3_DYNAMIC_REV superblocks only.
*
@ -436,32 +436,32 @@ struct ext3_super_block {
* feature set, it must abort and not try to meddle with
* things it doesn't understand...
*/
__u32 s_first_ino; /* First non-reserved inode */
__u16 s_inode_size; /* size of inode structure */
__u16 s_block_group_nr; /* block group # of this superblock */
__u32 s_feature_compat; /* compatible feature set */
/*60*/ __u32 s_feature_incompat; /* incompatible feature set */
__u32 s_feature_ro_compat; /* readonly-compatible feature set */
/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
ULONG s_first_ino; /* First non-reserved inode */
USHORT s_inode_size; /* size of inode structure */
USHORT s_block_group_nr; /* block group # of this superblock */
ULONG s_feature_compat; /* compatible feature set */
/*60*/ ULONG s_feature_incompat; /* incompatible feature set */
ULONG s_feature_ro_compat; /* readonly-compatible feature set */
/*68*/ UCHAR s_uuid[16]; /* 128-bit uuid for volume */
/*78*/ char s_volume_name[16]; /* volume name */
/*88*/ char s_last_mounted[64]; /* directory where last mounted */
/*C8*/ __u32 s_algorithm_usage_bitmap; /* For compression */
/*C8*/ ULONG s_algorithm_usage_bitmap; /* For compression */
/*
* Performance hints. Directory preallocation should only
* happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
*/
__u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
__u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
__u16 s_padding1;
UCHAR s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
UCHAR s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
USHORT s_padding1;
/*
* Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
*/
/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
/*E0*/ __u32 s_journal_inum; /* inode number of journal file */
__u32 s_journal_dev; /* device number of journal file */
__u32 s_last_orphan; /* start of list of inodes to delete */
/*D0*/ UCHAR s_journal_uuid[16]; /* uuid of journal superblock */
/*E0*/ ULONG s_journal_inum; /* inode number of journal file */
ULONG s_journal_dev; /* device number of journal file */
ULONG s_last_orphan; /* start of list of inodes to delete */
/*EC*/ __u32 s_reserved[197]; /* Padding to the end of the block */
/*EC*/ ULONG s_reserved[197]; /* Padding to the end of the block */
};
#ifdef __KERNEL__
@ -555,9 +555,9 @@ struct ext3_super_block {
#define EXT3_NAME_LEN 255
struct ext3_dir_entry {
__u32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */
__u16 name_len; /* Name length */
ULONG inode; /* Inode number */
USHORT rec_len; /* Directory entry length */
USHORT name_len; /* Name length */
char name[EXT3_NAME_LEN]; /* File name */
};
@ -568,10 +568,10 @@ struct ext3_dir_entry {
* file_type field.
*/
struct ext3_dir_entry_2 {
__u32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */
__u8 name_len; /* Name length */
__u8 file_type;
ULONG inode; /* Inode number */
USHORT rec_len; /* Directory entry length */
UCHAR name_len; /* Name length */
UCHAR file_type;
char name[EXT3_NAME_LEN]; /* File name */
};
@ -653,45 +653,45 @@ typedef struct ext3_dir_entry_2 EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
#define EXT2_S_IFLNK 0xA000 // Symbolic link
#define EXT2_S_IFSOCK 0xC000 // Socket
#define FAST_SYMLINK_MAX_NAME_SIZE (EXT3_N_BLOCKS * sizeof(U32)) /* 60 bytes */
#define FAST_SYMLINK_MAX_NAME_SIZE (EXT3_N_BLOCKS * sizeof(ULONG)) /* 60 bytes */
typedef struct
{
U64 FileSize; // File size
U64 FilePointer; // File pointer
U32* FileBlockList; // File block list
U8 DriveNumber; // Drive number of open file
ULONGLONG FileSize; // File size
ULONGLONG FilePointer; // File pointer
ULONG* FileBlockList; // File block list
UCHAR DriveNumber; // Drive number of open file
EXT2_INODE Inode; // File's inode
} EXT2_FILE_INFO, * PEXT2_FILE_INFO;
BOOL Ext2OpenVolume(U8 DriveNumber, U64 VolumeStartSector);
BOOL Ext2OpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector);
FILE* Ext2OpenFile(PUCHAR FileName);
BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer);
BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry);
BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffer);
U64 Ext2GetFileSize(FILE *FileHandle);
VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer);
U64 Ext2GetFilePointer(FILE *FileHandle);
BOOL Ext2ReadVolumeSectors(U8 DriveNumber, U64 SectorNumber, U64 SectorCount, PVOID Buffer);
BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry);
BOOL Ext2ReadFile(FILE *FileHandle, ULONGLONG BytesToRead, ULONGLONG* BytesRead, PVOID Buffer);
ULONGLONG Ext2GetFileSize(FILE *FileHandle);
VOID Ext2SetFilePointer(FILE *FileHandle, ULONGLONG NewFilePointer);
ULONGLONG Ext2GetFilePointer(FILE *FileHandle);
BOOL Ext2ReadVolumeSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONGLONG SectorCount, PVOID Buffer);
BOOL Ext2ReadSuperBlock(VOID);
BOOL Ext2ReadGroupDescriptors(VOID);
BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer);
BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer);
BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID Buffer);
U32 Ext2GetGroupDescBlockNumber(U32 Group);
U32 Ext2GetGroupDescOffsetInBlock(U32 Group);
U32 Ext2GetInodeGroupNumber(U32 Inode);
U32 Ext2GetInodeBlockNumber(U32 Inode);
U32 Ext2GetInodeOffsetInBlock(U32 Inode);
BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer);
BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer);
U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode);
U64 Ext2GetInodeFileSize(PEXT2_INODE Inode);
BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 IndirectBlock);
BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 DoubleIndirectBlock);
BOOL Ext2CopyTripleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 TripleIndirectBlock);
BOOL Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer);
BOOL Ext2ReadBlock(ULONG BlockNumber, PVOID Buffer);
BOOL Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer);
ULONG Ext2GetGroupDescBlockNumber(ULONG Group);
ULONG Ext2GetGroupDescOffsetInBlock(ULONG Group);
ULONG Ext2GetInodeGroupNumber(ULONG Inode);
ULONG Ext2GetInodeBlockNumber(ULONG Inode);
ULONG Ext2GetInodeOffsetInBlock(ULONG Inode);
BOOL Ext2ReadInode(ULONG Inode, PEXT2_INODE InodeBuffer);
BOOL Ext2ReadGroupDescriptor(ULONG Group, PEXT2_GROUP_DESC GroupBuffer);
ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode);
ULONGLONG Ext2GetInodeFileSize(PEXT2_INODE Inode);
BOOL Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG IndirectBlock);
BOOL Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG DoubleIndirectBlock);
BOOL Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG TripleIndirectBlock);
#endif // #defined __EXT2_H

View file

@ -29,25 +29,25 @@
#include <cache.h>
#include <machine.h>
U32 BytesPerSector; /* Number of bytes per sector */
U32 SectorsPerCluster; /* Number of sectors per cluster */
U32 FatVolumeStartSector; /* Absolute starting sector of the partition */
U32 FatSectorStart; /* Starting sector of 1st FAT table */
U32 ActiveFatSectorStart; /* Starting sector of active FAT table */
U32 NumberOfFats; /* Number of FAT tables */
U32 SectorsPerFat; /* Sectors per FAT table */
U32 RootDirSectorStart; /* Starting sector of the root directory (non-fat32) */
U32 RootDirSectors; /* Number of sectors of the root directory (non-fat32) */
U32 RootDirStartCluster; /* Starting cluster number of the root directory (fat32 only) */
U32 DataSectorStart; /* Starting sector of the data area */
ULONG BytesPerSector; /* Number of bytes per sector */
ULONG SectorsPerCluster; /* Number of sectors per cluster */
ULONG FatVolumeStartSector; /* Absolute starting sector of the partition */
ULONG FatSectorStart; /* Starting sector of 1st FAT table */
ULONG ActiveFatSectorStart; /* Starting sector of active FAT table */
ULONG NumberOfFats; /* Number of FAT tables */
ULONG SectorsPerFat; /* Sectors per FAT table */
ULONG RootDirSectorStart; /* Starting sector of the root directory (non-fat32) */
ULONG RootDirSectors; /* Number of sectors of the root directory (non-fat32) */
ULONG RootDirStartCluster; /* Starting cluster number of the root directory (fat32 only) */
ULONG DataSectorStart; /* Starting sector of the data area */
U32 FatType = 0; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */
U32 FatDriveNumber = 0;
ULONG FatType = 0; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */
ULONG FatDriveNumber = 0;
BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCount)
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector, ULONG PartitionSectorCount)
{
char ErrMsg[80];
U32 FatSize;
ULONG FatSize;
PFAT_BOOTSECTOR FatVolumeBootSector;
PFAT32_BOOTSECTOR Fat32VolumeBootSector;
PFATX_BOOTSECTOR FatXVolumeBootSector;
@ -288,13 +288,13 @@ BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCo
return TRUE;
}
U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount)
ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, ULONG PartitionSectorCount)
{
U32 RootDirSectors;
U32 DataSectorCount;
U32 SectorsPerFat;
U32 TotalSectors;
U32 CountOfClusters;
ULONG RootDirSectors;
ULONG DataSectorCount;
ULONG SectorsPerFat;
ULONG TotalSectors;
ULONG CountOfClusters;
PFAT32_BOOTSECTOR Fat32BootSector = (PFAT32_BOOTSECTOR)FatBootSector;
PFATX_BOOTSECTOR FatXBootSector = (PFATX_BOOTSECTOR)FatBootSector;
@ -343,7 +343,7 @@ U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount)
}
}
PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32 *DirectorySize, BOOL RootDirectory)
PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG *DirectorySize, BOOL RootDirectory)
{
PVOID DirectoryBuffer;
@ -405,15 +405,15 @@ PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32 *DirectorySize, BOOL Roo
return DirectoryBuffer;
}
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
U32 EntryCount;
U32 CurrentEntry;
ULONG EntryCount;
ULONG CurrentEntry;
PDIRENTRY DirEntry;
PLFN_DIRENTRY LfnDirEntry;
UCHAR LfnNameBuffer[265];
UCHAR ShortNameBuffer[20];
U32 StartCluster;
ULONG StartCluster;
EntryCount = DirectorySize / sizeof(DIRENTRY);
@ -590,7 +590,7 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, P
//
// Get the cluster chain
//
StartCluster = ((U32)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow;
StartCluster = ((ULONG)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow;
DbgPrint((DPRINT_FILESYSTEM, "StartCluster = 0x%x\n", StartCluster));
FatFileInfoPointer->FileFatChain = FatGetClusterChainArray(StartCluster);
@ -616,12 +616,12 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, P
return FALSE;
}
BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
U32 EntryCount;
U32 CurrentEntry;
ULONG EntryCount;
ULONG CurrentEntry;
PFATX_DIRENTRY DirEntry;
U32 FileNameLen;
ULONG FileNameLen;
EntryCount = DirectorySize / sizeof(FATX_DIRENTRY);
@ -690,11 +690,11 @@ BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize,
BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
int i;
U32 NumberOfPathParts;
ULONG NumberOfPathParts;
UCHAR PathPart[261];
PVOID DirectoryBuffer;
U32 DirectoryStartCluster = 0;
U32 DirectorySize;
ULONG DirectoryStartCluster = 0;
ULONG DirectorySize;
FAT_FILE_INFO FatFileInfo;
DbgPrint((DPRINT_FILESYSTEM, "FatLookupFile() FileName = %s\n", FileName));
@ -779,7 +779,7 @@ BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
*/
void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry)
{
U32 Idx;
ULONG Idx;
Idx = 0;
RtlZeroMemory(Buffer, 13);
@ -824,9 +824,9 @@ void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry)
* FatGetFatEntry()
* returns the Fat entry for a given cluster number
*/
BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer)
{
U32 fat = 0;
ULONG fat = 0;
int FatOffset;
int ThisFatSecNum;
int ThisFatEntOffset;
@ -860,7 +860,7 @@ BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
}
}
fat = *((U16 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
fat = *((USHORT *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
if (Cluster & 0x0001)
fat = fat >> 4; /* Cluster number is ODD */
else
@ -880,7 +880,7 @@ BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
return FALSE;
}
fat = *((U16 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
fat = *((USHORT *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
break;
@ -897,7 +897,7 @@ BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
}
// Get the fat entry
fat = (*((U32 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
fat = (*((ULONG *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
break;
@ -939,9 +939,9 @@ FILE* FatOpenFile(PUCHAR FileName)
return (FILE*)FileHandle;
}
U32 FatCountClustersInChain(U32 StartCluster)
ULONG FatCountClustersInChain(ULONG StartCluster)
{
U32 ClusterCount = 0;
ULONG ClusterCount = 0;
DbgPrint((DPRINT_FILESYSTEM, "FatCountClustersInChain() StartCluster = %d\n", StartCluster));
@ -976,17 +976,17 @@ U32 FatCountClustersInChain(U32 StartCluster)
return ClusterCount;
}
U32* FatGetClusterChainArray(U32 StartCluster)
ULONG* FatGetClusterChainArray(ULONG StartCluster)
{
U32 ClusterCount;
U32 ArraySize;
U32* ArrayPointer;
U32 Idx;
ULONG ClusterCount;
ULONG ArraySize;
ULONG* ArrayPointer;
ULONG Idx;
DbgPrint((DPRINT_FILESYSTEM, "FatGetClusterChainArray() StartCluster = %d\n", StartCluster));
ClusterCount = FatCountClustersInChain(StartCluster) + 1; // Lets get the 0x0ffffff8 on the end of the array
ArraySize = ClusterCount * sizeof(U32);
ArraySize = ClusterCount * sizeof(ULONG);
//
// Allocate array memory
@ -1036,9 +1036,9 @@ U32* FatGetClusterChainArray(U32 StartCluster)
* FatReadCluster()
* Reads the specified cluster into memory
*/
BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer)
BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer)
{
U32 ClusterStartSector;
ULONG ClusterStartSector;
ClusterStartSector = ((ClusterNumber - 2) * SectorsPerCluster) + DataSectorStart;
@ -1058,9 +1058,9 @@ BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer)
* FatReadClusterChain()
* Reads the specified clusters into memory
*/
BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buffer)
BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID Buffer)
{
U32 ClusterStartSector;
ULONG ClusterStartSector;
DbgPrint((DPRINT_FILESYSTEM, "FatReadClusterChain() StartClusterNumber = %d NumberOfClusters = %d Buffer = 0x%x\n", StartClusterNumber, NumberOfClusters, Buffer));
@ -1119,9 +1119,9 @@ BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buf
* FatReadPartialCluster()
* Reads part of a cluster into memory
*/
BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PVOID Buffer)
BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer)
{
U32 ClusterStartSector;
ULONG ClusterStartSector;
DbgPrint((DPRINT_FILESYSTEM, "FatReadPartialCluster() ClusterNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", ClusterNumber, StartingOffset, Length, Buffer));
@ -1142,14 +1142,14 @@ BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PV
* Reads BytesToRead from open file and
* returns the number of bytes read in BytesRead
*/
BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
BOOL FatReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
PFAT_FILE_INFO FatFileInfo = (PFAT_FILE_INFO)FileHandle;
U32 ClusterNumber;
U32 OffsetInCluster;
U32 LengthInCluster;
U32 NumberOfClusters;
U32 BytesPerCluster;
ULONG ClusterNumber;
ULONG OffsetInCluster;
ULONG LengthInCluster;
ULONG NumberOfClusters;
ULONG BytesPerCluster;
DbgPrint((DPRINT_FILESYSTEM, "FatReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer));
@ -1296,7 +1296,7 @@ BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer
return TRUE;
}
U32 FatGetFileSize(FILE *FileHandle)
ULONG FatGetFileSize(FILE *FileHandle)
{
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
@ -1305,7 +1305,7 @@ U32 FatGetFileSize(FILE *FileHandle)
return FatFileHandle->FileSize;
}
VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
VOID FatSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
{
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
@ -1314,7 +1314,7 @@ VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
FatFileHandle->FilePointer = NewFilePointer;
}
U32 FatGetFilePointer(FILE *FileHandle)
ULONG FatGetFilePointer(FILE *FileHandle)
{
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
@ -1323,7 +1323,7 @@ U32 FatGetFilePointer(FILE *FileHandle)
return FatFileHandle->FilePointer;
}
BOOL FatReadVolumeSectors(U32 DriveNumber, U32 SectorNumber, U32 SectorCount, PVOID Buffer)
BOOL FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer);
}

View file

@ -22,77 +22,77 @@
typedef struct _FAT_BOOTSECTOR
{
U8 JumpBoot[3]; // Jump instruction to boot code
U8 OemName[8]; // "MSWIN4.1" for MS formatted volumes
U16 BytesPerSector; // Bytes per sector
U8 SectorsPerCluster; // Number of sectors in a cluster
U16 ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
U8 NumberOfFats; // Number of FAT tables
U16 RootDirEntries; // Number of root directory entries (fat12/16)
U16 TotalSectors; // Number of total sectors on the drive, 16-bit
U8 MediaDescriptor; // Media descriptor byte
U16 SectorsPerFat; // Sectors per FAT table (fat12/16)
U16 SectorsPerTrack; // Number of sectors in a track
U16 NumberOfHeads; // Number of heads on the disk
U32 HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
U32 TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
U8 Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
U8 BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
U32 VolumeSerialNumber; // Volume serial number
U8 VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
U8 FileSystemType[8]; // One of the strings "FAT12 ", "FAT16 ", or "FAT "
UCHAR JumpBoot[3]; // Jump instruction to boot code
UCHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
USHORT BytesPerSector; // Bytes per sector
UCHAR SectorsPerCluster; // Number of sectors in a cluster
USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
UCHAR NumberOfFats; // Number of FAT tables
USHORT RootDirEntries; // Number of root directory entries (fat12/16)
USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
UCHAR MediaDescriptor; // Media descriptor byte
USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
USHORT SectorsPerTrack; // Number of sectors in a track
USHORT NumberOfHeads; // Number of heads on the disk
ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
ULONG VolumeSerialNumber; // Volume serial number
UCHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
UCHAR FileSystemType[8]; // One of the strings "FAT12 ", "FAT16 ", or "FAT "
U8 BootCodeAndData[448]; // The remainder of the boot sector
UCHAR BootCodeAndData[448]; // The remainder of the boot sector
U16 BootSectorMagic; // 0xAA55
USHORT BootSectorMagic; // 0xAA55
} PACKED FAT_BOOTSECTOR, *PFAT_BOOTSECTOR;
typedef struct _FAT32_BOOTSECTOR
{
U8 JumpBoot[3]; // Jump instruction to boot code
U8 OemName[8]; // "MSWIN4.1" for MS formatted volumes
U16 BytesPerSector; // Bytes per sector
U8 SectorsPerCluster; // Number of sectors in a cluster
U16 ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
U8 NumberOfFats; // Number of FAT tables
U16 RootDirEntries; // Number of root directory entries (fat12/16)
U16 TotalSectors; // Number of total sectors on the drive, 16-bit
U8 MediaDescriptor; // Media descriptor byte
U16 SectorsPerFat; // Sectors per FAT table (fat12/16)
U16 SectorsPerTrack; // Number of sectors in a track
U16 NumberOfHeads; // Number of heads on the disk
U32 HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
U32 TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
U32 SectorsPerFatBig; // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
U16 ExtendedFlags; // Extended flags (fat32)
U16 FileSystemVersion; // File system version (fat32)
U32 RootDirStartCluster; // Starting cluster of the root directory (fat32)
U16 FsInfo; // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
U16 BackupBootSector; // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
U8 Reserved[12]; // Reserved for future expansion
U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
U8 Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
U8 BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
U32 VolumeSerialNumber; // Volume serial number
U8 VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
U8 FileSystemType[8]; // Always set to the string "FAT32 "
UCHAR JumpBoot[3]; // Jump instruction to boot code
UCHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
USHORT BytesPerSector; // Bytes per sector
UCHAR SectorsPerCluster; // Number of sectors in a cluster
USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
UCHAR NumberOfFats; // Number of FAT tables
USHORT RootDirEntries; // Number of root directory entries (fat12/16)
USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
UCHAR MediaDescriptor; // Media descriptor byte
USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
USHORT SectorsPerTrack; // Number of sectors in a track
USHORT NumberOfHeads; // Number of heads on the disk
ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
ULONG SectorsPerFatBig; // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
USHORT ExtendedFlags; // Extended flags (fat32)
USHORT FileSystemVersion; // File system version (fat32)
ULONG RootDirStartCluster; // Starting cluster of the root directory (fat32)
USHORT FsInfo; // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
USHORT BackupBootSector; // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
UCHAR Reserved[12]; // Reserved for future expansion
UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
ULONG VolumeSerialNumber; // Volume serial number
UCHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
UCHAR FileSystemType[8]; // Always set to the string "FAT32 "
U8 BootCodeAndData[420]; // The remainder of the boot sector
UCHAR BootCodeAndData[420]; // The remainder of the boot sector
U16 BootSectorMagic; // 0xAA55
USHORT BootSectorMagic; // 0xAA55
} PACKED FAT32_BOOTSECTOR, *PFAT32_BOOTSECTOR;
typedef struct _FATX_BOOTSECTOR
{
U8 FileSystemType[4]; /* String "FATX" */
U32 VolumeSerialNumber; /* Volume serial number */
U32 SectorsPerCluster; /* Number of sectors in a cluster */
U16 NumberOfFats; /* Number of FAT tables */
U32 Unknown; /* Always 0? */
U8 Unused[494]; /* Actually size should be 4078 (boot block is 4096 bytes) */
UCHAR FileSystemType[4]; /* String "FATX" */
ULONG VolumeSerialNumber; /* Volume serial number */
ULONG SectorsPerCluster; /* Number of sectors in a cluster */
USHORT NumberOfFats; /* Number of FAT tables */
ULONG Unknown; /* Always 0? */
UCHAR Unused[494]; /* Actually size should be 4078 (boot block is 4096 bytes) */
} PACKED FATX_BOOTSECTOR, *PFATX_BOOTSECTOR;
@ -102,74 +102,74 @@ typedef struct _FATX_BOOTSECTOR
typedef struct //_DIRENTRY
{
UCHAR FileName[11]; /* Filename + extension */
U8 Attr; /* File attributes */
U8 ReservedNT; /* Reserved for use by Windows NT */
U8 TimeInTenths; /* Millisecond stamp at file creation */
U16 CreateTime; /* Time file was created */
U16 CreateDate; /* Date file was created */
U16 LastAccessDate; /* Date file was last accessed */
U16 ClusterHigh; /* High word of this entry's start cluster */
U16 Time; /* Time last modified */
U16 Date; /* Date last modified */
U16 ClusterLow; /* First cluster number low word */
U32 Size; /* File size */
UCHAR Attr; /* File attributes */
UCHAR ReservedNT; /* Reserved for use by Windows NT */
UCHAR TimeInTenths; /* Millisecond stamp at file creation */
USHORT CreateTime; /* Time file was created */
USHORT CreateDate; /* Date file was created */
USHORT LastAccessDate; /* Date file was last accessed */
USHORT ClusterHigh; /* High word of this entry's start cluster */
USHORT Time; /* Time last modified */
USHORT Date; /* Date last modified */
USHORT ClusterLow; /* First cluster number low word */
ULONG Size; /* File size */
} PACKED DIRENTRY, * PDIRENTRY;
typedef struct
{
U8 SequenceNumber; /* Sequence number for slot */
UCHAR SequenceNumber; /* Sequence number for slot */
WCHAR Name0_4[5]; /* First 5 characters in name */
U8 EntryAttributes; /* Attribute byte */
U8 Reserved; /* Always 0 */
U8 AliasChecksum; /* Checksum for 8.3 alias */
UCHAR EntryAttributes; /* Attribute byte */
UCHAR Reserved; /* Always 0 */
UCHAR AliasChecksum; /* Checksum for 8.3 alias */
WCHAR Name5_10[6]; /* 6 more characters in name */
U16 StartCluster; /* Starting cluster number */
USHORT StartCluster; /* Starting cluster number */
WCHAR Name11_12[2]; /* Last 2 characters in name */
} PACKED LFN_DIRENTRY, * PLFN_DIRENTRY;
typedef struct
{
U8 FileNameSize; /* Size of filename (max 42) */
U8 Attr; /* File attributes */
UCHAR FileNameSize; /* Size of filename (max 42) */
UCHAR Attr; /* File attributes */
UCHAR FileName[42]; /* Filename in ASCII, padded with 0xff (not zero-terminated) */
U32 StartCluster; /* Starting cluster number */
U32 Size; /* File size */
U16 Time; /* Time last modified */
U16 Date; /* Date last modified */
U16 CreateTime; /* Time file was created */
U16 CreateDate; /* Date file was created */
U16 LastAccessTime; /* Time file was last accessed */
U16 LastAccessDate; /* Date file was last accessed */
ULONG StartCluster; /* Starting cluster number */
ULONG Size; /* File size */
USHORT Time; /* Time last modified */
USHORT Date; /* Date last modified */
USHORT CreateTime; /* Time file was created */
USHORT CreateDate; /* Date file was created */
USHORT LastAccessTime; /* Time file was last accessed */
USHORT LastAccessDate; /* Date file was last accessed */
} PACKED FATX_DIRENTRY, * PFATX_DIRENTRY;
typedef struct
{
U32 FileSize; /* File size */
U32 FilePointer; /* File pointer */
U32* FileFatChain; /* File fat chain array */
U32 DriveNumber;
ULONG FileSize; /* File size */
ULONG FilePointer; /* File pointer */
ULONG* FileFatChain; /* File fat chain array */
ULONG DriveNumber;
} FAT_FILE_INFO, * PFAT_FILE_INFO;
BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCount);
U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount);
PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32* EntryCountPointer, BOOL RootDirectory);
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 EntryCount, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector, ULONG PartitionSectorCount);
ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, ULONG PartitionSectorCount);
PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG* EntryCountPointer, BOOL RootDirectory);
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG EntryCount, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry);
BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer);
BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer);
FILE* FatOpenFile(PUCHAR FileName);
U32 FatCountClustersInChain(U32 StartCluster);
U32* FatGetClusterChainArray(U32 StartCluster);
BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer);
BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buffer);
BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PVOID Buffer);
BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
U32 FatGetFileSize(FILE *FileHandle);
VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
U32 FatGetFilePointer(FILE *FileHandle);
BOOL FatReadVolumeSectors(U32 DriveNumber, U32 SectorNumber, U32 SectorCount, PVOID Buffer);
ULONG FatCountClustersInChain(ULONG StartCluster);
ULONG* FatGetClusterChainArray(ULONG StartCluster);
BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer);
BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID Buffer);
BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer);
BOOL FatReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
ULONG FatGetFileSize(FILE *FileHandle);
VOID FatSetFilePointer(FILE *FileHandle, ULONG NewFilePointer);
ULONG FatGetFilePointer(FILE *FileHandle);
BOOL FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
#define ATTR_NORMAL 0x00

View file

@ -36,7 +36,7 @@
// DATA
/////////////////////////////////////////////////////////////////////////////////////////////
U32 FileSystemType = 0; // Type of filesystem on boot device, set by FsOpenVolume()
ULONG FsType = 0; // Type of filesystem on boot device, set by FsOpenVolume()
/////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
@ -51,7 +51,7 @@ VOID FileSystemError(PUCHAR ErrorString)
/*
*
* BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber);
* BOOL FsOpenVolume(ULONG DriveNumber, ULONG PartitionNumber);
*
* This function is called to open a disk volume for file access.
* It must be called before any of the file functions will work.
@ -64,11 +64,11 @@ VOID FileSystemError(PUCHAR ErrorString)
* If it is zero then it opens the active (bootable) partition
*
*/
BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
BOOL FsOpenVolume(ULONG DriveNumber, ULONG PartitionNumber)
{
PARTITION_TABLE_ENTRY PartitionTableEntry;
UCHAR ErrorText[80];
U8 VolumeType;
UCHAR VolumeType;
DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", DriveNumber, PartitionNumber));
@ -78,7 +78,7 @@ BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
{
DbgPrint((DPRINT_FILESYSTEM, "Drive is a floppy diskette drive. Assuming FAT12 file system.\n"));
FileSystemType = FS_FAT;
FsType = FS_FAT;
return FatOpenVolume(DriveNumber, 0, 0);
}
@ -87,7 +87,7 @@ BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
{
DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
FileSystemType = FS_ISO9660;
FsType = FS_ISO9660;
return IsoOpenVolume(DriveNumber);
}
@ -137,16 +137,16 @@ BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
case PARTITION_XINT13:
case PARTITION_FAT32:
case PARTITION_FAT32_XINT13:
FileSystemType = FS_FAT;
FsType = FS_FAT;
return FatOpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition, PartitionTableEntry.PartitionSectorCount);
case PARTITION_EXT2:
FileSystemType = FS_EXT2;
FsType = FS_EXT2;
return Ext2OpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition);
case PARTITION_NTFS:
FileSystemType = FS_NTFS;
FsType = FS_NTFS;
return NtfsOpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition);
default:
FileSystemType = 0;
FsType = 0;
sprintf(ErrorText, "Unsupported file system. Type: 0x%x", VolumeType);
FileSystemError(ErrorText);
return FALSE;
@ -175,7 +175,7 @@ PFILE FsOpenFile(PUCHAR FileName)
//
// Check file system type and pass off to appropriate handler
//
switch (FileSystemType)
switch (FsType)
{
case FS_FAT:
FileHandle = FatOpenFile(FileName);
@ -219,9 +219,9 @@ VOID FsCloseFile(PFILE FileHandle)
* ReadFile()
* returns number of bytes read or EOF
*/
BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
BOOL FsReadFile(PFILE FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
U64 BytesReadBig;
ULONGLONG BytesReadBig;
BOOL Success;
//
@ -232,7 +232,7 @@ BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
*BytesRead = 0;
}
switch (FileSystemType)
switch (FsType)
{
case FS_FAT:
@ -246,7 +246,7 @@ BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
//return Ext2ReadFile(FileHandle, BytesToRead, BytesRead, Buffer);
Success = Ext2ReadFile(FileHandle, BytesToRead, &BytesReadBig, Buffer);
*BytesRead = (U32)BytesReadBig;
*BytesRead = (ULONG)BytesReadBig;
return Success;
case FS_NTFS:
@ -262,9 +262,9 @@ BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
return FALSE;
}
U32 FsGetFileSize(PFILE FileHandle)
ULONG FsGetFileSize(PFILE FileHandle)
{
switch (FileSystemType)
switch (FsType)
{
case FS_FAT:
@ -290,9 +290,9 @@ U32 FsGetFileSize(PFILE FileHandle)
return 0;
}
VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer)
VOID FsSetFilePointer(PFILE FileHandle, ULONG NewFilePointer)
{
switch (FileSystemType)
switch (FsType)
{
case FS_FAT:
@ -320,9 +320,9 @@ VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer)
}
}
U32 FsGetFilePointer(PFILE FileHandle)
ULONG FsGetFilePointer(PFILE FileHandle)
{
switch (FileSystemType)
switch (FsType)
{
case FS_FAT:
@ -369,10 +369,10 @@ BOOL FsIsEndOfFile(PFILE FileHandle)
* This function parses a path in the form of dir1\dir2\file1.ext
* and returns the number of parts it has (i.e. 3 - dir1,dir2,file1.ext)
*/
U32 FsGetNumPathParts(PUCHAR Path)
ULONG FsGetNumPathParts(PUCHAR Path)
{
U32 i;
U32 num;
ULONG i;
ULONG num;
for (i=0,num=0; i<(int)strlen(Path); i++)
{
@ -396,7 +396,7 @@ U32 FsGetNumPathParts(PUCHAR Path)
*/
VOID FsGetFirstNameFromPath(PUCHAR Buffer, PUCHAR Path)
{
U32 i;
ULONG i;
// Copy all the characters up to the end of the
// string or until we hit a '\' character

View file

@ -39,10 +39,10 @@
/*
*
* BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
* BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType);
*
*/
BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType)
BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType)
{
DbgPrint((DPRINT_FILESYSTEM, "FsRecognizeVolume() DriveNumber: 0x%x VolumeStartSector: %d\n", DriveNumber, VolumeStartSector));
@ -66,7 +66,7 @@ BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType)
return FALSE;
}
BOOL FsRecIsIso9660(U32 DriveNumber)
BOOL FsRecIsIso9660(ULONG DriveNumber)
{
PUCHAR Sector = (PUCHAR)DISKREADBUFFER;
@ -84,7 +84,7 @@ BOOL FsRecIsIso9660(U32 DriveNumber)
Sector[5] == '1');
}
BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector)
BOOL FsRecIsExt2(ULONG DriveNumber, ULONG VolumeStartSector)
{
PEXT2_SUPER_BLOCK SuperBlock = (PEXT2_SUPER_BLOCK)DISKREADBUFFER;
@ -102,7 +102,7 @@ BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector)
return FALSE;
}
BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector)
BOOL FsRecIsFat(ULONG DriveNumber, ULONG VolumeStartSector)
{
PFAT_BOOTSECTOR BootSector = (PFAT_BOOTSECTOR)DISKREADBUFFER;
PFAT32_BOOTSECTOR BootSector32 = (PFAT32_BOOTSECTOR)DISKREADBUFFER;
@ -124,7 +124,7 @@ BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector)
return FALSE;
}
BOOL FsRecIsNtfs(U32 DriveNumber, U32 VolumeStartSector)
BOOL FsRecIsNtfs(ULONG DriveNumber, ULONG VolumeStartSector)
{
PNTFS_BOOTSECTOR BootSector = (PNTFS_BOOTSECTOR)DISKREADBUFFER;
if (!MachDiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, BootSector))

View file

@ -20,10 +20,10 @@
#ifndef __FSREC_H
#define __FSREC_H
BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
BOOL FsRecIsIso9660(U32 DriveNumber);
BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector);
BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector);
BOOL FsRecIsNtfs(U32 DriveNumber, U32 VolumeStartSector);
BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType);
BOOL FsRecIsIso9660(ULONG DriveNumber);
BOOL FsRecIsExt2(ULONG DriveNumber, ULONG VolumeStartSector);
BOOL FsRecIsFat(ULONG DriveNumber, ULONG VolumeStartSector);
BOOL FsRecIsNtfs(ULONG DriveNumber, ULONG VolumeStartSector);
#endif // #defined __FSREC_H

View file

@ -32,13 +32,13 @@
#define SECTORSIZE 2048
static U32 IsoRootSector; // Starting sector of the root directory
static U32 IsoRootLength; // Length of the root directory
static ULONG IsoRootSector; // Starting sector of the root directory
static ULONG IsoRootLength; // Length of the root directory
U32 IsoDriveNumber = 0;
ULONG IsoDriveNumber = 0;
BOOL IsoOpenVolume(U32 DriveNumber)
BOOL IsoOpenVolume(ULONG DriveNumber)
{
PPVD Pvd = (PPVD)DISKREADBUFFER;
@ -65,11 +65,11 @@ BOOL IsoOpenVolume(U32 DriveNumber)
}
static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectoryLength, PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectoryLength, PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
{
PDIR_RECORD Record;
U32 Offset;
U32 i;
ULONG Offset;
ULONG i;
UCHAR Name[32];
DbgPrint((DPRINT_FILESYSTEM, "IsoSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectoryLength = %d FileName = %s\n", DirectoryBuffer, DirectoryLength, FileName));
@ -133,12 +133,12 @@ static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 Directory
* if allocation or read fails. The directory is specified by its
* starting sector and length.
*/
static PVOID IsoBufferDirectory(U32 DirectoryStartSector, U32 DirectoryLength)
static PVOID IsoBufferDirectory(ULONG DirectoryStartSector, ULONG DirectoryLength)
{
PVOID DirectoryBuffer;
PVOID Ptr;
U32 SectorCount;
U32 i;
ULONG SectorCount;
ULONG i;
DbgPrint((DPRINT_FILESYSTEM, "IsoBufferDirectory() DirectoryStartSector = %d DirectoryLength = %d\n", DirectoryStartSector, DirectoryLength));
@ -183,11 +183,11 @@ static PVOID IsoBufferDirectory(U32 DirectoryStartSector, U32 DirectoryLength)
static BOOL IsoLookupFile(PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
{
int i;
U32 NumberOfPathParts;
ULONG NumberOfPathParts;
UCHAR PathPart[261];
PVOID DirectoryBuffer;
U32 DirectorySector;
U32 DirectoryLength;
ULONG DirectorySector;
ULONG DirectoryLength;
ISO_FILE_INFO IsoFileInfo;
DbgPrint((DPRINT_FILESYSTEM, "IsoLookupFile() FileName = %s\n", FileName));
@ -293,14 +293,14 @@ FILE* IsoOpenFile(PUCHAR FileName)
* Reads BytesToRead from open file and
* returns the number of bytes read in BytesRead
*/
BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
BOOL IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
PISO_FILE_INFO IsoFileInfo = (PISO_FILE_INFO)FileHandle;
U32 SectorNumber;
U32 OffsetInSector;
U32 LengthInSector;
U32 NumberOfSectors;
U32 i;
ULONG SectorNumber;
ULONG OffsetInSector;
ULONG LengthInSector;
ULONG NumberOfSectors;
ULONG i;
DbgPrint((DPRINT_FILESYSTEM, "IsoReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer));
@ -451,7 +451,7 @@ BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer
}
U32 IsoGetFileSize(FILE *FileHandle)
ULONG IsoGetFileSize(FILE *FileHandle)
{
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
@ -460,7 +460,7 @@ U32 IsoGetFileSize(FILE *FileHandle)
return IsoFileHandle->FileSize;
}
VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
{
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
@ -469,7 +469,7 @@ VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
IsoFileHandle->FilePointer = NewFilePointer;
}
U32 IsoGetFilePointer(FILE *FileHandle)
ULONG IsoGetFilePointer(FILE *FileHandle)
{
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;

View file

@ -25,10 +25,10 @@ struct _DIR_RECORD
{
UCHAR RecordLength; // 1
UCHAR ExtAttrRecordLength; // 2
U32 ExtentLocationL; // 3-6
U32 ExtentLocationM; // 7-10
U32 DataLengthL; // 11-14
U32 DataLengthM; // 15-18
ULONG ExtentLocationL; // 3-6
ULONG ExtentLocationM; // 7-10
ULONG DataLengthL; // 11-14
ULONG DataLengthM; // 15-18
UCHAR Year; // 19
UCHAR Month; // 20
UCHAR Day; // 21
@ -39,7 +39,7 @@ struct _DIR_RECORD
UCHAR FileFlags; // 26
UCHAR FileUnitSize; // 27
UCHAR InterleaveGapSize; // 28
U32 VolumeSequenceNumber; // 29-32
ULONG VolumeSequenceNumber; // 29-32
UCHAR FileIdLength; // 33
UCHAR FileId[1]; // 34
} __attribute__((packed));
@ -71,18 +71,18 @@ struct _PVD
UCHAR SystemId[32]; // 9-40
UCHAR VolumeId[32]; // 41-72
UCHAR unused1[8]; // 73-80
U32 VolumeSpaceSizeL; // 81-84
U32 VolumeSpaceSizeM; // 85-88
ULONG VolumeSpaceSizeL; // 81-84
ULONG VolumeSpaceSizeM; // 85-88
UCHAR unused2[32]; // 89-120
U32 VolumeSetSize; // 121-124
U32 VolumeSequenceNumber; // 125-128
U32 LogicalBlockSize; // 129-132
U32 PathTableSizeL; // 133-136
U32 PathTableSizeM; // 137-140
U32 LPathTablePos; // 141-144
U32 LOptPathTablePos; // 145-148
U32 MPathTablePos; // 149-152
U32 MOptPathTablePos; // 153-156
ULONG VolumeSetSize; // 121-124
ULONG VolumeSequenceNumber; // 125-128
ULONG LogicalBlockSize; // 129-132
ULONG PathTableSizeL; // 133-136
ULONG PathTableSizeM; // 137-140
ULONG LPathTablePos; // 141-144
ULONG LOptPathTablePos; // 145-148
ULONG MPathTablePos; // 149-152
ULONG MOptPathTablePos; // 153-156
DIR_RECORD RootDirRecord; // 157-190
UCHAR VolumeSetIdentifier[128]; // 191-318
UCHAR PublisherIdentifier[128]; // 319-446
@ -97,19 +97,19 @@ typedef struct _PVD PVD, *PPVD;
typedef struct
{
U32 FileStart; // File start sector
U32 FileSize; // File size
U32 FilePointer; // File pointer
ULONG FileStart; // File start sector
ULONG FileSize; // File size
ULONG FilePointer; // File pointer
BOOL Directory;
U32 DriveNumber;
ULONG DriveNumber;
} ISO_FILE_INFO, * PISO_FILE_INFO;
BOOL IsoOpenVolume(U32 DriveNumber);
BOOL IsoOpenVolume(ULONG DriveNumber);
FILE* IsoOpenFile(PUCHAR FileName);
BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
U32 IsoGetFileSize(FILE *FileHandle);
VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
U32 IsoGetFilePointer(FILE *FileHandle);
BOOL IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
ULONG IsoGetFileSize(FILE *FileHandle);
VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer);
ULONG IsoGetFilePointer(FILE *FileHandle);
#endif // #defined __FAT_H

View file

@ -37,19 +37,19 @@
#include "ntfs.h"
PNTFS_BOOTSECTOR NtfsBootSector;
U32 NtfsClusterSize;
U32 NtfsMftRecordSize;
U32 NtfsIndexRecordSize;
U32 NtfsDriveNumber;
U32 NtfsSectorOfClusterZero;
ULONG NtfsClusterSize;
ULONG NtfsMftRecordSize;
ULONG NtfsIndexRecordSize;
ULONG NtfsDriveNumber;
ULONG NtfsSectorOfClusterZero;
PNTFS_MFT_RECORD NtfsMasterFileTable;
NTFS_ATTR_CONTEXT NtfsMFTContext;
PUCHAR NtfsDecodeRun(PUCHAR DataRun, S64 *DataRunOffset, U64 *DataRunLength)
PUCHAR NtfsDecodeRun(PUCHAR DataRun, LONGLONG *DataRunOffset, ULONGLONG *DataRunLength)
{
U8 DataRunOffsetSize;
U8 DataRunLengthSize;
S8 i;
UCHAR DataRunOffsetSize;
UCHAR DataRunLengthSize;
CHAR i;
DataRunOffsetSize = (*DataRun >> 4) & 0xF;
DataRunLengthSize = *DataRun & 0xF;
@ -75,7 +75,7 @@ PUCHAR NtfsDecodeRun(PUCHAR DataRun, S64 *DataRunOffset, U64 *DataRunLength)
DataRun++;
}
/* The last byte contains sign so we must process it different way. */
*DataRunOffset = ((S8)(*(DataRun++)) << (i << 3)) + *DataRunOffset;
*DataRunOffset = ((CHAR)(*(DataRun++)) << (i << 3)) + *DataRunOffset;
}
DbgPrint((DPRINT_FILESYSTEM, "DataRunOffsetSize: %x\n", DataRunOffsetSize));
@ -87,11 +87,11 @@ PUCHAR NtfsDecodeRun(PUCHAR DataRun, S64 *DataRunOffset, U64 *DataRunLength)
}
/* FIXME: Add support for attribute lists! */
BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U32 Type, PWCHAR Name)
BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, ULONG Type, PWCHAR Name)
{
PNTFS_ATTR_RECORD AttrRecord;
PNTFS_ATTR_RECORD AttrRecordEnd;
U32 NameLength;
ULONG NameLength;
PWCHAR AttrName;
AttrRecord = (PNTFS_ATTR_RECORD)((PCHAR)MftRecord + MftRecord->AttributesOffset);
@ -115,8 +115,8 @@ BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U
Context->Record = AttrRecord;
if (AttrRecord->IsNonResident)
{
S64 DataRunOffset;
U64 DataRunLength;
LONGLONG DataRunOffset;
ULONGLONG DataRunLength;
Context->CacheRun = (PUCHAR)Context->Record + Context->Record->NonResident.MappingPairsOffset;
Context->CacheRunOffset = 0;
@ -148,9 +148,9 @@ BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U
}
/* FIXME: Optimize for multisector reads. */
BOOL NtfsDiskRead(U64 Offset, U64 Length, PCHAR Buffer)
BOOL NtfsDiskRead(ULONGLONG Offset, ULONGLONG Length, PCHAR Buffer)
{
U16 ReadLength;
USHORT ReadLength;
DbgPrint((DPRINT_FILESYSTEM, "NtfsDiskRead - Offset: %I64d Length: %I64d\n", Offset, Length));
RtlZeroMemory((PCHAR)DISKREADBUFFER, 0x1000);
@ -190,16 +190,16 @@ BOOL NtfsDiskRead(U64 Offset, U64 Length, PCHAR Buffer)
return TRUE;
}
U64 NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, U64 Offset, PCHAR Buffer, U64 Length)
ULONGLONG NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, PCHAR Buffer, ULONGLONG Length)
{
U64 LastLCN;
ULONGLONG LastLCN;
PUCHAR DataRun;
S64 DataRunOffset;
U64 DataRunLength;
S64 DataRunStartLCN;
U64 CurrentOffset;
U64 ReadLength;
U64 AlreadyRead;
LONGLONG DataRunOffset;
ULONGLONG DataRunLength;
LONGLONG DataRunStartLCN;
ULONGLONG CurrentOffset;
ULONGLONG ReadLength;
ULONGLONG AlreadyRead;
if (!Context->Record->IsNonResident)
{
@ -316,31 +316,31 @@ U64 NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, U64 Offset, PCHAR Buffer, U64
BOOL NtfsFixupRecord(PNTFS_RECORD Record)
{
U16 *USA;
U16 USANumber;
U16 USACount;
U16 *Block;
USHORT *USA;
USHORT USANumber;
USHORT USACount;
USHORT *Block;
USA = (U16*)((PCHAR)Record + Record->USAOffset);
USA = (USHORT*)((PCHAR)Record + Record->USAOffset);
USANumber = *(USA++);
USACount = Record->USACount - 1; /* Exclude the USA Number. */
Block = (U16*)((PCHAR)Record + NtfsBootSector->BytesPerSector - 2);
Block = (USHORT*)((PCHAR)Record + NtfsBootSector->BytesPerSector - 2);
while (USACount)
{
if (*Block != USANumber)
return FALSE;
*Block = *(USA++);
Block = (U16*)((PCHAR)Block + NtfsBootSector->BytesPerSector);
Block = (USHORT*)((PCHAR)Block + NtfsBootSector->BytesPerSector);
USACount--;
}
return TRUE;
}
BOOL NtfsReadMftRecord(U32 MFTIndex, PNTFS_MFT_RECORD Buffer)
BOOL NtfsReadMftRecord(ULONG MFTIndex, PNTFS_MFT_RECORD Buffer)
{
U64 BytesRead;
ULONGLONG BytesRead;
BytesRead = NtfsReadAttribute(&NtfsMFTContext, MFTIndex * NtfsMftRecordSize, (PCHAR)Buffer, NtfsMftRecordSize);
if (BytesRead != NtfsMftRecordSize)
@ -354,9 +354,9 @@ BOOL NtfsReadMftRecord(U32 MFTIndex, PNTFS_MFT_RECORD Buffer)
VOID NtfsPrintFile(PNTFS_INDEX_ENTRY IndexEntry)
{
PWCHAR FileName;
U8 FileNameLength;
UCHAR FileNameLength;
CHAR AnsiFileName[256];
U8 i;
UCHAR i;
FileName = IndexEntry->FileName.FileName;
FileNameLength = IndexEntry->FileName.FileNameLength;
@ -372,8 +372,8 @@ VOID NtfsPrintFile(PNTFS_INDEX_ENTRY IndexEntry)
BOOL NtfsCompareFileName(PCHAR FileName, PNTFS_INDEX_ENTRY IndexEntry)
{
PWCHAR EntryFileName;
U8 EntryFileNameLength;
U8 i;
UCHAR EntryFileNameLength;
UCHAR i;
EntryFileName = IndexEntry->FileName.FileName;
EntryFileNameLength = IndexEntry->FileName.FileNameLength;
@ -402,21 +402,21 @@ BOOL NtfsCompareFileName(PCHAR FileName, PNTFS_INDEX_ENTRY IndexEntry)
return TRUE;
}
BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
BOOL NtfsFindMftRecord(ULONG MFTIndex, PCHAR FileName, ULONG *OutMFTIndex)
{
PNTFS_MFT_RECORD MftRecord;
U32 Magic;
ULONG Magic;
NTFS_ATTR_CONTEXT IndexRootCtx;
NTFS_ATTR_CONTEXT IndexBitmapCtx;
NTFS_ATTR_CONTEXT IndexAllocationCtx;
PNTFS_INDEX_ROOT IndexRoot;
U64 BitmapDataSize;
U64 IndexAllocationSize;
ULONGLONG BitmapDataSize;
ULONGLONG IndexAllocationSize;
PCHAR BitmapData;
PCHAR IndexRecord;
PNTFS_INDEX_ENTRY IndexEntry, IndexEntryEnd;
U32 RecordOffset;
U32 IndexBlockSize;
ULONG RecordOffset;
ULONG IndexBlockSize;
MftRecord = MmAllocateMemory(NtfsMftRecordSize);
if (MftRecord == NULL)
@ -508,8 +508,8 @@ BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
DbgPrint((DPRINT_FILESYSTEM, "RecordOffset: %x IndexAllocationSize: %x\n", RecordOffset, IndexAllocationSize));
for (; RecordOffset < IndexAllocationSize;)
{
U8 Bit = 1 << ((RecordOffset / IndexBlockSize) & 7);
U32 Byte = (RecordOffset / IndexBlockSize) >> 3;
UCHAR Bit = 1 << ((RecordOffset / IndexBlockSize) & 7);
ULONG Byte = (RecordOffset / IndexBlockSize) >> 3;
if ((BitmapData[Byte] & Bit))
break;
RecordOffset += IndexBlockSize;
@ -528,7 +528,7 @@ BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
}
/* FIXME */
IndexEntry = (PNTFS_INDEX_ENTRY)(IndexRecord + 0x18 + *(U16 *)(IndexRecord + 0x18));
IndexEntry = (PNTFS_INDEX_ENTRY)(IndexRecord + 0x18 + *(USHORT *)(IndexRecord + 0x18));
IndexEntryEnd = (PNTFS_INDEX_ENTRY)(IndexRecord + IndexBlockSize);
while (IndexEntry < IndexEntryEnd &&
@ -565,10 +565,10 @@ BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
BOOL NtfsLookupFile(PUCHAR FileName, PNTFS_MFT_RECORD MftRecord, PNTFS_ATTR_CONTEXT DataContext)
{
U32 NumberOfPathParts;
ULONG NumberOfPathParts;
UCHAR PathPart[261];
U32 CurrentMFTIndex;
U8 i;
ULONG CurrentMFTIndex;
UCHAR i;
DbgPrint((DPRINT_FILESYSTEM, "NtfsLookupFile() FileName = %s\n", FileName));
@ -606,7 +606,7 @@ BOOL NtfsLookupFile(PUCHAR FileName, PNTFS_MFT_RECORD MftRecord, PNTFS_ATTR_CONT
return TRUE;
}
BOOL NtfsOpenVolume(U32 DriveNumber, U32 VolumeStartSector)
BOOL NtfsOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
{
NtfsBootSector = (PNTFS_BOOTSECTOR)DISKREADBUFFER;
@ -703,36 +703,36 @@ FILE* NtfsOpenFile(PUCHAR FileName)
return (FILE*)FileHandle;
}
BOOL NtfsReadFile(FILE *File, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
BOOL NtfsReadFile(FILE *File, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
U64 BytesRead64;
ULONGLONG BytesRead64;
BytesRead64 = NtfsReadAttribute(&FileHandle->DataContext, FileHandle->Offset, Buffer, BytesToRead);
if (BytesRead64)
{
*BytesRead = (U32)BytesRead64;
*BytesRead = (ULONG)BytesRead64;
FileHandle->Offset += BytesRead64;
return TRUE;
}
return FALSE;
}
U32 NtfsGetFileSize(FILE *File)
ULONG NtfsGetFileSize(FILE *File)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
if (FileHandle->DataContext.Record->IsNonResident)
return (U32)FileHandle->DataContext.Record->NonResident.DataSize;
return (ULONG)FileHandle->DataContext.Record->NonResident.DataSize;
else
return (U32)FileHandle->DataContext.Record->Resident.ValueLength;
return (ULONG)FileHandle->DataContext.Record->Resident.ValueLength;
}
VOID NtfsSetFilePointer(FILE *File, U32 NewFilePointer)
VOID NtfsSetFilePointer(FILE *File, ULONG NewFilePointer)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
FileHandle->Offset = NewFilePointer;
}
U32 NtfsGetFilePointer(FILE *File)
ULONG NtfsGetFilePointer(FILE *File)
{
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
return FileHandle->Offset;

View file

@ -61,122 +61,122 @@
typedef struct
{
U8 JumpBoot[3]; // Jump to the boot loader routine
U8 SystemId[8]; // System Id ("NTFS ")
U16 BytesPerSector; // Bytes per sector
U8 SectorsPerCluster; // Number of sectors in a cluster
U8 Unused1[7];
U8 MediaDescriptor; // Media descriptor byte
U8 Unused2[2];
U16 SectorsPerTrack; // Number of sectors in a track
U16 NumberOfHeads; // Number of heads on the disk
U8 Unused3[8];
U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
U8 CurrentHead;
U8 BootSignature; // Extended boot signature (0x80)
U8 Unused4;
U64 VolumeSectorCount; // Number of sectors in the volume
U64 MftLocation;
U64 MftMirrorLocation;
S8 ClustersPerMftRecord; // Clusters per MFT Record
U8 Unused5[3];
S8 ClustersPerIndexRecord; // Clusters per Index Record
U8 Unused6[3];
U64 VolumeSerialNumber; // Volume serial number
U8 BootCodeAndData[430]; // The remainder of the boot sector
U16 BootSectorMagic; // 0xAA55
UCHAR JumpBoot[3]; // Jump to the boot loader routine
UCHAR SystemId[8]; // System Id ("NTFS ")
USHORT BytesPerSector; // Bytes per sector
UCHAR SectorsPerCluster; // Number of sectors in a cluster
UCHAR Unused1[7];
UCHAR MediaDescriptor; // Media descriptor byte
UCHAR Unused2[2];
USHORT SectorsPerTrack; // Number of sectors in a track
USHORT NumberOfHeads; // Number of heads on the disk
UCHAR Unused3[8];
UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
UCHAR CurrentHead;
UCHAR BootSignature; // Extended boot signature (0x80)
UCHAR Unused4;
ULONGLONG VolumeSectorCount; // Number of sectors in the volume
ULONGLONG MftLocation;
ULONGLONG MftMirrorLocation;
CHAR ClustersPerMftRecord; // Clusters per MFT Record
UCHAR Unused5[3];
CHAR ClustersPerIndexRecord; // Clusters per Index Record
UCHAR Unused6[3];
ULONGLONG VolumeSerialNumber; // Volume serial number
UCHAR BootCodeAndData[430]; // The remainder of the boot sector
USHORT BootSectorMagic; // 0xAA55
} PACKED NTFS_BOOTSECTOR, *PNTFS_BOOTSECTOR;
typedef struct
{
U32 Magic;
U16 USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
U16 USACount;
ULONG Magic;
USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
USHORT USACount;
} PACKED NTFS_RECORD, *PNTFS_RECORD;
typedef struct
{
U32 Magic;
U16 USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
U16 USACount;
U64 LogSequenceNumber;
U16 SequenceNumber;
U16 LinkCount;
U16 AttributesOffset;
U16 Flags;
U32 BytesInUse; // Number of bytes used in this mft record.
U32 BytesAllocated;
U64 BaseMFTRecord;
U16 NextAttributeInstance;
ULONG Magic;
USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
USHORT USACount;
ULONGLONG LogSequenceNumber;
USHORT SequenceNumber;
USHORT LinkCount;
USHORT AttributesOffset;
USHORT Flags;
ULONG BytesInUse; // Number of bytes used in this mft record.
ULONG BytesAllocated;
ULONGLONG BaseMFTRecord;
USHORT NextAttributeInstance;
} PACKED NTFS_MFT_RECORD, *PNTFS_MFT_RECORD;
typedef struct
{
U32 Type;
U32 Length;
U8 IsNonResident;
U8 NameLength;
U16 NameOffset;
U16 Flags;
U16 Instance;
ULONG Type;
ULONG Length;
UCHAR IsNonResident;
UCHAR NameLength;
USHORT NameOffset;
USHORT Flags;
USHORT Instance;
union
{
// Resident attributes
struct
{
U32 ValueLength;
U16 ValueOffset;
U16 Flags;
ULONG ValueLength;
USHORT ValueOffset;
USHORT Flags;
} PACKED Resident;
// Non-resident attributes
struct
{
U64 LowestVCN;
U64 HighestVCN;
U16 MappingPairsOffset;
U8 CompressionUnit;
U8 Reserved[5];
S64 AllocatedSize;
S64 DataSize;
S64 InitializedSize;
S64 CompressedSize;
ULONGLONG LowestVCN;
ULONGLONG HighestVCN;
USHORT MappingPairsOffset;
UCHAR CompressionUnit;
UCHAR Reserved[5];
LONGLONG AllocatedSize;
LONGLONG DataSize;
LONGLONG InitializedSize;
LONGLONG CompressedSize;
} PACKED NonResident;
} PACKED;
} PACKED NTFS_ATTR_RECORD, *PNTFS_ATTR_RECORD;
typedef struct
{
U32 EntriesOffset;
U32 IndexLength;
U32 AllocatedSize;
U8 Flags;
U8 Reserved[3];
ULONG EntriesOffset;
ULONG IndexLength;
ULONG AllocatedSize;
UCHAR Flags;
UCHAR Reserved[3];
} PACKED NTFS_INDEX_HEADER, *PNTFS_INDEX_HEADER;
typedef struct
{
U32 Type;
U32 CollationRule;
U32 IndexBlockSize;
U8 ClustersPerIndexBlock;
U8 Reserved[3];
ULONG Type;
ULONG CollationRule;
ULONG IndexBlockSize;
UCHAR ClustersPerIndexBlock;
UCHAR Reserved[3];
NTFS_INDEX_HEADER IndexHeader;
} PACKED NTFS_INDEX_ROOT, *PNTFS_INDEX_ROOT;
typedef struct
{
U64 ParentDirectory;
S64 CreationTime;
S64 LastDataChangeTime;
S64 LastMftChangeTime;
S64 LastAccessTime;
S64 AllocatedSize;
S64 DataSize;
U32 FileAttributes;
U16 PackedExtendedAttributeSize;
U16 Reserved;
U8 FileNameLength;
U8 FileNameType;
ULONGLONG ParentDirectory;
LONGLONG CreationTime;
LONGLONG LastDataChangeTime;
LONGLONG LastMftChangeTime;
LONGLONG LastAccessTime;
LONGLONG AllocatedSize;
LONGLONG DataSize;
ULONG FileAttributes;
USHORT PackedExtendedAttributeSize;
USHORT Reserved;
UCHAR FileNameLength;
UCHAR FileNameType;
WCHAR FileName[0];
} PACKED NTFS_FILE_NAME_ATTR, *PNTFS_FILE_NAME_ATTR;
@ -185,19 +185,19 @@ typedef struct {
{
struct
{
U64 IndexedFile;
ULONGLONG IndexedFile;
} PACKED Directory;
struct
{
U16 DataOffset;
U16 DataLength;
U32 Reserved;
USHORT DataOffset;
USHORT DataLength;
ULONG Reserved;
} PACKED ViewIndex;
} PACKED Data;
U16 Length;
U16 KeyLength;
U16 Flags;
U16 Reserved;
USHORT Length;
USHORT KeyLength;
USHORT Flags;
USHORT Reserved;
NTFS_FILE_NAME_ATTR FileName;
} PACKED NTFS_INDEX_ENTRY, *PNTFS_INDEX_ENTRY;
@ -205,24 +205,24 @@ typedef struct
{
PNTFS_ATTR_RECORD Record;
PUCHAR CacheRun;
U64 CacheRunOffset;
S64 CacheRunStartLCN;
U64 CacheRunLength;
S64 CacheRunLastLCN;
U64 CacheRunCurrentOffset;
ULONGLONG CacheRunOffset;
LONGLONG CacheRunStartLCN;
ULONGLONG CacheRunLength;
LONGLONG CacheRunLastLCN;
ULONGLONG CacheRunCurrentOffset;
} NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
typedef struct
{
NTFS_ATTR_CONTEXT DataContext;
U64 Offset;
ULONGLONG Offset;
} PACKED NTFS_FILE_HANDLE, *PNTFS_FILE_HANDLE;
BOOL NtfsOpenVolume(U32 DriveNumber, U32 VolumeStartSector);
BOOL NtfsOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector);
FILE* NtfsOpenFile(PUCHAR FileName);
BOOL NtfsReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
U32 NtfsGetFileSize(FILE *FileHandle);
VOID NtfsSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
U32 NtfsGetFilePointer(FILE *FileHandle);
BOOL NtfsReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
ULONG NtfsGetFileSize(FILE *FileHandle);
VOID NtfsSetFilePointer(FILE *FileHandle, ULONG NewFilePointer);
ULONG NtfsGetFilePointer(FILE *FileHandle);
#endif // #defined __NTFS_H

View file

@ -21,9 +21,9 @@
#define __BOOTMGR_H
U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSystemCount);
S32 GetTimeOut(VOID);
BOOL MainBootMenuKeyPressFilter(U32 KeyPress);
ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount);
LONG GetTimeOut(VOID);
BOOL MainBootMenuKeyPressFilter(ULONG KeyPress);
#endif // #defined __BOOTMGR_H

View file

@ -21,10 +21,10 @@
#ifndef __CACHE_H
#define __CACHE_H
BOOL CacheInitializeDrive(U32 DriveNumber);
BOOL CacheInitializeDrive(ULONG DriveNumber);
VOID CacheInvalidateCacheData(VOID);
BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOID Buffer);
BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorCount);
BOOL CacheReleaseMemory(U32 MinimumAmountToRelease);
BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount, PVOID Buffer);
BOOL CacheForceDiskSectorsIntoCache(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount);
BOOL CacheReleaseMemory(ULONG MinimumAmountToRelease);
#endif // defined __CACHE_H

View file

@ -24,13 +24,13 @@
typedef struct tagCMDLINEINFO
{
char *DefaultOperatingSystem;
S32 TimeOut;
LONG TimeOut;
} CMDLINEINFO, *PCMDLINEINFO;
extern void CmdLineParse(char *CmdLine);
extern char *CmdLineGetDefaultOS(void);
extern S32 CmdLineGetTimeOut(void);
extern LONG CmdLineGetTimeOut(void);
#endif /* __CMDLINE_H__ */

View file

@ -22,7 +22,7 @@
#ifndef __RS232_H
#define __RS232_H
BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate);
BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate);
BOOL Rs232PortGetByte(PUCHAR ByteRecieved);
BOOL Rs232PortPollByte(PUCHAR ByteRecieved);
VOID Rs232PortPutByte(UCHAR ByteToSend);

View file

@ -23,10 +23,10 @@
typedef struct _GEOMETRY
{
U32 Cylinders; // Number of cylinders on the disk
U32 Heads; // Number of heads on the disk
U32 Sectors; // Number of sectors per track
U32 BytesPerSector; // Number of bytes per sector
ULONG Cylinders; // Number of cylinders on the disk
ULONG Heads; // Number of heads on the disk
ULONG Sectors; // Number of sectors per track
ULONG BytesPerSector; // Number of bytes per sector
} GEOMETRY, *PGEOMETRY;
@ -35,14 +35,14 @@ typedef struct _GEOMETRY
//
typedef struct _EXTENDED_GEOMETRY
{
U16 Size;
U16 Flags;
U32 Cylinders;
U32 Heads;
U32 SectorsPerTrack;
U64 Sectors;
U16 BytesPerSector;
U32 PDPTE;
USHORT Size;
USHORT Flags;
ULONG Cylinders;
ULONG Heads;
ULONG SectorsPerTrack;
ULONGLONG Sectors;
USHORT BytesPerSector;
ULONG PDPTE;
} __attribute__((packed)) EXTENDED_GEOMETRY, *PEXTENDED_GEOMETRY;
//
@ -50,16 +50,16 @@ typedef struct _EXTENDED_GEOMETRY
//
typedef struct _PARTITION_TABLE_ENTRY
{
U8 BootIndicator; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
U8 StartHead; // Beginning head number
U8 StartSector; // Beginning sector (2 high bits of cylinder #)
U8 StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
U8 SystemIndicator; // System indicator
U8 EndHead; // Ending head number
U8 EndSector; // Ending sector (2 high bits of cylinder #)
U8 EndCylinder; // Ending cylinder# (low order bits of cylinder #)
U32 SectorCountBeforePartition; // Number of sectors preceding the partition
U32 PartitionSectorCount; // Number of sectors in the partition
UCHAR BootIndicator; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
UCHAR StartHead; // Beginning head number
UCHAR StartSector; // Beginning sector (2 high bits of cylinder #)
UCHAR StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
UCHAR SystemIndicator; // System indicator
UCHAR EndHead; // Ending head number
UCHAR EndSector; // Ending sector (2 high bits of cylinder #)
UCHAR EndCylinder; // Ending cylinder# (low order bits of cylinder #)
ULONG SectorCountBeforePartition; // Number of sectors preceding the partition
ULONG PartitionSectorCount; // Number of sectors in the partition
} PACKED PARTITION_TABLE_ENTRY, *PPARTITION_TABLE_ENTRY;
@ -68,11 +68,11 @@ typedef struct _PARTITION_TABLE_ENTRY
//
typedef struct _MASTER_BOOT_RECORD
{
U8 MasterBootRecordCodeAndData[0x1b8]; /* 0x000 */
U32 Signature; /* 0x1B8 */
U16 Reserved; /* 0x1BC */
UCHAR MasterBootRecordCodeAndData[0x1b8]; /* 0x000 */
ULONG Signature; /* 0x1B8 */
USHORT Reserved; /* 0x1BC */
PARTITION_TABLE_ENTRY PartitionTable[4]; /* 0x1BE */
U16 MasterBootRecordMagic; /* 0x1FE */
USHORT MasterBootRecordMagic; /* 0x1FE */
} PACKED MASTER_BOOT_RECORD, *PMASTER_BOOT_RECORD;
@ -106,10 +106,10 @@ typedef struct _MASTER_BOOT_RECORD
///////////////////////////////////////////////////////////////////////////////////////
#ifdef __i386__
BOOL DiskResetController(U32 DriveNumber);
BOOL DiskInt13ExtensionsSupported(U32 DriveNumber);
BOOL DiskResetController(ULONG DriveNumber);
BOOL DiskInt13ExtensionsSupported(ULONG DriveNumber);
//VOID DiskStopFloppyMotor(VOID);
BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSize);
BOOL DiskGetExtendedDriveParameters(ULONG DriveNumber, PVOID Buffer, USHORT BufferSize);
#endif // defined __i386__
@ -119,10 +119,10 @@ BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSiz
//
///////////////////////////////////////////////////////////////////////////////////////
VOID DiskReportError (BOOL bError);
VOID DiskError(PUCHAR ErrorString, U32 ErrorCode);
PUCHAR DiskGetErrorCodeString(U32 ErrorCode);
BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer); // Implemented in i386disk.c
BOOL DiskIsDriveRemovable(U32 DriveNumber);
VOID DiskError(PUCHAR ErrorString, ULONG ErrorCode);
PUCHAR DiskGetErrorCodeString(ULONG ErrorCode);
BOOL DiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); // Implemented in i386disk.c
BOOL DiskIsDriveRemovable(ULONG DriveNumber);
VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
///////////////////////////////////////////////////////////////////////////////////////
@ -130,10 +130,10 @@ VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
// Fixed Disk Partition Management Functions
//
///////////////////////////////////////////////////////////////////////////////////////
BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL DiskReadBootRecord(U32 DriveNumber, U64 LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);
BOOL DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);
#endif // defined __DISK_H

View file

@ -23,21 +23,21 @@
typedef struct
{
U8 DriveMapCount; // Count of drives currently mapped
UCHAR DriveMapCount; // Count of drives currently mapped
U8 DriveMap[8]; // Map of BIOS drives
UCHAR DriveMap[8]; // Map of BIOS drives
} PACKED DRIVE_MAP_LIST, *PDRIVE_MAP_LIST;
VOID DriveMapMapDrivesInSection(PUCHAR SectionName);
BOOL DriveMapIsValidDriveString(PUCHAR DriveString); // Checks the drive string ("hd0") for validity
U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName); // Returns a BIOS drive number for any given device name (e.g. 0x80 for 'hd0')
ULONG DriveMapGetBiosDriveNumber(PUCHAR DeviceName); // Returns a BIOS drive number for any given device name (e.g. 0x80 for 'hd0')
VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap); // Installs the int 13h handler for the drive mapper
VOID DriveMapRemoveInt13Handler(VOID); // Removes a previously installed int 13h drive map handler
extern PVOID DriveMapInt13HandlerStart;
extern PVOID DriveMapInt13HandlerEnd;
extern U32 DriveMapOldInt13HandlerAddress;
extern ULONG DriveMapOldInt13HandlerAddress;
extern DRIVE_MAP_LIST DriveMapInt13HandlerMapList;
#endif // #defined __DRIVEMAP_H

View file

@ -20,68 +20,29 @@
#ifndef __FREELDR_H
#define __FREELDR_H
#define NULL 0
#define TRUE 1
#define FALSE 0
#define BOOL int
#define BOOLEAN int
typedef BOOLEAN *PBOOLEAN;
#define CHAR char
#define PCHAR char *
#define UCHAR unsigned char
#define PUCHAR unsigned char *
#define WCHAR unsigned short
#define PWCHAR unsigned short *
#define ULONG unsigned long
#if defined(_WIN64)
#define ULONG_PTR __int64
#else
#define ULONG_PTR unsigned long
#endif
#define VOID void
#define PVOID VOID*
#ifdef __i386__
#define size_t unsigned int
typedef unsigned char U8;
typedef char S8;
typedef unsigned short U16;
typedef short S16;
typedef unsigned long U32;
typedef long S32;
typedef unsigned long long U64;
typedef long long S64;
typedef U8 __u8;
typedef S8 __s8;
typedef U16 __u16;
typedef S16 __s16;
typedef U32 __u32;
typedef S32 __s32;
typedef U64 __u64;
typedef S64 __s64;
#endif // __i386__
typedef U8 *PU8;
typedef U16 *PU16;
typedef U32 *PU32;
#include <ddk/ntddk.h>
#include <arch.h>
#include <reactos.h>
#include <rtl.h>
#include <disk.h>
#include <fs.h>
#include <ui.h>
#include <multiboot.h>
#include <mm.h>
#include <machine.h>
#include <inifile.h>
#include <video.h>
#include <portio.h>
#define ROUND_UP(N, S) (((N) + (S) - 1) & ~((S) - 1))
#define ROUND_DOWN(N, S) ((N) & ~((S) - 1))
#define Ke386EraseFlags(x) __asm__ __volatile__("pushl $0 ; popfl\n")
extern ULONG BootDrive; /* BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc. */
extern ULONG BootPartition; /* Boot Partition, 1-4 */
extern BOOL UserInterfaceUp; /* Tells us if the user interface is displayed */
#define PACKED __attribute__((packed))
extern U32 BootDrive; // BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc.
extern U32 BootPartition; // Boot Partition, 1-4
extern BOOL UserInterfaceUp; // Tells us if the user interface is displayed
void BootMain(char *CmdLine);
VOID RunLoader(VOID);
VOID BootMain(LPSTR CmdLine);
VOID RunLoader(VOID);
#endif // defined __FREELDR_H

View file

@ -33,15 +33,15 @@
#define PFILE FILE *
VOID FileSystemError(PUCHAR ErrorString);
BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber);
BOOL FsOpenVolume(ULONG DriveNumber, ULONG PartitionNumber);
PFILE FsOpenFile(PUCHAR FileName);
VOID FsCloseFile(PFILE FileHandle);
BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
U32 FsGetFileSize(PFILE FileHandle);
VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer);
U32 FsGetFilePointer(PFILE FileHandle);
BOOL FsReadFile(PFILE FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer);
ULONG FsGetFileSize(PFILE FileHandle);
VOID FsSetFilePointer(PFILE FileHandle, ULONG NewFilePointer);
ULONG FsGetFilePointer(PFILE FileHandle);
BOOL FsIsEndOfFile(PFILE FileHandle);
U32 FsGetNumPathParts(PUCHAR Path);
ULONG FsGetNumPathParts(PUCHAR Path);
VOID FsGetFirstNameFromPath(PUCHAR Buffer, PUCHAR Path);
#endif // #defined __FS_H

View file

@ -36,7 +36,7 @@
#define MAX_INF_STRING_LENGTH 512
typedef PU32 HINF, *PHINF;
typedef PULONG HINF, *PHINF;
typedef struct _INFCONTEXT
{
@ -52,7 +52,7 @@ typedef struct _INFCONTEXT
BOOLEAN
InfOpenFile (PHINF InfHandle,
PCHAR FileName,
PU32 ErrorLine);
PULONG ErrorLine);
VOID
InfCloseFile (HINF InfHandle);
@ -79,39 +79,39 @@ InfFindNextMatchLine (PINFCONTEXT ContextIn,
PINFCONTEXT ContextOut);
S32
LONG
InfGetLineCount (HINF InfHandle,
PCHAR Section);
S32
LONG
InfGetFieldCount (PINFCONTEXT Context);
BOOLEAN
InfGetBinaryField (PINFCONTEXT Context,
U32 FieldIndex,
PU8 ReturnBuffer,
U32 ReturnBufferSize,
PU32 RequiredSize);
ULONG FieldIndex,
PUCHAR ReturnBuffer,
ULONG ReturnBufferSize,
PULONG RequiredSize);
BOOLEAN
InfGetIntField (PINFCONTEXT Context,
U32 FieldIndex,
S32 *IntegerValue);
ULONG FieldIndex,
LONG *IntegerValue);
BOOLEAN
InfGetMultiSzField (PINFCONTEXT Context,
U32 FieldIndex,
ULONG FieldIndex,
PCHAR ReturnBuffer,
U32 ReturnBufferSize,
PU32 RequiredSize);
ULONG ReturnBufferSize,
PULONG RequiredSize);
BOOLEAN
InfGetStringField (PINFCONTEXT Context,
U32 FieldIndex,
ULONG FieldIndex,
PCHAR ReturnBuffer,
U32 ReturnBufferSize,
PU32 RequiredSize);
ULONG ReturnBufferSize,
PULONG RequiredSize);
@ -122,7 +122,7 @@ InfGetData (PINFCONTEXT Context,
BOOLEAN
InfGetDataField (PINFCONTEXT Context,
U32 FieldIndex,
ULONG FieldIndex,
PCHAR *Data);
#endif /* __INFCACHE_H__ */

View file

@ -22,14 +22,14 @@
BOOL IniFileInitialize(VOID);
BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId);
U32 IniGetNumSectionItems(U32 SectionId);
U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex);
U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex);
BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName, U32 NameSize, PUCHAR SettingValue, U32 ValueSize);
BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32 BufferSize);
BOOL IniAddSection(PUCHAR SectionName, U32* SectionId);
BOOL IniAddSettingValueToSection(U32 SectionId, PUCHAR SettingName, PUCHAR SettingValue);
BOOL IniOpenSection(PUCHAR SectionName, ULONG* SectionId);
ULONG IniGetNumSectionItems(ULONG SectionId);
ULONG IniGetSectionSettingNameSize(ULONG SectionId, ULONG SettingIndex);
ULONG IniGetSectionSettingValueSize(ULONG SectionId, ULONG SettingIndex);
BOOL IniReadSettingByNumber(ULONG SectionId, ULONG SettingNumber, PUCHAR SettingName, ULONG NameSize, PUCHAR SettingValue, ULONG ValueSize);
BOOL IniReadSettingByName(ULONG SectionId, PUCHAR SettingName, PUCHAR Buffer, ULONG BufferSize);
BOOL IniAddSection(PUCHAR SectionName, ULONG* SectionId);
BOOL IniAddSettingValueToSection(ULONG SectionId, PUCHAR SettingName, PUCHAR SettingValue);
#endif // defined __PARSEINI_H

View file

@ -45,34 +45,34 @@
typedef struct
{
U8 BootCode1[0x20];
UCHAR BootCode1[0x20];
U16 CommandLineMagic;
U16 CommandLineOffset;
USHORT CommandLineMagic;
USHORT CommandLineOffset;
U8 BootCode2[0x1CD];
UCHAR BootCode2[0x1CD];
U8 SetupSectors;
U16 RootFlags;
U16 SystemSize;
U16 SwapDevice;
U16 RamSize;
U16 VideoMode;
U16 RootDevice;
U16 BootFlag; // 0xAA55
UCHAR SetupSectors;
USHORT RootFlags;
USHORT SystemSize;
USHORT SwapDevice;
USHORT RamSize;
USHORT VideoMode;
USHORT RootDevice;
USHORT BootFlag; // 0xAA55
} PACKED LINUX_BOOTSECTOR, *PLINUX_BOOTSECTOR;
typedef struct
{
U8 JumpInstruction[2];
U32 SetupHeaderSignature; // Signature for SETUP-header
U16 Version; // Version number of header format
U16 RealModeSwitch; // Default switch
U16 SetupSeg; // SETUPSEG
U16 StartSystemSeg;
U16 KernelVersion; // Offset to kernel version string
U8 TypeOfLoader; // Loader ID
UCHAR JumpInstruction[2];
ULONG SetupHeaderSignature; // Signature for SETUP-header
USHORT Version; // Version number of header format
USHORT RealModeSwitch; // Default switch
USHORT SetupSeg; // SETUPSEG
USHORT StartSystemSeg;
USHORT KernelVersion; // Offset to kernel version string
UCHAR TypeOfLoader; // Loader ID
// =0, old one (LILO, Loadlin,
// Bootlin, SYSLX, bootsect...)
// else it is set by the loader:
@ -83,7 +83,7 @@ typedef struct
// T=4 for ETHERBOOT
// V = version
U8 LoadFlags; // flags, unused bits must be zero (RFU)
UCHAR LoadFlags; // flags, unused bits must be zero (RFU)
// LOADED_HIGH = 1
// bit within loadflags,
// if set, then the kernel is loaded high
@ -93,39 +93,39 @@ typedef struct
// can be used for heap purposes.
// Only the loader knows what is free!
U16 SetupMoveSize; // size to move, when we (setup) are not
USHORT SetupMoveSize; // size to move, when we (setup) are not
// loaded at 0x90000. We will move ourselves
// to 0x90000 then just before jumping into
// the kernel. However, only the loader
// know how much of data behind us also needs
// to be loaded.
U32 Code32Start; // here loaders can put a different
ULONG Code32Start; // here loaders can put a different
// start address for 32-bit code.
//
// 0x1000 = default for zImage
//
// 0x100000 = default for big kernel
U32 RamdiskAddress; // address of loaded ramdisk image
ULONG RamdiskAddress; // address of loaded ramdisk image
// Here the loader (or kernel generator) puts
// the 32-bit address were it loaded the image.
U32 RamdiskSize; // its size in bytes
ULONG RamdiskSize; // its size in bytes
U16 BootSectKludgeOffset;
U16 BootSectKludgeSegment;
U16 HeapEnd; // space from here (exclusive) down to
USHORT BootSectKludgeOffset;
USHORT BootSectKludgeSegment;
USHORT HeapEnd; // space from here (exclusive) down to
// end of setup code can be used by setup
// for local heap purposes.
U16 Pad1;
U32 CommandLinePointer; // 32-bit pointer to the kernel command line
U32 InitrdAddressMax; // Highest legal initrd address
USHORT Pad1;
ULONG CommandLinePointer; // 32-bit pointer to the kernel command line
ULONG InitrdAddressMax; // Highest legal initrd address
} PACKED LINUX_SETUPSECTOR, *PLINUX_SETUPSECTOR;
VOID BootNewLinuxKernel(VOID); // Implemented in linux.S
VOID BootOldLinuxKernel(U32 KernelSize); // Implemented in linux.S
VOID BootOldLinuxKernel(ULONG KernelSize); // Implemented in linux.S
VOID LoadAndBootLinux(PUCHAR OperatingSystemName, PUCHAR Description);

View file

@ -40,28 +40,28 @@ typedef struct tagMACHVTBL
BOOL (*ConsKbHit)(VOID);
int (*ConsGetCh)(VOID);
VOID (*VideoClearScreen)(U8 Attr);
VOID (*VideoClearScreen)(UCHAR Attr);
VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOL Init);
VOID (*VideoGetDisplaySize)(PU32 Width, PU32 Height, PU32 Depth);
U32 (*VideoGetBufferSize)(VOID);
VOID (*VideoSetTextCursorPosition)(U32 X, U32 Y);
VOID (*VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth);
ULONG (*VideoGetBufferSize)(VOID);
VOID (*VideoSetTextCursorPosition)(ULONG X, ULONG Y);
VOID (*VideoHideShowTextCursor)(BOOL Show);
VOID (*VideoPutChar)(int Ch, U8 Attr, unsigned X, unsigned Y);
VOID (*VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y);
VOID (*VideoCopyOffScreenBufferToVRAM)(PVOID Buffer);
BOOL (*VideoIsPaletteFixed)(VOID);
VOID (*VideoSetPaletteColor)(U8 Color, U8 Red, U8 Green, U8 Blue);
VOID (*VideoGetPaletteColor)(U8 Color, U8* Red, U8* Green, U8* Blue);
VOID (*VideoSetPaletteColor)(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue);
VOID (*VideoGetPaletteColor)(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue);
VOID (*VideoSync)(VOID);
VOID (*VideoPrepareForReactOS)(VOID);
U32 (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
ULONG (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize);
BOOL (*DiskReadLogicalSectors)(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
BOOL (*DiskGetPartitionEntry)(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL (*DiskGetDriveGeometry)(U32 DriveNumber, PGEOMETRY DriveGeometry);
U32 (*DiskGetCacheableBlockCount)(U32 DriveNumber);
BOOL (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOL (*DiskGetPartitionEntry)(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOL (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber);
VOID (*RTCGetCurrentDateTime)(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
VOID (*RTCGetCurrentDateTime)(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second);
VOID (*HwDetect)(VOID);
} MACHVTBL, *PMACHVTBL;

View file

@ -29,23 +29,23 @@
typedef struct
{
U64 BaseAddress;
U64 Length;
U32 Type;
U32 Reserved;
ULONGLONG BaseAddress;
ULONGLONG Length;
ULONG Type;
ULONG Reserved;
} PACKED BIOS_MEMORY_MAP, *PBIOS_MEMORY_MAP;
U32 GetSystemMemorySize(VOID); // Returns the amount of total memory in the system
ULONG GetSystemMemorySize(VOID); // Returns the amount of total memory in the system
//BOOL MmInitializeMemoryManager(U32 LowMemoryStart, U32 LowMemoryLength);
//BOOL MmInitializeMemoryManager(ULONG LowMemoryStart, ULONG LowMemoryLength);
BOOL MmInitializeMemoryManager(VOID);
PVOID MmAllocateMemory(U32 MemorySize);
PVOID MmAllocateMemory(ULONG MemorySize);
VOID MmFreeMemory(PVOID MemoryPointer);
//PVOID MmAllocateLowMemory(U32 MemorySize);
//PVOID MmAllocateLowMemory(ULONG MemorySize);
//VOID MmFreeLowMemory(PVOID MemoryPointer);
PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress);
PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress);
PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress);
PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress);
#endif // defined __MEMORY_H

View file

@ -89,38 +89,34 @@ typedef struct elf_section_header_table
unsigned long shndx;
} elf_section_header_table_t;
/* The Multiboot information. */
typedef struct multiboot_info
typedef struct _LOADER_PARAMETER_BLOCK
{
unsigned long flags;
unsigned long mem_lower;
unsigned long mem_upper;
unsigned long boot_device;
unsigned long cmdline;
unsigned long mods_count;
unsigned long mods_addr;
#if 0
/* reactos and loadros define this entry with a size of 12 byte but the union is 16 byte */
union
{
aout_symbol_table_t aout_sym;
elf_section_header_table_t elf_sec;
} u;
#else
char syms[12];
#endif
unsigned long mmap_length;
unsigned long mmap_addr;
} multiboot_info_t;
ULONG Flags;
ULONG MemLower;
ULONG MemHigher;
ULONG BootDevice;
ULONG CommandLine;
ULONG ModsCount;
ULONG ModsAddr;
UCHAR Syms[12];
ULONG MmapLength;
ULONG MmapAddr;
ULONG DrivesCount;
ULONG DrivesAddr;
ULONG ConfigTable;
ULONG BootLoaderName;
ULONG PageDirectoryStart;
ULONG PageDirectoryEnd;
ULONG KernelBase;
} LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;
/* The module structure. */
typedef struct module
{
unsigned long mod_start;
unsigned long mod_end;
unsigned long string;
unsigned long reserved;
} module_t;
typedef struct _FRLDR_MODULE {
ULONG_PTR ModuleStart;
ULONG_PTR ModuleEnd;
LPSTR ModuleName;
ULONG Reserved;
} FRLDR_MODULE, *PFRLDR_MODULE;
/* The memory map. Be careful that the offset 0 is base_addr_low
but no size. */
@ -136,27 +132,92 @@ typedef struct memory_map
} memory_map_t;
multiboot_header_t mb_header; // Multiboot header structure defined in kernel image file
multiboot_info_t mb_info; // Multiboot info structure passed to kernel
char multiboot_kernel_cmdline[255]; // Command line passed to kernel
module_t multiboot_modules[64]; // Array to hold boot module info loaded for the kernel
LOADER_PARAMETER_BLOCK LoaderBlock; /* Multiboot info structure passed to kernel */
char multiboot_kernel_cmdline[255]; // Command line passed to kernel
FRLDR_MODULE multiboot_modules[64]; // Array to hold boot module info loaded for the kernel
char multiboot_module_strings[64][256]; // Array to hold module names
unsigned long multiboot_memory_map_descriptor_size;
memory_map_t multiboot_memory_map[32]; // Memory map
memory_map_t multiboot_memory_map[32]; // Memory map
void boot_reactos(void);
#include "fs.h" // Included FILE structure definition
BOOL MultiBootLoadKernel(FILE *KernelImage);
//BOOL MultiBootLoadModule(FILE *ModuleImage, char *ModuleName);
PVOID MultiBootLoadModule(FILE *ModuleImage, char *ModuleName, U32* ModuleSize);
BOOL
STDCALL
FrLdrBootReactOs(VOID);
BOOL
STDCALL
FrLdrMapKernel(FILE *KernelImage);
ULONG_PTR
STDCALL
FrLdrCreateModule(LPSTR ModuleName);
ULONG_PTR
STDCALL
FrLdrLoadModule(FILE *ModuleImage,
LPSTR ModuleName,
PULONG ModuleSize);
BOOL
STDCALL
FrLdrLoadKernel(PCHAR szFileName,
INT nPos);
BOOL
FrLdrLoadNlsFile(PCHAR szSystemRoot,
PCHAR szErrorOut);
BOOL
FrLdrLoadDriver(PCHAR szFileName,
INT nPos);
BOOL
LoadSymbolFile(PCHAR szSystemRoot,
PCHAR ModuleName,
INT nPos);
VOID
FrLdrLoadBootDrivers(PCHAR szSystemRoot,
INT nPos);
BOOL
STDCALL
FrLdrCloseModule(ULONG_PTR ModuleBase,
ULONG dwModuleSize);
VOID
STDCALL
FrLdrStartup(ULONG Magic);
VOID
FASTCALL
FrLdrGetKernelBase(VOID);
VOID
FASTCALL
FrLdrSetupPae(ULONG Magic);
VOID
FASTCALL
FrLdrGetPaeMode(VOID);
VOID
FASTCALL
FrLdrSetupPageDirectory(VOID);
VOID
LoadAndBootReactOS(PUCHAR OperatingSystemName);
VOID FASTCALL AsmCode(VOID);
typedef VOID (FASTCALL *ASMCODE)(ULONG Magic,
PLOADER_PARAMETER_BLOCK LoaderBlock);
int GetBootPartition(char *OperatingSystemName);
PVOID MultiBootCreateModule(char *ModuleName);
BOOL MultiBootCloseModule(PVOID ModuleBase, U32 dwModuleSize);
#endif /* ! ASM */

View file

@ -20,9 +20,9 @@
#ifndef __OSLIST_H
#define __OSLIST_H
BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32* OperatingSystemCountPointer);
U32 CountOperatingSystems(U32 SectionId);
BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32 OperatingSystemCount);
BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG* OperatingSystemCountPointer);
ULONG CountOperatingSystems(ULONG SectionId);
BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG OperatingSystemCount);
BOOL RemoveQuotes(PUCHAR QuotedString);
#endif // #defined __OSLIST_H

View file

@ -27,52 +27,52 @@
*/
VOID
/*STDCALL*/
READ_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
STDCALL
READ_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, ULONG Count);
VOID
/*STDCALL*/
READ_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
STDCALL
READ_PORT_BUFFER_ULONG (ULONG* Port, ULONG* Value, ULONG Count);
VOID
/*STDCALL*/
READ_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
STDCALL
READ_PORT_BUFFER_USHORT (USHORT* Port, USHORT* Value, ULONG Count);
UCHAR
/*STDCALL*/
STDCALL
READ_PORT_UCHAR (PUCHAR Port);
U32
/*STDCALL*/
READ_PORT_ULONG (U32* Port);
ULONG
STDCALL
READ_PORT_ULONG (ULONG* Port);
U16
/*STDCALL*/
READ_PORT_USHORT (U16* Port);
USHORT
STDCALL
READ_PORT_USHORT (USHORT* Port);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
STDCALL
WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, ULONG Count);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
STDCALL
WRITE_PORT_BUFFER_ULONG (ULONG* Port, ULONG* Value, ULONG Count);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
STDCALL
WRITE_PORT_BUFFER_USHORT (USHORT* Port, USHORT* Value, ULONG Count);
VOID
/*STDCALL*/
STDCALL
WRITE_PORT_UCHAR (PUCHAR Port, UCHAR Value);
VOID
/*STDCALL*/
WRITE_PORT_ULONG (U32* Port, U32 Value);
STDCALL
WRITE_PORT_ULONG (ULONG* Port, ULONG Value);
VOID
/*STDCALL*/
WRITE_PORT_USHORT (U16* Port, U16 Value);
STDCALL
WRITE_PORT_USHORT (USHORT* Port, USHORT Value);
#endif // defined __PORTIO_H

View file

@ -26,23 +26,23 @@
// ReactOS Loading Functions
//
///////////////////////////////////////////////////////////////////////////////////////
void LoadAndBootReactOS(PUCHAR OperatingSystemName);
VOID LoadAndBootReactOS(PUCHAR OperatingSystemName);
///////////////////////////////////////////////////////////////////////////////////////
//
// ReactOS Setup Loader Functions
//
///////////////////////////////////////////////////////////////////////////////////////
VOID ReactOSRunSetupLoader(VOID);
VOID ReactOSRunSetupLoader(VOID);
///////////////////////////////////////////////////////////////////////////////////////
//
// ARC Path Functions
//
///////////////////////////////////////////////////////////////////////////////////////
BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPartition);
void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partition);
U32 ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath);
BOOL DissectArcPath(LPSTR ArcPath, LPSTR BootPath, PULONG BootDrive, PULONG BootPartition);
VOID ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, ULONG Disk, ULONG Partition);
ULONG ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath);
#endif // defined __REACTOS_H

View file

@ -22,23 +22,6 @@
#include <freeldr.h>
///////////////////////////////////////////////////////////////////////////////////////
//
// String Functions
//
///////////////////////////////////////////////////////////////////////////////////////
int strlen(char *str);
char * strcpy(char *dest, char *src);
char * strncpy(char *dest, char *src, size_t count);
char * strcat(char *dest, char *src);
char * strncat(char *dst, const char *src, size_t n);
char * strchr(const char *s, int c);
char * strrchr(const char *s, int c);
int strcmp(const char *string1, const char *string2);
int stricmp(const char *string1, const char *string2);
int strncmp(const char *string1, const char *string2, size_t length);
int strnicmp(const char *string1, const char *string2, size_t length);
///////////////////////////////////////////////////////////////////////////////////////
//
// Memory Functions
@ -52,7 +35,6 @@ void * memset(void *src, int val, size_t count);
#define RtlCompareMemory(Source1, Source2, Length) memcmp(Source1, Source2, Length)
#define RtlCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
#define RtlFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
#define RtlMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length) memset(Destination, 0, Length)
///////////////////////////////////////////////////////////////////////////////////////
@ -117,7 +99,7 @@ PLIST_ITEM RtlListRemoveTail(PLIST_ITEM ListHead); // Removes the entry a
PLIST_ITEM RtlListGetHead(PLIST_ITEM ListHead); // Returns the entry at the head of the list
PLIST_ITEM RtlListGetTail(PLIST_ITEM ListHead); // Returns the entry at the tail of the list
BOOL RtlListIsEmpty(PLIST_ITEM ListHead); // Indicates whether a doubly linked list is empty
U32 RtlListCountEntries(PLIST_ITEM ListHead); // Counts the entries in a doubly linked list
ULONG RtlListCountEntries(PLIST_ITEM ListHead); // Counts the entries in a doubly linked list
PLIST_ITEM RtlListGetPrevious(PLIST_ITEM ListEntry); // Returns the previous item in the list
PLIST_ITEM RtlListGetNext(PLIST_ITEM ListEntry); // Returns the next item in the list
PLIST_ITEM RtlListRemoveEntry(PLIST_ITEM ListEntry); // Removes the entry from the list

View file

@ -21,8 +21,8 @@
#define __UI_H
extern U32 UiScreenWidth; // Screen Width
extern U32 UiScreenHeight; // Screen Height
extern ULONG UiScreenWidth; // Screen Width
extern ULONG UiScreenHeight; // Screen Height
extern UCHAR UiStatusBarFgColor; // Status bar foreground color
extern UCHAR UiStatusBarBgColor; // Status bar background color
@ -57,26 +57,26 @@ extern UCHAR UiMonthNames[12][15];
BOOL UiInitialize(BOOLEAN ShowGui); // Initialize User-Interface
VOID UiUnInitialize(PUCHAR BootText); // Un-initialize User-Interface
VOID UiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
VOID UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
VOID UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom); // Draws a shadow on the bottom and right sides of the area specified
VOID UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
VOID UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
VOID UiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
VOID UiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PUCHAR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
VOID UiDrawStatusText(PUCHAR StatusText); // Draws text at the very bottom line on the screen
VOID UiUpdateDateTime(VOID); // Updates the date and time
VOID UiInfoBox(PUCHAR MessageText); // Displays a info box on the screen
VOID UiMessageBox(PUCHAR MessageText); // Displays a message box on the screen with an ok button
VOID UiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID UiShowMessageBoxesInSection(PUCHAR SectionName); // Displays all the message boxes in a given section
VOID UiEscapeString(PUCHAR String); // Processes a string and changes all occurances of "\n" to '\n'
BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length);
BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, ULONG Length);
UCHAR UiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
UCHAR UiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars); // Truncates a string to MaxChars by adding an ellipsis on the end '...'
VOID UiTruncateStringEllipsis(PUCHAR StringText, ULONG MaxChars); // Truncates a string to MaxChars by adding an ellipsis on the end '...'
VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
VOID UiFadeOut(VOID); // Fades the screen out
@ -86,9 +86,9 @@ VOID UiFadeOut(VOID); // Fades the screen out
// Menu Functions
//
///////////////////////////////////////////////////////////////////////////////////////
typedef BOOL (*UiMenuKeyPressFilterCallback)(U32 KeyPress);
typedef BOOL (*UiMenuKeyPressFilterCallback)(ULONG KeyPress);
BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
BOOL UiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);

View file

@ -22,42 +22,25 @@
typedef struct
{
U8 Red;
U8 Green;
U8 Blue;
UCHAR Red;
UCHAR Green;
UCHAR Blue;
} PACKED PALETTE_ENTRY, *PPALETTE_ENTRY;
extern PVOID VideoOffScreenBuffer;
U16 BiosIsVesaSupported(VOID); // Implemented in i386vid.S, returns the VESA version
USHORT BiosIsVesaSupported(VOID); // Implemented in i386vid.S, returns the VESA version
PVOID VideoAllocateOffScreenBuffer(VOID); // Returns a pointer to an off-screen buffer sufficient for the current video mode
#if 0 /* Not used */
U32 VideoGetMemoryBankForPixel(U32 X, U32 Y);
U32 VideoGetMemoryBankForPixel16(U32 X, U32 Y);
U32 VideoGetBankOffsetForPixel(U32 X, U32 Y);
U32 VideoGetBankOffsetForPixel16(U32 X, U32 Y);
VOID VideoSetMemoryBank(U16 BankNumber);
U32 VideoGetOffScreenMemoryOffsetForPixel(U32 X, U32 Y);
#endif
VOID VideoCopyOffScreenBufferToVRAM(VOID);
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount);
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount);
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount);
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount);
#if 0 /* Not used */
VOID VideoSetPixel16(U32 X, U32 Y, U8 Color);
VOID VideoSetPixel256(U32 X, U32 Y, U8 Color);
VOID VideoSetPixelRGB(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue);
VOID VideoSetPixel16_OffScreen(U32 X, U32 Y, U8 Color);
VOID VideoSetPixel256_OffScreen(U32 X, U32 Y, U8 Color);
VOID VideoSetPixelRGB_OffScreen(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue);
#endif
VOID VideoSetAllColorsToBlack(U32 ColorCount);
VOID VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount);
VOID VideoFadeOut(U32 ColorCount);
VOID VideoSetAllColorsToBlack(ULONG ColorCount);
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount);
VOID VideoFadeOut(ULONG ColorCount);
#endif // defined __VIDEO_H

View file

@ -56,7 +56,7 @@ typedef struct _INFCACHELINE
struct _INFCACHELINE *Next;
struct _INFCACHELINE *Prev;
S32 FieldCount;
LONG FieldCount;
PCHAR Key;
@ -74,7 +74,7 @@ typedef struct _INFCACHESECTION
PINFCACHELINE FirstLine;
PINFCACHELINE LastLine;
S32 LineCount;
LONG LineCount;
CHAR Name[1];
} INFCACHESECTION, *PINFCACHESECTION;
@ -241,7 +241,7 @@ InfpCacheAddSection (PINFCACHE Cache,
PCHAR Name)
{
PINFCACHESECTION Section = NULL;
U32 Size;
ULONG Size;
if (Cache == NULL || Name == NULL)
{
@ -341,7 +341,7 @@ InfpAddFieldToLine (PINFCACHELINE Line,
PCHAR Data)
{
PINFCACHEFIELD Field;
U32 Size;
ULONG Size;
Size = sizeof(INFCACHEFIELD) + strlen(Data);
Field = (PINFCACHEFIELD)MmAllocateMemory (Size);
@ -839,7 +839,7 @@ static BOOLEAN
InfpParseBuffer (PINFCACHE file,
const CHAR *buffer,
const CHAR *end,
PU32 error_line)
PULONG error_line)
{
struct parser parser;
const CHAR *pos = buffer;
@ -877,17 +877,17 @@ InfpParseBuffer (PINFCACHE file,
BOOLEAN
InfOpenFile(PHINF InfHandle,
PCHAR FileName,
PU32 ErrorLine)
PULONG ErrorLine)
{
PFILE FileHandle;
PCHAR FileBuffer;
U32 FileSize;
ULONG FileSize;
PINFCACHE Cache;
BOOLEAN Success;
*InfHandle = NULL;
*ErrorLine = (U32)-1;
*ErrorLine = (ULONG)-1;
/* Open the inf file */
@ -1144,7 +1144,7 @@ InfFindNextMatchLine (PINFCONTEXT ContextIn,
}
S32
LONG
InfGetLineCount(HINF InfHandle,
PCHAR Section)
{
@ -1184,7 +1184,7 @@ InfGetLineCount(HINF InfHandle,
/* InfGetLineText */
S32
LONG
InfGetFieldCount(PINFCONTEXT Context)
{
if (Context == NULL || Context->Line == NULL)
@ -1196,16 +1196,16 @@ InfGetFieldCount(PINFCONTEXT Context)
BOOLEAN
InfGetBinaryField (PINFCONTEXT Context,
U32 FieldIndex,
PU8 ReturnBuffer,
U32 ReturnBufferSize,
PU32 RequiredSize)
ULONG FieldIndex,
PUCHAR ReturnBuffer,
ULONG ReturnBufferSize,
PULONG RequiredSize)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
U32 Index;
U32 Size;
PU8 Ptr;
ULONG Index;
ULONG Size;
PUCHAR Ptr;
if (Context == NULL || Context->Line == NULL || FieldIndex == 0)
{
@ -1252,12 +1252,12 @@ InfGetBinaryField (PINFCONTEXT Context,
BOOLEAN
InfGetIntField (PINFCONTEXT Context,
U32 FieldIndex,
S32 *IntegerValue)
ULONG FieldIndex,
LONG *IntegerValue)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
U32 Index;
ULONG Index;
PCHAR Ptr;
if (Context == NULL || Context->Line == NULL || IntegerValue == NULL)
@ -1295,16 +1295,16 @@ InfGetIntField (PINFCONTEXT Context,
BOOLEAN
InfGetMultiSzField (PINFCONTEXT Context,
U32 FieldIndex,
ULONG FieldIndex,
PCHAR ReturnBuffer,
U32 ReturnBufferSize,
PU32 RequiredSize)
ULONG ReturnBufferSize,
PULONG RequiredSize)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
PINFCACHEFIELD FieldPtr;
U32 Index;
U32 Size;
ULONG Index;
ULONG Size;
PCHAR Ptr;
if (Context == NULL || Context->Line == NULL || FieldIndex == 0)
@ -1364,16 +1364,16 @@ InfGetMultiSzField (PINFCONTEXT Context,
BOOLEAN
InfGetStringField (PINFCONTEXT Context,
U32 FieldIndex,
ULONG FieldIndex,
PCHAR ReturnBuffer,
U32 ReturnBufferSize,
PU32 RequiredSize)
ULONG ReturnBufferSize,
PULONG RequiredSize)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
U32 Index;
ULONG Index;
PCHAR Ptr;
U32 Size;
ULONG Size;
if (Context == NULL || Context->Line == NULL || FieldIndex == 0)
{
@ -1456,12 +1456,12 @@ InfGetData (PINFCONTEXT Context,
BOOLEAN
InfGetDataField (PINFCONTEXT Context,
U32 FieldIndex,
ULONG FieldIndex,
PCHAR *Data)
{
PINFCACHELINE CacheLine;
PINFCACHEFIELD CacheField;
U32 Index;
ULONG Index;
if (Context == NULL || Context->Line == NULL || Data == NULL)
{

View file

@ -48,29 +48,29 @@ typedef struct
{
LIST_ITEM ListEntry;
PUCHAR SectionName;
U32 SectionItemCount;
ULONG SectionItemCount;
PINI_SECTION_ITEM SectionItemList;
} INI_SECTION, *PINI_SECTION;
extern PINI_SECTION IniFileSectionListHead;
extern U32 IniFileSectionCount;
extern U32 IniFileSettingCount;
extern ULONG IniFileSectionCount;
extern ULONG IniFileSettingCount;
PFILE IniOpenIniFile(U8 BootDriveNumber, U8 BootPartitionNumber);
PFILE IniOpenIniFile(UCHAR BootDriveNumber, UCHAR BootPartitionNumber);
BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize);
U32 IniGetNextLineSize(PUCHAR IniFileData, U32 IniFileSize, U32 CurrentOffset);
U32 IniGetNextLine(PUCHAR IniFileData, U32 IniFileSize, PUCHAR Buffer, U32 BufferSize, U32 CurrentOffset);
BOOL IniIsLineEmpty(PUCHAR LineOfText, U32 TextLength);
BOOL IniIsCommentLine(PUCHAR LineOfText, U32 TextLength);
BOOL IniIsSectionName(PUCHAR LineOfText, U32 TextLength);
U32 IniGetSectionNameSize(PUCHAR SectionNameLine, U32 LineLength);
VOID IniExtractSectionName(PUCHAR SectionName, PUCHAR SectionNameLine, U32 LineLength);
BOOL IniIsSetting(PUCHAR LineOfText, U32 TextLength);
U32 IniGetSettingNameSize(PUCHAR SettingNameLine, U32 LineLength);
U32 IniGetSettingValueSize(PUCHAR SettingValueLine, U32 LineLength);
VOID IniExtractSettingName(PUCHAR SettingName, PUCHAR SettingNameLine, U32 LineLength);
VOID IniExtractSettingValue(PUCHAR SettingValue, PUCHAR SettingValueLine, U32 LineLength);
BOOL IniParseFile(PUCHAR IniFileData, ULONG IniFileSize);
ULONG IniGetNextLineSize(PUCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset);
ULONG IniGetNextLine(PUCHAR IniFileData, ULONG IniFileSize, PUCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset);
BOOL IniIsLineEmpty(PUCHAR LineOfText, ULONG TextLength);
BOOL IniIsCommentLine(PUCHAR LineOfText, ULONG TextLength);
BOOL IniIsSectionName(PUCHAR LineOfText, ULONG TextLength);
ULONG IniGetSectionNameSize(PUCHAR SectionNameLine, ULONG LineLength);
VOID IniExtractSectionName(PUCHAR SectionName, PUCHAR SectionNameLine, ULONG LineLength);
BOOL IniIsSetting(PUCHAR LineOfText, ULONG TextLength);
ULONG IniGetSettingNameSize(PUCHAR SettingNameLine, ULONG LineLength);
ULONG IniGetSettingValueSize(PUCHAR SettingValueLine, ULONG LineLength);
VOID IniExtractSettingName(PUCHAR SettingName, PUCHAR SettingNameLine, ULONG LineLength);
VOID IniExtractSettingValue(PUCHAR SettingValue, PUCHAR SettingValueLine, ULONG LineLength);
#endif // defined __INI_H

View file

@ -29,7 +29,7 @@ BOOL IniFileInitialize(VOID)
{
PFILE Freeldr_Ini; // File handle for freeldr.ini
PUCHAR FreeLoaderIniFileData;
U32 FreeLoaderIniFileSize;
ULONG FreeLoaderIniFileSize;
BOOL Success;
// Open freeldr.ini
@ -87,7 +87,7 @@ BOOL IniFileInitialize(VOID)
return Success;
}
PFILE IniOpenIniFile(U8 BootDriveNumber, U8 BootPartitionNumber)
PFILE IniOpenIniFile(UCHAR BootDriveNumber, UCHAR BootPartitionNumber)
{
PFILE IniFileHandle; // File handle for freeldr.ini

View file

@ -24,7 +24,7 @@
#include <debug.h>
#include <mm.h>
BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
BOOL IniOpenSection(PUCHAR SectionName, ULONG* SectionId)
{
PINI_SECTION Section;
@ -41,7 +41,7 @@ BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
if (stricmp(SectionName, Section->SectionName) == 0)
{
// We found it
*SectionId = (U32)Section;
*SectionId = (ULONG)Section;
DbgPrint((DPRINT_INIFILE, "IniOpenSection() Found it! SectionId = 0x%x\n", SectionId));
return TRUE;
}
@ -55,7 +55,7 @@ BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
return FALSE;
}
U32 IniGetNumSectionItems(U32 SectionId)
ULONG IniGetNumSectionItems(ULONG SectionId)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
@ -65,7 +65,7 @@ U32 IniGetNumSectionItems(U32 SectionId)
return Section->SectionItemCount;
}
U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex)
ULONG IniGetSectionSettingNameSize(ULONG SectionId, ULONG SettingIndex)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
@ -73,7 +73,7 @@ U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex)
return (strlen(Section->SectionItemList[SettingIndex].ItemName) + 1);
}
U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex)
ULONG IniGetSectionSettingValueSize(ULONG SectionId, ULONG SettingIndex)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
@ -81,12 +81,12 @@ U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex)
return (strlen(Section->SectionItemList[SettingIndex].ItemValue) + 1);
}
BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName, U32 NameSize, PUCHAR SettingValue, U32 ValueSize)
BOOL IniReadSettingByNumber(ULONG SectionId, ULONG SettingNumber, PUCHAR SettingName, ULONG NameSize, PUCHAR SettingValue, ULONG ValueSize)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;
#ifdef DEBUG
U32 RealSettingNumber = SettingNumber;
ULONG RealSettingNumber = SettingNumber;
#endif
DbgPrint((DPRINT_INIFILE, ".001 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
@ -131,7 +131,7 @@ BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName
return FALSE;
}
BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32 BufferSize)
BOOL IniReadSettingByName(ULONG SectionId, PUCHAR SettingName, PUCHAR Buffer, ULONG BufferSize)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;
@ -163,7 +163,7 @@ BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32
return FALSE;
}
BOOL IniAddSection(PUCHAR SectionName, U32* SectionId)
BOOL IniAddSection(PUCHAR SectionName, ULONG* SectionId)
{
PINI_SECTION Section;
@ -198,12 +198,12 @@ BOOL IniAddSection(PUCHAR SectionName, U32* SectionId)
RtlListInsertTail((PLIST_ITEM)IniFileSectionListHead, (PLIST_ITEM)Section);
}
*SectionId = (U32)Section;
*SectionId = (ULONG)Section;
return TRUE;
}
BOOL IniAddSettingValueToSection(U32 SectionId, PUCHAR SettingName, PUCHAR SettingValue)
BOOL IniAddSettingValueToSection(ULONG SectionId, PUCHAR SettingName, PUCHAR SettingValue)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;

View file

@ -26,17 +26,17 @@
PINI_SECTION IniFileSectionListHead = NULL;
U32 IniFileSectionCount = 0;
U32 IniFileSettingCount = 0;
ULONG IniFileSectionCount = 0;
ULONG IniFileSettingCount = 0;
BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize)
BOOL IniParseFile(PUCHAR IniFileData, ULONG IniFileSize)
{
U32 CurrentOffset;
U32 CurrentLineNumber;
ULONG CurrentOffset;
ULONG CurrentLineNumber;
PUCHAR IniFileLine;
U32 IniFileLineSize;
U32 LineLength;
ULONG IniFileLineSize;
ULONG LineLength;
PINI_SECTION CurrentSection = NULL;
PINI_SECTION_ITEM CurrentItem = NULL;
@ -189,10 +189,10 @@ BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize)
return TRUE;
}
U32 IniGetNextLineSize(PUCHAR IniFileData, U32 IniFileSize, U32 CurrentOffset)
ULONG IniGetNextLineSize(PUCHAR IniFileData, ULONG IniFileSize, ULONG CurrentOffset)
{
U32 Idx;
U32 LineCharCount = 0;
ULONG Idx;
ULONG LineCharCount = 0;
// Loop through counting chars until we hit the end of the
// file or we encounter a new line char
@ -216,9 +216,9 @@ U32 IniGetNextLineSize(PUCHAR IniFileData, U32 IniFileSize, U32 CurrentOffset)
return LineCharCount;
}
U32 IniGetNextLine(PUCHAR IniFileData, U32 IniFileSize, PUCHAR Buffer, U32 BufferSize, U32 CurrentOffset)
ULONG IniGetNextLine(PUCHAR IniFileData, ULONG IniFileSize, PUCHAR Buffer, ULONG BufferSize, ULONG CurrentOffset)
{
U32 Idx;
ULONG Idx;
// Loop through grabbing chars until we hit the end of the
// file or we encounter a new line char
@ -252,9 +252,9 @@ U32 IniGetNextLine(PUCHAR IniFileData, U32 IniFileSize, PUCHAR Buffer, U32 Buffe
return CurrentOffset;
}
BOOL IniIsLineEmpty(PUCHAR LineOfText, U32 TextLength)
BOOL IniIsLineEmpty(PUCHAR LineOfText, ULONG TextLength)
{
U32 Idx;
ULONG Idx;
// Check for text (skipping whitespace)
for (Idx=0; Idx<TextLength; Idx++)
@ -275,9 +275,9 @@ BOOL IniIsLineEmpty(PUCHAR LineOfText, U32 TextLength)
return TRUE;
}
BOOL IniIsCommentLine(PUCHAR LineOfText, U32 TextLength)
BOOL IniIsCommentLine(PUCHAR LineOfText, ULONG TextLength)
{
U32 Idx;
ULONG Idx;
// Check the first character (skipping whitespace)
// and make sure that it is an opening bracket
@ -301,9 +301,9 @@ BOOL IniIsCommentLine(PUCHAR LineOfText, U32 TextLength)
return FALSE;
}
BOOL IniIsSectionName(PUCHAR LineOfText, U32 TextLength)
BOOL IniIsSectionName(PUCHAR LineOfText, ULONG TextLength)
{
U32 Idx;
ULONG Idx;
// Check the first character (skipping whitespace)
// and make sure that it is an opening bracket
@ -327,10 +327,10 @@ BOOL IniIsSectionName(PUCHAR LineOfText, U32 TextLength)
return FALSE;
}
U32 IniGetSectionNameSize(PUCHAR SectionNameLine, U32 LineLength)
ULONG IniGetSectionNameSize(PUCHAR SectionNameLine, ULONG LineLength)
{
U32 Idx;
U32 NameSize;
ULONG Idx;
ULONG NameSize;
// Find the opening bracket (skipping whitespace)
for (Idx=0; Idx<LineLength; Idx++)
@ -368,10 +368,10 @@ U32 IniGetSectionNameSize(PUCHAR SectionNameLine, U32 LineLength)
return NameSize;
}
VOID IniExtractSectionName(PUCHAR SectionName, PUCHAR SectionNameLine, U32 LineLength)
VOID IniExtractSectionName(PUCHAR SectionName, PUCHAR SectionNameLine, ULONG LineLength)
{
U32 Idx;
U32 DestIdx;
ULONG Idx;
ULONG DestIdx;
// Find the opening bracket (skipping whitespace)
for (Idx=0; Idx<LineLength; Idx++)
@ -408,9 +408,9 @@ VOID IniExtractSectionName(PUCHAR SectionName, PUCHAR SectionNameLine, U32 LineL
SectionName[DestIdx] = '\0';
}
BOOL IniIsSetting(PUCHAR LineOfText, U32 TextLength)
BOOL IniIsSetting(PUCHAR LineOfText, ULONG TextLength)
{
U32 Idx;
ULONG Idx;
// Basically just check for an '=' equals sign
for (Idx=0; Idx<TextLength; Idx++)
@ -424,10 +424,10 @@ BOOL IniIsSetting(PUCHAR LineOfText, U32 TextLength)
return FALSE;
}
U32 IniGetSettingNameSize(PUCHAR SettingNameLine, U32 LineLength)
ULONG IniGetSettingNameSize(PUCHAR SettingNameLine, ULONG LineLength)
{
U32 Idx;
U32 NameSize;
ULONG Idx;
ULONG NameSize;
// Skip whitespace
for (Idx=0; Idx<LineLength; Idx++)
@ -462,10 +462,10 @@ U32 IniGetSettingNameSize(PUCHAR SettingNameLine, U32 LineLength)
return NameSize;
}
U32 IniGetSettingValueSize(PUCHAR SettingValueLine, U32 LineLength)
ULONG IniGetSettingValueSize(PUCHAR SettingValueLine, ULONG LineLength)
{
U32 Idx;
U32 ValueSize;
ULONG Idx;
ULONG ValueSize;
// Skip whitespace
for (Idx=0; Idx<LineLength; Idx++)
@ -515,10 +515,10 @@ U32 IniGetSettingValueSize(PUCHAR SettingValueLine, U32 LineLength)
return ValueSize;
}
VOID IniExtractSettingName(PUCHAR SettingName, PUCHAR SettingNameLine, U32 LineLength)
VOID IniExtractSettingName(PUCHAR SettingName, PUCHAR SettingNameLine, ULONG LineLength)
{
U32 Idx;
U32 DestIdx;
ULONG Idx;
ULONG DestIdx;
// Skip whitespace
for (Idx=0; Idx<LineLength; Idx++)
@ -552,10 +552,10 @@ VOID IniExtractSettingName(PUCHAR SettingName, PUCHAR SettingNameLine, U32 LineL
SettingName[DestIdx] = '\0';
}
VOID IniExtractSettingValue(PUCHAR SettingValue, PUCHAR SettingValueLine, U32 LineLength)
VOID IniExtractSettingValue(PUCHAR SettingValue, PUCHAR SettingValueLine, ULONG LineLength)
{
U32 Idx;
U32 DestIdx;
ULONG Idx;
ULONG DestIdx;
// Skip whitespace
for (Idx=0; Idx<LineLength; Idx++)

View file

@ -40,15 +40,15 @@
PLINUX_BOOTSECTOR LinuxBootSector = NULL;
PLINUX_SETUPSECTOR LinuxSetupSector = NULL;
U32 SetupSectorSize = 0;
ULONG SetupSectorSize = 0;
BOOL NewStyleLinuxKernel = FALSE;
U32 LinuxKernelSize = 0;
U32 LinuxInitrdSize = 0;
ULONG LinuxKernelSize = 0;
ULONG LinuxInitrdSize = 0;
UCHAR LinuxKernelName[260];
UCHAR LinuxInitrdName[260];
BOOL LinuxHasInitrd = FALSE;
UCHAR LinuxCommandLine[260] = "";
U32 LinuxCommandLineSize = 0;
ULONG LinuxCommandLineSize = 0;
PVOID LinuxKernelLoadAddress = NULL;
PVOID LinuxInitrdLoadAddress = NULL;
UCHAR LinuxBootDescription[80];
@ -227,7 +227,7 @@ BOOL LinuxParseIniSection(PUCHAR OperatingSystemName)
{
UCHAR SettingName[260];
UCHAR SettingValue[260];
U32 SectionId;
ULONG SectionId;
// Find all the message box settings and run them
UiShowMessageBoxesInSection(OperatingSystemName);
@ -316,7 +316,7 @@ BOOL LinuxReadBootSector(PFILE LinuxKernelFile)
BOOL LinuxReadSetupSector(PFILE LinuxKernelFile)
{
U8 TempLinuxSetupSector[512];
UCHAR TempLinuxSetupSector[512];
LinuxSetupSector = (PLINUX_SETUPSECTOR)TempLinuxSetupSector;
@ -382,7 +382,7 @@ BOOL LinuxReadSetupSector(PFILE LinuxKernelFile)
BOOL LinuxReadKernel(PFILE LinuxKernelFile)
{
U32 BytesLoaded;
ULONG BytesLoaded;
UCHAR StatusText[260];
PVOID LoadAddress;
@ -455,7 +455,7 @@ BOOL LinuxCheckKernelVersion(VOID)
BOOL LinuxReadInitrd(PFILE LinuxInitrdFile)
{
U32 BytesLoaded;
ULONG BytesLoaded;
UCHAR StatusText[260];
sprintf(StatusText, "Loading %s", LinuxInitrdName);
@ -479,7 +479,7 @@ BOOL LinuxReadInitrd(PFILE LinuxInitrdFile)
}
// Set the information in the setup struct
LinuxSetupSector->RamdiskAddress = (U32)LinuxInitrdLoadAddress;
LinuxSetupSector->RamdiskAddress = (ULONG)LinuxInitrdLoadAddress;
LinuxSetupSector->RamdiskSize = LinuxInitrdSize;
DbgPrint((DPRINT_LINUX, "RamdiskAddress: 0x%x\n", LinuxSetupSector->RamdiskAddress));

View file

@ -65,7 +65,7 @@ MachConsGetCh()
}
VOID
MachVideoClearScreen(U8 Attr)
MachVideoClearScreen(UCHAR Attr)
{
MachVtbl.VideoClearScreen(Attr);
}
@ -77,19 +77,19 @@ MachVideoSetDisplayMode(char *DisplayMode, BOOL Init)
}
VOID
MachVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
MachVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
{
return MachVtbl.VideoGetDisplaySize(Width, Height, Depth);
}
U32
ULONG
MachVideoGetBufferSize(VOID)
{
return MachVtbl.VideoGetBufferSize();
}
VOID
MachVideoSetTextCursorPosition(U32 X, U32 Y)
MachVideoSetTextCursorPosition(ULONG X, ULONG Y)
{
return MachVtbl.VideoSetTextCursorPosition(X, Y);
}
@ -101,7 +101,7 @@ MachVideoHideShowTextCursor(BOOL Show)
}
VOID
MachVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
MachVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
{
MachVtbl.VideoPutChar(Ch, Attr, X, Y);
}
@ -119,13 +119,13 @@ MachVideoIsPaletteFixed(VOID)
}
VOID
MachVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
MachVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
{
return MachVtbl.VideoSetPaletteColor(Color, Red, Green, Blue);
}
VOID
MachVideoGetPaletteColor(U8 Color, U8 *Red, U8 *Green, U8 *Blue)
MachVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
{
return MachVtbl.VideoGetPaletteColor(Color, Red, Green, Blue);
}
@ -142,38 +142,38 @@ MachVideoPrepareForReactOS(VOID)
MachVtbl.VideoPrepareForReactOS();
}
U32
MachGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
ULONG
MachGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
{
return MachVtbl.GetMemoryMap(BiosMemoryMap, MaxMemoryMapSize);
}
BOOL
MachDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
return MachVtbl.DiskReadLogicalSectors(DriveNumber, SectorNumber, SectorCount, Buffer);
}
BOOL
MachDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
MachDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
return MachVtbl.DiskGetPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
}
BOOL
MachDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry)
MachDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry)
{
return MachVtbl.DiskGetDriveGeometry(DriveNumber, DriveGeometry);
}
U32
MachDiskGetCacheableBlockCount(U32 DriveNumber)
ULONG
MachDiskGetCacheableBlockCount(ULONG DriveNumber)
{
return MachVtbl.DiskGetCacheableBlockCount(DriveNumber);
}
VOID
MachRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
MachRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
{
MachVtbl.RTCGetCurrentDateTime(Year, Month, Day, Hour, Minute, Second);
}

View file

@ -34,9 +34,9 @@ VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
PFILE FilePointer;
UCHAR SettingName[80];
UCHAR SettingValue[80];
U32 SectionId;
ULONG SectionId;
UCHAR FileName[260];
U32 BytesRead;
ULONG BytesRead;
// Find all the message box settings and run them
UiShowMessageBoxesInSection(OperatingSystemName);
@ -90,7 +90,7 @@ VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
}
// Check for validity
if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{
UiMessageBox("Invalid boot sector magic (0xaa55)");
return;
@ -113,7 +113,7 @@ VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
U32 SectionId;
ULONG SectionId;
PARTITION_TABLE_ENTRY PartitionTableEntry;
// Find all the message box settings and run them
@ -159,7 +159,7 @@ VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
}
// Check for validity
if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{
UiMessageBox("Invalid boot sector magic (0xaa55)");
return;
@ -182,7 +182,7 @@ VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
{
UCHAR SettingName[80];
UCHAR SettingValue[80];
U32 SectionId;
ULONG SectionId;
// Find all the message box settings and run them
UiShowMessageBoxesInSection(OperatingSystemName);
@ -211,7 +211,7 @@ VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
}
// Check for validity
if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
if (*((USHORT*)(0x7c00 + 0x1fe)) != 0xaa55)
{
UiMessageBox("Invalid boot sector magic (0xaa55)");
return;

View file

@ -30,8 +30,8 @@
typedef struct
{
U32 PageAllocated; // Zero = free, non-zero = allocated
U32 PageAllocationLength; // Number of pages allocated (or zero if this isn't the first page in the chain)
ULONG PageAllocated; // Zero = free, non-zero = allocated
ULONG PageAllocationLength; // Number of pages allocated (or zero if this isn't the first page in the chain)
} PACKED PAGE_LOOKUP_TABLE_ITEM, *PPAGE_LOOKUP_TABLE_ITEM;
//
@ -44,27 +44,27 @@ typedef struct
extern PVOID PageLookupTableAddress;
extern U32 TotalPagesInLookupTable;
extern U32 FreePagesInLookupTable;
extern U32 LastFreePageHint;
extern ULONG TotalPagesInLookupTable;
extern ULONG FreePagesInLookupTable;
extern ULONG LastFreePageHint;
#ifdef DEBUG
PUCHAR MmGetSystemMemoryMapTypeString(U32 Type);
PUCHAR MmGetSystemMemoryMapTypeString(ULONG Type);
#endif
U32 MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address
PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the last address of memory from the memory map
U32 MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions
PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory)
VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Sorts the BIOS_MEMORY_MAP array so the first element corresponds to the first address in memory
VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Inits the page lookup table according to the memory types in the memory map
VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount, U32 PageAllocated); // Marks the specified pages as allocated or free in the lookup table
VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount); // Allocates the specified pages in the lookup table
U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount); // Returns the number of free pages in the lookup table
U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded); // Returns the page number of the first available page range from the end of memory
U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded, U32 LastPage); // Returns the page number of the first available page range before the specified page
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount); // Removes entries in the memory map that describe memory above 4G
VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory
BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, U32 TotalPageCount, PVOID PageAddress, U32 PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE
ULONG MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address
PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Returns the last address of memory from the memory map
ULONG MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions
PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory)
VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Sorts the BIOS_MEMORY_MAP array so the first element corresponds to the first address in memory
VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Inits the page lookup table according to the memory types in the memory map
VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, ULONG PageAllocated); // Marks the specified pages as allocated or free in the lookup table
VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount); // Allocates the specified pages in the lookup table
ULONG MmCountFreePagesInLookupTable(PVOID PageLookupTable, ULONG TotalPageCount); // Returns the number of free pages in the lookup table
ULONG MmFindAvailablePagesFromEnd(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded); // Returns the page number of the first available page range from the end of memory
ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, ULONG LastPage); // Returns the page number of the first available page range before the specified page
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG* MapCount); // Removes entries in the memory map that describe memory above 4G
VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory
BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE
#endif // defined __MEM_H

View file

@ -30,11 +30,11 @@
#ifdef DEBUG
typedef struct
{
U32 Type;
ULONG Type;
UCHAR TypeString[20];
} MEMORY_TYPE, *PMEMORY_TYPE;
U32 MemoryTypeCount = 5;
ULONG MemoryTypeCount = 5;
MEMORY_TYPE MemoryTypeArray[] =
{
{ 0, "Unknown Memory" },
@ -46,16 +46,16 @@ MEMORY_TYPE MemoryTypeArray[] =
#endif
PVOID PageLookupTableAddress = NULL;
U32 TotalPagesInLookupTable = 0;
U32 FreePagesInLookupTable = 0;
U32 LastFreePageHint = 0;
ULONG TotalPagesInLookupTable = 0;
ULONG FreePagesInLookupTable = 0;
ULONG LastFreePageHint = 0;
BOOL MmInitializeMemoryManager(VOID)
{
BIOS_MEMORY_MAP BiosMemoryMap[32];
U32 BiosMemoryMapEntryCount;
ULONG BiosMemoryMapEntryCount;
#ifdef DEBUG
U32 Index;
ULONG Index;
#endif
DbgPrint((DPRINT_MEMORY, "Initializing Memory Manager.\n"));
@ -105,9 +105,9 @@ BOOL MmInitializeMemoryManager(VOID)
}
#ifdef DEBUG
PUCHAR MmGetSystemMemoryMapTypeString(U32 Type)
PUCHAR MmGetSystemMemoryMapTypeString(ULONG Type)
{
U32 Index;
ULONG Index;
for (Index=1; Index<MemoryTypeCount; Index++)
{
@ -121,16 +121,16 @@ PUCHAR MmGetSystemMemoryMapTypeString(U32 Type)
}
#endif
U32 MmGetPageNumberFromAddress(PVOID Address)
ULONG MmGetPageNumberFromAddress(PVOID Address)
{
return ((U32)Address) / MM_PAGE_SIZE;
return ((ULONG)Address) / MM_PAGE_SIZE;
}
PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount)
{
U64 MaxStartAddressSoFar;
U64 EndAddressOfMemory;
U32 Index;
ULONGLONG MaxStartAddressSoFar;
ULONGLONG EndAddressOfMemory;
ULONG Index;
MaxStartAddressSoFar = 0;
EndAddressOfMemory = 0;
@ -147,17 +147,17 @@ PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
}
}
DbgPrint((DPRINT_MEMORY, "MmGetEndAddressOfAnyMemory() returning 0x%x\n", (U32)EndAddressOfMemory));
DbgPrint((DPRINT_MEMORY, "MmGetEndAddressOfAnyMemory() returning 0x%x\n", (ULONG)EndAddressOfMemory));
return (PVOID)(U32)EndAddressOfMemory;
return (PVOID)(ULONG)EndAddressOfMemory;
}
U32 MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
ULONG MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount)
{
U32 PageCount;
U64 EndAddress;
ULONG PageCount;
ULONGLONG EndAddress;
EndAddress = (U64)(U32)MmGetEndAddressOfAnyMemory(BiosMemoryMap, MapCount);
EndAddress = (ULONGLONG)(ULONG)MmGetEndAddressOfAnyMemory(BiosMemoryMap, MapCount);
// Since MmGetEndAddressOfAnyMemory() won't
// return addresses higher than 0xFFFFFFFF
@ -178,10 +178,10 @@ U32 MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, U32
return PageCount;
}
PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount)
{
U32 TotalPageCount;
U32 PageLookupTableSize;
ULONG TotalPageCount;
ULONG PageLookupTableSize;
PVOID PageLookupTableMemAddress;
int Index;
BIOS_MEMORY_MAP TempBiosMemoryMap[32];
@ -199,7 +199,7 @@ PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCo
// then we'll put our page lookup table here
if (TempBiosMemoryMap[Index].Type == MEMTYPE_USABLE && TempBiosMemoryMap[Index].Length >= PageLookupTableSize)
{
PageLookupTableMemAddress = (PVOID)(U32)(TempBiosMemoryMap[Index].BaseAddress + (TempBiosMemoryMap[Index].Length - PageLookupTableSize));
PageLookupTableMemAddress = (PVOID)(ULONG)(TempBiosMemoryMap[Index].BaseAddress + (TempBiosMemoryMap[Index].Length - PageLookupTableSize));
break;
}
}
@ -209,10 +209,10 @@ PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCo
return PageLookupTableMemAddress;
}
VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount)
{
U32 Index;
U32 LoopCount;
ULONG Index;
ULONG LoopCount;
BIOS_MEMORY_MAP TempMapItem;
// Loop once for each entry in the memory map minus one
@ -231,15 +231,15 @@ VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
}
}
VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount)
{
U32 MemoryMapStartPage;
U32 MemoryMapEndPage;
U32 MemoryMapPageCount;
U32 MemoryMapPageAllocated;
U32 PageLookupTableStartPage;
U32 PageLookupTablePageCount;
U32 Index;
ULONG MemoryMapStartPage;
ULONG MemoryMapEndPage;
ULONG MemoryMapPageCount;
ULONG MemoryMapPageAllocated;
ULONG PageLookupTableStartPage;
ULONG PageLookupTablePageCount;
ULONG Index;
DbgPrint((DPRINT_MEMORY, "MmInitPageLookupTable()\n"));
@ -250,8 +250,8 @@ VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMO
for (Index=0; Index<MapCount; Index++)
{
MemoryMapStartPage = MmGetPageNumberFromAddress((PVOID)(U32)BiosMemoryMap[Index].BaseAddress);
MemoryMapEndPage = MmGetPageNumberFromAddress((PVOID)(U32)(BiosMemoryMap[Index].BaseAddress + BiosMemoryMap[Index].Length - 1));
MemoryMapStartPage = MmGetPageNumberFromAddress((PVOID)(ULONG)BiosMemoryMap[Index].BaseAddress);
MemoryMapEndPage = MmGetPageNumberFromAddress((PVOID)(ULONG)(BiosMemoryMap[Index].BaseAddress + BiosMemoryMap[Index].Length - 1));
MemoryMapPageCount = (MemoryMapEndPage - MemoryMapStartPage) + 1;
MemoryMapPageAllocated = (BiosMemoryMap[Index].Type == MEMTYPE_USABLE) ? 0 : BiosMemoryMap[Index].Type;
DbgPrint((DPRINT_MEMORY, "Marking pages as type %d: StartPage: %d PageCount: %d\n", MemoryMapPageAllocated, MemoryMapStartPage, MemoryMapPageCount));
@ -269,10 +269,10 @@ VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMO
MmMarkPagesInLookupTable(PageLookupTable, PageLookupTableStartPage, PageLookupTablePageCount, MEMTYPE_RESERVED);
}
VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount, U32 PageAllocated)
VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, ULONG PageAllocated)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 Index;
ULONG Index;
for (Index=StartPage; Index<(StartPage+PageCount); Index++)
{
@ -286,10 +286,10 @@ VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCoun
DbgPrint((DPRINT_MEMORY, "MmMarkPagesInLookupTable() Done\n"));
}
VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount)
VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 Index;
ULONG Index;
for (Index=StartPage; Index<(StartPage+PageCount); Index++)
{
@ -298,11 +298,11 @@ VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 Page
}
}
U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount)
ULONG MmCountFreePagesInLookupTable(PVOID PageLookupTable, ULONG TotalPageCount)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 Index;
U32 FreePageCount;
ULONG Index;
ULONG FreePageCount;
FreePageCount = 0;
for (Index=0; Index<TotalPageCount; Index++)
@ -316,11 +316,11 @@ U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount)
return FreePageCount;
}
U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded)
ULONG MmFindAvailablePagesFromEnd(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 AvailablePagesSoFar;
U32 Index;
ULONG AvailablePagesSoFar;
ULONG Index;
if (LastFreePageHint > TotalPageCount)
{
@ -349,11 +349,11 @@ U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 P
return 0;
}
U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded, U32 LastPage)
ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, ULONG LastPage)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 AvailablePagesSoFar;
U32 Index;
ULONG AvailablePagesSoFar;
ULONG Index;
if (LastPage > TotalPageCount)
{
@ -382,7 +382,7 @@ U32 MmFindAvailablePagesBeforePage(PVOID PageLookupTable, U32 TotalPageCount, U3
return 0;
}
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount)
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG* MapCount)
{
int Index;
int Index2;
@ -406,10 +406,10 @@ VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount)
}
}
VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount)
VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 Index;
ULONG Index;
for (Index=TotalPageCount-1; Index>0; Index--)
{
@ -421,11 +421,11 @@ VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount)
}
}
BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, U32 TotalPageCount, PVOID PageAddress, U32 PageCount)
BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount)
{
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 StartPage;
U32 Index;
ULONG StartPage;
ULONG Index;
StartPage = MmGetPageNumberFromAddress(PageAddress);

View file

@ -27,7 +27,7 @@
#ifdef DEBUG
U32 AllocationCount = 0;
ULONG AllocationCount = 0;
VOID VerifyHeap(VOID);
VOID DumpMemoryAllocMap(VOID);
@ -36,10 +36,10 @@ VOID DecrementAllocationCount(VOID);
VOID MemAllocTest(VOID);
#endif // DEBUG
PVOID MmAllocateMemory(U32 MemorySize)
PVOID MmAllocateMemory(ULONG MemorySize)
{
U32 PagesNeeded;
U32 FirstFreePageFromEnd;
ULONG PagesNeeded;
ULONG FirstFreePageFromEnd;
PVOID MemPointer;
if (MemorySize == 0)
@ -87,10 +87,10 @@ PVOID MmAllocateMemory(U32 MemorySize)
return MemPointer;
}
PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress)
PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress)
{
U32 PagesNeeded;
U32 StartPageNumber;
ULONG PagesNeeded;
ULONG StartPageNumber;
PVOID MemPointer;
if (MemorySize == 0)
@ -139,11 +139,11 @@ PVOID MmAllocateMemoryAtAddress(U32 MemorySize, PVOID DesiredAddress)
return MemPointer;
}
PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress)
PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress)
{
U32 PagesNeeded;
U32 FirstFreePageFromEnd;
U32 DesiredAddressPageNumber;
ULONG PagesNeeded;
ULONG FirstFreePageFromEnd;
ULONG DesiredAddressPageNumber;
PVOID MemPointer;
if (MemorySize == 0)
@ -158,7 +158,7 @@ PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress)
PagesNeeded = ROUND_UP(MemorySize, MM_PAGE_SIZE) / MM_PAGE_SIZE;
// Get the page number for their desired address
DesiredAddressPageNumber = (U32)DesiredAddress / MM_PAGE_SIZE;
DesiredAddressPageNumber = (ULONG)DesiredAddress / MM_PAGE_SIZE;
// If we don't have enough available mem
// then return NULL
@ -196,9 +196,9 @@ PVOID MmAllocateHighestMemoryBelowAddress(U32 MemorySize, PVOID DesiredAddress)
VOID MmFreeMemory(PVOID MemoryPointer)
{
U32 PageNumber;
U32 PageCount;
U32 Idx;
ULONG PageNumber;
ULONG PageCount;
ULONG Idx;
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress;
#ifdef DEBUG
@ -255,9 +255,9 @@ VOID MmFreeMemory(PVOID MemoryPointer)
#ifdef DEBUG
VOID VerifyHeap(VOID)
{
U32 Idx;
U32 Idx2;
U32 Count;
ULONG Idx;
ULONG Idx2;
ULONG Count;
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress;
if (DUMP_MEM_MAP_ON_VERIFY)
@ -315,7 +315,7 @@ VOID VerifyHeap(VOID)
VOID DumpMemoryAllocMap(VOID)
{
U32 Idx;
ULONG Idx;
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress;
DbgPrint((DPRINT_MEMORY, "----------- Memory Allocation Bitmap -----------\n"));
@ -400,7 +400,7 @@ VOID MemAllocTest(VOID)
}
#endif // DEBUG
U32 GetSystemMemorySize(VOID)
ULONG GetSystemMemorySize(VOID)
{
return (TotalPagesInLookupTable * MM_PAGE_SIZE);
}

View file

@ -1,233 +1,728 @@
/*
* FreeLoader
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: Freeloader
* FILE: boot/freeldr/freeldr/multiboot.c
* PURPOSE: ReactOS Loader
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Hartmutt Birr - SMP/PAE Code
*/
#include <freeldr.h>
#include <arch.h>
#include <rtl.h>
#include <fs.h>
#include <multiboot.h>
#include <ui.h>
#include <inifile.h>
#include <mm.h>
#include <internal/i386/ke.h>
unsigned long next_module_load_base = 0;
module_t* pOpenModule = NULL;
#define NDEBUG
#include <debug.h>
/* Base Addres of Kernel in Physical Memory */
#define KERNEL_BASE_PHYS 0x200000
/* Bits to shift to convert a Virtual Address into an Offset in the Page Table */
#define PFN_SHIFT 12
/* Bits to shift to convert a Virtual Address into an Offset in the Page Directory */
#define PDE_SHIFT 20
#define PDE_SHIFT_PAE 18
/* Converts a Relative Address read from the Kernel into a Physical Address */
#define RaToPa(p) \
(ULONG_PTR)((ULONG_PTR)p + KERNEL_BASE_PHYS)
/* Converts a Phsyical Address Pointer into a Page Frame Number */
#define PaPtrToPfn(p) \
(((ULONG_PTR)&p) >> PFN_SHIFT)
/* Converts a Phsyical Address into a Page Frame Number */
#define PaToPfn(p) \
((p) >> PFN_SHIFT)
#define STARTUP_BASE 0xF0000000
#define HYPERSPACE_BASE 0xF0800000
#define APIC_BASE 0xFEC00000
#define KPCR_BASE 0xFF000000
#define LowMemPageTableIndex 0
#define StartupPageTableIndex (STARTUP_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
#define HyperspacePageTableIndex (HYPERSPACE_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
#define KpcrPageTableIndex (KPCR_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
#define ApicPageTableIndex (APIC_BASE >> 20) / sizeof(HARDWARE_PTE_X86)
#define LowMemPageTableIndexPae 0
#define StartupPageTableIndexPae (STARTUP_BASE >> 21)
#define HyperspacePageTableIndexPae (HYPERSPACE_BASE >> 21)
#define KpcrPageTableIndexPae (KPCR_BASE >> 21)
#define ApicPageTableIndexPae (APIC_BASE >> 21)
BOOL MultiBootLoadKernel(FILE *KernelImage)
{
U32* ImageHeaders;
int Idx;
U32 dwHeaderChecksum;
U32 dwFileLoadOffset;
U32 dwDataSize;
U32 dwBssSize;
#define KernelEntryPoint (KernelEntry - KERNEL_BASE_PHYS) + KernelBase
// Allocate 8192 bytes for multiboot header
ImageHeaders = (U32*)MmAllocateMemory(8192);
if (ImageHeaders == NULL)
{
return FALSE;
}
/* Load Address of Next Module */
ULONG_PTR NextModuleBase = 0;
/*
* Load the first 8192 bytes of the kernel image
* so we can search for the multiboot header
*/
if (!FsReadFile(KernelImage, 8192, NULL, ImageHeaders))
{
MmFreeMemory(ImageHeaders);
return FALSE;
}
/* Currently Opened Module */
PFRLDR_MODULE CurrentModule = NULL;
/*
* Now find the multiboot header and copy it
*/
for (Idx=0; Idx<2048; Idx++)
{
// Did we find it?
if (ImageHeaders[Idx] == MULTIBOOT_HEADER_MAGIC)
{
// Yes, copy it and break out of this loop
memcpy(&mb_header, &ImageHeaders[Idx], sizeof(multiboot_header_t));
/* Unrelocated Kernel Base in Virtual Memory */
ULONG_PTR KernelBase;
break;
}
}
/* Wether PAE is to be used or not */
BOOLEAN PaeModeEnabled;
MmFreeMemory(ImageHeaders);
/* Kernel Entrypoint in Physical Memory */
ULONG_PTR KernelEntry;
/*
* If we reached the end of the 8192 bytes without
* finding the multiboot header then return error
*/
if (Idx == 2048)
{
UiMessageBox("No multiboot header found!");
return FALSE;
}
/* Page Directory and Tables for non-PAE Systems */
extern ULONG_PTR startup_pagedirectory;
extern ULONG_PTR lowmem_pagetable;
extern ULONG_PTR kernel_pagetable;
extern ULONG_PTR hyperspace_pagetable;
extern ULONG_PTR _pae_pagedirtable;
extern ULONG_PTR apic_pagetable;
extern ULONG_PTR kpcr_pagetable;
/*printf("multiboot header:\n");
printf("0x%x\n", mb_header.magic);
printf("0x%x\n", mb_header.flags);
printf("0x%x\n", mb_header.checksum);
printf("0x%x\n", mb_header.header_addr);
printf("0x%x\n", mb_header.load_addr);
printf("0x%x\n", mb_header.load_end_addr);
printf("0x%x\n", mb_header.bss_end_addr);
printf("0x%x\n", mb_header.entry_addr);
getch();*/
/* Page Directory and Tables for PAE Systems */
extern ULONG_PTR startup_pagedirectorytable_pae;
extern ULONG_PTR startup_pagedirectory_pae;
extern ULONG_PTR lowmem_pagetable_pae;
extern ULONG_PTR kernel_pagetable_pae;
extern ULONG_PTR hyperspace_pagetable_pae;
extern ULONG_PTR pagedirtable_pae;
extern ULONG_PTR apic_pagetable_pae;
extern ULONG_PTR kpcr_pagetable_pae;
/*
* Calculate the checksum and make sure it matches
*/
dwHeaderChecksum = mb_header.magic;
dwHeaderChecksum += mb_header.flags;
dwHeaderChecksum += mb_header.checksum;
if (dwHeaderChecksum != 0)
{
UiMessageBox("Multiboot header checksum invalid!");
return FALSE;
}
/*
* Get the file offset, this should be 0, and move the file pointer
*/
dwFileLoadOffset = (Idx * sizeof(U32)) - (mb_header.header_addr - mb_header.load_addr);
FsSetFilePointer(KernelImage, dwFileLoadOffset);
/*
* Load the file image
*/
dwDataSize = (mb_header.load_end_addr - mb_header.load_addr);
FsReadFile(KernelImage, dwDataSize, NULL, (void*)mb_header.load_addr);
typedef struct _HARDWARE_PTE_X86 {
ULONG Valid : 1;
ULONG Write : 1;
ULONG Owner : 1;
ULONG WriteThrough : 1;
ULONG CacheDisable : 1;
ULONG Accessed : 1;
ULONG Dirty : 1;
ULONG LargePage : 1;
ULONG Global : 1;
ULONG CopyOnWrite : 1;
ULONG Prototype : 1;
ULONG reserved : 1;
ULONG PageFrameNumber : 20;
} HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
/*
* Initialize bss area
*/
dwBssSize = (mb_header.bss_end_addr - mb_header.load_end_addr);
memset((void*)mb_header.load_end_addr, 0, dwBssSize);
typedef struct _HARDWARE_PTE_X64 {
ULONG Valid : 1;
ULONG Write : 1;
ULONG Owner : 1;
ULONG WriteThrough : 1;
ULONG CacheDisable : 1;
ULONG Accessed : 1;
ULONG Dirty : 1;
ULONG LargePage : 1;
ULONG Global : 1;
ULONG CopyOnWrite : 1;
ULONG Prototype : 1;
ULONG reserved : 1;
ULONG PageFrameNumber : 20;
ULONG reserved2 : 31;
ULONG NoExecute : 1;
} HARDWARE_PTE_X64, *PHARDWARE_PTE_X64;
next_module_load_base = ROUND_UP(mb_header.bss_end_addr, /*PAGE_SIZE*/4096);
typedef struct _PAGE_DIRECTORY_X86 {
HARDWARE_PTE_X86 Pde[1024];
} PAGE_DIRECTORY_x86, *PPAGE_DIRECTORY_X86;
return TRUE;
typedef struct _PAGE_DIRECTORY_X64 {
HARDWARE_PTE_X64 Pde[2048];
} PAGE_DIRECTORY_X64, *PPAGE_DIRECTORY_X64;
typedef struct _PAGE_DIRECTORY_TABLE_X64 {
HARDWARE_PTE_X64 Pde[4];
} PAGE_DIRECTORY_TABLE_X64, *PPAGE_DIRECTORY_TABLE_X64;
/* FUNCTIONS *****************************************************************/
/*++
* FrLdrStartup
* INTERNAL
*
* Prepares the system for loading the Kernel.
*
* Params:
* Magic - Multiboot Magic
*
* Returns:
* None.
*
* Remarks:
* None.
*
*--*/
VOID
STDCALL
FrLdrStartup(ULONG Magic)
{
/* Disable Interrupts */
Ke386DisableInterrupts();
/* Re-initalize EFLAGS */
Ke386EraseFlags();
/* Get Kernel Base and Set MmSystemRangeStart */
FrLdrGetKernelBase();
FrLdrGetPaeMode();
/* Initialize the page directory */
FrLdrSetupPageDirectory();
/* Initialize Paging, Write-Protection and Load NTOSKRNL */
FrLdrSetupPae(Magic);
}
PVOID MultiBootLoadModule(FILE *ModuleImage, char *ModuleName, U32* ModuleSize)
/*++
* FrLdrSetupPae
* INTERNAL
*
* Configures PAE on a MP System, and sets the PDBR if it's supported, or if
* the system is UP.
*
* Params:
* Magic - Multiboot Magic
*
* Returns:
* None.
*
* Remarks:
* None.
*
*--*/
VOID
FASTCALL
FrLdrSetupPae(ULONG Magic)
{
U32 dwModuleSize;
module_t* pModule;
char* ModuleNameString;
char * TempName;
/*
* Get current module data structure and module name string array
*/
pModule = &multiboot_modules[mb_info.mods_count];
do {
TempName = strchr( ModuleName, '\\' );
if( TempName )
ModuleName = TempName + 1;
} while( TempName );
ULONG_PTR PageDirectoryBaseAddress = (ULONG_PTR)&startup_pagedirectory;
ASMCODE PagedJump;
ModuleNameString = multiboot_module_strings[mb_info.mods_count];
dwModuleSize = FsGetFileSize(ModuleImage);
pModule->mod_start = next_module_load_base;
pModule->mod_end = next_module_load_base + dwModuleSize;
strcpy(ModuleNameString, ModuleName);
pModule->string = (unsigned long)ModuleNameString;
/*
* Load the file image
*/
FsReadFile(ModuleImage, dwModuleSize, NULL, (void*)next_module_load_base);
if (PaeModeEnabled)
{
PageDirectoryBaseAddress = (ULONG_PTR)&startup_pagedirectorytable_pae;
/* Enable PAE */
Ke386SetCr4(Ke386GetCr4() | X86_CR4_PAE);
}
/* Set the PDBR */
Ke386SetPageTableDirectory(PageDirectoryBaseAddress);
/* Enable Paging and Write Protect*/
Ke386SetCr0(Ke386GetCr0() | X86_CR0_PG | X86_CR0_WP);
/* Jump to Kernel */
PagedJump = (ASMCODE)KernelEntryPoint;
PagedJump(Magic, &LoaderBlock);
}
next_module_load_base = ROUND_UP(pModule->mod_end, /*PAGE_SIZE*/4096);
mb_info.mods_count++;
if (ModuleSize != NULL)
*ModuleSize = dwModuleSize;
return((PVOID)pModule->mod_start);
/*++
* FrLdrGetKernelBase
* INTERNAL
*
* Gets the Kernel Base to use.
*
* Params:
*
* Returns:
* None.
*
* Remarks:
* Sets both the FreeLdr internal variable as well as the one which
* will be used by the Kernel.
*
*--*/
VOID
FASTCALL
FrLdrGetKernelBase(VOID)
{
PCHAR p1;
PCHAR p2;
/* Read Command Line */
for(p1 = (PCHAR)&LoaderBlock.CommandLine; *p1 && (p2 = strchr(p1, '/')); p2++) {
/* Find "/3GB" */
if (!strnicmp(p2, "3GB", 3)) {
/* Make sure there's nothing following it */
if (p2[3] == ' ' || p2[3] == 0) {
/* Use 3GB */
KernelBase = 0xC0000000;
} else {
/* Use 2GB */
KernelBase = 0x80000000;
}
}
}
/* Set KernelBase */
LoaderBlock.KernelBase = KernelBase;
}
#if 0
int GetBootPartition(char *OperatingSystemName)
/*++
* FrLdrGetPaeMode
* INTERNAL
*
* Determines whether PAE mode shoudl be enabled or not.
*
* Params:
* None.
*
* Returns:
* None.
*
* Remarks:
* None.
*
*--*/
VOID
FASTCALL
FrLdrGetPaeMode(VOID)
{
int BootPartitionNumber = -1;
char value[1024];
U32 SectionId;
/* FIXME: Read command line */
PaeModeEnabled = FALSE;
if (IniOpenSection(OperatingSystemName, &SectionId))
{
if (IniReadSettingByName(SectionId, "BootPartition", value, 1024))
{
BootPartitionNumber = atoi(value);
}
}
return BootPartitionNumber;
}
#endif
PVOID MultiBootCreateModule(char *ModuleName)
{
module_t* pModule;
char* ModuleNameString;
/*
* Get current module data structure and module name string array
*/
pModule = &multiboot_modules[mb_info.mods_count];
ModuleNameString = multiboot_module_strings[mb_info.mods_count];
pModule->mod_start = next_module_load_base;
pModule->mod_end = -1;
strcpy(ModuleNameString, ModuleName);
pModule->string = (unsigned long)ModuleNameString;
pOpenModule = pModule;
return((PVOID)pModule->mod_start);
if (PaeModeEnabled)
{
}
}
BOOL MultiBootCloseModule(PVOID ModuleBase, U32 dwModuleSize)
/*++
* FrLdrSetupPageDirectory
* INTERNAL
*
* Sets up the ReactOS Startup Page Directory.
*
* Params:
* None.
*
* Returns:
* None.
*
* Remarks:
* We are setting PDEs, but using the equvivalent (for our purpose) PTE structure.
* As such, please note that PageFrameNumber == PageEntryNumber.
*
*--*/
VOID
FASTCALL
FrLdrSetupPageDirectory(VOID)
{
module_t* pModule;
PPAGE_DIRECTORY_X86 PageDir;
PPAGE_DIRECTORY_TABLE_X64 PageDirTablePae;
PPAGE_DIRECTORY_X64 PageDirPae;
ULONG KernelPageTableIndex;
ULONG i;
if ((pOpenModule != NULL) &&
((module_t*)ModuleBase == (module_t*)pOpenModule->mod_start) &&
(pOpenModule->mod_end == -1))
{
pModule = pOpenModule;
pModule->mod_end = pModule->mod_start + dwModuleSize;
if (PaeModeEnabled) {
/* Get the Kernel Table Index */
KernelPageTableIndex = (KernelBase >> 21);
next_module_load_base = ROUND_UP(pModule->mod_end, /*PAGE_SIZE*/4096);
mb_info.mods_count++;
pOpenModule = NULL;
/* Get the Startup Page Directory Table */
PageDirTablePae = (PPAGE_DIRECTORY_TABLE_X64)&startup_pagedirectorytable_pae;
return(TRUE);
}
/* Get the Startup Page Directory */
PageDirPae = (PPAGE_DIRECTORY_X64)&startup_pagedirectory_pae;
return(FALSE);
/* Set the Startup page directory table */
for (i = 0; i < 4; i++)
{
PageDirTablePae->Pde[i].Valid = 1;
PageDirTablePae->Pde[i].PageFrameNumber = PaPtrToPfn(startup_pagedirectory_pae) + i;
}
/* Set up the Low Memory PDE */
for (i = 0; i < 2; i++)
{
PageDirPae->Pde[LowMemPageTableIndexPae + i].Valid = 1;
PageDirPae->Pde[LowMemPageTableIndexPae + i].Write = 1;
PageDirPae->Pde[LowMemPageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(lowmem_pagetable_pae) + i;
}
/* Set up the Kernel PDEs */
for (i = 0; i < 3; i++)
{
PageDirPae->Pde[KernelPageTableIndex + i].Valid = 1;
PageDirPae->Pde[KernelPageTableIndex + i].Write = 1;
PageDirPae->Pde[KernelPageTableIndex + i].PageFrameNumber = PaPtrToPfn(kernel_pagetable_pae) + i;
}
/* Set up the Startup PDE */
for (i = 0; i < 4; i++)
{
PageDirPae->Pde[StartupPageTableIndexPae + i].Valid = 1;
PageDirPae->Pde[StartupPageTableIndexPae + i].Write = 1;
PageDirPae->Pde[StartupPageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(startup_pagedirectory_pae) + i;
}
/* Set up the Hyperspace PDE */
for (i = 0; i < 2; i++)
{
PageDirPae->Pde[HyperspacePageTableIndexPae + i].Valid = 1;
PageDirPae->Pde[HyperspacePageTableIndexPae + i].Write = 1;
PageDirPae->Pde[HyperspacePageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(hyperspace_pagetable_pae) + i;
}
/* Set up the Apic PDE */
for (i = 0; i < 2; i++)
{
PageDirPae->Pde[ApicPageTableIndexPae + i].Valid = 1;
PageDirPae->Pde[ApicPageTableIndexPae + i].Write = 1;
PageDirPae->Pde[ApicPageTableIndexPae + i].PageFrameNumber = PaPtrToPfn(apic_pagetable_pae) + i;
}
/* Set up the KPCR PDE */
PageDirPae->Pde[KpcrPageTableIndexPae].Valid = 1;
PageDirPae->Pde[KpcrPageTableIndexPae].Write = 1;
PageDirPae->Pde[KpcrPageTableIndexPae].PageFrameNumber = PaPtrToPfn(kpcr_pagetable_pae);
/* Set up Low Memory PTEs */
PageDirPae = (PPAGE_DIRECTORY_X64)&lowmem_pagetable_pae;
for (i=0; i<1024; i++) {
PageDirPae->Pde[i].Valid = 1;
PageDirPae->Pde[i].Write = 1;
PageDirPae->Pde[i].Owner = 1;
PageDirPae->Pde[i].PageFrameNumber = i;
}
/* Set up Kernel PTEs */
PageDirPae = (PPAGE_DIRECTORY_X64)&kernel_pagetable_pae;
for (i=0; i<1536; i++) {
PageDirPae->Pde[i].Valid = 1;
PageDirPae->Pde[i].Write = 1;
PageDirPae->Pde[i].PageFrameNumber = PaToPfn(KERNEL_BASE_PHYS) + i;
}
/* Set up APIC PTEs */
PageDirPae = (PPAGE_DIRECTORY_X64)&apic_pagetable_pae;
PageDirPae->Pde[0].Valid = 1;
PageDirPae->Pde[0].Write = 1;
PageDirPae->Pde[0].CacheDisable = 1;
PageDirPae->Pde[0].WriteThrough = 1;
PageDirPae->Pde[0].PageFrameNumber = PaToPfn(APIC_BASE);
PageDirPae->Pde[0x200].Valid = 1;
PageDirPae->Pde[0x200].Write = 1;
PageDirPae->Pde[0x200].CacheDisable = 1;
PageDirPae->Pde[0x200].WriteThrough = 1;
PageDirPae->Pde[0x200].PageFrameNumber = PaToPfn(APIC_BASE + KERNEL_BASE_PHYS);
/* Set up KPCR PTEs */
PageDirPae = (PPAGE_DIRECTORY_X64)&kpcr_pagetable_pae;
PageDirPae->Pde[0].Valid = 1;
PageDirPae->Pde[0].Write = 1;
PageDirPae->Pde[0].PageFrameNumber = 1;
} else {
/* Get the Kernel Table Index */
KernelPageTableIndex = (KernelBase >> PDE_SHIFT) / sizeof(HARDWARE_PTE_X86);
/* Get the Startup Page Directory */
PageDir = (PPAGE_DIRECTORY_X86)&startup_pagedirectory;
/* Set up the Low Memory PDE */
PageDir->Pde[LowMemPageTableIndex].Valid = 1;
PageDir->Pde[LowMemPageTableIndex].Write = 1;
PageDir->Pde[LowMemPageTableIndex].PageFrameNumber = PaPtrToPfn(lowmem_pagetable);
/* Set up the Kernel PDEs */
PageDir->Pde[KernelPageTableIndex].Valid = 1;
PageDir->Pde[KernelPageTableIndex].Write = 1;
PageDir->Pde[KernelPageTableIndex].PageFrameNumber = PaPtrToPfn(kernel_pagetable);
PageDir->Pde[KernelPageTableIndex + 1].Valid = 1;
PageDir->Pde[KernelPageTableIndex + 1].Write = 1;
PageDir->Pde[KernelPageTableIndex + 1].PageFrameNumber = PaPtrToPfn(kernel_pagetable + 4096);
/* Set up the Startup PDE */
PageDir->Pde[StartupPageTableIndex].Valid = 1;
PageDir->Pde[StartupPageTableIndex].Write = 1;
PageDir->Pde[StartupPageTableIndex].PageFrameNumber = PaPtrToPfn(startup_pagedirectory);
/* Set up the Hyperspace PDE */
PageDir->Pde[HyperspacePageTableIndex].Valid = 1;
PageDir->Pde[HyperspacePageTableIndex].Write = 1;
PageDir->Pde[HyperspacePageTableIndex].PageFrameNumber = PaPtrToPfn(hyperspace_pagetable);
/* Set up the Apic PDE */
PageDir->Pde[ApicPageTableIndex].Valid = 1;
PageDir->Pde[ApicPageTableIndex].Write = 1;
PageDir->Pde[ApicPageTableIndex].PageFrameNumber = PaPtrToPfn(apic_pagetable);
/* Set up the KPCR PDE */
PageDir->Pde[KpcrPageTableIndex].Valid = 1;
PageDir->Pde[KpcrPageTableIndex].Write = 1;
PageDir->Pde[KpcrPageTableIndex].PageFrameNumber = PaPtrToPfn(kpcr_pagetable);
/* Set up Low Memory PTEs */
PageDir = (PPAGE_DIRECTORY_X86)&lowmem_pagetable;
for (i=0; i<1024; i++) {
PageDir->Pde[i].Valid = 1;
PageDir->Pde[i].Write = 1;
PageDir->Pde[i].Owner = 1;
PageDir->Pde[i].PageFrameNumber = PaToPfn(i * PAGE_SIZE);
}
/* Set up Kernel PTEs */
PageDir = (PPAGE_DIRECTORY_X86)&kernel_pagetable;
for (i=0; i<1536; i++) {
PageDir->Pde[i].Valid = 1;
PageDir->Pde[i].Write = 1;
PageDir->Pde[i].PageFrameNumber = PaToPfn(KERNEL_BASE_PHYS + i * PAGE_SIZE);
}
/* Set up APIC PTEs */
PageDir = (PPAGE_DIRECTORY_X86)&apic_pagetable;
PageDir->Pde[0].Valid = 1;
PageDir->Pde[0].Write = 1;
PageDir->Pde[0].CacheDisable = 1;
PageDir->Pde[0].WriteThrough = 1;
PageDir->Pde[0].PageFrameNumber = PaToPfn(APIC_BASE);
PageDir->Pde[0x200].Valid = 1;
PageDir->Pde[0x200].Write = 1;
PageDir->Pde[0x200].CacheDisable = 1;
PageDir->Pde[0x200].WriteThrough = 1;
PageDir->Pde[0x200].PageFrameNumber = PaToPfn(APIC_BASE + KERNEL_BASE_PHYS);
/* Set up KPCR PTEs */
PageDir = (PPAGE_DIRECTORY_X86)&kpcr_pagetable;
PageDir->Pde[0].Valid = 1;
PageDir->Pde[0].Write = 1;
PageDir->Pde[0].PageFrameNumber = 1;
}
return;
}
/*++
* FrLdrMapKernel
* INTERNAL
*
* Maps the Kernel into memory, does PE Section Mapping, initalizes the
* uninitialized data sections, and relocates the image.
*
* Params:
* KernelImage - FILE Structure representing the ntoskrnl image file.
*
* Returns:
* TRUE if the Kernel was mapped.
*
* Remarks:
* None.
*
*--*/
BOOL
STDCALL
FrLdrMapKernel(FILE *KernelImage)
{
PIMAGE_DOS_HEADER ImageHeader;
PIMAGE_NT_HEADERS NtHeader;
PIMAGE_SECTION_HEADER Section;
ULONG SectionCount;
ULONG ImageSize;
ULONG_PTR SourceSection;
ULONG_PTR TargetSection;
ULONG SectionSize;
LONG i;
/* Allocate 1024 bytes for PE Header */
ImageHeader = (PIMAGE_DOS_HEADER)MmAllocateMemory(1024);
/* Make sure it was succesful */
if (ImageHeader == NULL) {
return FALSE;
}
/* Load the first 1024 bytes of the kernel image so we can read the PE header */
if (!FsReadFile(KernelImage, 1024, NULL, ImageHeader)) {
/* Fail if we couldn't read */
MmFreeMemory(ImageHeader);
return FALSE;
}
/* Now read the MZ header to get the offset to the PE Header */
NtHeader = (PIMAGE_NT_HEADERS)((PCHAR)ImageHeader + ImageHeader->e_lfanew);
/* Save the Image Base */
KernelBase = NtHeader->OptionalHeader.ImageBase;
/* Save Entrypoint */
KernelEntry = RaToPa(NtHeader->OptionalHeader.AddressOfEntryPoint);
/* Save the Image Size */
ImageSize = NtHeader->OptionalHeader.SizeOfImage;
/* Free the Header */
MmFreeMemory(ImageHeader);
/* Set the file pointer to zero */
FsSetFilePointer(KernelImage, 0);
/* Load the file image */
FsReadFile(KernelImage, ImageSize, NULL, (PVOID)KERNEL_BASE_PHYS);
/* Reload the NT Header */
NtHeader = (PIMAGE_NT_HEADERS)((PCHAR)KERNEL_BASE_PHYS + ImageHeader->e_lfanew);
/* Load the first section */
Section = IMAGE_FIRST_SECTION(NtHeader);
SectionCount = NtHeader->FileHeader.NumberOfSections - 1;
/* Now go to the last section */
Section += SectionCount;
/* Walk each section backwards */
for (i=SectionCount; i >= 0; i--, Section--) {
/* Get the disk location and the memory location, and the size */
SourceSection = RaToPa(Section->PointerToRawData);
TargetSection = RaToPa(Section->VirtualAddress);
SectionSize = Section->SizeOfRawData;
/* If the section is already mapped correctly, go to the next */
if (SourceSection == TargetSection) continue;
/* Load it into memory */
memmove((PVOID)TargetSection, (PVOID)SourceSection, SectionSize);
/* Check for unitilizated data */
if (Section->SizeOfRawData < Section->Misc.VirtualSize) {
/* Zero it out */
memset((PVOID)RaToPa(Section->VirtualAddress + Section->SizeOfRawData),
0,
Section->Misc.VirtualSize - Section->SizeOfRawData);
}
}
/* Now relocate the file */
/* FIXME: ADD RELOC CODE */
/* Increase the next Load Base */
NextModuleBase = ROUND_UP(KERNEL_BASE_PHYS + ImageSize, PAGE_SIZE);
/* Return Success */
return TRUE;
}
ULONG_PTR
STDCALL
FrLdrLoadModule(FILE *ModuleImage,
LPSTR ModuleName,
PULONG ModuleSize)
{
ULONG LocalModuleSize;
PFRLDR_MODULE ModuleData;
LPSTR NameBuffer;
LPSTR TempName;
/* Get current module data structure and module name string array */
ModuleData = &multiboot_modules[LoaderBlock.ModsCount];
/* Get only the Module Name */
do {
TempName = strchr(ModuleName, '\\');
if(TempName) {
ModuleName = TempName + 1;
}
} while(TempName);
NameBuffer = multiboot_module_strings[LoaderBlock.ModsCount];
/* Get Module Size */
LocalModuleSize = FsGetFileSize(ModuleImage);
/* Fill out Module Data Structure */
ModuleData->ModuleStart = NextModuleBase;
ModuleData->ModuleEnd = NextModuleBase + LocalModuleSize;
/* Save name */
strcpy(NameBuffer, ModuleName);
ModuleData->ModuleName = NameBuffer;
/* Load the file image */
FsReadFile(ModuleImage, LocalModuleSize, NULL, (PVOID)NextModuleBase);
/* Move to next memory block and increase Module Count */
NextModuleBase = ROUND_UP(ModuleData->ModuleEnd, PAGE_SIZE);
LoaderBlock.ModsCount++;
/* Return Module Size if required */
if (ModuleSize != NULL) {
*ModuleSize = LocalModuleSize;
}
return(ModuleData->ModuleStart);
}
ULONG_PTR
STDCALL
FrLdrCreateModule(LPSTR ModuleName)
{
PFRLDR_MODULE ModuleData;
LPSTR NameBuffer;
/* Get current module data structure and module name string array */
ModuleData = &multiboot_modules[LoaderBlock.ModsCount];
NameBuffer = multiboot_module_strings[LoaderBlock.ModsCount];
/* Set up the structure */
ModuleData->ModuleStart = NextModuleBase;
ModuleData->ModuleEnd = -1;
/* Copy the name */
strcpy(NameBuffer, ModuleName);
ModuleData->ModuleName = NameBuffer;
/* Set the current Module */
CurrentModule = ModuleData;
/* Return Module Base Address */
return(ModuleData->ModuleStart);
}
BOOL
STDCALL
FrLdrCloseModule(ULONG_PTR ModuleBase,
ULONG ModuleSize)
{
PFRLDR_MODULE ModuleData = CurrentModule;
/* Make sure a module is opened */
if (ModuleData) {
/* Make sure this is the right module and that it hasn't been closed */
if ((ModuleBase == ModuleData->ModuleStart) && (ModuleData->ModuleEnd == -1)) {
/* Close the Module */
ModuleData->ModuleEnd = ModuleData->ModuleStart + ModuleSize;
/* Set the next Module Base and increase the number of modules */
NextModuleBase = ROUND_UP(ModuleData->ModuleEnd, PAGE_SIZE);
LoaderBlock.ModsCount++;
/* Close the currently opened module */
CurrentModule = NULL;
/* Success */
return(TRUE);
}
}
/* Failure path */
return(FALSE);
}

View file

@ -67,11 +67,11 @@ enum OptionMenuItems
REBOOT = 11,
};
U32 OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
ULONG OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
VOID DoOptionsMenu(VOID)
{
U32 SelectedMenuItem;
ULONG SelectedMenuItem;
if (!UiDisplayMenu(OptionsMenuList, OptionsMenuItemCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
{

View file

@ -24,16 +24,16 @@
#include <mm.h>
#include <ui.h>
BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32* OperatingSystemCountPointer)
BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG* OperatingSystemCountPointer)
{
U32 Idx;
U32 CurrentOperatingSystemIndex;
ULONG Idx;
ULONG CurrentOperatingSystemIndex;
UCHAR SettingName[260];
UCHAR SettingValue[260];
U32 OperatingSystemCount;
U32 SectionId;
U32 OperatingSystemSectionId;
U32 SectionSettingCount;
ULONG OperatingSystemCount;
ULONG SectionId;
ULONG OperatingSystemSectionId;
ULONG SectionSettingCount;
PUCHAR *OperatingSystemSectionNames;
PUCHAR *OperatingSystemDisplayNames;
@ -85,13 +85,13 @@ BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNames
return TRUE;
}
U32 CountOperatingSystems(U32 SectionId)
ULONG CountOperatingSystems(ULONG SectionId)
{
U32 Idx;
ULONG Idx;
UCHAR SettingName[260];
UCHAR SettingValue[260];
U32 OperatingSystemCount = 0;
U32 SectionSettingCount;
ULONG OperatingSystemCount = 0;
ULONG SectionSettingCount;
//
// Loop through and count the operating systems
@ -115,9 +115,9 @@ U32 CountOperatingSystems(U32 SectionId)
return OperatingSystemCount;
}
BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, U32 OperatingSystemCount)
BOOL AllocateListMemory(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, ULONG OperatingSystemCount)
{
U32 Idx;
ULONG Idx;
PUCHAR *OperatingSystemSectionNames = NULL;
PUCHAR *OperatingSystemDisplayNames = NULL;

View file

@ -23,7 +23,7 @@
#include <rtl.h>
BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPartition)
BOOL DissectArcPath(char *ArcPath, char *BootPath, ULONG* BootDrive, ULONG* BootPartition)
{
char *p;
@ -73,7 +73,7 @@ BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPart
return TRUE;
}
void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partition)
void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, ULONG Disk, ULONG Partition)
{
char tmp[50];
@ -109,10 +109,10 @@ void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partiti
}
}
U32 ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath)
ULONG ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath)
{
char * p;
U32 DriveNumber = 0;
ULONG DriveNumber = 0;
if (strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
return 0;

View file

@ -45,119 +45,119 @@
/* BLOCK_OFFSET = offset in file after header block */
typedef U32 BLOCK_OFFSET, *PBLOCK_OFFSET;
typedef ULONG BLOCK_OFFSET, *PBLOCK_OFFSET;
/* header for registry hive file : */
typedef struct _HIVE_HEADER
{
/* Hive identifier "regf" (0x66676572) */
U32 BlockId;
ULONG BlockId;
/* Update counter */
U32 UpdateCounter1;
ULONG UpdateCounter1;
/* Update counter */
U32 UpdateCounter2;
ULONG UpdateCounter2;
/* When this hive file was last modified */
U64 DateModified; /* FILETIME */
ULONGLONG DateModified; /* FILETIME */
/* Registry format version ? (1?) */
U32 Unused3;
ULONG Unused3;
/* Registry format version ? (3?) */
U32 Unused4;
ULONG Unused4;
/* Registry format version ? (0?) */
U32 Unused5;
ULONG Unused5;
/* Registry format version ? (1?) */
U32 Unused6;
ULONG Unused6;
/* Offset into file from the byte after the end of the base block.
If the hive is volatile, this is the actual pointer to the KEY_CELL */
BLOCK_OFFSET RootKeyOffset;
/* Size of each hive block ? */
U32 BlockSize;
ULONG BlockSize;
/* (1?) */
U32 Unused7;
ULONG Unused7;
/* Name of hive file */
WCHAR FileName[64];
/* ? */
U32 Unused8[83];
ULONG Unused8[83];
/* Checksum of first 0x200 bytes */
U32 Checksum;
ULONG Checksum;
} __attribute__((packed)) HIVE_HEADER, *PHIVE_HEADER;
typedef struct _BIN_HEADER
{
/* Bin identifier "hbin" (0x6E696268) */
U32 HeaderId;
ULONG HeaderId;
/* Bin offset */
BLOCK_OFFSET BinOffset;
/* Size in bytes, multiple of the block size (4KB) */
U32 BinSize;
ULONG BinSize;
/* ? */
U32 Unused1;
ULONG Unused1;
/* When this bin was last modified */
U64 DateModified; /* FILETIME */
ULONGLONG DateModified; /* FILETIME */
/* ? */
U32 Unused2;
ULONG Unused2;
} __attribute__((packed)) HBIN, *PHBIN;
typedef struct _CELL_HEADER
{
/* <0 if used, >0 if free */
S32 CellSize;
LONG CellSize;
} __attribute__((packed)) CELL_HEADER, *PCELL_HEADER;
typedef struct _KEY_CELL
{
/* Size of this cell */
S32 CellSize;
LONG CellSize;
/* Key cell identifier "kn" (0x6b6e) */
U16 Id;
USHORT Id;
/* ? */
U16 Type;
USHORT Type;
/* Time of last flush */
U64 LastWriteTime; /* FILETIME */
ULONGLONG LastWriteTime; /* FILETIME */
/* ? */
U32 UnUsed1;
ULONG UnUsed1;
/* Block offset of parent key cell */
BLOCK_OFFSET ParentKeyOffset;
/* Count of sub keys for the key in this key cell */
U32 NumberOfSubKeys;
ULONG NumberOfSubKeys;
/* ? */
U32 UnUsed2;
ULONG UnUsed2;
/* Block offset of has table for FIXME: subkeys/values? */
BLOCK_OFFSET HashTableOffset;
/* ? */
U32 UnUsed3;
ULONG UnUsed3;
/* Count of values contained in this key cell */
U32 NumberOfValues;
ULONG NumberOfValues;
/* Block offset of VALUE_LIST_CELL */
BLOCK_OFFSET ValueListOffset;
@ -169,16 +169,16 @@ typedef struct _KEY_CELL
BLOCK_OFFSET ClassNameOffset;
/* ? */
U32 Unused4[5];
ULONG Unused4[5];
/* Size in bytes of key name */
U16 NameSize;
USHORT NameSize;
/* Size of class name in bytes */
U16 ClassSize;
USHORT ClassSize;
/* Name of key (not zero terminated) */
U8 Name[0];
UCHAR Name[0];
} __attribute__((packed)) KEY_CELL, *PKEY_CELL;
@ -193,36 +193,36 @@ typedef struct _KEY_CELL
typedef struct _HASH_RECORD
{
BLOCK_OFFSET KeyOffset;
U32 HashValue;
ULONG HashValue;
} __attribute__((packed)) HASH_RECORD, *PHASH_RECORD;
typedef struct _HASH_TABLE_CELL
{
S32 CellSize;
U16 Id;
U16 HashTableSize;
LONG CellSize;
USHORT Id;
USHORT HashTableSize;
HASH_RECORD Table[0];
} __attribute__((packed)) HASH_TABLE_CELL, *PHASH_TABLE_CELL;
typedef struct _VALUE_LIST_CELL
{
S32 CellSize;
LONG CellSize;
BLOCK_OFFSET ValueOffset[0];
} __attribute__((packed)) VALUE_LIST_CELL, *PVALUE_LIST_CELL;
typedef struct _VALUE_CELL
{
S32 CellSize;
U16 Id; // "kv"
U16 NameSize; // length of Name
U32 DataSize; // length of datas in the cell pointed by DataOffset
LONG CellSize;
USHORT Id; // "kv"
USHORT NameSize; // length of Name
ULONG DataSize; // length of datas in the cell pointed by DataOffset
BLOCK_OFFSET DataOffset;// datas are here if high bit of DataSize is set
U32 DataType;
U16 Flags;
U16 Unused1;
ULONG DataType;
USHORT Flags;
USHORT Unused1;
UCHAR Name[0]; /* warning : not zero terminated */
} __attribute__((packed)) VALUE_CELL, *PVALUE_CELL;
@ -236,26 +236,26 @@ typedef struct _VALUE_CELL
typedef struct _DATA_CELL
{
S32 CellSize;
LONG CellSize;
UCHAR Data[0];
} __attribute__((packed)) DATA_CELL, *PDATA_CELL;
typedef struct _REGISTRY_HIVE
{
U32 FileSize;
ULONG FileSize;
PHIVE_HEADER HiveHeader;
U32 BlockListSize;
ULONG BlockListSize;
PHBIN *BlockList;
U32 FreeListSize;
U32 FreeListMax;
ULONG FreeListSize;
ULONG FreeListMax;
PCELL_HEADER *FreeList;
BLOCK_OFFSET *FreeListOffset;
} REGISTRY_HIVE, *PREGISTRY_HIVE;
static PVOID MbBase = NULL;
static U32 MbSize = 0;
static ULONG MbSize = 0;
/* FUNCTIONS ****************************************************************/
@ -268,13 +268,13 @@ InitMbMemory (PVOID ChunkBase)
static PVOID
AllocateMbMemory (U32 MemSize)
AllocateMbMemory (ULONG MemSize)
{
PVOID CurBase;
CurBase = MbBase;
MbBase = (PVOID)((U32)MbBase + MemSize);
MbBase = (PVOID)((ULONG)MbBase + MemSize);
MbSize += MemSize;
return CurBase;
@ -286,7 +286,7 @@ FreeMbMemory (VOID)
MbSize = 0;
}
static U32
static ULONG
GetMbAllocatedSize (VOID)
{
return MbSize;
@ -329,8 +329,8 @@ static VOID
CmiCreateDefaultRootKeyCell (PKEY_CELL RootKeyCell, PCHAR KeyName)
{
PCHAR BaseKeyName;
U32 NameSize;
U32 CellSize;
ULONG NameSize;
ULONG CellSize;
assert (RootKeyCell);
@ -428,12 +428,12 @@ CmiCreateHive (PCHAR KeyName)
BinCell->BinOffset = 0;
/* Init root key cell */
RootKeyCell = (PKEY_CELL)((U32)BinCell + REG_HBIN_DATA_OFFSET);
RootKeyCell = (PKEY_CELL)((ULONG)BinCell + REG_HBIN_DATA_OFFSET);
CmiCreateDefaultRootKeyCell(RootKeyCell, KeyName);
Hive->HiveHeader->RootKeyOffset = REG_HBIN_DATA_OFFSET;
/* Init free cell */
FreeCell = (PCELL_HEADER)((U32)RootKeyCell - RootKeyCell->CellSize);
FreeCell = (PCELL_HEADER)((ULONG)RootKeyCell - RootKeyCell->CellSize);
FreeCell->CellSize = REG_BLOCK_SIZE - (REG_HBIN_DATA_OFFSET - RootKeyCell->CellSize);
Hive->FreeList[0] = FreeCell;
@ -463,9 +463,9 @@ static PHBIN
CmiGetBin (PREGISTRY_HIVE Hive,
BLOCK_OFFSET BlockOffset)
{
U32 BlockIndex;
ULONG BlockIndex;
if (BlockOffset == (U32) -1)
if (BlockOffset == (ULONG) -1)
return NULL;
BlockIndex = BlockOffset / REG_BLOCK_SIZE;
@ -483,10 +483,10 @@ CmiMergeFree(PREGISTRY_HIVE RegistryHive,
{
BLOCK_OFFSET BlockOffset;
BLOCK_OFFSET BinOffset;
U32 BlockSize;
U32 BinSize;
ULONG BlockSize;
ULONG BinSize;
PHBIN Bin;
U32 i;
ULONG i;
DbgPrint((DPRINT_REGISTRY, "CmiMergeFree(Block %lx Offset %lx Size %lx) called\n",
FreeBlock, FreeOffset, FreeBlock->CellSize));
@ -574,9 +574,9 @@ CmiAddFree(PREGISTRY_HIVE RegistryHive,
{
PCELL_HEADER *tmpList;
BLOCK_OFFSET *tmpListOffset;
S32 minInd;
S32 maxInd;
S32 medInd;
LONG minInd;
LONG maxInd;
LONG medInd;
assert(RegistryHive);
assert(FreeBlock);
@ -675,15 +675,15 @@ CmiAddFree(PREGISTRY_HIVE RegistryHive,
static BOOL
CmiAddBin(PREGISTRY_HIVE RegistryHive,
U32 BlockCount,
ULONG BlockCount,
PVOID *NewBlock,
PBLOCK_OFFSET NewBlockOffset)
{
PCELL_HEADER tmpBlock;
PHBIN *BlockList;
PHBIN tmpBin;
U32 BinSize;
U32 i;
ULONG BinSize;
ULONG i;
BinSize = BlockCount * REG_BLOCK_SIZE;
tmpBin = AllocateMbMemory (BinSize);
@ -722,7 +722,7 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
RegistryHive->BlockListSize += BlockCount;
/* Initialize a free block in this heap : */
tmpBlock = (PCELL_HEADER)((U32) tmpBin + REG_HBIN_DATA_OFFSET);
tmpBlock = (PCELL_HEADER)((ULONG) tmpBin + REG_HBIN_DATA_OFFSET);
tmpBlock->CellSize = (REG_BLOCK_SIZE - REG_HBIN_DATA_OFFSET);
*NewBlock = (PVOID) tmpBlock;
@ -736,12 +736,12 @@ CmiAddBin(PREGISTRY_HIVE RegistryHive,
static BOOL
CmiAllocateCell (PREGISTRY_HIVE RegistryHive,
S32 CellSize,
LONG CellSize,
PVOID *Block,
PBLOCK_OFFSET pBlockOffset)
{
PCELL_HEADER NewBlock;
U32 i;
ULONG i;
*Block = NULL;
@ -790,7 +790,7 @@ CmiAllocateCell (PREGISTRY_HIVE RegistryHive,
/* Split the block in two parts */
if (NewBlock->CellSize > CellSize)
{
NewBlock = (PCELL_HEADER) ((U32)NewBlock + CellSize);
NewBlock = (PCELL_HEADER) ((ULONG)NewBlock + CellSize);
NewBlock->CellSize = ((PCELL_HEADER) (*Block))->CellSize - CellSize;
CmiAddFree (RegistryHive,
NewBlock,
@ -814,9 +814,9 @@ CmiGetCell (PREGISTRY_HIVE Hive,
BLOCK_OFFSET BlockOffset)
{
PHBIN Bin;
U32 BlockIndex;
ULONG BlockIndex;
if (BlockOffset == (U32) -1)
if (BlockOffset == (ULONG) -1)
return NULL;
BlockIndex = BlockOffset / REG_BLOCK_SIZE;
@ -827,17 +827,17 @@ CmiGetCell (PREGISTRY_HIVE Hive,
if (Bin == NULL)
return NULL;
return (PVOID)((U32)Bin + (BlockOffset - Bin->BinOffset));
return (PVOID)((ULONG)Bin + (BlockOffset - Bin->BinOffset));
}
static BOOL
CmiAllocateHashTableCell (PREGISTRY_HIVE Hive,
PBLOCK_OFFSET HBOffset,
U32 SubKeyCount)
ULONG SubKeyCount)
{
PHASH_TABLE_CELL HashCell;
U32 NewHashSize;
ULONG NewHashSize;
BOOL Status;
NewHashSize = sizeof(HASH_TABLE_CELL) +
@ -866,7 +866,7 @@ CmiAddKeyToParentHashTable (PREGISTRY_HIVE Hive,
{
PHASH_TABLE_CELL HashBlock;
PKEY_CELL ParentKeyCell;
U32 i;
ULONG i;
ParentKeyCell = CmiGetCell (Hive, ParentKeyOffset);
if (ParentKeyCell == NULL)
@ -902,10 +902,10 @@ CmiAddKeyToParentHashTable (PREGISTRY_HIVE Hive,
static BOOL
CmiAllocateValueListCell (PREGISTRY_HIVE Hive,
PBLOCK_OFFSET ValueListOffset,
U32 ValueCount)
ULONG ValueCount)
{
PVALUE_LIST_CELL ValueListCell;
U32 ValueListSize;
ULONG ValueListSize;
BOOL Status;
ValueListSize = sizeof(VALUE_LIST_CELL) +
@ -931,7 +931,7 @@ CmiAllocateValueCell(PREGISTRY_HIVE Hive,
PCHAR ValueName)
{
PVALUE_CELL NewValueCell;
U32 NameSize;
ULONG NameSize;
BOOL Status;
NameSize = (ValueName == NULL) ? 0 : strlen (ValueName);
@ -996,9 +996,9 @@ CmiAddValueToKeyValueList(PREGISTRY_HIVE Hive,
static VOID
memexpand (PWCHAR Dst,
PCHAR Src,
U32 Length)
ULONG Length)
{
U32 i;
ULONG i;
for (i = 0; i < Length; i++)
Dst[i] = (WCHAR)Src[i];
@ -1008,16 +1008,16 @@ memexpand (PWCHAR Dst,
static BOOL
CmiExportValue (PREGISTRY_HIVE Hive,
BLOCK_OFFSET KeyCellOffset,
HKEY Key,
FRLDRHKEY Key,
PVALUE Value)
{
BLOCK_OFFSET ValueCellOffset;
BLOCK_OFFSET DataCellOffset;
PVALUE_CELL ValueCell;
PDATA_CELL DataCell;
U32 SrcDataSize;
U32 DstDataSize;
U32 DataType;
ULONG SrcDataSize;
ULONG DstDataSize;
ULONG DataType;
PUCHAR Data;
BOOL Expand = FALSE;
@ -1121,16 +1121,16 @@ CmiExportValue (PREGISTRY_HIVE Hive,
static BOOL
CmiExportSubKey (PREGISTRY_HIVE Hive,
BLOCK_OFFSET ParentKeyOffset,
HKEY ParentKey,
HKEY Key)
FRLDRHKEY ParentKey,
FRLDRHKEY Key)
{
BLOCK_OFFSET NKBOffset;
PKEY_CELL NewKeyCell;
U32 KeyCellSize;
U32 SubKeyCount;
U32 ValueCount;
ULONG KeyCellSize;
ULONG SubKeyCount;
ULONG ValueCount;
PLIST_ENTRY Entry;
HKEY SubKey;
FRLDRHKEY SubKey;
PVALUE Value;
DbgPrint((DPRINT_REGISTRY, "CmiExportSubKey('%s') called\n", Key->Name));
@ -1243,11 +1243,11 @@ CmiExportSubKey (PREGISTRY_HIVE Hive,
static VOID
CmiCalcHiveChecksum (PREGISTRY_HIVE Hive)
{
U32 *Buffer;
U32 Sum;
U32 i;
ULONG *Buffer;
ULONG Sum;
ULONG i;
Buffer = (U32*)Hive->HiveHeader;
Buffer = (ULONG*)Hive->HiveHeader;
Sum = 0;
for (i = 0; i < 127; i++)
Sum += Buffer[i];
@ -1261,11 +1261,11 @@ CmiExportHive (PREGISTRY_HIVE Hive,
PCHAR KeyName)
{
PKEY_CELL KeyCell;
HKEY Key;
U32 SubKeyCount;
U32 ValueCount;
FRLDRHKEY Key;
ULONG SubKeyCount;
ULONG ValueCount;
PLIST_ENTRY Entry;
HKEY SubKey;
FRLDRHKEY SubKey;
PVALUE Value;
DbgPrint((DPRINT_REGISTRY, "CmiExportHive(%x, '%s') called\n", Hive, KeyName));
@ -1354,16 +1354,16 @@ CmiExportHive (PREGISTRY_HIVE Hive,
static BOOL
RegImportValue (PHBIN RootBin,
PVALUE_CELL ValueCell,
HKEY Key)
FRLDRHKEY Key)
{
PDATA_CELL DataCell;
PWCHAR wName;
PCHAR cName;
S32 Error;
S32 DataSize;
LONG Error;
LONG DataSize;
PCHAR cBuffer;
PWCHAR wBuffer;
S32 i;
LONG i;
if (ValueCell->CellSize >= 0 || ValueCell->Id != REG_VALUE_CELL_ID)
{
@ -1461,16 +1461,16 @@ RegImportValue (PHBIN RootBin,
static BOOL
RegImportSubKey(PHBIN RootBin,
PKEY_CELL KeyCell,
HKEY ParentKey)
FRLDRHKEY ParentKey)
{
PHASH_TABLE_CELL HashCell;
PKEY_CELL SubKeyCell;
PVALUE_LIST_CELL ValueListCell;
PVALUE_CELL ValueCell = NULL;
PCHAR cName;
HKEY SubKey;
S32 Error;
U32 i;
FRLDRHKEY SubKey;
LONG Error;
ULONG i;
DbgPrint((DPRINT_REGISTRY, "KeyCell: %x\n", KeyCell));
@ -1548,16 +1548,16 @@ RegImportSubKey(PHBIN RootBin,
BOOL
RegImportBinaryHive(PCHAR ChunkBase,
U32 ChunkSize)
ULONG ChunkSize)
{
PHIVE_HEADER HiveHeader;
PHBIN RootBin;
PKEY_CELL KeyCell;
PHASH_TABLE_CELL HashCell;
PKEY_CELL SubKeyCell;
HKEY SystemKey;
U32 i;
S32 Error;
FRLDRHKEY SystemKey;
ULONG i;
LONG Error;
DbgPrint((DPRINT_REGISTRY, "RegImportBinaryHive(%x, %u) called\n",ChunkBase,ChunkSize));
@ -1569,7 +1569,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
return FALSE;
}
RootBin = (PHBIN)((U32)HiveHeader + REG_BLOCK_SIZE);
RootBin = (PHBIN)((ULONG)HiveHeader + REG_BLOCK_SIZE);
DbgPrint((DPRINT_REGISTRY, "RootBin: %x\n", RootBin));
if (RootBin->HeaderId != REG_BIN_ID || RootBin->BinSize == 0)
{
@ -1577,7 +1577,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
return FALSE;
}
KeyCell = (PKEY_CELL)((U32)RootBin + REG_HBIN_DATA_OFFSET);
KeyCell = (PKEY_CELL)((ULONG)RootBin + REG_HBIN_DATA_OFFSET);
DbgPrint((DPRINT_REGISTRY, "KeyCell: %x\n", KeyCell));
DbgPrint((DPRINT_REGISTRY, "KeyCell->CellSize: %x\n", KeyCell->CellSize));
DbgPrint((DPRINT_REGISTRY, "KeyCell->Id: %x\n", KeyCell->Id));
@ -1603,14 +1603,14 @@ RegImportBinaryHive(PCHAR ChunkBase,
/* Enumerate and add subkeys */
if (KeyCell->NumberOfSubKeys > 0)
{
HashCell = (PHASH_TABLE_CELL)((U32)RootBin + KeyCell->HashTableOffset);
HashCell = (PHASH_TABLE_CELL)((ULONG)RootBin + KeyCell->HashTableOffset);
DbgPrint((DPRINT_REGISTRY, "HashCell: %x\n", HashCell));
for (i = 0; i < KeyCell->NumberOfSubKeys; i++)
{
DbgPrint((DPRINT_REGISTRY, "KeyOffset[%d]: %x\n", i, HashCell->Table[i].KeyOffset));
SubKeyCell = (PKEY_CELL)((U32)RootBin + HashCell->Table[i].KeyOffset);
SubKeyCell = (PKEY_CELL)((ULONG)RootBin + HashCell->Table[i].KeyOffset);
DbgPrint((DPRINT_REGISTRY, "SubKeyCell[%d]: %x\n", i, SubKeyCell));
@ -1626,7 +1626,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
BOOL
RegExportBinaryHive(PCHAR KeyName,
PCHAR ChunkBase,
U32* ChunkSize)
ULONG* ChunkSize)
{
PREGISTRY_HIVE Hive;

File diff suppressed because it is too large Load diff

View file

@ -26,18 +26,18 @@
#include <ui.h>
static HKEY RootKey;
static FRLDRHKEY RootKey;
VOID
RegInitializeRegistry (VOID)
{
#if 0
HKEY TestKey;
FRLDRHKEY TestKey;
#endif
/* Create root key */
RootKey = (HKEY) MmAllocateMemory (sizeof(KEY));
RootKey = (FRLDRHKEY) MmAllocateMemory (sizeof(KEY));
InitializeListHead (&RootKey->SubKeyList);
InitializeListHead (&RootKey->ValueList);
@ -94,19 +94,19 @@ RegInitializeRegistry (VOID)
}
S32
LONG
RegInitCurrentControlSet(BOOL LastKnownGood)
{
CHAR ControlSetKeyName[80];
HKEY SelectKey;
HKEY SystemKey;
HKEY ControlSetKey;
HKEY LinkKey;
U32 CurrentSet = 0;
U32 DefaultSet = 0;
U32 LastKnownGoodSet = 0;
U32 DataSize;
S32 Error;
FRLDRHKEY SelectKey;
FRLDRHKEY SystemKey;
FRLDRHKEY ControlSetKey;
FRLDRHKEY LinkKey;
ULONG CurrentSet = 0;
ULONG DefaultSet = 0;
ULONG LastKnownGoodSet = 0;
ULONG DataSize;
LONG Error;
Error = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\Select",
@ -117,7 +117,7 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
return(Error);
}
DataSize = sizeof(U32);
DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
"Default",
NULL,
@ -129,7 +129,7 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
return(Error);
}
DataSize = sizeof(U32);
DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
"LastKnownGood",
NULL,
@ -204,15 +204,15 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
}
S32
RegCreateKey(HKEY ParentKey,
LONG
RegCreateKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
PHKEY Key)
PFRLDRHKEY Key)
{
PLIST_ENTRY Ptr;
HKEY SearchKey = INVALID_HANDLE_VALUE;
HKEY CurrentKey;
HKEY NewKey;
FRLDRHKEY SearchKey = INVALID_HANDLE_VALUE;
FRLDRHKEY CurrentKey;
FRLDRHKEY NewKey;
PCHAR p;
PCHAR name;
int subkeyLength;
@ -237,7 +237,7 @@ RegCreateKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
CurrentKey = (HKEY)CurrentKey->Data;
CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
while (*KeyName != 0)
@ -279,7 +279,7 @@ RegCreateKey(HKEY ParentKey,
if (Ptr == &CurrentKey->SubKeyList)
{
/* no key found -> create new subkey */
NewKey = (HKEY)MmAllocateMemory(sizeof(KEY));
NewKey = (FRLDRHKEY)MmAllocateMemory(sizeof(KEY));
if (NewKey == NULL)
return(ERROR_OUTOFMEMORY);
@ -315,7 +315,7 @@ RegCreateKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
CurrentKey = (HKEY)CurrentKey->Data;
CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
}
@ -329,8 +329,8 @@ RegCreateKey(HKEY ParentKey,
}
S32
RegDeleteKey(HKEY Key,
LONG
RegDeleteKey(FRLDRHKEY Key,
PCHAR Name)
{
@ -344,16 +344,16 @@ RegDeleteKey(HKEY Key,
}
S32
RegEnumKey(HKEY Key,
U32 Index,
LONG
RegEnumKey(FRLDRHKEY Key,
ULONG Index,
PCHAR Name,
U32* NameSize)
ULONG* NameSize)
{
PLIST_ENTRY Ptr;
HKEY SearchKey;
U32 Count = 0;
U32 Size;
FRLDRHKEY SearchKey;
ULONG Count = 0;
ULONG Size;
Ptr = Key->SubKeyList.Flink;
while (Ptr != &Key->SubKeyList)
@ -382,14 +382,14 @@ RegEnumKey(HKEY Key,
}
S32
RegOpenKey(HKEY ParentKey,
LONG
RegOpenKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
PHKEY Key)
PFRLDRHKEY Key)
{
PLIST_ENTRY Ptr;
HKEY SearchKey = INVALID_HANDLE_VALUE;
HKEY CurrentKey;
FRLDRHKEY SearchKey = INVALID_HANDLE_VALUE;
FRLDRHKEY CurrentKey;
PCHAR p;
PCHAR name;
int subkeyLength;
@ -416,7 +416,7 @@ RegOpenKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
CurrentKey = (HKEY)CurrentKey->Data;
CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
while (*KeyName != 0)
@ -468,7 +468,7 @@ RegOpenKey(HKEY ParentKey,
/* Check whether current key is a link */
if (CurrentKey->DataType == REG_LINK)
{
CurrentKey = (HKEY)CurrentKey->Data;
CurrentKey = (FRLDRHKEY)CurrentKey->Data;
}
}
@ -482,12 +482,12 @@ RegOpenKey(HKEY ParentKey,
}
S32
RegSetValue(HKEY Key,
LONG
RegSetValue(FRLDRHKEY Key,
PCHAR ValueName,
U32 Type,
ULONG Type,
PUCHAR Data,
U32 DataSize)
ULONG DataSize)
{
PLIST_ENTRY Ptr;
PVALUE Value = NULL;
@ -583,14 +583,14 @@ RegSetValue(HKEY Key,
}
S32
RegQueryValue(HKEY Key,
LONG
RegQueryValue(FRLDRHKEY Key,
PCHAR ValueName,
U32* Type,
ULONG* Type,
PUCHAR Data,
U32* DataSize)
ULONG* DataSize)
{
U32 Size;
ULONG Size;
PLIST_ENTRY Ptr;
PVALUE Value = NULL;
@ -670,8 +670,8 @@ RegQueryValue(HKEY Key,
}
S32
RegDeleteValue(HKEY Key,
LONG
RegDeleteValue(FRLDRHKEY Key,
PCHAR ValueName)
{
PLIST_ENTRY Ptr;
@ -727,18 +727,18 @@ RegDeleteValue(HKEY Key,
}
S32
RegEnumValue(HKEY Key,
U32 Index,
LONG
RegEnumValue(FRLDRHKEY Key,
ULONG Index,
PCHAR ValueName,
U32* NameSize,
U32* Type,
ULONG* NameSize,
ULONG* Type,
PUCHAR Data,
U32* DataSize)
ULONG* DataSize)
{
PLIST_ENTRY Ptr;
PVALUE Value;
U32 Count = 0;
ULONG Count = 0;
if (Key->Data != NULL)
{
@ -813,15 +813,15 @@ RegEnumValue(HKEY Key,
}
U32
RegGetSubKeyCount (HKEY Key)
ULONG
RegGetSubKeyCount (FRLDRHKEY Key)
{
return Key->SubKeyCount;
}
U32
RegGetValueCount (HKEY Key)
ULONG
RegGetValueCount (FRLDRHKEY Key)
{
if (Key->DataSize != 0)
return Key->ValueCount + 1;

View file

@ -24,30 +24,23 @@
#define INVALID_HANDLE_VALUE NULL
typedef struct _LIST_ENTRY
{
struct _LIST_ENTRY *Flink;
struct _LIST_ENTRY *Blink;
} LIST_ENTRY, *PLIST_ENTRY;
typedef struct _REG_KEY
{
LIST_ENTRY KeyList;
LIST_ENTRY SubKeyList;
LIST_ENTRY ValueList;
U32 SubKeyCount;
U32 ValueCount;
ULONG SubKeyCount;
ULONG ValueCount;
U32 NameSize;
ULONG NameSize;
PUCHAR Name;
/* default data */
U32 DataType;
U32 DataSize;
ULONG DataType;
ULONG DataSize;
PUCHAR Data;
} KEY, *HKEY, **PHKEY;
} KEY, *FRLDRHKEY, **PFRLDRHKEY;
typedef struct _REG_VALUE
@ -55,18 +48,17 @@ typedef struct _REG_VALUE
LIST_ENTRY ValueList;
/* value name */
U32 NameSize;
ULONG NameSize;
PUCHAR Name;
/* value data */
U32 DataType;
U32 DataSize;
ULONG DataType;
ULONG DataSize;
PUCHAR Data;
} VALUE, *PVALUE;
#define ERROR_SUCCESS 0L
#define ERROR_PATH_NOT_FOUND 2L
#define ERROR_OUTOFMEMORY 14L
#define ERROR_INVALID_PARAMETER 87L
#define ERROR_MORE_DATA 234L
@ -149,22 +141,6 @@ typedef struct _REG_VALUE
assert((ListEntry)->Flink->Blink == (ListEntry)); \
}
/*
* BOOLEAN
* IsListEmpty (
* PLIST_ENTRY ListHead
* );
*
* FUNCTION:
* Checks if a double linked list is empty
*
* ARGUMENTS:
* ListHead = Head of the list
*/
#define IsListEmpty(ListHead) \
((ListHead)->Flink == (ListHead))
/*
*VOID
*RemoveEntryList (
@ -194,23 +170,6 @@ typedef struct _REG_VALUE
(ListEntry)->Blink = NULL; \
}
/*
* PURPOSE: Returns the byte offset of a field within a structure
*/
#define FIELD_OFFSET(Type,Field) (S32)(&(((Type *)(0))->Field))
/*
* PURPOSE: Returns the base address structure if the caller knows the
* address of a field within the structure
* ARGUMENTS:
* Address = address of the field
* Type = Type of the whole structure
* Field = Name of the field whose address is none
*/
#define CONTAINING_RECORD(Address,Type,Field) \
(Type *)(((S32)Address) - FIELD_OFFSET(Type,Field))
#define REG_NONE 0
#define REG_SZ 1
#define REG_EXPAND_SZ 2
@ -229,73 +188,73 @@ typedef struct _REG_VALUE
VOID
RegInitializeRegistry(VOID);
S32
LONG
RegInitCurrentControlSet(BOOL LastKnownGood);
S32
RegCreateKey(HKEY ParentKey,
LONG
RegCreateKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
PHKEY Key);
PFRLDRHKEY Key);
S32
RegDeleteKey(HKEY Key,
LONG
RegDeleteKey(FRLDRHKEY Key,
PCHAR Name);
S32
RegEnumKey(HKEY Key,
U32 Index,
LONG
RegEnumKey(FRLDRHKEY Key,
ULONG Index,
PCHAR Name,
U32* NameSize);
ULONG* NameSize);
S32
RegOpenKey(HKEY ParentKey,
LONG
RegOpenKey(FRLDRHKEY ParentKey,
PCHAR KeyName,
PHKEY Key);
PFRLDRHKEY Key);
S32
RegSetValue(HKEY Key,
LONG
RegSetValue(FRLDRHKEY Key,
PCHAR ValueName,
U32 Type,
ULONG Type,
PUCHAR Data,
U32 DataSize);
ULONG DataSize);
S32
RegQueryValue(HKEY Key,
LONG
RegQueryValue(FRLDRHKEY Key,
PCHAR ValueName,
U32* Type,
ULONG* Type,
PUCHAR Data,
U32* DataSize);
ULONG* DataSize);
S32
RegDeleteValue(HKEY Key,
LONG
RegDeleteValue(FRLDRHKEY Key,
PCHAR ValueName);
S32
RegEnumValue(HKEY Key,
U32 Index,
LONG
RegEnumValue(FRLDRHKEY Key,
ULONG Index,
PCHAR ValueName,
U32* NameSize,
U32* Type,
ULONG* NameSize,
ULONG* Type,
PUCHAR Data,
U32* DataSize);
ULONG* DataSize);
U32
RegGetSubKeyCount (HKEY Key);
ULONG
RegGetSubKeyCount (FRLDRHKEY Key);
U32
RegGetValueCount (HKEY Key);
ULONG
RegGetValueCount (FRLDRHKEY Key);
BOOL
RegImportBinaryHive (PCHAR ChunkBase,
U32 ChunkSize);
ULONG ChunkSize);
BOOL
RegExportBinaryHive (PCHAR KeyName,
PCHAR ChunkBase,
U32* ChunkSize);
ULONG* ChunkSize);
#endif /* __REGISTRY_H */

View file

@ -97,7 +97,7 @@ LoadKernel(PCHAR szSourcePath, PCHAR szFileName)
/*
* Load the kernel
*/
MultiBootLoadKernel(FilePointer);
FrLdrMapKernel(FilePointer);
return(TRUE);
}
@ -162,7 +162,7 @@ LoadDriver(PCHAR szSourcePath, PCHAR szFileName)
#endif
/* Load the driver */
MultiBootLoadModule(FilePointer, szFileName, NULL);
FrLdrLoadModule(FilePointer, szFileName, NULL);
return(TRUE);
}
@ -227,7 +227,7 @@ LoadNlsFile(PCHAR szSourcePath, PCHAR szFileName, PCHAR szModuleName)
#endif
/* Load the driver */
MultiBootLoadModule(FilePointer, szModuleName, NULL);
FrLdrLoadModule(FilePointer, szModuleName, NULL);
return(TRUE);
}
@ -235,44 +235,44 @@ LoadNlsFile(PCHAR szSourcePath, PCHAR szFileName, PCHAR szModuleName)
VOID RunLoader(VOID)
{
PVOID Base;
U32 Size;
ULONG_PTR Base;
ULONG Size;
char *SourcePath;
char *LoadOptions;
int i;
HINF InfHandle;
U32 ErrorLine;
ULONG ErrorLine;
INFCONTEXT InfContext;
/* Setup multiboot information structure */
mb_info.flags = MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
mb_info.boot_device = 0xffffffff;
mb_info.cmdline = (unsigned long)multiboot_kernel_cmdline;
mb_info.mods_count = 0;
mb_info.mods_addr = (unsigned long)multiboot_modules;
mb_info.mmap_length = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&multiboot_memory_map, 32) * sizeof(memory_map_t);
if (mb_info.mmap_length)
LoaderBlock.Flags = MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
LoaderBlock.BootDevice = 0xffffffff;
LoaderBlock.CommandLine = (unsigned long)multiboot_kernel_cmdline;
LoaderBlock.ModsCount = 0;
LoaderBlock.ModsAddr = (unsigned long)multiboot_modules;
LoaderBlock.MmapLength = (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP)(PVOID)&multiboot_memory_map, 32) * sizeof(memory_map_t);
if (LoaderBlock.MmapLength)
{
mb_info.mmap_addr = (unsigned long)&multiboot_memory_map;
mb_info.flags |= MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_MEMORY_MAP;
LoaderBlock.MmapAddr = (unsigned long)&multiboot_memory_map;
LoaderBlock.Flags |= MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_MEMORY_MAP;
multiboot_memory_map_descriptor_size = sizeof(memory_map_t); // GetBiosMemoryMap uses a fixed value of 24
for (i = 0; i < (mb_info.mmap_length / sizeof(memory_map_t)); i++)
for (i = 0; i < (LoaderBlock.MmapLength / sizeof(memory_map_t)); i++)
{
if (MEMTYPE_USABLE == multiboot_memory_map[i].type &&
0 == multiboot_memory_map[i].base_addr_low)
{
mb_info.mem_lower = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024;
if (640 < mb_info.mem_lower)
LoaderBlock.MemLower = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024;
if (640 < LoaderBlock.MemLower)
{
mb_info.mem_lower = 640;
LoaderBlock.MemLower = 640;
}
}
if (MEMTYPE_USABLE == multiboot_memory_map[i].type &&
multiboot_memory_map[i].base_addr_low <= 1024 * 1024 &&
1024 * 1024 <= multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low)
{
mb_info.mem_upper = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024 - 1024;
LoaderBlock.MemHigher = (multiboot_memory_map[i].base_addr_low + multiboot_memory_map[i].length_low) / 1024 - 1024;
}
#if 0
printf("start: %x\t size: %x\t type %d\n",
@ -283,8 +283,8 @@ VOID RunLoader(VOID)
}
}
#if 0
printf("low_mem = %d\n", mb_info.mem_lower);
printf("high_mem = %d\n", mb_info.mem_upper);
printf("low_mem = %d\n", LoaderBlock.MemLower);
printf("high_mem = %d\n", LoaderBlock.MemHigher);
MachConsGetCh();
#endif
@ -308,8 +308,8 @@ VOID RunLoader(VOID)
#endif
/* set boot drive and partition */
((char *)(&mb_info.boot_device))[0] = (char)BootDrive;
((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
((char *)(&LoaderBlock.BootDevice))[0] = (char)BootDrive;
((char *)(&LoaderBlock.BootDevice))[1] = (char)BootPartition;
/* Open boot drive */
@ -383,9 +383,9 @@ VOID RunLoader(VOID)
/* Export the hardware hive */
Base = MultiBootCreateModule ("HARDWARE");
RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", Base, &Size);
MultiBootCloseModule (Base, Size);
Base = FrLdrCreateModule ("HARDWARE");
RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PVOID)Base, &Size);
FrLdrCloseModule (Base, Size);
#if 0
printf("Base: %x\n", Base);
@ -571,7 +571,8 @@ for(;;);
/* Now boot the kernel */
DiskStopFloppyMotor();
boot_reactos();
MachVideoPrepareForReactOS();
FrLdrStartup(0x2badb002);
}
/* EOF */

View file

@ -92,9 +92,9 @@ BOOL RtlListIsEmpty(PLIST_ITEM ListHead)
return (ListHead->ListNext == NULL);
}
U32 RtlListCountEntries(PLIST_ITEM ListHead)
ULONG RtlListCountEntries(PLIST_ITEM ListHead)
{
U32 Count = 0;
ULONG Count = 0;
while (ListHead != NULL)
{

View file

@ -19,7 +19,7 @@
#include <rtl.h>
int strlen(char *str)
size_t strlen(const char *str)
{
int len;
@ -28,7 +28,7 @@ int strlen(char *str)
return len;
}
char *strcpy(char *dest, char *src)
char *strcpy(char *dest, const char *src)
{
char *ret = dest;
@ -39,7 +39,7 @@ char *strcpy(char *dest, char *src)
return ret;
}
char *strncpy(char *dest, char *src, size_t count)
char *strncpy(char *dest, const char *src, size_t count)
{
char *ret = dest;
@ -52,7 +52,7 @@ char *strncpy(char *dest, char *src, size_t count)
return ret;
}
char *strcat(char *dest, char *src)
char *strcat(char *dest, const char *src)
{
char *ret = dest;

View file

@ -30,19 +30,19 @@ VOID GuiDrawBackdrop(VOID)
{
}
VOID GuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
VOID GuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
{
}
VOID GuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
VOID GuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
{
}
VOID GuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
VOID GuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
{
}
VOID GuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
VOID GuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr)
{
}
@ -70,7 +70,7 @@ VOID GuiMessageBoxCritical(PUCHAR MessageText)
{
}
VOID GuiDrawProgressBar(U32 Position, U32 Range)
VOID GuiDrawProgressBar(ULONG Position, ULONG Range)
{
}

View file

@ -29,17 +29,17 @@
//
///////////////////////////////////////////////////////////////////////////////////////
VOID GuiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
VOID GuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
VOID GuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom); // Draws a shadow on the bottom and right sides of the area specified
VOID GuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
VOID GuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
VOID GuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
VOID GuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
VOID GuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
VOID GuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
VOID GuiDrawStatusText(PUCHAR StatusText); // Draws text at the very bottom line on the screen
VOID GuiUpdateDateTime(VOID); // Updates the date and time
VOID GuiSaveScreen(PUCHAR Buffer); // Saves the screen so that it can be restored later
VOID GuiRestoreScreen(PUCHAR Buffer); // Restores the screen from a previous save
VOID GuiMessageBox(PUCHAR MessageText); // Displays a message box on the screen with an ok button
VOID GuiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
VOID GuiDrawProgressBar(U32 Position, U32 Range); // Draws the progress bar showing nPos percent filled
VOID GuiDrawProgressBar(ULONG Position, ULONG Range); // Draws the progress bar showing nPos percent filled
UCHAR GuiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
UCHAR GuiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
@ -49,7 +49,7 @@ UCHAR GuiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill int
// Menu Functions
//
///////////////////////////////////////////////////////////////////////////////////////
BOOL GuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem);
BOOL GuiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem);

View file

@ -136,10 +136,10 @@ VOID TuiDrawBackdrop(VOID)
* FillArea()
* This function assumes coordinates are zero-based
*/
VOID TuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
U32 i, j;
ULONG i, j;
// Clip the area to the screen
// FIXME: This code seems to have problems... Uncomment and view ;-)
@ -172,10 +172,10 @@ VOID TuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR
* DrawShadow()
* This function assumes coordinates are zero-based
*/
VOID TuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
U32 Idx;
ULONG Idx;
// Shade the bottom of the area
if (Bottom < (UiScreenHeight - 1))
@ -232,7 +232,7 @@ VOID TuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
* DrawBox()
* This function assumes coordinates are zero-based
*/
VOID TuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
{
UCHAR ULCorner, URCorner, LLCorner, LRCorner;
@ -304,10 +304,10 @@ VOID TuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR
* DrawText()
* This function assumes coordinates are zero-based
*/
VOID TuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
VOID TuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
U32 i, j;
ULONG i, j;
// Draw the text
for (i=X, j=0; Text[j] && i<UiScreenWidth; i++,j++)
@ -317,18 +317,18 @@ VOID TuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
}
}
VOID TuiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextString, UCHAR Attr)
VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PUCHAR TextString, UCHAR Attr)
{
U32 TextLength;
U32 BoxWidth;
U32 BoxHeight;
U32 LineBreakCount;
U32 Index;
U32 LastIndex;
U32 RealLeft;
U32 RealTop;
U32 X;
U32 Y;
ULONG TextLength;
ULONG BoxWidth;
ULONG BoxHeight;
ULONG LineBreakCount;
ULONG Index;
ULONG LastIndex;
ULONG RealLeft;
ULONG RealTop;
ULONG X;
ULONG Y;
UCHAR Temp[2];
TextLength = strlen(TextString);
@ -380,7 +380,7 @@ VOID TuiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextSt
VOID TuiDrawStatusText(PUCHAR StatusText)
{
U32 i;
ULONG i;
TuiDrawText(0, UiScreenHeight-1, " ", ATTR(UiStatusBarFgColor, UiStatusBarBgColor));
TuiDrawText(1, UiScreenHeight-1, StatusText, ATTR(UiStatusBarFgColor, UiStatusBarBgColor));
@ -395,8 +395,8 @@ VOID TuiDrawStatusText(PUCHAR StatusText)
VOID TuiUpdateDateTime(VOID)
{
U32 Year, Month, Day;
U32 Hour, Minute, Second;
ULONG Year, Month, Day;
ULONG Hour, Minute, Second;
UCHAR DateString[40];
UCHAR TimeString[40];
UCHAR TempString[20];
@ -479,7 +479,7 @@ VOID TuiUpdateDateTime(VOID)
VOID TuiSaveScreen(PUCHAR Buffer)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
U32 i;
ULONG i;
for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
{
@ -490,7 +490,7 @@ VOID TuiSaveScreen(PUCHAR Buffer)
VOID TuiRestoreScreen(PUCHAR Buffer)
{
PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
U32 i;
ULONG i;
for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
{
@ -603,11 +603,11 @@ VOID TuiMessageBoxCritical(PUCHAR MessageText)
}
VOID TuiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText)
VOID TuiDrawProgressBarCenter(ULONG Position, ULONG Range, PUCHAR ProgressText)
{
U32 Left, Top, Right, Bottom;
U32 Width = 50; // Allow for 50 "bars"
U32 Height = 2;
ULONG Left, Top, Right, Bottom;
ULONG Width = 50; // Allow for 50 "bars"
ULONG Height = 2;
Left = (UiScreenWidth - Width - 4) / 2;
Right = Left + Width + 3;
@ -618,10 +618,10 @@ VOID TuiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText)
TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
}
VOID TuiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText)
VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PUCHAR ProgressText)
{
U32 i;
U32 ProgressBarWidth = (Right - Left) - 3;
ULONG i;
ULONG ProgressBarWidth = (Right - Left) - 3;
// First make sure the progress bar text fits
UiTruncateStringEllipsis(ProgressText, ProgressBarWidth - 4);
@ -765,7 +765,7 @@ VOID TuiFadeOut(VOID)
}
BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length)
BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, ULONG Length)
{
int width = 8;
int height = 1;

View file

@ -32,20 +32,20 @@ BOOL TuiInitialize(VOID); // Initialize User-Interface
VOID TuiUnInitialize(VOID); // Un-initialize User-Interface
VOID TuiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
VOID TuiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
VOID TuiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom); // Draws a shadow on the bottom and right sides of the area specified
VOID TuiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
VOID TuiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
VOID TuiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
VOID TuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PUCHAR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
VOID TuiDrawStatusText(PUCHAR StatusText); // Draws text at the very bottom line on the screen
VOID TuiUpdateDateTime(VOID); // Updates the date and time
VOID TuiSaveScreen(PUCHAR Buffer); // Saves the screen so that it can be restored later
VOID TuiRestoreScreen(PUCHAR Buffer); // Restores the screen from a previous save
VOID TuiMessageBox(PUCHAR MessageText); // Displays a message box on the screen with an ok button
VOID TuiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
VOID TuiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID TuiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length);
VOID TuiDrawProgressBarCenter(ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, ULONG Length);
UCHAR TuiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
UCHAR TuiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
@ -62,23 +62,23 @@ VOID TuiFadeOut(VOID); // Fades the screen out
typedef struct
{
PUCHAR *MenuItemList;
U32 MenuItemCount;
S32 MenuTimeRemaining;
U32 SelectedMenuItem;
ULONG MenuItemCount;
LONG MenuTimeRemaining;
ULONG SelectedMenuItem;
U32 Left;
U32 Top;
U32 Right;
U32 Bottom;
ULONG Left;
ULONG Top;
ULONG Right;
ULONG Bottom;
} TUI_MENU_INFO, *PTUI_MENU_INFO;
VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo);
VOID TuiDrawMenu(PTUI_MENU_INFO MenuInfo);
VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo);
VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber);
U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter);
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG MenuItemNumber);
ULONG TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter);
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
/*

View file

@ -28,12 +28,12 @@
#include <video.h>
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{
TUI_MENU_INFO MenuInformation;
U32 LastClockSecond;
U32 CurrentClockSecond;
U32 KeyPress;
ULONG LastClockSecond;
ULONG CurrentClockSecond;
ULONG KeyPress;
//
// The first thing we need to check is the timeout
@ -145,10 +145,10 @@ BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuIte
VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo)
{
U32 Idx;
U32 Width;
U32 Height;
U32 Length;
ULONG Idx;
ULONG Width;
ULONG Height;
ULONG Length;
//
// Height is the menu item count plus 2 (top border & bottom border)
@ -186,7 +186,7 @@ VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo)
VOID TuiDrawMenu(PTUI_MENU_INFO MenuInfo)
{
U32 Idx;
ULONG Idx;
//
// Draw the backdrop
@ -218,7 +218,7 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
{
UCHAR MenuLineText[80];
UCHAR TempString[80];
U32 Idx;
ULONG Idx;
//
// Draw the menu box
@ -262,13 +262,13 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
}
}
VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG MenuItemNumber)
{
U32 Idx;
ULONG Idx;
UCHAR MenuLineText[80];
U32 SpaceTotal;
U32 SpaceLeft;
U32 SpaceRight;
ULONG SpaceTotal;
ULONG SpaceLeft;
ULONG SpaceRight;
UCHAR Attribute;
//
@ -335,9 +335,9 @@ VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
}
}
U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter)
ULONG TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter)
{
U32 KeyEvent = 0;
ULONG KeyEvent = 0;
//
// Check for a keypress

View file

@ -28,8 +28,8 @@
#include <version.h>
#include <video.h>
U32 UiScreenWidth = 80; // Screen Width
U32 UiScreenHeight = 25; // Screen Height
ULONG UiScreenWidth = 80; // Screen Width
ULONG UiScreenHeight = 25; // Screen Height
UCHAR UiStatusBarFgColor = COLOR_BLACK; // Status bar foreground color
UCHAR UiStatusBarBgColor = COLOR_CYAN; // Status bar background color
@ -61,10 +61,10 @@ UCHAR UiMonthNames[12][15] = { "January ", "February ", "March ", "April ", "May
BOOL UiInitialize(BOOLEAN ShowGui)
{
U32 SectionId;
ULONG SectionId;
UCHAR DisplayModeText[260];
UCHAR SettingText[260];
U32 Depth;
ULONG Depth;
if (!ShowGui) {
if (!TuiInitialize())
@ -233,7 +233,7 @@ VOID UiDrawBackdrop(VOID)
}
}
VOID UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
{
if (VideoTextMode == UiDisplayMode)
{
@ -246,7 +246,7 @@ VOID UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR
}
}
VOID UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
{
if (VideoTextMode == UiDisplayMode)
{
@ -259,7 +259,7 @@ VOID UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
}
}
VOID UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
{
if (VideoTextMode == UiDisplayMode)
{
@ -272,7 +272,7 @@ VOID UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR
}
}
VOID UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
VOID UiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr)
{
if (VideoTextMode == UiDisplayMode)
{
@ -285,7 +285,7 @@ VOID UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
}
}
VOID UiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextString, UCHAR Attr)
VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PUCHAR TextString, UCHAR Attr)
{
if (VideoTextMode == UiDisplayMode)
{
@ -328,16 +328,16 @@ VOID UiUpdateDateTime(VOID)
VOID UiInfoBox(PUCHAR MessageText)
{
U32 TextLength;
U32 BoxWidth;
U32 BoxHeight;
U32 LineBreakCount;
U32 Index;
U32 LastIndex;
U32 Left;
U32 Top;
U32 Right;
U32 Bottom;
ULONG TextLength;
ULONG BoxWidth;
ULONG BoxHeight;
ULONG LineBreakCount;
ULONG Index;
ULONG LastIndex;
ULONG Left;
ULONG Top;
ULONG Right;
ULONG Bottom;
TextLength = strlen(MessageText);
@ -465,7 +465,7 @@ UCHAR UiTextToFillStyle(PUCHAR FillStyleText)
}
}
VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText)
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PUCHAR ProgressText)
{
if (!UserInterfaceUp) return;
@ -480,7 +480,7 @@ VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText)
}
}
VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText)
VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PUCHAR ProgressText)
{
if (VideoTextMode == UiDisplayMode)
{
@ -495,12 +495,12 @@ VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U
VOID UiShowMessageBoxesInSection(PUCHAR SectionName)
{
U32 Idx;
ULONG Idx;
UCHAR SettingName[80];
UCHAR SettingValue[80];
PUCHAR MessageBoxText;
U32 MessageBoxTextSize;
U32 SectionId;
ULONG MessageBoxTextSize;
ULONG SectionId;
if (!IniOpenSection(SectionName, &SectionId))
{
@ -547,7 +547,7 @@ VOID UiShowMessageBoxesInSection(PUCHAR SectionName)
VOID UiEscapeString(PUCHAR String)
{
U32 Idx;
ULONG Idx;
for (Idx=0; Idx<strlen(String); Idx++)
{
@ -563,7 +563,7 @@ VOID UiEscapeString(PUCHAR String)
}
}
VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars)
VOID UiTruncateStringEllipsis(PUCHAR StringText, ULONG MaxChars)
{
if (strlen(StringText) > MaxChars)
{
@ -571,7 +571,7 @@ VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars)
}
}
BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
BOOL UiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{
if (VideoTextMode == UiDisplayMode)
{
@ -611,7 +611,7 @@ VOID UiFadeOut(VOID)
}
}
BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length)
BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, ULONG Length)
{
if (VideoTextMode == UiDisplayMode)
{

View file

@ -25,9 +25,9 @@
#define RGB_MAX 64
#define RGB_MAX_PER_ITERATION 64
VOID VideoSetAllColorsToBlack(U32 ColorCount)
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
{
U32 Color;
ULONG Color;
MachVideoSync();
@ -37,10 +37,10 @@ VOID VideoSetAllColorsToBlack(U32 ColorCount)
}
}
VOID VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount)
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
{
U32 Index;
U32 Color;
ULONG Index;
ULONG Color;
PALETTE_ENTRY PaletteColors[ColorCount];
for (Index=0; Index<RGB_MAX; Index++)
@ -92,13 +92,13 @@ VOID VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount)
}
}
VOID VideoFadeOut(U32 ColorCount)
VOID VideoFadeOut(ULONG ColorCount)
{
U32 Index;
U32 Color;
U8 Red;
U8 Green;
U8 Blue;
ULONG Index;
ULONG Color;
UCHAR Red;
UCHAR Green;
UCHAR Blue;
for (Index=0; Index<RGB_MAX; Index++)
{

View file

@ -21,9 +21,9 @@
#include <video.h>
#include <machine.h>
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
{
U32 Color;
ULONG Color;
for (Color=0; Color<ColorCount; Color++)
{
@ -31,9 +31,9 @@ VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
}
}
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
{
U32 Color;
ULONG Color;
MachVideoSync();

View file

@ -28,7 +28,7 @@ PVOID VideoOffScreenBuffer = NULL;
PVOID VideoAllocateOffScreenBuffer(VOID)
{
U32 BufferSize;
ULONG BufferSize;
if (VideoOffScreenBuffer != NULL)
{

View file

@ -14,17 +14,15 @@
; 0x3000 Startup code for the APs (this code)
;
;
; Base address of common area for BSP and APs
;
LOAD_BASE equ 00200000h
;
; Magic value to be put in EAX when multiboot.S is called as part of the
; application processor initialization process
;
AP_MAGIC equ 12481020h
X86_CR4_PAE equ 00000020h
;
; Segment selectors
;
@ -48,9 +46,22 @@ _APstart:
mov eax, 3000h + APgdt - _APstart
lgdt [eax]
mov eax, [2004h] ; Set the page directory
mov cr3, eax
mov eax, [200ch]
cmp eax,0
je NoPae
mov eax,cr4
or eax,X86_CR4_PAE
mov cr4,eax
NoPae:
mov eax, cr0
or eax, 00010001h ; Turn on protected mode and write protection
or eax, 80010001h ; Turn on protected mode, paging and write protection
mov cr0, eax
db 0eah
@ -72,9 +83,10 @@ flush:
mov eax, [eax]
mov esp, eax
; Jump to start of the kernel with AP magic in eax
mov eax, AP_MAGIC
jmp dword KERNEL_CS:(LOAD_BASE + 0x1000)
; Jump to start of the kernel with AP magic in ecx
mov ecx, AP_MAGIC
mov eax,[2008h]
jmp eax
; Never get here

View file

@ -38,8 +38,11 @@
typedef struct __attribute__((packed)) _COMMON_AREA_INFO
{
ULONG Stack; /* Location of AP stack */
ULONG Debug[16]; /* For debugging */
ULONG Stack; /* Location of AP stack */
ULONG PageDirectory; /* Page directory for an AP */
ULONG NtProcessStartup; /* Kernel entry point for an AP */
ULONG PaeModeEnabled; /* PAE mode is enabled */
ULONG Debug[16]; /* For debugging */
} COMMON_AREA_INFO, *PCOMMON_AREA_INFO;
CPU_INFO CPUMap[MAX_CPU]; /* Map of all CPUs in the system */
@ -81,6 +84,7 @@ extern VOID MpsIpiInterrupt(VOID);
WRITE_PORT_UCHAR((PUCHAR)0x71, value); \
})
extern PVOID IMPORTED MmSystemRangeStart;
/* FUNCTIONS *****************************************************************/
@ -1094,6 +1098,15 @@ HalStartNextProcessor(ULONG Unknown1,
/* Write the location of the AP stack */
Common->Stack = (ULONG)ProcessorStack;
/* Write the page directory page */
Ke386GetPageTableDirectory(Common->PageDirectory);
/* Write the kernel entry point */
Common->NtProcessStartup = (ULONG_PTR)RtlImageNtHeader(MmSystemRangeStart)->OptionalHeader.AddressOfEntryPoint + (ULONG_PTR)MmSystemRangeStart;
/* Write the state of the mae mode */
Common->PaeModeEnabled = Ke386GetCr4() & X86_CR4_PAE ? 1 : 0;
DPRINT1("%x %x %x %x\n", Common->Stack, Common->PageDirectory, Common->NtProcessStartup, Common->PaeModeEnabled);
DPRINT("CPU %d got stack at 0x%X\n", CPU, Common->Stack);
#if 0

View file

@ -517,6 +517,9 @@ typedef struct _LOADER_PARAMETER_BLOCK
ULONG DrivesAddr;
ULONG ConfigTable;
ULONG BootLoaderName;
ULONG PageDirectoryStart;
ULONG PageDirectoryEnd;
ULONG KernelBase;
} LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;
typedef enum _KAPC_ENVIRONMENT

Some files were not shown because too many files have changed in this diff Show more