1 /* ----------------------------------------------------------------------- *
3 * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
4 * Copyright 2012 Intel Corporation; author: H. Peter Anvin
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall
16 * be included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
27 * ----------------------------------------------------------------------- */
32 * Definitions used to boot a Linux kernel
35 #ifndef _SYSLINUX_LINUX_H
36 #define _SYSLINUX_LINUX_H
40 #include <klibc/compiler.h>
42 /* A chunk of an initramfs. These are kept as a doubly-linked
43 circular list with headnode; the headnode is distinguished by
44 having len == 0. The data pointer can be NULL if data_len is zero;
45 if data_len < len then the balance of the region is zeroed. */
48 struct initramfs
*prev
, *next
;
54 #define INITRAMFS_MAX_ALIGN 4096
56 struct setup_data_header
{
63 struct setup_data
*prev
, *next
;
65 struct setup_data_header hdr
;
69 #define SETUP_E820_EXT 1
72 #define XLF_KERNEL_64 (1 << 0)
73 #define XLF_CAN_BE_LOADED_ABOVE_4G (1 << 1)
74 #define XLF_EFI_HANDOVER_32 (1 << 2)
75 #define XLF_EFI_HANDOVER_64 (1 << 3)
78 uint8_t boot_sector_1
[0x0020];
79 uint16_t old_cmd_line_magic
;
80 uint16_t old_cmd_line_offset
;
81 uint8_t boot_sector_2
[0x01f1 - 0x0024];
92 uint32_t realmode_swtch
;
94 uint16_t kernel_version
;
95 uint8_t type_of_loader
;
97 uint16_t setup_move_size
;
98 uint32_t code32_start
;
99 uint32_t ramdisk_image
;
100 uint32_t ramdisk_size
;
101 uint32_t bootsect_kludge
;
102 uint16_t heap_end_ptr
;
104 uint32_t cmd_line_ptr
;
105 uint32_t initrd_addr_max
;
106 uint32_t kernel_alignment
;
107 uint8_t relocatable_kernel
;
108 uint8_t min_alignment
;
110 uint32_t cmdline_max_len
;
111 uint32_t hardware_subarch
;
112 uint64_t hardware_subarch_data
;
113 uint32_t payload_offset
;
114 uint32_t payload_length
;
116 uint64_t pref_address
;
118 uint32_t handover_offset
;
122 uint8_t orig_x
; /* 0x00 */
123 uint8_t orig_y
; /* 0x01 */
124 uint16_t ext_mem_k
; /* 0x02 */
125 uint16_t orig_video_page
; /* 0x04 */
126 uint8_t orig_video_mode
; /* 0x06 */
127 uint8_t orig_video_cols
; /* 0x07 */
128 uint8_t flags
; /* 0x08 */
129 uint8_t unused2
; /* 0x09 */
130 uint16_t orig_video_ega_bx
;/* 0x0a */
131 uint16_t unused3
; /* 0x0c */
132 uint8_t orig_video_lines
; /* 0x0e */
133 uint8_t orig_video_isVGA
; /* 0x0f */
134 uint16_t orig_video_points
;/* 0x10 */
136 /* VESA graphic mode -- linear frame buffer */
137 uint16_t lfb_width
; /* 0x12 */
138 uint16_t lfb_height
; /* 0x14 */
139 uint16_t lfb_depth
; /* 0x16 */
140 uint32_t lfb_base
; /* 0x18 */
141 uint32_t lfb_size
; /* 0x1c */
142 uint16_t cl_magic
, cl_offset
; /* 0x20 */
143 uint16_t lfb_linelength
; /* 0x24 */
144 uint8_t red_size
; /* 0x26 */
145 uint8_t red_pos
; /* 0x27 */
146 uint8_t green_size
; /* 0x28 */
147 uint8_t green_pos
; /* 0x29 */
148 uint8_t blue_size
; /* 0x2a */
149 uint8_t blue_pos
; /* 0x2b */
150 uint8_t rsvd_size
; /* 0x2c */
151 uint8_t rsvd_pos
; /* 0x2d */
152 uint16_t vesapm_seg
; /* 0x2e */
153 uint16_t vesapm_off
; /* 0x30 */
154 uint16_t pages
; /* 0x32 */
155 uint16_t vesa_attributes
; /* 0x34 */
156 uint32_t capabilities
; /* 0x36 */
157 uint8_t _reserved
[6]; /* 0x3a */
160 int syslinux_boot_linux(void *kernel_buf
, size_t kernel_size
,
161 struct initramfs
*initramfs
,
162 struct setup_data
*setup_data
,
165 /* Initramfs manipulation functions */
167 struct initramfs
*initramfs_init(void);
168 int initramfs_add_data(struct initramfs
*ihead
, const void *data
,
169 size_t data_len
, size_t len
, size_t align
);
170 int initramfs_mknod(struct initramfs
*ihead
, const char *filename
,
172 uint16_t mode
, size_t len
, uint32_t major
, uint32_t minor
);
173 int initramfs_add_file(struct initramfs
*ihead
, const void *data
,
174 size_t data_len
, size_t len
,
175 const char *filename
, int do_mkdir
, uint32_t mode
);
176 int initramfs_load_file(struct initramfs
*ihead
, const char *src_filename
,
177 const char *dst_filename
, int do_mkdir
, uint32_t mode
);
178 int initramfs_add_trailer(struct initramfs
*ihead
);
179 int initramfs_load_archive(struct initramfs
*ihead
, const char *filename
);
181 /* Get the combined size of the initramfs */
182 static inline uint32_t initramfs_size(struct initramfs
*initramfs
)
184 struct initramfs
*ip
;
190 for (ip
= initramfs
->next
; ip
->len
; ip
= ip
->next
) {
191 size
= (size
+ ip
->align
- 1) & ~(ip
->align
- 1); /* Alignment */
198 /* Setup data manipulation functions */
200 struct setup_data
*setup_data_init(void);
201 int setup_data_add(struct setup_data
*head
, uint32_t type
,
202 const void *data
, size_t data_len
);
203 int setup_data_load(struct setup_data
*head
, uint32_t type
,
204 const char *filename
);
206 #endif /* _SYSLINUX_LINUX_H */