Alex Ionescu <ionucu@videotron.ca>
[reactos.git] / reactos / boot / freeldr / freeldr / include / multiboot.h
1 /* multiboot.h - the header for Multiboot */
2 /* Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18
19 #ifndef __MULTIBOOT_H
20 #define __MULTIBOOT_H
21
22 /* Macros. */
23
24 /* The magic number for the Multiboot header. */
25 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002
26
27 /* The flags for the Multiboot header. */
28 #define MULTIBOOT_HEADER_FLAGS 0x00010003
29
30 /* The magic number passed by a Multiboot-compliant boot loader. */
31 #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
32
33 /* The size of our stack (16KB). */
34 #define STACK_SIZE 0x4000
35
36 /* C symbol format. HAVE_ASM_USCORE is defined by configure. */
37 #ifdef HAVE_ASM_USCORE
38 # define EXT_C(sym) _ ## sym
39 #else
40 # define EXT_C(sym) sym
41 #endif
42
43 #define MB_INFO_FLAG_MEM_SIZE 0x00000001
44 #define MB_INFO_FLAG_BOOT_DEVICE 0x00000002
45 #define MB_INFO_FLAG_COMMAND_LINE 0x00000004
46 #define MB_INFO_FLAG_MODULES 0x00000008
47 #define MB_INFO_FLAG_AOUT_SYMS 0x00000010
48 #define MB_INFO_FLAG_ELF_SYMS 0x00000020
49 #define MB_INFO_FLAG_MEMORY_MAP 0x00000040
50 #define MB_INFO_FLAG_DRIVES 0x00000080
51 #define MB_INFO_FLAG_CONFIG_TABLE 0x00000100
52 #define MB_INFO_FLAG_BOOT_LOADER_NAME 0x00000200
53 #define MB_INFO_FLAG_APM_TABLE 0x00000400
54 #define MB_INFO_FLAG_GRAPHICS_TABLE 0x00000800
55 #define MB_INFO_FLAG_ACPI_TABLE 0x00001000
56
57 #ifndef ASM
58 /* Do not include here in boot.S. */
59
60 /* Types. */
61
62 /* The Multiboot header. */
63 typedef struct multiboot_header
64 {
65 unsigned long magic;
66 unsigned long flags;
67 unsigned long checksum;
68 unsigned long header_addr;
69 unsigned long load_addr;
70 unsigned long load_end_addr;
71 unsigned long bss_end_addr;
72 unsigned long entry_addr;
73 } multiboot_header_t;
74
75 /* The symbol table for a.out. */
76 typedef struct aout_symbol_table
77 {
78 unsigned long tabsize;
79 unsigned long strsize;
80 unsigned long addr;
81 unsigned long reserved;
82 } aout_symbol_table_t;
83
84 /* The section header table for ELF. */
85 typedef struct elf_section_header_table
86 {
87 unsigned long num;
88 unsigned long size;
89 unsigned long addr;
90 unsigned long shndx;
91 } elf_section_header_table_t;
92
93 typedef struct _LOADER_PARAMETER_BLOCK
94 {
95 ULONG Flags;
96 ULONG MemLower;
97 ULONG MemHigher;
98 ULONG BootDevice;
99 ULONG CommandLine;
100 ULONG ModsCount;
101 ULONG ModsAddr;
102 UCHAR Syms[12];
103 ULONG MmapLength;
104 ULONG MmapAddr;
105 ULONG DrivesCount;
106 ULONG DrivesAddr;
107 ULONG ConfigTable;
108 ULONG BootLoaderName;
109 ULONG PageDirectoryStart;
110 ULONG PageDirectoryEnd;
111 ULONG KernelBase;
112 } LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK;
113
114 /* The module structure. */
115 typedef struct _FRLDR_MODULE {
116 ULONG_PTR ModuleStart;
117 ULONG_PTR ModuleEnd;
118 LPSTR ModuleName;
119 ULONG Reserved;
120 } FRLDR_MODULE, *PFRLDR_MODULE;
121
122 /* The memory map. Be careful that the offset 0 is base_addr_low
123 but no size. */
124 typedef struct memory_map
125 {
126 //unsigned long size;
127 unsigned long base_addr_low;
128 unsigned long base_addr_high;
129 unsigned long length_low;
130 unsigned long length_high;
131 unsigned long type;
132 unsigned long reserved;
133 } memory_map_t;
134
135
136 LOADER_PARAMETER_BLOCK LoaderBlock; /* Multiboot info structure passed to kernel */
137 char multiboot_kernel_cmdline[255]; // Command line passed to kernel
138 FRLDR_MODULE multiboot_modules[64]; // Array to hold boot module info loaded for the kernel
139 char multiboot_module_strings[64][256]; // Array to hold module names
140 unsigned long multiboot_memory_map_descriptor_size;
141 memory_map_t multiboot_memory_map[32]; // Memory map
142
143
144 void boot_reactos(void);
145
146 #include "fs.h" // Included FILE structure definition
147
148 BOOL
149 STDCALL
150 FrLdrBootReactOs(VOID);
151
152 BOOL
153 STDCALL
154 FrLdrMapKernel(FILE *KernelImage);
155
156 ULONG_PTR
157 STDCALL
158 FrLdrCreateModule(LPSTR ModuleName);
159
160 ULONG_PTR
161 STDCALL
162 FrLdrLoadModule(FILE *ModuleImage,
163 LPSTR ModuleName,
164 PULONG ModuleSize);
165
166 BOOL
167 STDCALL
168 FrLdrLoadKernel(PCHAR szFileName,
169 INT nPos);
170
171 BOOL
172 FrLdrLoadNlsFile(PCHAR szSystemRoot,
173 PCHAR szErrorOut);
174
175 BOOL
176 FrLdrLoadDriver(PCHAR szFileName,
177 INT nPos);
178 BOOL
179 LoadSymbolFile(PCHAR szSystemRoot,
180 PCHAR ModuleName,
181 INT nPos);
182
183 VOID
184 FrLdrLoadBootDrivers(PCHAR szSystemRoot,
185 INT nPos);
186
187 BOOL
188 STDCALL
189 FrLdrCloseModule(ULONG_PTR ModuleBase,
190 ULONG dwModuleSize);
191
192 VOID
193 STDCALL
194 FrLdrStartup(ULONG Magic);
195
196 VOID
197 FASTCALL
198 FrLdrGetKernelBase(VOID);
199
200 VOID
201 FASTCALL
202 FrLdrSetupPae(ULONG Magic);
203
204 VOID
205 FASTCALL
206 FrLdrGetPaeMode(VOID);
207
208 VOID
209 FASTCALL
210 FrLdrSetupPageDirectory(VOID);
211
212 VOID
213 LoadAndBootReactOS(PUCHAR OperatingSystemName);
214
215 VOID FASTCALL AsmCode(VOID);
216 typedef VOID (FASTCALL *ASMCODE)(ULONG Magic,
217 PLOADER_PARAMETER_BLOCK LoaderBlock);
218
219 int GetBootPartition(char *OperatingSystemName);
220
221
222
223 #endif /* ! ASM */
224
225
226 #endif // defined __MULTIBOOT_H