diff --git a/reactos/boot/freeldr/freeldr/arch/i386/arch.S b/reactos/boot/freeldr/freeldr/arch/i386/arch.S index 722b63c9352..3c8c2f959f5 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/arch.S +++ b/reactos/boot/freeldr/freeldr/arch/i386/arch.S @@ -20,8 +20,7 @@ .intel_syntax noprefix #define HEX(y) 0x##y -#define ASM -#include +#include #include .code16 diff --git a/reactos/boot/freeldr/freeldr/arch/i386/int386.S b/reactos/boot/freeldr/freeldr/arch/i386/int386.S index 14086bf391f..1d614675fc9 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/int386.S +++ b/reactos/boot/freeldr/freeldr/arch/i386/int386.S @@ -20,8 +20,7 @@ .text .code16 -#define ASM -#include +#include /* Only these flags are propagated into Int386() */ #define FLAGS_PROP (I386FLAG_CF | \ @@ -172,9 +171,9 @@ Int386_vector_opcode: movsb /* Restore segment and all other registers */ - - - popal + + + popal popw %gs popw %fs popw %es diff --git a/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c b/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c index dcc51ef2b59..272401d2c36 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c @@ -1,6 +1,9 @@ #include -#define NDEBUG -#include + +/* For KeStallExecutionProcessor */ +#if defined(_M_IX86) || defined(_M_AMD64) +#include +#endif VOID NTAPI @@ -75,6 +78,7 @@ NTAPI KeStallExecutionProcessor( IN ULONG MicroSeconds) { +#if defined(_M_IX86) || defined(_M_AMD64) REGS Regs; ULONG usec_this; @@ -111,4 +115,7 @@ KeStallExecutionProcessor( MicroSeconds -= usec_this; } +#else + #error unimplemented +#endif } diff --git a/reactos/boot/freeldr/freeldr/include/arch.h b/reactos/boot/freeldr/freeldr/include/arch.h deleted file mode 100644 index 9888601a434..00000000000 --- a/reactos/boot/freeldr/freeldr/include/arch.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __ASM__ -#pragma once -#endif - -#ifndef HEX -#define HEX(y) 0x##y -#endif - -#ifdef _M_AMD64 -#include -#endif - -#if defined (_M_IX86) -/* Defines needed for switching between real and protected mode */ -#define NULL_DESC HEX(00) /* NULL descriptor */ -#define PMODE_CS HEX(08) /* PMode code selector, base 0 limit 4g */ -#define PMODE_DS HEX(10) /* PMode data selector, base 0 limit 4g */ -#define RMODE_CS HEX(18) /* RMode code selector, base 0 limit 64k */ -#define RMODE_DS HEX(20) /* RMode data selector, base 0 limit 64k */ -#endif - -#define CR0_PE_SET HEX(00000001) /* OR this value with CR0 to enable pmode */ -#define CR0_PE_CLR HEX(FFFFFFFE) /* AND this value with CR0 to disable pmode */ - -#define STACK16ADDR HEX(7000) /* The 16-bit stack top will be at 0000:7000 */ -#define STACK32ADDR HEX(78000) /* The 32-bit stack top will be at 7000:8000, or 0x78000 */ - -#if defined (_M_IX86) || defined (_M_AMD64) -#define BIOSCALLBUFFER 0x78000 /* Buffer to store temporary data for any Int386() call */ -#define BIOSCALLBUFSEGMENT 0x7800 /* Buffer to store temporary data for any Int386() call */ -#define BIOSCALLBUFOFFSET 0x0000 /* Buffer to store temporary data for any Int386() call */ -#define FILESYSBUFFER 0x80000 /* Buffer to store file system data (e.g. cluster buffer for FAT) */ -#define DISKREADBUFFER 0x90000 /* Buffer to store data read in from the disk via the BIOS */ -#define DISKREADBUFFER_SIZE 512 -#elif defined(_M_PPC) || defined(_M_MIPS) -#define DISKREADBUFFER 0x80000000 -#define FILESYSBUFFER 0x80000000 -#elif defined(_M_ARM) -extern ULONG gDiskReadBuffer, gFileSysBuffer; -#define DISKREADBUFFER gDiskReadBuffer -#define FILESYSBUFFER gFileSysBuffer -#endif - -/* Makes "x" a global variable or label */ -#define EXTERN(x) .global x; x: - - -// Flag Masks -#define I386FLAG_CF HEX(0001) // Carry Flag -#define I386FLAG_RESV1 HEX(0002) // Reserved - Must be 1 -#define I386FLAG_PF HEX(0004) // Parity Flag -#define I386FLAG_RESV2 HEX(0008) // Reserved - Must be 0 -#define I386FLAG_AF HEX(0010) // Auxiliary Flag -#define I386FLAG_RESV3 HEX(0020) // Reserved - Must be 0 -#define I386FLAG_ZF HEX(0040) // Zero Flag -#define I386FLAG_SF HEX(0080) // Sign Flag -#define I386FLAG_TF HEX(0100) // Trap Flag (Single Step) -#define I386FLAG_IF HEX(0200) // Interrupt Flag -#define I386FLAG_DF HEX(0400) // Direction Flag -#define I386FLAG_OF HEX(0800) // Overflow Flag - - -#ifndef __ASM__ - -#include -typedef struct -{ - unsigned long eax; - unsigned long ebx; - unsigned long ecx; - unsigned long edx; - - unsigned long esi; - unsigned long edi; - - unsigned short ds; - unsigned short es; - unsigned short fs; - unsigned short gs; - - unsigned long eflags; - -} DWORDREGS; - -typedef struct -{ - unsigned short ax, _upper_ax; - unsigned short bx, _upper_bx; - unsigned short cx, _upper_cx; - unsigned short dx, _upper_dx; - - unsigned short si, _upper_si; - unsigned short di, _upper_di; - - unsigned short ds; - unsigned short es; - unsigned short fs; - unsigned short gs; - - unsigned short flags, _upper_flags; - -} WORDREGS; - -typedef struct -{ - unsigned char al; - unsigned char ah; - unsigned short _upper_ax; - unsigned char bl; - unsigned char bh; - unsigned short _upper_bx; - unsigned char cl; - unsigned char ch; - unsigned short _upper_cx; - unsigned char dl; - unsigned char dh; - unsigned short _upper_dx; - - unsigned short si, _upper_si; - unsigned short di, _upper_di; - - unsigned short ds; - unsigned short es; - unsigned short fs; - unsigned short gs; - - unsigned short flags, _upper_flags; - -} BYTEREGS; - - -typedef union -{ - DWORDREGS x; - DWORDREGS d; - WORDREGS w; - BYTEREGS b; -} REGS; -#include - -// Int386() -// -// Real mode interrupt vector interface -// -// (E)FLAGS can *only* be returned by this function, not set. -// Make sure all memory pointers are in SEG:OFFS format and -// not linear addresses, unless the interrupt handler -// specifically handles linear addresses. -int Int386(int ivec, REGS* in, REGS* out); - -// This macro tests the Carry Flag -// If CF is set then the call failed (usually) -#define INT386_SUCCESS(regs) ((regs.x.eflags & I386FLAG_CF) == 0) - -void EnableA20(void); - -VOID ChainLoadBiosBootSectorCode(VOID); // Implemented in boot.S -VOID SoftReboot(VOID); // Implemented in boot.S - -VOID DetectHardware(VOID); // Implemented in hardware.c - -#endif /* ! __ASM__ */ diff --git a/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h b/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h index da68bcedf6b..433fbb4f5e1 100644 --- a/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h +++ b/reactos/boot/freeldr/freeldr/include/arch/amd64/amd64.h @@ -56,11 +56,7 @@ #ifndef ASM VOID FrLdrSetupGdtIdt(VOID); - -#include -#define FrldrBootDrive *((PULONG)BSS_BootDrive) -#define FrldrBootPartition *((PULONG)BSS_BootPartition) - +#define MachInit PcMachInit #endif /* EOF */ diff --git a/reactos/boot/freeldr/freeldr/include/arch/amd64/hardware.h b/reactos/boot/freeldr/freeldr/include/arch/amd64/hardware.h deleted file mode 100644 index b6da01e555e..00000000000 --- a/reactos/boot/freeldr/freeldr/include/arch/amd64/hardware.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * FreeLoader - * - * Copyright (C) 2003 Eric Kohl - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#ifndef __REGISTRY_H -#include "../../reactos/registry.h" -#endif - -#define CONFIG_CMD(bus, dev_fn, where) \ - (0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3)) - - -// -// Static heap for ARC Hardware Component Tree -// 16KB oughta be enough for anyone. -// -#define HW_MAX_ARC_HEAP_SIZE 16 * 1024 - -// -// ARC Component Configuration Routines -// -VOID -NTAPI -FldrCreateSystemKey( - OUT PCONFIGURATION_COMPONENT_DATA *SystemKey -); - -VOID -NTAPI -FldrCreateComponentKey( - IN PCONFIGURATION_COMPONENT_DATA SystemKey, - IN CONFIGURATION_CLASS Class, - IN CONFIGURATION_TYPE Type, - IN IDENTIFIER_FLAG Flags, - IN ULONG Key, - IN ULONG Affinity, - IN PCHAR IdentifierString, - IN PCM_PARTIAL_RESOURCE_LIST ResourceList, - IN ULONG Size, - OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey -); - -/* PROTOTYPES ***************************************************************/ - -/* hardware.c */ - -VOID StallExecutionProcessor(ULONG Microseconds); - -VOID HalpCalibrateStallExecution(VOID); - -/* hwacpi.c */ -VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber); - -/* hwapm.c */ -VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber); - -/* hwpci.c */ -VOID DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber); - -/* i386cpu.S */ -ULONG CpuidSupported(VOID); -VOID GetCpuid(ULONG Level, - ULONG *eax, - ULONG *ebx, - ULONG *ecx, - ULONG *edx); -ULONGLONG RDTSC(VOID); - -/* i386pnp.S */ -ULONG_PTR PnpBiosSupported(VOID); -ULONG PnpBiosGetDeviceNodeCount(ULONG *NodeSize, - ULONG *NodeCount); -ULONG PnpBiosGetDeviceNode(UCHAR *NodeId, - UCHAR *NodeBuffer); - -/* EOF */ diff --git a/reactos/boot/freeldr/freeldr/include/arch/amd64/machpc.h b/reactos/boot/freeldr/freeldr/include/arch/amd64/machpc.h deleted file mode 100644 index 2205524d590..00000000000 --- a/reactos/boot/freeldr/freeldr/include/arch/amd64/machpc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* $Id: machpc.h 32135 2008-02-05 11:13:17Z ros-arm-bringup $ - * - * FreeLoader - * - * Copyright (C) 2003 Eric Kohl - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#ifndef __MEMORY_H -#include "mm.h" -#endif - -#define MachInit PcMachInit -VOID PcMachInit(const char *CmdLine); - -VOID PcConsPutChar(int Ch); -BOOLEAN PcConsKbHit(VOID); -int PcConsGetCh(VOID); - -VOID PcVideoClearScreen(UCHAR Attr); -VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init); -VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth); -ULONG PcVideoGetBufferSize(VOID); -VOID PcVideoSetTextCursorPosition(ULONG X, ULONG Y); -VOID PcVideoHideShowTextCursor(BOOLEAN Show); -VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y); -VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer); -BOOLEAN PcVideoIsPaletteFixed(VOID); -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(IN BOOLEAN Setup); -VOID PcPrepareForReactOS(IN BOOLEAN Setup); - -ULONG PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize); - -BOOLEAN PcDiskGetBootPath(char *BootPath, unsigned Size); -BOOLEAN PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); -BOOLEAN PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); -BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry); -ULONG PcDiskGetCacheableBlockCount(ULONG DriveNumber); - -TIMEINFO* PcGetTime(VOID); - -PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID); - -/* EOF */ diff --git a/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h b/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h index 1668b4f4daa..3bc931076d3 100644 --- a/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h +++ b/reactos/boot/freeldr/freeldr/include/arch/arm/hardware.h @@ -35,3 +35,7 @@ extern ULONG SecondLevelDcacheSize; extern ULONG SecondLevelDcacheFillSize; extern ULONG SecondLevelIcacheSize; extern ULONG SecondLevelIcacheFillSize; + +extern ULONG gDiskReadBuffer, gFileSysBuffer; +#define DISKREADBUFFER gDiskReadBuffer +#define FILESYSBUFFER gFileSysBuffer diff --git a/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h b/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h deleted file mode 100644 index 9126b815fcc..00000000000 --- a/reactos/boot/freeldr/freeldr/include/arch/i386/realmode.h +++ /dev/null @@ -1,13 +0,0 @@ - - -/* These addresses specify the realmode "BSS section" */ -#define BSS_START HEX(7000) -#define BSS_CallbackAddress BSS_START + 0 -#define BSS_CallbackReturn BSS_START + 8 -#define BSS_BootDrive BSS_START + 16 -#define BSS_BootPartition BSS_START + 20 - -#define PE_LOAD_BASE HEX(9000) -#define IMAGE_DOS_HEADER_e_lfanew 36 -#define IMAGE_FILE_HEADER_SIZE 20 -#define IMAGE_OPTIONAL_HEADER_AddressOfEntryPoint 16 diff --git a/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h b/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h similarity index 96% rename from reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h rename to reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h index 5974067cd2b..34211664948 100644 --- a/reactos/boot/freeldr/freeldr/include/arch/i386/hardware.h +++ b/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h @@ -20,10 +20,6 @@ #pragma once -#ifndef __REGISTRY_H -#include "../../reactos/registry.h" -#endif - #define CONFIG_CMD(bus, dev_fn, where) \ (0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3)) @@ -85,7 +81,7 @@ VOID GetCpuid(ULONG Level, ULONGLONG RDTSC(VOID); /* i386pnp.S */ -ULONG PnpBiosSupported(VOID); +ULONG_PTR PnpBiosSupported(VOID); ULONG PnpBiosGetDeviceNodeCount(ULONG *NodeSize, ULONG *NodeCount); ULONG PnpBiosGetDeviceNode(UCHAR *NodeId, diff --git a/reactos/boot/freeldr/freeldr/include/arch/i386/machpc.h b/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h similarity index 100% rename from reactos/boot/freeldr/freeldr/include/arch/i386/machpc.h rename to reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h diff --git a/reactos/boot/freeldr/freeldr/include/arch/pc/pcbios.h b/reactos/boot/freeldr/freeldr/include/arch/pc/pcbios.h new file mode 100644 index 00000000000..61ff8df5211 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/include/arch/pc/pcbios.h @@ -0,0 +1,98 @@ +#ifndef __ASM__ + +#include +typedef struct +{ + unsigned long eax; + unsigned long ebx; + unsigned long ecx; + unsigned long edx; + + unsigned long esi; + unsigned long edi; + + unsigned short ds; + unsigned short es; + unsigned short fs; + unsigned short gs; + + unsigned long eflags; + +} DWORDREGS; + +typedef struct +{ + unsigned short ax, _upper_ax; + unsigned short bx, _upper_bx; + unsigned short cx, _upper_cx; + unsigned short dx, _upper_dx; + + unsigned short si, _upper_si; + unsigned short di, _upper_di; + + unsigned short ds; + unsigned short es; + unsigned short fs; + unsigned short gs; + + unsigned short flags, _upper_flags; + +} WORDREGS; + +typedef struct +{ + unsigned char al; + unsigned char ah; + unsigned short _upper_ax; + unsigned char bl; + unsigned char bh; + unsigned short _upper_bx; + unsigned char cl; + unsigned char ch; + unsigned short _upper_cx; + unsigned char dl; + unsigned char dh; + unsigned short _upper_dx; + + unsigned short si, _upper_si; + unsigned short di, _upper_di; + + unsigned short ds; + unsigned short es; + unsigned short fs; + unsigned short gs; + + unsigned short flags, _upper_flags; + +} BYTEREGS; + + +typedef union +{ + DWORDREGS x; + DWORDREGS d; + WORDREGS w; + BYTEREGS b; +} REGS; +#include + +// Int386() +// +// Real mode interrupt vector interface +// +// (E)FLAGS can *only* be returned by this function, not set. +// Make sure all memory pointers are in SEG:OFFS format and +// not linear addresses, unless the interrupt handler +// specifically handles linear addresses. +int Int386(int ivec, REGS* in, REGS* out); + +// This macro tests the Carry Flag +// If CF is set then the call failed (usually) +#define INT386_SUCCESS(regs) ((regs.x.eflags & I386FLAG_CF) == 0) + +void EnableA20(void); +VOID ChainLoadBiosBootSectorCode(VOID); // Implemented in boot.S +VOID SoftReboot(VOID); // Implemented in boot.S +VOID DetectHardware(VOID); // Implemented in hardware.c + +#endif /* ! __ASM__ */ diff --git a/reactos/boot/freeldr/freeldr/include/arch/i386/pxe.h b/reactos/boot/freeldr/freeldr/include/arch/pc/pxe.h similarity index 100% rename from reactos/boot/freeldr/freeldr/include/arch/i386/pxe.h rename to reactos/boot/freeldr/freeldr/include/arch/pc/pxe.h diff --git a/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h b/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h new file mode 100644 index 00000000000..a24ad5b78b4 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h @@ -0,0 +1,57 @@ + +#ifndef HEX +#define HEX(y) 0x##y +#endif + +/* Memory layout */ +#define STACK16ADDR HEX(7000) /* The 16-bit stack top will be at 0000:7000 */ +#define BSS_START HEX(7000) +#define FREELDR_BASE HEX(8000) +#define FREELDR_PE_BASE HEX(9000) +#define STACK32ADDR HEX(78000) /* The 32-bit stack top will be at 7000:8000, or 0x78000 */ +#define BIOSCALLBUFFER HEX(78000) /* Buffer to store temporary data for any Int386() call */ +#define BIOSCALLBUFSEGMENT HEX(7800) /* Buffer to store temporary data for any Int386() call */ +#define BIOSCALLBUFOFFSET HEX(0000) /* Buffer to store temporary data for any Int386() call */ +#define FILESYSBUFFER HEX(80000) /* Buffer to store file system data (e.g. cluster buffer for FAT) */ +#define DISKREADBUFFER HEX(90000) /* Buffer to store data read in from the disk via the BIOS */ +#define DISKREADBUFFER_SIZE 512 + +/* These addresses specify the realmode "BSS section" layout */ +#define BSS_CallbackAddress BSS_START + 0 +#define BSS_CallbackReturn BSS_START + 8 +#define BSS_BootDrive BSS_START + 16 +#define BSS_BootPartition BSS_START + 20 + +#ifdef _M_AMD64 +#define FrldrBootDrive *((PULONG)BSS_BootDrive) +#define FrldrBootPartition *((PULONG)BSS_BootPartition) +#endif + +// Flag Masks +#define I386FLAG_CF HEX(0001) // Carry Flag +#define I386FLAG_RESV1 HEX(0002) // Reserved - Must be 1 +#define I386FLAG_PF HEX(0004) // Parity Flag +#define I386FLAG_RESV2 HEX(0008) // Reserved - Must be 0 +#define I386FLAG_AF HEX(0010) // Auxiliary Flag +#define I386FLAG_RESV3 HEX(0020) // Reserved - Must be 0 +#define I386FLAG_ZF HEX(0040) // Zero Flag +#define I386FLAG_SF HEX(0080) // Sign Flag +#define I386FLAG_TF HEX(0100) // Trap Flag (Single Step) +#define I386FLAG_IF HEX(0200) // Interrupt Flag +#define I386FLAG_DF HEX(0400) // Direction Flag +#define I386FLAG_OF HEX(0800) // Overflow Flag + +#define CR0_PE_SET HEX(00000001) /* OR this value with CR0 to enable pmode */ +#define CR0_PE_CLR HEX(FFFFFFFE) /* AND this value with CR0 to disable pmode */ + +/* Defines needed for switching between real and protected mode */ +#ifdef _M_IX86 +#define NULL_DESC HEX(00) /* NULL descriptor */ +#define PMODE_CS HEX(08) /* PMode code selector, base 0 limit 4g */ +#define PMODE_DS HEX(10) /* PMode data selector, base 0 limit 4g */ +#define RMODE_CS HEX(18) /* RMode code selector, base 0 limit 64k */ +#define RMODE_DS HEX(20) /* RMode data selector, base 0 limit 64k */ +#endif + +/* Makes "x" a global variable or label */ +#define EXTERN(x) .global x; x: diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index 3545c2c8f64..b229f874ac9 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -29,6 +29,7 @@ #define ROUND_UP(n, align) \ ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) +/* public headers */ #define NTOSAPI #define printf TuiPrintf #include @@ -45,78 +46,80 @@ #include #include #include -#include -#include #include +#include +#include +#include +#include +#include + +/* internal headers */ +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include +#include +#include #include -#include -#include + /* file system headers */ #include #include #include #include #include + /* ui support */ #include #include #include #include -/* arch files */ + +/* arch specific includes */ #if defined(_M_IX86) #include #include -#include #include -#include #include #include -#include +#include +#include +#include +#include +#include #include +#elif defined(_M_AMD64) +#include +#include +#include +#include +#include +#include +#include #elif defined(_M_PPC) #include #elif defined(_M_ARM) #include #elif defined(_M_MIPS) #include -#elif defined(_M_AMD64) -#include -#include -#include -#include #endif -/* misc files */ -#include -#include -#include -#include -#include -/* Needed by boot manager */ -#include -#include -#include -/* Externals */ -#include -#include -/* Needed if debuging is enabled */ -#include -/* Swap */ -#include -/* Internal shared PCI header */ -#include VOID BootMain(LPSTR CmdLine); VOID RunLoader(VOID);