]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4util/include/mb_info.h
e21ac83891799214728effad41496076eff9ceef
[l4.git] / l4 / pkg / l4util / include / mb_info.h
1 /**
2  * \file
3  *
4  * \brief       Multiboot info structure as defined by GRUB */
5 /*
6  * (c) 2008-2009 Technische Universität Dresden
7  * This file is part of TUD:OS and distributed under the terms of the
8  * GNU Lesser General Public License 2.1.
9  * Please see the COPYING-LGPL-2.1 file for details.
10  */
11
12 #ifndef L4UTIL_MB_INFO_H
13 #define L4UTIL_MB_INFO_H
14
15 #ifndef __ASSEMBLY__
16
17 #include <l4/sys/l4int.h>
18
19 /**
20  * \anchor struct_l4util_mod_list
21  *  The structure type "mod_list" is used by the 
22  *  \ref struct_l4util_mb_info "multiboot_info" structure.
23  */
24
25 typedef struct
26 {
27   l4_uint32_t mod_start;        /**< Starting address of module in memory. */
28   l4_uint32_t mod_end;          /**< End address of module in memory. */
29   l4_uint32_t cmdline;          /**< Module command line */
30   l4_uint32_t pad;              /**< padding to take it to 16 bytes */
31 } l4util_mb_mod_t;
32
33
34 /**
35  *  INT-15, AX=E820 style "AddressRangeDescriptor"
36  *  ...with a "size" parameter on the front which is the structure size - 4,
37  *  pointing to the next one, up until the full buffer length of the memory
38  *  map has been reached.
39  */
40
41 typedef struct __attribute__((packed))
42 {
43   l4_uint32_t struct_size;      /** <Size of structure */
44   l4_uint64_t addr;             /** <Start address */
45   l4_uint64_t size;             /** <Size of memory range */
46   l4_uint32_t type;             /** <type of memory range */
47   /* unspecified optional padding... */
48 } l4util_mb_addr_range_t;
49
50 #define l4util_mb_for_each_mmap_entry(i, mbi) \
51   for (i = (l4util_mb_addr_range_t *) mbi->mmap_addr; \
52        (unsigned long)i < mbi->mmap_addr + mbi->mmap_length; \
53        i = (l4util_mb_addr_range_t *)((unsigned long)i + mmap->struct_size + sizeof (mmap->struct_size)))
54
55 /** usable memory "Type", all others are reserved.  */
56 #define MB_ARD_MEMORY           1
57
58 /**
59  * Address Range Types (ART) from "Advanced Configuration and Power Interface
60  * Specification" Rev3.0a (p. 390). Other values are undefined.
61  */
62 #define MB_ART_MEMORY   1  /**< available, usable RAM */
63 #define MB_ART_RESERVED 2  /**< in use or reserved by system */
64 #define MB_ART_ACPI     3  /**< ACPI Reclaim Memory (RAM that contains
65                                 ACPI tables) */
66 #define MB_ART_NVS      4  /**< ACPI NVS Memory (must not be used by the OS */
67 #define MB_ART_UNUSABLE 5  /**< memory in which errores have been detected */
68
69
70 /** Drive Info structure.  */
71 typedef struct
72 {
73   l4_uint32_t size;             /** <The size of this structure.  */
74   l4_uint8_t drive_number;      /** <The BIOS drive number.  */
75   l4_uint8_t drive_mode;        /** <The access mode (see below).  */
76   l4_uint16_t drive_cylinders;  /** <number of cylinders  */
77   l4_uint8_t drive_heads;       /** <number of heads */
78   l4_uint8_t drive_sectors;     /** <number of sectors per track */
79   l4_uint16_t drive_ports[0];   /** <Array of I/O ports used for the drive. */
80 } l4util_mb_drive_t;
81
82 /* Drive Mode.  */
83 #define MB_DI_CHS_MODE          0
84 #define MB_DI_LBA_MODE          1
85
86
87 /** APM BIOS info.  */
88 typedef struct
89 {
90   l4_uint16_t version;
91   l4_uint16_t cseg;
92   l4_uint32_t offset;
93   l4_uint16_t cseg_16;
94   l4_uint16_t dseg_16;
95   l4_uint16_t cseg_len;
96   l4_uint16_t cseg_16_len;
97   l4_uint16_t dseg_16_len;
98 } l4util_mb_apm_t;
99
100
101 /** VBE controller information. */
102 typedef struct
103 {
104   l4_uint8_t signature[4];
105   l4_uint16_t version;
106   l4_uint32_t oem_string;
107   l4_uint32_t capabilities;
108   l4_uint32_t video_mode;
109   l4_uint16_t total_memory;
110   l4_uint16_t oem_software_rev;
111   l4_uint32_t oem_vendor_name;
112   l4_uint32_t oem_product_name;
113   l4_uint32_t oem_product_rev;
114   l4_uint8_t reserved[222];
115   l4_uint8_t oem_data[256];
116 } __attribute__((packed)) l4util_mb_vbe_ctrl_t;
117
118
119 /** VBE mode information. */
120 typedef struct
121 {
122   /** @name all VESA versions
123   * @{ */
124   l4_uint16_t mode_attributes;
125   l4_uint8_t win_a_attributes;
126   l4_uint8_t win_b_attributes;
127   l4_uint16_t win_granularity;
128   l4_uint16_t win_size;
129   l4_uint16_t win_a_segment;
130   l4_uint16_t win_b_segment;
131   l4_uint32_t win_func;
132   l4_uint16_t bytes_per_scanline;
133   /** @} */
134
135   /** @name >= VESA version 1.2
136    * @{ */
137   l4_uint16_t x_resolution;
138   l4_uint16_t y_resolution;
139   l4_uint8_t x_char_size;
140   l4_uint8_t y_char_size;
141   l4_uint8_t number_of_planes;
142   l4_uint8_t bits_per_pixel;
143   l4_uint8_t number_of_banks;
144   l4_uint8_t memory_model;
145   l4_uint8_t bank_size;
146   l4_uint8_t number_of_image_pages;
147   l4_uint8_t reserved0;
148   /** @} */
149
150   /** @name direct color
151    * @{ */
152   l4_uint8_t red_mask_size;
153   l4_uint8_t red_field_position;
154   l4_uint8_t green_mask_size;
155   l4_uint8_t green_field_position;
156   l4_uint8_t blue_mask_size;
157   l4_uint8_t blue_field_position;
158   l4_uint8_t reserved_mask_size;
159   l4_uint8_t reserved_field_position;
160   l4_uint8_t direct_color_mode_info;
161   /** @} */
162
163   /** @name >= VESA version 2.0 
164    * @{*/
165   l4_uint32_t phys_base;
166   l4_uint32_t reserved1;
167   l4_uint16_t reversed2;
168   /** @} */
169
170   /** @name >= VESA version 3.0
171    * @{*/
172   l4_uint16_t linear_bytes_per_scanline;
173   l4_uint8_t banked_number_of_image_pages;
174   l4_uint8_t linear_number_of_image_pages;
175   l4_uint8_t linear_red_mask_size;
176   l4_uint8_t linear_red_field_position;
177   l4_uint8_t linear_green_mask_size;
178   l4_uint8_t linear_green_field_position;
179   l4_uint8_t linear_blue_mask_size;
180   l4_uint8_t linear_blue_field_position;
181   l4_uint8_t linear_reserved_mask_size;
182   l4_uint8_t linear_reserved_field_position;
183   l4_uint32_t max_pixel_clock;
184
185   /* The VBE spec says this structure should have a size of 256 bytes but
186    * the described structure layout is only 255 bytes... */
187   l4_uint8_t reserved3[189 + 1];
188   /** @} */
189 } __attribute__ ((packed)) l4util_mb_vbe_mode_t;
190
191
192 /**
193  * \anchor struct_l4util_mb_info
194  *  MultiBoot Info description
195  *
196  *  This is the struct passed to the boot image.  This is done by placing
197  *  its address in the EAX register.
198  */
199
200 typedef struct
201 {
202   l4_uint32_t flags;            /**< MultiBoot info version number */
203   l4_uint32_t mem_lower;        /**< available memory below 1MB */
204   l4_uint32_t mem_upper;        /**< available memory starting from 1MB [kB] */
205   l4_uint32_t boot_device;      /**< "root" partition */
206   l4_uint32_t cmdline;          /**< Kernel command line */
207   l4_uint32_t mods_count;       /**< number of modules */
208   l4_uint32_t mods_addr;        /**< module list */
209
210   union
211   {
212     struct
213     {
214       /** (a.out) Kernel symbol table info */
215       l4_uint32_t tabsize;
216       l4_uint32_t strsize;
217       l4_uint32_t addr;
218       l4_uint32_t pad;
219     }
220     a;
221     
222     struct
223     {
224       /** (ELF) Kernel section header table */
225       l4_uint32_t num;
226       l4_uint32_t size;
227       l4_uint32_t addr;
228       l4_uint32_t shndx;
229     }
230     e;
231   }
232   syms;
233   
234   l4_uint32_t mmap_length;      /**< size of memory mapping buffer */
235   l4_uint32_t mmap_addr;        /**< address of memory mapping buffer */
236   l4_uint32_t drives_length;    /**< size of drive info buffer */
237   l4_uint32_t drives_addr;      /**< address of driver info buffer */
238   l4_uint32_t config_table;     /**< ROM configuration table */
239   l4_uint32_t boot_loader_name; /**< Boot Loader Name */
240   l4_uint32_t apm_table;        /**< APM table */
241   l4_uint32_t vbe_ctrl_info;    /**< VESA video contoller info */
242   l4_uint32_t vbe_mode_info;    /**< VESA video mode info */
243   l4_uint16_t vbe_mode;         /**< VESA video mode number */
244   l4_uint16_t vbe_interface_seg; /**< VESA segment of prot BIOS interface */
245   l4_uint16_t vbe_interface_off; /**< VESA offset of prot BIOS interface */
246   l4_uint16_t vbe_interface_len; /**< VESA lenght of prot BIOS interface */
247 } l4util_mb_info_t;
248
249 #endif /* ! __ASSEMBLY__ */
250
251 /**
252  *  Flags to be set in the 'flags' parameter above
253  */
254
255 /** is there basic lower/upper memory information? */
256 #define L4UTIL_MB_MEMORY                0x00000001
257
258 /** is there a boot device set? */
259 #define L4UTIL_MB_BOOTDEV               0x00000002
260
261 /** is the command-line defined? */
262 #define L4UTIL_MB_CMDLINE               0x00000004
263
264 /** are there modules to do something with? */
265 #define L4UTIL_MB_MODS                  0x00000008
266
267 /* These next two are mutually exclusive */
268 /** is there a symbol table loaded? */
269 #define L4UTIL_MB_AOUT_SYMS             0x00000010
270
271 /** is there an ELF section header table? */
272 #define L4UTIL_MB_ELF_SHDR              0x00000020
273
274 /** is there a full memory map? */
275 #define L4UTIL_MB_MEM_MAP               0x00000040
276
277 /** Is there drive info?  */
278 #define L4UTIL_MB_DRIVE_INFO            0x00000080
279
280 /** Is there a config table?  */
281 #define L4UTIL_MB_CONFIG_TABLE          0x00000100
282
283 /** Is there a boot loader name?  */
284 #define L4UTIL_MB_BOOT_LOADER_NAME      0x00000200
285
286 /** Is there a APM table?  */
287 #define L4UTIL_MB_APM_TABLE             0x00000400
288
289 /** Is there video information?  */
290 #define L4UTIL_MB_VIDEO_INFO            0x00000800
291
292
293 /** If we are multiboot-compliant, this value is present in the eax register */
294 #define L4UTIL_MB_VALID                 0x2BADB002UL
295 #define L4UTIL_MB_VALID_ASM             0x2BADB002
296
297
298 #endif
299