1*199767f8SToomas Soome /*
2*199767f8SToomas Soome  * This file and its contents are supplied under the terms of the
3*199767f8SToomas Soome  * Common Development and Distribution License ("CDDL"), version 1.0.
4*199767f8SToomas Soome  * You may only use this file in accordance with the terms of version
5*199767f8SToomas Soome  * 1.0 of the CDDL.
6*199767f8SToomas Soome  *
7*199767f8SToomas Soome  * A full copy of the text of the CDDL should have accompanied this
8*199767f8SToomas Soome  * source.  A copy of the CDDL is also available via the Internet at
9*199767f8SToomas Soome  * http://www.illumos.org/license/CDDL.
10*199767f8SToomas Soome  */
11*199767f8SToomas Soome 
12*199767f8SToomas Soome /*
13*199767f8SToomas Soome  * Copyright 2015 Toomas Soome <tsoome@me.com>
14*199767f8SToomas Soome  */
15*199767f8SToomas Soome 
16*199767f8SToomas Soome #ifndef _LINUX_H
17*199767f8SToomas Soome #define	_LINUX_H
18*199767f8SToomas Soome 
19*199767f8SToomas Soome #ifdef __cplusplus
20*199767f8SToomas Soome extern "C" {
21*199767f8SToomas Soome #endif
22*199767f8SToomas Soome 
23*199767f8SToomas Soome #ifndef ASM_FILE
24*199767f8SToomas Soome /* For the Linux/i386 boot protocol version 2.10.  */
25*199767f8SToomas Soome struct linux_kernel_header
26*199767f8SToomas Soome {
27*199767f8SToomas Soome   uint8_t code1[0x0020];
28*199767f8SToomas Soome   uint16_t cl_magic;               /* Magic number 0xA33F */
29*199767f8SToomas Soome   uint16_t cl_offset;              /* The offset of command line */
30*199767f8SToomas Soome   uint8_t code2[0x01F1 - 0x0020 - 2 - 2];
31*199767f8SToomas Soome   uint8_t setup_sects;             /* The size of the setup in sectors */
32*199767f8SToomas Soome   uint16_t root_flags;             /* If the root is mounted readonly */
33*199767f8SToomas Soome   uint16_t syssize;                /* obsolete */
34*199767f8SToomas Soome   uint16_t swap_dev;               /* obsolete */
35*199767f8SToomas Soome   uint16_t ram_size;               /* obsolete */
36*199767f8SToomas Soome   uint16_t vid_mode;               /* Video mode control */
37*199767f8SToomas Soome   uint16_t root_dev;               /* Default root device number */
38*199767f8SToomas Soome   uint16_t boot_flag;              /* 0xAA55 magic number */
39*199767f8SToomas Soome   uint16_t jump;                   /* Jump instruction */
40*199767f8SToomas Soome   uint32_t header;                 /* Magic signature "HdrS" */
41*199767f8SToomas Soome   uint16_t version;                /* Boot protocol version supported */
42*199767f8SToomas Soome   uint32_t realmode_swtch;         /* Boot loader hook */
43*199767f8SToomas Soome   uint16_t start_sys;              /* The load-low segment (obsolete) */
44*199767f8SToomas Soome   uint16_t kernel_version;         /* Points to kernel version string */
45*199767f8SToomas Soome   uint8_t type_of_loader;          /* Boot loader identifier */
46*199767f8SToomas Soome   uint8_t loadflags;               /* Boot protocol option flags */
47*199767f8SToomas Soome   uint16_t setup_move_size;        /* Move to high memory size */
48*199767f8SToomas Soome   uint32_t code32_start;           /* Boot loader hook */
49*199767f8SToomas Soome   uint32_t ramdisk_image;          /* initrd load address */
50*199767f8SToomas Soome   uint32_t ramdisk_size;           /* initrd size */
51*199767f8SToomas Soome   uint32_t bootsect_kludge;        /* obsolete */
52*199767f8SToomas Soome   uint16_t heap_end_ptr;           /* Free memory after setup end */
53*199767f8SToomas Soome   uint16_t pad1;                   /* Unused */
54*199767f8SToomas Soome   uint32_t cmd_line_ptr;           /* Points to the kernel command line */
55*199767f8SToomas Soome   uint32_t initrd_addr_max;        /* Highest address for initrd */
56*199767f8SToomas Soome   uint32_t kernel_alignment;
57*199767f8SToomas Soome   uint8_t relocatable;
58*199767f8SToomas Soome   uint8_t min_alignment;
59*199767f8SToomas Soome   uint8_t pad[2];
60*199767f8SToomas Soome   uint32_t cmdline_size;
61*199767f8SToomas Soome   uint32_t hardware_subarch;
62*199767f8SToomas Soome   uint64_t hardware_subarch_data;
63*199767f8SToomas Soome   uint32_t payload_offset;
64*199767f8SToomas Soome   uint32_t payload_length;
65*199767f8SToomas Soome   uint64_t setup_data;
66*199767f8SToomas Soome   uint64_t pref_address;
67*199767f8SToomas Soome   uint32_t init_size;
68*199767f8SToomas Soome } __attribute__ ((packed));
69*199767f8SToomas Soome #endif
70*199767f8SToomas Soome 
71*199767f8SToomas Soome #define	LINUX_VID_MODE_NORMAL		0xFFFF
72*199767f8SToomas Soome #define	LINUX_VID_MODE_EXTENDED		0xFFFE
73*199767f8SToomas Soome #define	LINUX_VID_MODE_ASK		0xFFFD
74*199767f8SToomas Soome 
75*199767f8SToomas Soome #define	BOOTSEC_SIGNATURE		0xAA55
76*199767f8SToomas Soome #define	LINUX_BOOT_LOADER_TYPE		0x72
77*199767f8SToomas Soome #define	LINUX_BZIMAGE_ADDR		0x100000
78*199767f8SToomas Soome #define	LINUX_CL_END_OFFSET		0x90FF
79*199767f8SToomas Soome #define	LINUX_CL_MAGIC			0xA33F
80*199767f8SToomas Soome #define	LINUX_CL_OFFSET			0x9000
81*199767f8SToomas Soome #define	LINUX_DEFAULT_SETUP_SECTS	4
82*199767f8SToomas Soome #define	LINUX_ESP			0x9000
83*199767f8SToomas Soome #define	LINUX_FLAG_BIG_KERNEL		0x1
84*199767f8SToomas Soome #define	LINUX_FLAG_CAN_USE_HEAP		0x80
85*199767f8SToomas Soome #define	LINUX_HEAP_END_OFFSET		(0x9000 - 0x200)
86*199767f8SToomas Soome #define	LINUX_MAGIC_SIGNATURE		0x53726448
87*199767f8SToomas Soome #define	LINUX_MAX_SETUP_SECTS		64
88*199767f8SToomas Soome #define	LINUX_OLD_REAL_MODE_ADDR	0x90000
89*199767f8SToomas Soome #define	LINUX_SETUP_MOVE_SIZE		0x9100
90*199767f8SToomas Soome #define	LINUX_ZIMAGE_ADDR		0x10000
91*199767f8SToomas Soome #define	LINUX_INITRD_MAX_ADDRESS	0x38000000
92*199767f8SToomas Soome 
93*199767f8SToomas Soome #ifdef __cplusplus
94*199767f8SToomas Soome }
95*199767f8SToomas Soome #endif
96*199767f8SToomas Soome 
97*199767f8SToomas Soome #endif /* _LINUX_H */