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