github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/bootstrap/linux_defns.h (about)

     1  /*
     2   * linux_defns.h: Linux kernel type definitions
     3   *
     4   * Copyright (c) 2006-2009, Intel Corporation
     5   * All rights reserved.
     6   *
     7   * Redistribution and use in source and binary forms, with or without
     8   * modification, are permitted provided that the following conditions
     9   * are met:
    10   *
    11   *   * Redistributions of source code must retain the above copyright
    12   *     notice, this list of conditions and the following disclaimer.
    13   *   * Redistributions in binary form must reproduce the above
    14   *     copyright notice, this list of conditions and the following
    15   *     disclaimer in the documentation and/or other materials provided
    16   *     with the distribution.
    17   *   * Neither the name of the Intel Corporation nor the names of its
    18   *     contributors may be used to endorse or promote products derived
    19   *     from this software without specific prior written permission.
    20   *
    21   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    22   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    23   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    24   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    25   * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    26   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    27   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    28   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    29   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    30   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    31   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    32   * OF THE POSSIBILITY OF SUCH DAMAGE.
    33   *
    34   */
    35  
    36  #ifndef __LINUX_DEFNS_H__
    37  #define __LINUX_DEFNS_H__
    38  
    39  #define SECTOR_SIZE (1 << 9)      /* 0x200 = 512B */
    40  
    41  #define KERNEL_HEADER_OFFSET    0x1F1
    42  
    43  /* linux kernel header */
    44  typedef struct __attribute__ ((packed)) {
    45      uint8_t  setup_sects;    /* The size of the setup in sectors */
    46          #define DEFAULT_SECTOR_NUM   4   /* default sector number 4 */
    47          #define MAX_SECTOR_NUM       64  /* max sector number 64 */
    48  
    49      uint16_t root_flags;     /* If set, the root is mounted readonly */
    50      uint32_t syssize;        /* The size of the 32-bit code in 16-byte paras */
    51      uint16_t ram_size;       /* DO NOT USE - for bootsect.S use only */
    52      uint16_t vid_mode;       /* Video mode control */
    53      uint16_t root_dev;       /* Default root device number */
    54      uint16_t boot_flag;      /* 0xAA55 magic number */
    55      uint16_t jump;           /* Jump instruction */
    56  
    57      uint32_t header;         /* Magic signature "HdrS" */
    58          #define HDRS_MAGIC          0x53726448
    59  
    60      uint16_t version;        /* Boot protocol version supported */
    61      uint32_t realmode_swtch; /* Boot loader hook */
    62      uint16_t start_sys;      /* The load-low segment (0x1000) (obsolete) */
    63      uint16_t kernel_version; /* Points to kernel version string */
    64  
    65      uint8_t  type_of_loader; /* Boot loader identifier */
    66          #define LOADER_TYPE_LILO            0x01
    67          #define LOADER_TYPE_LOADLIN         0x10
    68          #define LOADER_TYPE_BOOTSECT_LOADER 0x20
    69          #define LOADER_TYPE_SYSLINUX        0x30
    70          #define LOADER_TYPE_ETHERBOOT       0x40
    71          #define LOADER_TYPE_ELILO           0x50
    72          #define LOADER_TYPE_GRUB            0x71
    73          #define LOADER_TYPE_U_BOOT          0x80
    74          #define LOADER_TYPE_XEN             0x90
    75          #define LOADER_TYPE_UNKNOWN         0xFF
    76  
    77      uint8_t  loadflags;      /* Boot protocol option flags */
    78          #define FLAG_LOAD_HIGH      0x01
    79          #define FLAG_CAN_USE_HEAP   0x80
    80  
    81      uint16_t setup_move_size;/* Move to high memory size (used with hooks) */
    82      uint32_t code32_start;   /* Boot loader hook */
    83      uint32_t ramdisk_image;  /* initrd load address (set by boot loader) */
    84      uint32_t ramdisk_size;   /* initrd size (set by boot loader) */
    85      uint32_t bootsect_kludge;/* DO NOT USE - for bootsect.S use only */
    86      uint16_t heap_end_ptr;   /* Free memory after setup end */
    87      uint16_t pad1;           /* Unused */
    88      uint32_t cmd_line_ptr;   /* 32-bit pointer to the kernel command line */
    89      uint32_t initrd_addr_max;/* Highest legal initrd address */
    90      uint32_t kernel_alignment;         /* Physical addr alignment
    91                                            required for kernel */
    92      uint8_t  relocatable_kernel;       /* Whether kernel is relocatable
    93                                            or not */
    94      uint8_t  pad2[3];                  /* Unused */
    95      uint32_t cmdline_size;             /* Maximum size of the kernel
    96                                            command line */
    97      uint32_t hardware_subarch;         /* Hardware subarchitecture */
    98      uint64_t hardware_subarch_data;    /* Subarchitecture-specific data */
    99      uint32_t payload_offset;
   100      uint32_t payload_length;
   101      uint64_t setup_data;
   102  } linux_kernel_header_t;
   103  
   104  typedef struct __attribute__ ((packed)) {
   105      uint8_t               screen_info[0x040-0x000];                 /* 0x000 */
   106      uint8_t               apm_bios_info[0x054-0x040];               /* 0x040 */
   107      uint8_t               _pad2[4];                                 /* 0x054 */
   108      uint8_t               tboot_shared_addr[8];                     /* 0x058 */
   109      uint8_t               ist_info[0x070-0x060];                    /* 0x060 */
   110      uint8_t               _pad3[16];                                /* 0x070 */
   111      uint8_t               hd0_info[16];     /* obsolete! */         /* 0x080 */
   112      uint8_t               hd1_info[16];     /* obsolete! */         /* 0x090 */
   113      uint8_t               sys_desc_table[0x0b0-0x0a0];              /* 0x0a0 */
   114      uint8_t               _pad4[144];                               /* 0x0b0 */
   115      uint8_t               edid_info[0x1c0-0x140];                   /* 0x140 */
   116      uint8_t               efi_info[0x1e0-0x1c0];                    /* 0x1c0 */
   117      uint8_t               alt_mem_k[0x1e4-0x1e0];                   /* 0x1e0 */
   118      uint8_t               scratch[0x1e8-0x1e4];                     /* 0x1e4 */
   119      uint8_t               e820_entries;                             /* 0x1e8 */
   120      uint8_t               eddbuf_entries;                           /* 0x1e9 */
   121      uint8_t               edd_mbr_sig_buf_entries;                  /* 0x1ea */
   122      uint8_t               _pad6[6];                                 /* 0x1eb */
   123      linux_kernel_header_t hdr;    /* setup header */                /* 0x1f1 */
   124      uint8_t               _pad7[0x290-0x1f1-sizeof(linux_kernel_header_t)];
   125      uint8_t               edd_mbr_sig_buffer[0x2d0-0x290];          /* 0x290 */
   126      e820entry_t           e820_map[E820MAX];                        /* 0x2d0 */
   127      uint8_t               _pad8[48];                                /* 0xcd0 */
   128      uint8_t               eddbuf[0xeec-0xd00];                      /* 0xd00 */
   129      uint8_t               _pad9[276];                               /* 0xeec */
   130  } boot_params_t;
   131  
   132  typedef struct __attribute__ ((packed)) {
   133          u8  orig_x;                                                 /* 0x00 */
   134          u8  orig_y;                                                 /* 0x01 */
   135          u16 ext_mem_k;          /* extended memory size in kb */    /* 0x02 */
   136          u16 orig_video_page;                                        /* 0x04 */
   137          u8  orig_video_mode;    /* representing the specific mode
   138                                  that was in effect when booting */  /* 0x06 */
   139          u8  orig_video_cols;                                        /* 0x07 */
   140          u16 unused2;                                                /* 0x08 */
   141          u16 orig_video_ega_bx;  /* video state and installed
   142                                  memory */                           /* 0x0a */
   143          u16 unused3;                                                /* 0x0c */
   144          u8  orig_video_lines;                                       /* 0x0e */
   145          u8  orig_video_isVGA;   /* distinguish between VGA text
   146                                  and vesa lfb based screen setups */ /* 0x0f */
   147          u16 orig_video_points;  /* font height */                   /* 0x10 */
   148  } screen_info_t;
   149  
   150  /* recommended layout
   151          |  Protected-mode kernel    |  The kernel protected-mode code.
   152  100000  +---------------------------+
   153          |  I/O memory hole          |
   154  0A0000  +---------------------------+
   155          |  Reserved for BIOS        |  Do not use.  Reserved for BIOS EBDA.
   156  099100  +---------------------------+
   157          |  cmdline                  |
   158  099000  +---------------------------+
   159          |  Stack/heap               |  For use by the kernel real-mode code.
   160  098000  +---------------------------+
   161          |  Kernel setup             |  The kernel real-mode code.
   162  090200  +---------------------------+
   163          |  Kernel boot sector       |  The kernel legacy boot sector.
   164  090000  +---------------------------+
   165          |  Boot loader              |  <- Boot sector entry point 0000:7C00
   166  001000  +---------------------------+
   167          |  Reserved for MBR/BIOS    |
   168  000800  +---------------------------+
   169          |  Typically used by MBR    |
   170  000600  +---------------------------+
   171          |  BIOS use only            |
   172  000000  +---------------------------+
   173  */
   174  
   175  #define BZIMAGE_PROTECTED_START 0x100000
   176  #define LEGACY_REAL_START       0x90000
   177  
   178  #define REAL_KERNEL_OFFSET      0x0000
   179  #define BOOT_SECTOR_OFFSET      0x0200
   180  #define KERNEL_CMDLINE_OFFSET   0x9000
   181  #define REAL_END_OFFSET         0x9100
   182  
   183  #define REAL_MODE_SIZE          REAL_END_OFFSET - REAL_KERNEL_OFFSET
   184  
   185  #endif /* __LINUX_DEFNS_H__ */
   186  
   187  /*
   188   * Local variables:
   189   * mode: C
   190   * c-set-style: "BSD"
   191   * c-basic-offset: 4
   192   * tab-width: 4
   193   * indent-tabs-mode: nil
   194   * End:
   195   */