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