c51f70dab9fc81f5b0d65e08ec87c9e60c6bb849
[reactos.git] / boot / freeldr / freeldr / include / linux.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 #include <fs.h>
21 #include <oslist.h>
22
23 #ifndef __LINUX_H
24 #define __LINUX_H
25
26 #ifdef _M_IX86
27
28 #define LINUX_LOADER_TYPE_LILO 0x01
29 #define LINUX_LOADER_TYPE_LOADLIN 0x11
30 #define LINUX_LOADER_TYPE_BOOTSECT 0x21
31 #define LINUX_LOADER_TYPE_SYSLINUX 0x31
32 #define LINUX_LOADER_TYPE_ETHERBOOT 0x41
33 #define LINUX_LOADER_TYPE_FREELOADER 0x81
34
35 #define LINUX_COMMAND_LINE_MAGIC 0xA33F
36
37 #define LINUX_SETUP_HEADER_ID 0x53726448 // 'HdrS'
38
39 #define LINUX_BOOT_SECTOR_MAGIC 0xAA55
40
41 #define LINUX_KERNEL_LOAD_ADDRESS 0x100000
42
43 #define LINUX_FLAG_LOAD_HIGH 0x01
44 #define LINUX_FLAG_CAN_USE_HEAP 0x80
45
46 #define LINUX_MAX_INITRD_ADDRESS 0x38000000
47
48 #include <pshpack1.h>
49 typedef struct
50 {
51 UCHAR BootCode1[0x20];
52
53 USHORT CommandLineMagic;
54 USHORT CommandLineOffset;
55
56 UCHAR BootCode2[0x1CD];
57
58 UCHAR SetupSectors;
59 USHORT RootFlags;
60 USHORT SystemSize;
61 USHORT SwapDevice;
62 USHORT RamSize;
63 USHORT VideoMode;
64 USHORT RootDevice;
65 USHORT BootFlag; // 0xAA55
66
67 } LINUX_BOOTSECTOR, *PLINUX_BOOTSECTOR;
68
69 typedef struct
70 {
71 UCHAR JumpInstruction[2];
72 ULONG SetupHeaderSignature; // Signature for SETUP-header
73 USHORT Version; // Version number of header format
74 USHORT RealModeSwitch; // Default switch
75 USHORT SetupSeg; // SETUPSEG
76 USHORT StartSystemSeg;
77 USHORT KernelVersion; // Offset to kernel version string
78 UCHAR TypeOfLoader; // Loader ID
79 // =0, old one (LILO, Loadlin,
80 // Bootlin, SYSLX, bootsect...)
81 // else it is set by the loader:
82 // 0xTV: T=0 for LILO
83 // T=1 for Loadlin
84 // T=2 for bootsect-loader
85 // T=3 for SYSLX
86 // T=4 for ETHERBOOT
87 // V = version
88
89 UCHAR LoadFlags; // flags, unused bits must be zero (RFU)
90 // LOADED_HIGH = 1
91 // bit within loadflags,
92 // if set, then the kernel is loaded high
93 // CAN_USE_HEAP = 0x80
94 // if set, the loader also has set heap_end_ptr
95 // to tell how much space behind setup.S
96 // can be used for heap purposes.
97 // Only the loader knows what is free!
98
99 USHORT SetupMoveSize; // size to move, when we (setup) are not
100 // loaded at 0x90000. We will move ourselves
101 // to 0x90000 then just before jumping into
102 // the kernel. However, only the loader
103 // know how much of data behind us also needs
104 // to be loaded.
105
106 ULONG Code32Start; // here loaders can put a different
107 // start address for 32-bit code.
108 //
109 // 0x1000 = default for zImage
110 //
111 // 0x100000 = default for big kernel
112
113 ULONG RamdiskAddress; // address of loaded ramdisk image
114 // Here the loader (or kernel generator) puts
115 // the 32-bit address were it loaded the image.
116 ULONG RamdiskSize; // its size in bytes
117
118 USHORT BootSectKludgeOffset;
119 USHORT BootSectKludgeSegment;
120 USHORT HeapEnd; // space from here (exclusive) down to
121 // end of setup code can be used by setup
122 // for local heap purposes.
123 USHORT Pad1;
124 ULONG CommandLinePointer; // 32-bit pointer to the kernel command line
125 ULONG InitrdAddressMax; // Highest legal initrd address
126
127
128 } LINUX_SETUPSECTOR, *PLINUX_SETUPSECTOR;
129 #include <poppack.h>
130
131 // Implemented in linux.S
132 VOID __cdecl BootLinuxKernel(
133 IN ULONG KernelSize,
134 IN PVOID KernelCurrentLoadAddress,
135 IN PVOID KernelTargetLoadAddress,
136 IN UCHAR DriveNumber,
137 IN ULONG PartitionNumber);
138
139 ARC_STATUS
140 LoadAndBootLinux(
141 IN ULONG Argc,
142 IN PCHAR Argv[],
143 IN PCHAR Envp[]);
144
145 #endif // _M_IX86
146
147 #endif // defined __LINUX_H