Skip to content

Commit

Permalink
Make asm-x86/bootparam.h includable from userspace.
Browse files Browse the repository at this point in the history
To actually write a bootloader (or, say, the lguest launcher)
currently requires duplication of these structures.  Making them
includable from userspace is much nicer.

We merge the common userspace-required definitions of e820_32/64.h
into e820.h for export.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Rusty Russell committed Oct 23, 2007
1 parent 9525ca0 commit ee8e7cf
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 225 deletions.
2 changes: 1 addition & 1 deletion Documentation/lguest/lguest.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
#include "../../include/linux/lguest_launcher.h"
#include "../../include/asm-x86/e820_32.h"
#include "../../include/asm-x86/e820.h"
/*:*/

#define PAGE_PRESENT 0x7 /* Present, RW, Execute */
Expand Down
3 changes: 3 additions & 0 deletions include/asm-x86/Kbuild
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include include/asm-generic/Kbuild.asm

header-y += boot.h
header-y += bootparam.h
header-y += debugreg.h
header-y += ldt.h
header-y += msr-index.h
Expand All @@ -14,8 +15,10 @@ unifdef-y += a.out_32.h
unifdef-y += a.out_64.h
unifdef-y += byteorder_32.h
unifdef-y += byteorder_64.h
unifdef-y += e820.h
unifdef-y += elf_32.h
unifdef-y += elf_64.h
unifdef-y += ist.h
unifdef-y += mce.h
unifdef-y += msgbuf_32.h
unifdef-y += msgbuf_64.h
Expand Down
108 changes: 54 additions & 54 deletions include/asm-x86/bootparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,85 +10,85 @@
#include <video/edid.h>

struct setup_header {
u8 setup_sects;
u16 root_flags;
u32 syssize;
u16 ram_size;
__u8 setup_sects;
__u16 root_flags;
__u32 syssize;
__u16 ram_size;
#define RAMDISK_IMAGE_START_MASK 0x07FF
#define RAMDISK_PROMPT_FLAG 0x8000
#define RAMDISK_LOAD_FLAG 0x4000
u16 vid_mode;
u16 root_dev;
u16 boot_flag;
u16 jump;
u32 header;
u16 version;
u32 realmode_swtch;
u16 start_sys;
u16 kernel_version;
u8 type_of_loader;
u8 loadflags;
__u16 vid_mode;
__u16 root_dev;
__u16 boot_flag;
__u16 jump;
__u32 header;
__u16 version;
__u32 realmode_swtch;
__u16 start_sys;
__u16 kernel_version;
__u8 type_of_loader;
__u8 loadflags;
#define LOADED_HIGH (1<<0)
#define KEEP_SEGMENTS (1<<6)
#define CAN_USE_HEAP (1<<7)
u16 setup_move_size;
u32 code32_start;
u32 ramdisk_image;
u32 ramdisk_size;
u32 bootsect_kludge;
u16 heap_end_ptr;
u16 _pad1;
u32 cmd_line_ptr;
u32 initrd_addr_max;
u32 kernel_alignment;
u8 relocatable_kernel;
u8 _pad2[3];
u32 cmdline_size;
u32 hardware_subarch;
u64 hardware_subarch_data;
__u16 setup_move_size;
__u32 code32_start;
__u32 ramdisk_image;
__u32 ramdisk_size;
__u32 bootsect_kludge;
__u16 heap_end_ptr;
__u16 _pad1;
__u32 cmd_line_ptr;
__u32 initrd_addr_max;
__u32 kernel_alignment;
__u8 relocatable_kernel;
__u8 _pad2[3];
__u32 cmdline_size;
__u32 hardware_subarch;
__u64 hardware_subarch_data;
} __attribute__((packed));

struct sys_desc_table {
u16 length;
u8 table[14];
__u16 length;
__u8 table[14];
};

struct efi_info {
u32 _pad1;
u32 efi_systab;
u32 efi_memdesc_size;
u32 efi_memdesc_version;
u32 efi_memmap;
u32 efi_memmap_size;
u32 _pad2[2];
__u32 _pad1;
__u32 efi_systab;
__u32 efi_memdesc_size;
__u32 efi_memdesc_version;
__u32 efi_memmap;
__u32 efi_memmap_size;
__u32 _pad2[2];
};

/* The so-called "zeropage" */
struct boot_params {
struct screen_info screen_info; /* 0x000 */
struct apm_bios_info apm_bios_info; /* 0x040 */
u8 _pad2[12]; /* 0x054 */
__u8 _pad2[12]; /* 0x054 */
struct ist_info ist_info; /* 0x060 */
u8 _pad3[16]; /* 0x070 */
u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
__u8 _pad3[16]; /* 0x070 */
__u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
__u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
struct sys_desc_table sys_desc_table; /* 0x0a0 */
u8 _pad4[144]; /* 0x0b0 */
__u8 _pad4[144]; /* 0x0b0 */
struct edid_info edid_info; /* 0x140 */
struct efi_info efi_info; /* 0x1c0 */
u32 alt_mem_k; /* 0x1e0 */
u32 scratch; /* Scratch field! */ /* 0x1e4 */
u8 e820_entries; /* 0x1e8 */
u8 eddbuf_entries; /* 0x1e9 */
u8 edd_mbr_sig_buf_entries; /* 0x1ea */
u8 _pad6[6]; /* 0x1eb */
__u32 alt_mem_k; /* 0x1e0 */
__u32 scratch; /* Scratch field! */ /* 0x1e4 */
__u8 e820_entries; /* 0x1e8 */
__u8 eddbuf_entries; /* 0x1e9 */
__u8 edd_mbr_sig_buf_entries; /* 0x1ea */
__u8 _pad6[6]; /* 0x1eb */
struct setup_header hdr; /* setup header */ /* 0x1f1 */
u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
__u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
__u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
struct e820entry e820_map[E820MAX]; /* 0x2d0 */
u8 _pad8[48]; /* 0xcd0 */
__u8 _pad8[48]; /* 0xcd0 */
struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */
u8 _pad9[276]; /* 0xeec */
__u8 _pad9[276]; /* 0xeec */
} __attribute__((packed));

#endif /* _ASM_BOOTPARAM_H */
28 changes: 28 additions & 0 deletions include/asm-x86/e820.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
#ifndef __ASM_E820_H
#define __ASM_E820_H
#define E820MAP 0x2d0 /* our map */
#define E820MAX 128 /* number of entries in E820MAP */
#define E820NR 0x1e8 /* # entries in E820MAP */

#define E820_RAM 1
#define E820_RESERVED 2
#define E820_ACPI 3
#define E820_NVS 4

#ifndef __ASSEMBLY__
struct e820entry {
__u64 addr; /* start of memory segment */
__u64 size; /* size of memory segment */
__u32 type; /* type of memory segment */
} __attribute__((packed));

struct e820map {
__u32 nr_map;
struct e820entry map[E820MAX];
};
#endif /* __ASSEMBLY__ */

#ifdef __KERNEL__
#ifdef CONFIG_X86_32
# include "e820_32.h"
#else
# include "e820_64.h"
#endif
#endif /* __KERNEL__ */

#endif /* __ASM_E820_H */
21 changes: 0 additions & 21 deletions include/asm-x86/e820_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,10 @@
#ifndef __E820_HEADER
#define __E820_HEADER

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

#define E820_RAM 1
#define E820_RESERVED 2
#define E820_ACPI 3
#define E820_NVS 4

#define HIGH_MEMORY (1024*1024)

#ifndef __ASSEMBLY__

struct e820entry {
u64 addr; /* start of memory segment */
u64 size; /* size of memory segment */
u32 type; /* type of memory segment */
} __attribute__((packed));

struct e820map {
u32 nr_map;
struct e820entry map[E820MAX];
};

extern struct e820map e820;

extern int e820_all_mapped(unsigned long start, unsigned long end,
Expand All @@ -56,5 +36,4 @@ static inline void e820_mark_nosave_regions(void)
#endif

#endif/*!__ASSEMBLY__*/

#endif/*__E820_HEADER*/
20 changes: 0 additions & 20 deletions include/asm-x86/e820_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,7 @@
#ifndef __E820_HEADER
#define __E820_HEADER

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

#define E820_RAM 1
#define E820_RESERVED 2
#define E820_ACPI 3
#define E820_NVS 4

#ifndef __ASSEMBLY__
struct e820entry {
u64 addr; /* start of memory segment */
u64 size; /* size of memory segment */
u32 type; /* type of memory segment */
} __attribute__((packed));

struct e820map {
u32 nr_map;
struct e820entry map[E820MAX];
};

extern unsigned long find_e820_area(unsigned long start, unsigned long end,
unsigned size);
extern void add_memory_region(unsigned long start, unsigned long size,
Expand Down
12 changes: 6 additions & 6 deletions include/asm-x86/ist.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
*/


#ifdef __KERNEL__

#include <linux/types.h>

struct ist_info {
u32 signature;
u32 command;
u32 event;
u32 perf_level;
__u32 signature;
__u32 command;
__u32 event;
__u32 perf_level;
};

#ifdef __KERNEL__

extern struct ist_info ist_info;

#endif /* __KERNEL__ */
Expand Down
2 changes: 2 additions & 0 deletions include/linux/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ unifdef-y += cyclades.h
unifdef-y += dccp.h
unifdef-y += dirent.h
unifdef-y += dlm.h
unifdef-y += edd.h
unifdef-y += elfcore.h
unifdef-y += errno.h
unifdef-y += errqueue.h
Expand Down Expand Up @@ -306,6 +307,7 @@ unifdef-y += rtc.h
unifdef-y += rtnetlink.h
unifdef-y += scc.h
unifdef-y += sched.h
unifdef-y += screen_info.h
unifdef-y += sdla.h
unifdef-y += selinux_netlink.h
unifdef-y += sem.h
Expand Down
30 changes: 15 additions & 15 deletions include/linux/apm_bios.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@
* General Public License for more details.
*/

typedef unsigned short apm_event_t;
typedef unsigned short apm_eventinfo_t;
#include <linux/types.h>

struct apm_bios_info {
__u16 version;
__u16 cseg;
__u32 offset;
__u16 cseg_16;
__u16 dseg;
__u16 flags;
__u16 cseg_len;
__u16 cseg_16_len;
__u16 dseg_len;
};

#ifdef __KERNEL__

#include <linux/types.h>
typedef unsigned short apm_event_t;
typedef unsigned short apm_eventinfo_t;

#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8)
#define APM_CS_16 (APM_CS + 8)
#define APM_DS (APM_CS_16 + 8)

struct apm_bios_info {
u16 version;
u16 cseg;
u32 offset;
u16 cseg_16;
u16 dseg;
u16 flags;
u16 cseg_len;
u16 cseg_16_len;
u16 dseg_len;
};

/* Results of APM Installation Check */
#define APM_16_BIT_SUPPORT 0x0001
#define APM_32_BIT_SUPPORT 0x0002
Expand Down
Loading

0 comments on commit ee8e7cf

Please sign in to comment.