e8c729704dcf63b1a8128f2c6d7656e0f7fe8a65
[reactos.git] / reactos / boot / freeldr / freeldr / include / arch / pc / x86common.h
1
2 #ifndef HEX
3 #define HEX(y) 0x##y
4 #endif
5
6 /* Memory layout */
7 //#ifdef _M_AMD64
8 #define PML4_ADDRESS HEX(1000) /* One page PML4 page table */
9 #define PDP_ADDRESS HEX(2000) /* One page PDP page table */
10 #define PD_ADDRESS HEX(3000) /* One page PD page table */
11 //#endif
12 #define STACK16ADDR HEX(6F00) /* The 16-bit stack top will be at 0000:6F00 */
13 #define BSS_START HEX(6F00)
14 #define FREELDR_BASE HEX(F800)
15 #define FREELDR_PE_BASE HEX(10000)
16 #define DISKREADBUFFER HEX(80000) /* Buffer to store data read in from the disk via the BIOS */
17 #define STACKLOWLIMIT HEX(90000)
18 #define STACK32ADDR HEX(98000) /* The 32-bit stack top will be at 9000:8000, or 0xA8000 */
19 #define STACK64ADDR HEX(98000) /* The 64-bit stack top will be at 98000 */
20 #define BIOSCALLBUFFER HEX(98000) /* Buffer to store temporary data for any Int386() call */
21 #define DISKREADBUFFER_SIZE HEX(10000)
22
23 #define BIOSCALLBUFSEGMENT (BIOSCALLBUFFER/16) /* Buffer to store temporary data for any Int386() call */
24 #define BIOSCALLBUFOFFSET HEX(0000) /* Buffer to store temporary data for any Int386() call */
25 #define BIOSCALLBUFSIZE PAGE_SIZE /* max is sizeof(VESA_SVGA_INFO) = 512 */
26
27 /* These addresses specify the realmode "BSS section" layout */
28 #define BSS_RealModeEntry (BSS_START + 0)
29 #define BSS_CallbackReturn (BSS_START + 4)
30 #define BSS_RegisterSet (BSS_START + 8) /* size = 40 */
31 #define BSS_IntVector (BSS_START + 52)
32 #define BSS_PxeEntryPoint (BSS_START + 56)
33 #define BSS_PxeBufferSegment (BSS_START + 60)
34 #define BSS_PxeBufferOffset (BSS_START + 64)
35 #define BSS_PxeFunction (BSS_START + 68)
36 #define BSS_PxeResult (BSS_START + 72)
37 #define BSS_PnpBiosEntryPoint (BSS_START + 76)
38 #define BSS_PnpBiosDataSegment (BSS_START + 80)
39 #define BSS_PnpBiosBufferSegment (BSS_START + 84)
40 #define BSS_PnpBiosBufferOffset (BSS_START + 88)
41 #define BSS_PnpNodeSize (BSS_START + 92)
42 #define BSS_PnpNodeCount (BSS_START + 96)
43 #define BSS_PnpNodeNumber (BSS_START + 100)
44 #define BSS_PnpResult (BSS_START + 104)
45 #define BSS_BootDrive (BSS_START + 108) // 1 byte
46 #define BSS_BootPartition (BSS_START + 109) // 1 byte
47
48
49 /* Realmode function IDs */
50 #define FNID_Int386 0
51 #define FNID_SoftReboot 1
52 #define FNID_ChainLoadBiosBootSectorCode 2
53 #define FNID_PxeCallApi 3
54 #define FNID_PnpBiosGetDeviceNodeCount 4
55 #define FNID_PnpBiosGetDeviceNode 5
56 #define FNID_BootLinuxKernel 6
57
58 /* Flag Masks */
59 #define CR0_PE_SET HEX(00000001) /* OR this value with CR0 to enable pmode */
60 #define CR0_PE_CLR HEX(FFFFFFFE) /* AND this value with CR0 to disable pmode */
61
62 /* Defines needed for switching between real and protected mode */
63 //#ifdef _M_IX86
64 #define NULL_DESC HEX(00) /* NULL descriptor */
65 #define PMODE_CS HEX(08) /* PMode code selector, base 0 limit 4g */
66 #define PMODE_DS HEX(10) /* PMode data selector, base 0 limit 4g */
67 #define RMODE_CS HEX(18) /* RMode code selector, base 0 limit 64k */
68 #define RMODE_DS HEX(20) /* RMode data selector, base 0 limit 64k */
69 //#else
70 /* Long mode selectors */
71 #define LMODE_CS HEX(10)
72 #define LMODE_DS HEX(18)
73 #define CMODE_CS HEX(30)
74 //#endif
75
76 /* Makes "x" a global variable or label */
77 #define EXTERN(x) .global x; x: