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