de159735d351c1293f716070283843f9eaaca7f1
[reactos.git] / reactos / boot / freeldr / freeldr / include / reactos.h
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef __REACTOS_H
21 #define __REACTOS_H
22
23 /* Base Addres of Kernel in Physical Memory */
24 #define KERNEL_BASE_PHYS 0x800000
25
26 #if defined(_M_IX86)
27
28 /* Bits to shift to convert a Virtual Address into an Offset in the Page Table */
29 #define PFN_SHIFT 12
30
31 /* Bits to shift to convert a Virtual Address into an Offset in the Page Directory */
32 #define PDE_SHIFT 22
33 #define PDE_SHIFT_PAE 18
34
35 /* Converts a Physical Address Pointer into a Page Frame Number */
36 #define PaPtrToPfn(p) \
37 (((ULONG_PTR)&p) >> PFN_SHIFT)
38
39 /* Converts a Physical Address into a Page Frame Number */
40 #define PaToPfn(p) \
41 ((p) >> PFN_SHIFT)
42
43 #define STARTUP_BASE 0xC0000000
44 #define HAL_BASE 0xFFC00000
45 #define APIC_BASE 0xFFFE0000
46
47 #define LowMemPageTableIndex 0
48 #define StartupPageTableIndex (STARTUP_BASE >> 22)
49 #define HalPageTableIndex (HAL_BASE >> 22)
50
51 typedef struct _PAGE_DIRECTORY_X86
52 {
53 HARDWARE_PTE Pde[1024];
54 } PAGE_DIRECTORY_X86, *PPAGE_DIRECTORY_X86;
55
56 #endif
57
58 ///////////////////////////////////////////////////////////////////////////////////////
59 //
60 // ReactOS Loading Functions
61 //
62 ///////////////////////////////////////////////////////////////////////////////////////
63 VOID LoadAndBootReactOS(PCSTR OperatingSystemName);
64
65 ///////////////////////////////////////////////////////////////////////////////////////
66 //
67 // ReactOS Setup Loader Functions
68 //
69 ///////////////////////////////////////////////////////////////////////////////////////
70 VOID ReactOSRunSetupLoader(VOID);
71
72 ///////////////////////////////////////////////////////////////////////////////////////
73 //
74 // ARC Path Functions
75 //
76 ///////////////////////////////////////////////////////////////////////////////////////
77 BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* BootPartition);
78 VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, ULONG Disk, ULONG Partition);
79 ULONG ConvertArcNameToBiosDriveNumber(PCHAR ArcPath);
80
81 ///////////////////////////////////////////////////////////////////////////////////////
82 //
83 // Loader Functions And Definitions
84 //
85 ///////////////////////////////////////////////////////////////////////////////////////
86 extern ROS_LOADER_PARAMETER_BLOCK LoaderBlock; /* Multiboot info structure passed to kernel */
87 extern char reactos_kernel_cmdline[255]; // Command line passed to kernel
88 extern LOADER_MODULE reactos_modules[64]; // Array to hold boot module info loaded for the kernel
89 extern char reactos_module_strings[64][256]; // Array to hold module names
90 typedef struct _reactos_mem_data {
91 unsigned long memory_map_descriptor_size;
92 memory_map_t memory_map[32]; // Memory map
93 } reactos_mem_data_t;
94 extern reactos_mem_data_t reactos_mem_data;
95 #define reactos_memory_map_descriptor_size reactos_mem_data.memory_map_descriptor_size
96 #define reactos_memory_map reactos_mem_data.memory_map
97
98 VOID FASTCALL FrLdrSetupPae(ULONG Magic);
99 VOID FASTCALL FrLdrSetupPageDirectory(VOID);
100 VOID FASTCALL FrLdrGetPaeMode(VOID);
101 BOOLEAN NTAPI FrLdrMapKernel(PFILE KernelImage);
102 ULONG_PTR NTAPI FrLdrCreateModule(LPCSTR ModuleName);
103 ULONG_PTR NTAPI FrLdrLoadModule(PFILE ModuleImage, LPCSTR ModuleName, PULONG ModuleSize);
104 BOOLEAN NTAPI FrLdrCloseModule(ULONG_PTR ModuleBase, ULONG dwModuleSize);
105 VOID NTAPI FrLdrStartup(ULONG Magic);
106 typedef VOID (NTAPI *ROS_KERNEL_ENTRY_POINT)(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock);
107
108 PVOID
109 NTAPI
110 FrLdrMapImage(
111 IN PFILE Image,
112 IN PCHAR ShortName,
113 IN ULONG ImageType
114 );
115
116 PVOID
117 NTAPI
118 FrLdrReadAndMapImage(
119 IN PFILE Image,
120 IN PCHAR ShortName,
121 IN ULONG ImageType
122 );
123
124 PVOID
125 NTAPI
126 FrLdrLoadImage(
127 IN PCHAR szFileName,
128 IN INT nPos,
129 IN ULONG ImageType
130 );
131
132 #endif // defined __REACTOS_H