summaryrefslogtreecommitdiff
path: root/util/mkelfImage/linux-i386/x86-linux.h
blob: 521988815c1d80462981cf15dc4293a65304c536 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#ifndef X86_LINUX_H
#define X86_LINUX_H

#define E820MAP	0x2d0		/* our map */
#define E820MAX	32		/* number of entries in E820MAP */
#define E820NR	0x1e8		/* # entries in E820MAP */

#ifndef ASSEMBLY

struct e820entry {
	uint64_t addr;	/* start of memory segment */
	uint64_t size;	/* size of memory segment */
	uint32_t type;		/* type of memory segment */
#define E820_RAM	1
#define E820_RESERVED	2
#define E820_ACPI	3 /* usable as RAM once ACPI tables have been read */
#define E820_NVS	4
} __attribute__((packed));

/* FIXME expand on drive_info_struct... */
struct drive_info_struct {
	uint8_t dummy[32];
};
struct sys_desc_table {
	uint16_t length;
	uint8_t  table[318];
};

struct apm_bios_info {
	uint16_t version;       /* 0x40 */
	uint16_t cseg;		/* 0x42 */
	uint32_t offset;	/* 0x44 */
	uint16_t cseg_16;	/* 0x48 */
	uint16_t dseg;		/* 0x4a */
	uint16_t flags;		/* 0x4c */
	uint16_t cseg_len;	/* 0x4e */
	uint16_t cseg_16_len;	/* 0x50 */
	uint16_t dseg_len;	/* 0x52 */
	uint8_t  reserved[44];	/* 0x54 */
};


struct x86_linux_param_header {
	uint8_t  orig_x;			/* 0x00 */
	uint8_t  orig_y;			/* 0x01 */
	uint16_t ext_mem_k;			/* 0x02 -- EXT_MEM_K sits here */
	uint16_t orig_video_page;		/* 0x04 */
	uint8_t  orig_video_mode;		/* 0x06 */
	uint8_t  orig_video_cols;		/* 0x07 */
	uint16_t unused2;			/* 0x08 */
	uint16_t orig_video_ega_bx;		/* 0x0a */
	uint16_t unused3;			/* 0x0c */
	uint8_t	 orig_video_lines;		/* 0x0e */
	uint8_t	 orig_video_isVGA;		/* 0x0f */
	uint16_t orig_video_points;		/* 0x10 */

	/* VESA graphic mode -- linear frame buffer */
	uint16_t lfb_width;			/* 0x12 */
	uint16_t lfb_height;			/* 0x14 */
	uint16_t lfb_depth;			/* 0x16 */
	uint32_t lfb_base;			/* 0x18 */
	uint32_t lfb_size;			/* 0x1c */
	uint16_t cl_magic;			/* 0x20 */
#define CL_MAGIC_VALUE 0xA33F
	uint16_t cl_offset;			/* 0x22 */
	uint16_t lfb_linelength;		/* 0x24 */
	uint8_t	 red_size;			/* 0x26 */
	uint8_t	 red_pos;			/* 0x27 */
	uint8_t	 green_size;			/* 0x28 */
	uint8_t	 green_pos;			/* 0x29 */
	uint8_t	 blue_size;			/* 0x2a */
	uint8_t	 blue_pos;			/* 0x2b */
	uint8_t	 rsvd_size;			/* 0x2c */
	uint8_t	 rsvd_pos;			/* 0x2d */
	uint16_t vesapm_seg;			/* 0x2e */
	uint16_t vesapm_off;			/* 0x30 */
	uint16_t pages;				/* 0x32 */
	uint8_t  reserved4[12];			/* 0x34 -- 0x3f reserved for future expansion */

	struct apm_bios_info apm_bios_info;	/* 0x40 */
	struct drive_info_struct drive_info;	/* 0x80 */
	struct sys_desc_table sys_desc_table;	/* 0xa0 */
	uint32_t alt_mem_k;			/* 0x1e0 */
	uint8_t  reserved5[4];			/* 0x1e4 */
	uint8_t  e820_map_nr;			/* 0x1e8 */
	uint8_t  reserved6[8];			/* 0x1e9 */
	uint8_t  setup_sects;			/* 0x1f1 */
	uint16_t mount_root_rdonly;		/* 0x1f2 */
	uint8_t  reserved7[4];			/* 0x1f4 */
	uint16_t ramdisk_flags;			/* 0x1f8 */
#define RAMDISK_IMAGE_START_MASK  	0x07FF
#define RAMDISK_PROMPT_FLAG		0x8000
#define RAMDISK_LOAD_FLAG		0x4000
	uint16_t vid_mode;			/* 0x1fa */
	uint16_t root_dev;			/* 0x1fc */
	uint8_t  reserved9[1];			/* 0x1fe */
	uint8_t  aux_device_info;		/* 0x1ff */
	/* 2.00+ */
	uint8_t  reserved10[2];			/* 0x200 */
	uint8_t  header_magic[4];		/* 0x202 */
	uint16_t protocol_version;		/* 0x206 */
	uint8_t  reserved11[8];			/* 0x208 */
	uint8_t  loader_type;			/* 0x210 */
#define LOADER_TYPE_LOADLIN         1
#define LOADER_TYPE_BOOTSECT_LOADER 2
#define LOADER_TYPE_SYSLINUX        3
#define LOADER_TYPE_ETHERBOOT       4
#define LOADER_TYPE_UNKNOWN         0xFF
	uint8_t  loader_flags;			/* 0x211 */
	uint8_t  reserved12[2];			/* 0x212 */
	uint32_t kernel_start;			/* 0x214 */
	uint32_t initrd_start;			/* 0x218 */
	uint32_t initrd_size;			/* 0x21c */
	uint8_t  reserved13[4];			/* 0x220 */
	/* 2.01+ */
	uint16_t heap_end_ptr;			/* 0x224 */
	uint8_t  reserved14[2];			/* 0x226 */
	/* 2.02+ */
	uint32_t cmd_line_ptr;			/* 0x228 */
	/* 2.03+ */
	uint32_t initrd_addr_max;		/* 0x22c */
	uint8_t  reserved15[160];		/* 0x230 */
	struct e820entry e820_map[E820MAX];	/* 0x2d0 */
						/* 0x550 */
#define COMMAND_LINE_SIZE 256
};

struct x86_linux_header {
	uint8_t  reserved1[0x1f1];		/* 0x000 */
	uint8_t  setup_sects;			/* 0x1f1 */
	uint16_t root_flags;			/* 0x1f2 */
	uint8_t  reserved2[6];			/* 0x1f4 */
	uint16_t vid_mode;			/* 0x1fa */
	uint16_t root_dev;			/* 0x1fc */
	uint16_t boot_sector_magic;		/* 0x1fe */
	/* 2.00+ */
	uint8_t  reserved3[2];			/* 0x200 */
	uint8_t  header_magic[4];		/* 0x202 */
	uint16_t protocol_version;		/* 0x206 */
	uint32_t realmode_swtch;		/* 0x208 */
	uint16_t start_sys;			/* 0x20c */
	uint16_t kver_addr;			/* 0x20e */
	uint8_t  type_of_loader;		/* 0x210 */
	uint8_t  loadflags;			/* 0x211 */
	uint16_t setup_move_size;		/* 0x212 */
	uint32_t code32_start;			/* 0x214 */
	uint32_t ramdisk_image;			/* 0x218 */
	uint32_t ramdisk_size;			/* 0x21c */
	uint8_t  reserved4[4];			/* 0x220 */
	/* 2.01+ */
	uint16_t heap_end_ptr;			/* 0x224 */
	uint8_t  reserved5[2];			/* 0x226 */
	/* 2.02+ */
	uint32_t cmd_line_ptr;			/* 0x228 */
	/* 2.03+ */
	uint32_t initrd_addr_max;		/* 0x22c */
	uint8_t  tail[32*1024];			/* 0x230 */
} __attribute__ ((packed));

#endif /* ASSEMBLY */

#endif /* X86_LINUX_H */