- Move from using include guards to pragma once.
[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 #pragma once
21
22 /* Base Addres of Kernel in Physical Memory */
23 #define KERNEL_BASE_PHYS 0x800000
24
25 #if defined(_M_IX86)
26
27 /* Bits to shift to convert a Virtual Address into an Offset in the Page Table */
28 #define PFN_SHIFT 12
29
30 /* Bits to shift to convert a Virtual Address into an Offset in the Page Directory */
31 #define PDE_SHIFT 22
32 #define PDE_SHIFT_PAE 18
33
34 /* Converts a Physical Address Pointer into a Page Frame Number */
35 #define PaPtrToPfn(p) \
36 (((ULONG_PTR)&p) >> PFN_SHIFT)
37
38 /* Converts a Physical Address into a Page Frame Number */
39 #define PaToPfn(p) \
40 ((p) >> PFN_SHIFT)
41
42 #define STARTUP_BASE 0xC0000000
43 #define HAL_BASE 0xFFC00000
44 #define APIC_BASE 0xFFFE0000
45
46 #define LowMemPageTableIndex 0
47 #define StartupPageTableIndex (STARTUP_BASE >> 22)
48 #define HalPageTableIndex (HAL_BASE >> 22)
49
50 typedef struct _PAGE_DIRECTORY_X86
51 {
52 HARDWARE_PTE Pde[1024];
53 } PAGE_DIRECTORY_X86, *PPAGE_DIRECTORY_X86;
54
55 #endif
56
57 ///////////////////////////////////////////////////////////////////////////////////////
58 //
59 // ReactOS Loading Functions
60 //
61 ///////////////////////////////////////////////////////////////////////////////////////
62 VOID LoadAndBootReactOS(PCSTR OperatingSystemName);
63
64 ///////////////////////////////////////////////////////////////////////////////////////
65 //
66 // ReactOS Setup Loader Functions
67 //
68 ///////////////////////////////////////////////////////////////////////////////////////
69 VOID ReactOSRunSetupLoader(VOID);
70
71 ///////////////////////////////////////////////////////////////////////////////////////
72 //
73 // ARC Path Functions
74 //
75 ///////////////////////////////////////////////////////////////////////////////////////
76 BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* BootPartition);
77 VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, ULONG Disk, ULONG Partition);
78 ULONG ConvertArcNameToBiosDriveNumber(PCHAR ArcPath);
79
80 ///////////////////////////////////////////////////////////////////////////////////////
81 //
82 // Loader Functions And Definitions
83 //
84 ///////////////////////////////////////////////////////////////////////////////////////
85 extern ROS_LOADER_PARAMETER_BLOCK LoaderBlock; /* Multiboot info structure passed to kernel */
86 extern char reactos_kernel_cmdline[255]; // Command line passed to kernel
87 extern LOADER_MODULE reactos_modules[64]; // Array to hold boot module info loaded for the kernel
88 extern char reactos_module_strings[64][256]; // Array to hold module names
89 typedef struct _reactos_mem_data {
90 unsigned long memory_map_descriptor_size;
91 memory_map_t memory_map[32]; // Memory map
92 } reactos_mem_data_t;
93 extern reactos_mem_data_t reactos_mem_data;
94 #define reactos_memory_map_descriptor_size reactos_mem_data.memory_map_descriptor_size
95 #define reactos_memory_map reactos_mem_data.memory_map
96
97 VOID FASTCALL FrLdrSetupPae(ULONG Magic);
98 VOID FASTCALL FrLdrSetupPageDirectory(VOID);
99 VOID FASTCALL FrLdrGetPaeMode(VOID);
100 BOOLEAN NTAPI FrLdrMapKernel(PFILE KernelImage);
101 ULONG_PTR NTAPI FrLdrCreateModule(LPCSTR ModuleName);
102 ULONG_PTR NTAPI FrLdrLoadModule(PFILE ModuleImage, LPCSTR ModuleName, PULONG ModuleSize);
103 BOOLEAN NTAPI FrLdrCloseModule(ULONG_PTR ModuleBase, ULONG dwModuleSize);
104 VOID NTAPI FrLdrStartup(ULONG Magic);
105 typedef VOID (NTAPI *ROS_KERNEL_ENTRY_POINT)(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock);
106
107 PVOID
108 NTAPI
109 FrLdrMapImage(
110 IN PFILE Image,
111 IN PCHAR ShortName,
112 IN ULONG ImageType
113 );
114
115 PVOID
116 NTAPI
117 FrLdrReadAndMapImage(
118 IN PFILE Image,
119 IN PCHAR ShortName,
120 IN ULONG ImageType
121 );
122
123 PVOID
124 NTAPI
125 FrLdrLoadImage(
126 IN PCHAR szFileName,
127 IN INT nPos,
128 IN ULONG ImageType
129 );