Sync to trunk head(r38096)
[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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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_AMD64)
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 HYPERSPACE_BASE 0xC0400000
45 #define HAL_BASE 0xFFC00000
46 #define APIC_BASE 0xFFFE0000
47
48 #define LowMemPageTableIndex 0
49 #define StartupPageTableIndex (STARTUP_BASE >> 22)
50 #define HyperspacePageTableIndex (HYPERSPACE_BASE >> 22)
51 #define HalPageTableIndex (HAL_BASE >> 22)
52
53 typedef struct _PAGE_DIRECTORY_X86
54 {
55 HARDWARE_PTE Pde[1024];
56 } PAGE_DIRECTORY_X86, *PPAGE_DIRECTORY_X86;
57
58 #endif
59
60 ///////////////////////////////////////////////////////////////////////////////////////
61 //
62 // ReactOS Loading Functions
63 //
64 ///////////////////////////////////////////////////////////////////////////////////////
65 VOID LoadAndBootReactOS(PCSTR OperatingSystemName);
66
67 ///////////////////////////////////////////////////////////////////////////////////////
68 //
69 // ReactOS Setup Loader Functions
70 //
71 ///////////////////////////////////////////////////////////////////////////////////////
72 VOID ReactOSRunSetupLoader(VOID);
73
74 ///////////////////////////////////////////////////////////////////////////////////////
75 //
76 // ARC Path Functions
77 //
78 ///////////////////////////////////////////////////////////////////////////////////////
79 BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* BootPartition);
80 VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, ULONG Disk, ULONG Partition);
81 ULONG ConvertArcNameToBiosDriveNumber(PCHAR ArcPath);
82
83 ///////////////////////////////////////////////////////////////////////////////////////
84 //
85 // Loader Functions And Definitions
86 //
87 ///////////////////////////////////////////////////////////////////////////////////////
88 extern ROS_LOADER_PARAMETER_BLOCK LoaderBlock; /* Multiboot info structure passed to kernel */
89 extern char reactos_kernel_cmdline[255]; // Command line passed to kernel
90 extern LOADER_MODULE reactos_modules[64]; // Array to hold boot module info loaded for the kernel
91 extern char reactos_module_strings[64][256]; // Array to hold module names
92 typedef struct _reactos_mem_data {
93 unsigned long memory_map_descriptor_size;
94 memory_map_t memory_map[32]; // Memory map
95 } reactos_mem_data_t;
96 extern reactos_mem_data_t reactos_mem_data;
97 #define reactos_memory_map_descriptor_size reactos_mem_data.memory_map_descriptor_size
98 #define reactos_memory_map reactos_mem_data.memory_map
99
100 VOID FASTCALL FrLdrSetupPae(ULONG Magic);
101 VOID FASTCALL FrLdrSetupPageDirectory(VOID);
102 VOID FASTCALL FrLdrGetPaeMode(VOID);
103 BOOLEAN NTAPI FrLdrMapKernel(FILE *KernelImage);
104 ULONG_PTR NTAPI FrLdrCreateModule(LPCSTR ModuleName);
105 ULONG_PTR NTAPI FrLdrLoadModule(FILE *ModuleImage, LPCSTR ModuleName, PULONG ModuleSize);
106 BOOLEAN NTAPI FrLdrCloseModule(ULONG_PTR ModuleBase, ULONG dwModuleSize);
107 VOID NTAPI FrLdrStartup(ULONG Magic);
108 typedef VOID (FASTCALL *ROS_KERNEL_ENTRY_POINT)(ULONG Magic, PROS_LOADER_PARAMETER_BLOCK LoaderBlock);
109
110 PVOID
111 NTAPI
112 FrLdrMapImage(
113 IN FILE *Image,
114 IN PCHAR ShortName,
115 IN ULONG ImageType
116 );
117
118 PVOID
119 NTAPI
120 FrLdrReadAndMapImage(
121 IN FILE *Image,
122 IN PCHAR ShortName,
123 IN ULONG ImageType
124 );
125
126 PVOID
127 NTAPI
128 FrLdrLoadImage(
129 IN PCHAR szFileName,
130 IN INT nPos,
131 IN ULONG ImageType
132 );
133
134 #endif // defined __REACTOS_H