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