|
| 1 | +/* |
| 2 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 3 | + * of this software and associated documentation files (the "Software"), to |
| 4 | + * deal in the Software without restriction, including without limitation the |
| 5 | + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 6 | + * sell copies of the Software, and to permit persons to whom the Software is |
| 7 | + * furnished to do so, subject to the following conditions: |
| 8 | + * |
| 9 | + * The above copyright notice and this permission notice shall be included in |
| 10 | + * all copies or substantial portions of the Software. |
| 11 | + * |
| 12 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 13 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 14 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 15 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 16 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 17 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 18 | + * DEALINGS IN THE SOFTWARE. |
| 19 | + * |
| 20 | + * Copyright (c) 2016, Citrix Systems, Inc. |
| 21 | + */ |
| 22 | + |
| 23 | +/* |
| 24 | + * automatically generated by rust-bindgen using: |
| 25 | + * |
| 26 | + * # bindgen start_info.h -- -include stdint.h > start_info.rs |
| 27 | + * |
| 28 | + * From the canonical version in upstream Xen repository |
| 29 | + * xen/include/public/arch-x86/hvm/start_info.h |
| 30 | + * at commit: |
| 31 | + * a2e84d8e42c9e878fff17b738d8e5c5d83888f31 |
| 32 | + * |
| 33 | + * The generated file has been edited to eliminate unnecessary |
| 34 | + * definitions, add comments, and relocate definitions and tests for clarity. |
| 35 | + * Added Default to the list of traits that are automatically derived. |
| 36 | + * |
| 37 | + * The definitions in this file are intended to be exported and used by a particular |
| 38 | + * VMM implementation in order to boot a Linux guest using the PVH entry point as |
| 39 | + * specified in the x86/HVM direct boot ABI. |
| 40 | + * These structures contain all the required information (cmdline address, ACPI RSDP, |
| 41 | + * memory maps, etc) that must be written to guest memory before starting guest |
| 42 | + * execution by jumping to the PVH entry point address. |
| 43 | + * A comparable set of definitions to hvm_start_info and hvm_memmap_table_entry in this |
| 44 | + * file would be the boot_params and boot_e820_entry definitions used by the Linux |
| 45 | + * 64-bit boot protocol. |
| 46 | + * |
| 47 | + * Start of day structure passed to PVH guests and to HVM guests in %ebx. |
| 48 | + * |
| 49 | + * NOTE: nothing will be loaded at physical address 0, so a 0 value in any |
| 50 | + * of the address fields should be treated as not present. |
| 51 | + * |
| 52 | + * 0 +----------------+ |
| 53 | + * | magic | Contains the magic value XEN_HVM_START_MAGIC_VALUE |
| 54 | + * | | ("xEn3" with the 0x80 bit of the "E" set). |
| 55 | + * 4 +----------------+ |
| 56 | + * | version | Version of this structure. Current version is 1. New |
| 57 | + * | | versions are guaranteed to be backwards-compatible. |
| 58 | + * 8 +----------------+ |
| 59 | + * | flags | SIF_xxx flags. |
| 60 | + * 12 +----------------+ |
| 61 | + * | nr_modules | Number of modules passed to the kernel. |
| 62 | + * 16 +----------------+ |
| 63 | + * | modlist_paddr | Physical address of an array of modules |
| 64 | + * | | (layout of the structure below). |
| 65 | + * 24 +----------------+ |
| 66 | + * | cmdline_paddr | Physical address of the command line, |
| 67 | + * | | a zero-terminated ASCII string. |
| 68 | + * 32 +----------------+ |
| 69 | + * | rsdp_paddr | Physical address of the RSDP ACPI data structure. |
| 70 | + * 40 +----------------+ |
| 71 | + * | memmap_paddr | Physical address of the (optional) memory map. Only |
| 72 | + * | | present in version 1 and newer of the structure. |
| 73 | + * 48 +----------------+ |
| 74 | + * | memmap_entries | Number of entries in the memory map table. Zero |
| 75 | + * | | if there is no memory map being provided. Only |
| 76 | + * | | present in version 1 and newer of the structure. |
| 77 | + * 52 +----------------+ |
| 78 | + * | reserved | Version 1 and newer only. |
| 79 | + * 56 +----------------+ |
| 80 | + * |
| 81 | + * The layout of each entry in the module structure is the following: |
| 82 | + * |
| 83 | + * 0 +----------------+ |
| 84 | + * | paddr | Physical address of the module. |
| 85 | + * 8 +----------------+ |
| 86 | + * | size | Size of the module in bytes. |
| 87 | + * 16 +----------------+ |
| 88 | + * | cmdline_paddr | Physical address of the command line, |
| 89 | + * | | a zero-terminated ASCII string. |
| 90 | + * 24 +----------------+ |
| 91 | + * | reserved | |
| 92 | + * 32 +----------------+ |
| 93 | + * |
| 94 | + * The layout of each entry in the memory map table is as follows: |
| 95 | + * |
| 96 | + * 0 +----------------+ |
| 97 | + * | addr | Base address |
| 98 | + * 8 +----------------+ |
| 99 | + * | size | Size of mapping in bytes |
| 100 | + * 16 +----------------+ |
| 101 | + * | type | Type of mapping as defined between the hypervisor |
| 102 | + * | | and guest. See XEN_HVM_MEMMAP_TYPE_* values below. |
| 103 | + * 20 +----------------| |
| 104 | + * | reserved | |
| 105 | + * 24 +----------------+ |
| 106 | + * |
| 107 | + * The address and sizes are always a 64bit little endian unsigned integer. |
| 108 | + * |
| 109 | + * NB: Xen on x86 will always try to place all the data below the 4GiB |
| 110 | + * boundary. |
| 111 | + * |
| 112 | + * Version numbers of the hvm_start_info structure have evolved like this: |
| 113 | + * |
| 114 | + * Version 0: Initial implementation. |
| 115 | + * |
| 116 | + * Version 1: Added the memmap_paddr/memmap_entries fields (plus 4 bytes of |
| 117 | + * padding) to the end of the hvm_start_info struct. These new |
| 118 | + * fields can be used to pass a memory map to the guest. The |
| 119 | + * memory map is optional and so guests that understand version 1 |
| 120 | + * of the structure must check that memmap_entries is non-zero |
| 121 | + * before trying to read the memory map. |
| 122 | + */ |
| 123 | + |
| 124 | +#[repr(C)] |
| 125 | +#[derive(Debug, Copy, Clone, Default)] |
| 126 | +pub struct hvm_start_info { |
| 127 | + pub magic: u32, |
| 128 | + pub version: u32, |
| 129 | + pub flags: u32, |
| 130 | + pub nr_modules: u32, |
| 131 | + pub modlist_paddr: u64, |
| 132 | + pub cmdline_paddr: u64, |
| 133 | + pub rsdp_paddr: u64, |
| 134 | + pub memmap_paddr: u64, |
| 135 | + pub memmap_entries: u32, |
| 136 | + pub reserved: u32, |
| 137 | +} |
| 138 | + |
| 139 | +#[repr(C)] |
| 140 | +#[derive(Debug, Copy, Clone, Default)] |
| 141 | +pub struct hvm_modlist_entry { |
| 142 | + pub paddr: u64, |
| 143 | + pub size: u64, |
| 144 | + pub cmdline_paddr: u64, |
| 145 | + pub reserved: u64, |
| 146 | +} |
| 147 | + |
| 148 | +#[repr(C)] |
| 149 | +#[derive(Debug, Copy, Clone, Default)] |
| 150 | +pub struct hvm_memmap_table_entry { |
| 151 | + pub addr: u64, |
| 152 | + pub size: u64, |
| 153 | + pub type_: u32, |
| 154 | + pub reserved: u32, |
| 155 | +} |
| 156 | + |
| 157 | +#[cfg(test)] |
| 158 | +mod tests { |
| 159 | + use super::*; |
| 160 | + |
| 161 | + #[test] |
| 162 | + fn bindgen_test_layout_hvm_start_info() { |
| 163 | + assert_eq!( |
| 164 | + ::std::mem::size_of::<hvm_start_info>(), |
| 165 | + 56usize, |
| 166 | + concat!("Size of: ", stringify!(hvm_start_info)) |
| 167 | + ); |
| 168 | + assert_eq!( |
| 169 | + ::std::mem::align_of::<hvm_start_info>(), |
| 170 | + 8usize, |
| 171 | + concat!("Alignment of ", stringify!(hvm_start_info)) |
| 172 | + ); |
| 173 | + assert_eq!( |
| 174 | + unsafe { &(*(::std::ptr::null::<hvm_start_info>())).magic as *const _ as usize }, |
| 175 | + 0usize, |
| 176 | + concat!( |
| 177 | + "Offset of field: ", |
| 178 | + stringify!(hvm_start_info), |
| 179 | + "::", |
| 180 | + stringify!(magic) |
| 181 | + ) |
| 182 | + ); |
| 183 | + assert_eq!( |
| 184 | + unsafe { &(*(::std::ptr::null::<hvm_start_info>())).version as *const _ as usize }, |
| 185 | + 4usize, |
| 186 | + concat!( |
| 187 | + "Offset of field: ", |
| 188 | + stringify!(hvm_start_info), |
| 189 | + "::", |
| 190 | + stringify!(version) |
| 191 | + ) |
| 192 | + ); |
| 193 | + assert_eq!( |
| 194 | + unsafe { &(*(::std::ptr::null::<hvm_start_info>())).flags as *const _ as usize }, |
| 195 | + 8usize, |
| 196 | + concat!( |
| 197 | + "Offset of field: ", |
| 198 | + stringify!(hvm_start_info), |
| 199 | + "::", |
| 200 | + stringify!(flags) |
| 201 | + ) |
| 202 | + ); |
| 203 | + assert_eq!( |
| 204 | + unsafe { &(*(::std::ptr::null::<hvm_start_info>())).nr_modules as *const _ as usize }, |
| 205 | + 12usize, |
| 206 | + concat!( |
| 207 | + "Offset of field: ", |
| 208 | + stringify!(hvm_start_info), |
| 209 | + "::", |
| 210 | + stringify!(nr_modules) |
| 211 | + ) |
| 212 | + ); |
| 213 | + assert_eq!( |
| 214 | + unsafe { |
| 215 | + &(*(::std::ptr::null::<hvm_start_info>())).modlist_paddr as *const _ as usize |
| 216 | + }, |
| 217 | + 16usize, |
| 218 | + concat!( |
| 219 | + "Offset of field: ", |
| 220 | + stringify!(hvm_start_info), |
| 221 | + "::", |
| 222 | + stringify!(modlist_paddr) |
| 223 | + ) |
| 224 | + ); |
| 225 | + assert_eq!( |
| 226 | + unsafe { |
| 227 | + &(*(::std::ptr::null::<hvm_start_info>())).cmdline_paddr as *const _ as usize |
| 228 | + }, |
| 229 | + 24usize, |
| 230 | + concat!( |
| 231 | + "Offset of field: ", |
| 232 | + stringify!(hvm_start_info), |
| 233 | + "::", |
| 234 | + stringify!(cmdline_paddr) |
| 235 | + ) |
| 236 | + ); |
| 237 | + assert_eq!( |
| 238 | + unsafe { &(*(::std::ptr::null::<hvm_start_info>())).rsdp_paddr as *const _ as usize }, |
| 239 | + 32usize, |
| 240 | + concat!( |
| 241 | + "Offset of field: ", |
| 242 | + stringify!(hvm_start_info), |
| 243 | + "::", |
| 244 | + stringify!(rsdp_paddr) |
| 245 | + ) |
| 246 | + ); |
| 247 | + assert_eq!( |
| 248 | + unsafe { &(*(::std::ptr::null::<hvm_start_info>())).memmap_paddr as *const _ as usize }, |
| 249 | + 40usize, |
| 250 | + concat!( |
| 251 | + "Offset of field: ", |
| 252 | + stringify!(hvm_start_info), |
| 253 | + "::", |
| 254 | + stringify!(memmap_paddr) |
| 255 | + ) |
| 256 | + ); |
| 257 | + assert_eq!( |
| 258 | + unsafe { |
| 259 | + &(*(::std::ptr::null::<hvm_start_info>())).memmap_entries as *const _ as usize |
| 260 | + }, |
| 261 | + 48usize, |
| 262 | + concat!( |
| 263 | + "Offset of field: ", |
| 264 | + stringify!(hvm_start_info), |
| 265 | + "::", |
| 266 | + stringify!(memmap_entries) |
| 267 | + ) |
| 268 | + ); |
| 269 | + assert_eq!( |
| 270 | + unsafe { &(*(::std::ptr::null::<hvm_start_info>())).reserved as *const _ as usize }, |
| 271 | + 52usize, |
| 272 | + concat!( |
| 273 | + "Offset of field: ", |
| 274 | + stringify!(hvm_start_info), |
| 275 | + "::", |
| 276 | + stringify!(reserved) |
| 277 | + ) |
| 278 | + ); |
| 279 | + } |
| 280 | + |
| 281 | + #[test] |
| 282 | + fn bindgen_test_layout_hvm_modlist_entry() { |
| 283 | + assert_eq!( |
| 284 | + ::std::mem::size_of::<hvm_modlist_entry>(), |
| 285 | + 32usize, |
| 286 | + concat!("Size of: ", stringify!(hvm_modlist_entry)) |
| 287 | + ); |
| 288 | + assert_eq!( |
| 289 | + ::std::mem::align_of::<hvm_modlist_entry>(), |
| 290 | + 8usize, |
| 291 | + concat!("Alignment of ", stringify!(hvm_modlist_entry)) |
| 292 | + ); |
| 293 | + assert_eq!( |
| 294 | + unsafe { &(*(::std::ptr::null::<hvm_modlist_entry>())).paddr as *const _ as usize }, |
| 295 | + 0usize, |
| 296 | + concat!( |
| 297 | + "Offset of field: ", |
| 298 | + stringify!(hvm_modlist_entry), |
| 299 | + "::", |
| 300 | + stringify!(paddr) |
| 301 | + ) |
| 302 | + ); |
| 303 | + assert_eq!( |
| 304 | + unsafe { &(*(::std::ptr::null::<hvm_modlist_entry>())).size as *const _ as usize }, |
| 305 | + 8usize, |
| 306 | + concat!( |
| 307 | + "Offset of field: ", |
| 308 | + stringify!(hvm_modlist_entry), |
| 309 | + "::", |
| 310 | + stringify!(size) |
| 311 | + ) |
| 312 | + ); |
| 313 | + assert_eq!( |
| 314 | + unsafe { |
| 315 | + &(*(::std::ptr::null::<hvm_modlist_entry>())).cmdline_paddr as *const _ as usize |
| 316 | + }, |
| 317 | + 16usize, |
| 318 | + concat!( |
| 319 | + "Offset of field: ", |
| 320 | + stringify!(hvm_modlist_entry), |
| 321 | + "::", |
| 322 | + stringify!(cmdline_paddr) |
| 323 | + ) |
| 324 | + ); |
| 325 | + assert_eq!( |
| 326 | + unsafe { &(*(::std::ptr::null::<hvm_modlist_entry>())).reserved as *const _ as usize }, |
| 327 | + 24usize, |
| 328 | + concat!( |
| 329 | + "Offset of field: ", |
| 330 | + stringify!(hvm_modlist_entry), |
| 331 | + "::", |
| 332 | + stringify!(reserved) |
| 333 | + ) |
| 334 | + ); |
| 335 | + } |
| 336 | + |
| 337 | + #[test] |
| 338 | + fn bindgen_test_layout_hvm_memmap_table_entry() { |
| 339 | + assert_eq!( |
| 340 | + ::std::mem::size_of::<hvm_memmap_table_entry>(), |
| 341 | + 24usize, |
| 342 | + concat!("Size of: ", stringify!(hvm_memmap_table_entry)) |
| 343 | + ); |
| 344 | + assert_eq!( |
| 345 | + ::std::mem::align_of::<hvm_memmap_table_entry>(), |
| 346 | + 8usize, |
| 347 | + concat!("Alignment of ", stringify!(hvm_memmap_table_entry)) |
| 348 | + ); |
| 349 | + assert_eq!( |
| 350 | + unsafe { &(*(::std::ptr::null::<hvm_memmap_table_entry>())).addr as *const _ as usize }, |
| 351 | + 0usize, |
| 352 | + concat!( |
| 353 | + "Offset of field: ", |
| 354 | + stringify!(hvm_memmap_table_entry), |
| 355 | + "::", |
| 356 | + stringify!(addr) |
| 357 | + ) |
| 358 | + ); |
| 359 | + assert_eq!( |
| 360 | + unsafe { &(*(::std::ptr::null::<hvm_memmap_table_entry>())).size as *const _ as usize }, |
| 361 | + 8usize, |
| 362 | + concat!( |
| 363 | + "Offset of field: ", |
| 364 | + stringify!(hvm_memmap_table_entry), |
| 365 | + "::", |
| 366 | + stringify!(size) |
| 367 | + ) |
| 368 | + ); |
| 369 | + assert_eq!( |
| 370 | + unsafe { |
| 371 | + &(*(::std::ptr::null::<hvm_memmap_table_entry>())).type_ as *const _ as usize |
| 372 | + }, |
| 373 | + 16usize, |
| 374 | + concat!( |
| 375 | + "Offset of field: ", |
| 376 | + stringify!(hvm_memmap_table_entry), |
| 377 | + "::", |
| 378 | + stringify!(type_) |
| 379 | + ) |
| 380 | + ); |
| 381 | + assert_eq!( |
| 382 | + unsafe { |
| 383 | + &(*(::std::ptr::null::<hvm_memmap_table_entry>())).reserved as *const _ as usize |
| 384 | + }, |
| 385 | + 20usize, |
| 386 | + concat!( |
| 387 | + "Offset of field: ", |
| 388 | + stringify!(hvm_memmap_table_entry), |
| 389 | + "::", |
| 390 | + stringify!(reserved) |
| 391 | + ) |
| 392 | + ); |
| 393 | + } |
| 394 | +} |
0 commit comments