11// SPDX-License-Identifier: Apache-2.0
22// Copyright 2020 Google LLC
33
4- use core :: mem :: size_of ;
4+ use pvh :: start_info :: { MemmapTableEntry , StartInfo } ;
55
66use crate :: {
77 bootinfo:: { EntryType , Info , MemoryEntry } ,
88 common,
99 layout:: MemoryDescriptor ,
1010} ;
1111
12- // Structures from xen/include/public/arch-x86/hvm/start_info.h
13- #[ derive( Debug ) ]
14- #[ repr( C ) ]
15- pub struct StartInfo {
16- magic : [ u8 ; 4 ] ,
17- version : u32 ,
18- flags : u32 ,
19- nr_modules : u32 ,
20- modlist_paddr : u64 ,
21- cmdline_paddr : u64 ,
22- rsdp_paddr : u64 ,
23- memmap_paddr : u64 ,
24- memmap_entries : u32 ,
25- _pad : u32 ,
26- }
27-
28- #[ derive( Clone , Copy , Debug ) ]
29- #[ repr( C ) ]
30- struct MemMapEntry {
31- addr : u64 ,
32- size : u64 ,
33- entry_type : u32 ,
34- _pad : u32 ,
35- }
36-
37- impl From < MemMapEntry > for MemoryEntry {
38- fn from ( value : MemMapEntry ) -> Self {
12+ impl From < MemmapTableEntry > for MemoryEntry {
13+ fn from ( value : MemmapTableEntry ) -> Self {
3914 Self {
4015 addr : value. addr ,
4116 size : value. size ,
42- entry_type : EntryType :: from ( value. entry_type ) ,
17+ entry_type : EntryType :: from ( value. ty ) ,
4318 }
4419 }
4520}
@@ -63,7 +38,7 @@ impl Info for StartInfo {
6338 }
6439 fn entry ( & self , idx : usize ) -> MemoryEntry {
6540 assert ! ( idx < self . num_entries( ) ) ;
66- let ptr = self . memmap_paddr as * const MemMapEntry ;
41+ let ptr = self . memmap_paddr as * const MemmapTableEntry ;
6742 let entry = unsafe { * ptr. add ( idx) } ;
6843 MemoryEntry :: from ( entry)
6944 }
@@ -77,34 +52,7 @@ impl Info for StartInfo {
7752
7853// The PVH Boot Protocol starts at the 32-bit entrypoint to our firmware.
7954extern "C" {
80- fn ram32_start ( ) ;
55+ fn ram32_start ( ) -> ! ;
8156}
8257
83- // The kind/name/desc of the PHV ELF Note are from xen/include/public/elfnote.h.
84- // This is the "Physical entry point into the kernel".
85- const XEN_ELFNOTE_PHYS32_ENTRY : u32 = 18 ;
86- type Name = [ u8 ; 4 ] ;
87- type Desc = unsafe extern "C" fn ( ) ;
88-
89- // We make sure our ELF Note has an alignment of 4 for maximum compatibility.
90- // Some software (QEMU) calculates padding incorectly if alignment != 4.
91- #[ repr( C , packed( 4 ) ) ]
92- struct Note {
93- name_size : u32 ,
94- desc_size : u32 ,
95- kind : u32 ,
96- name : Name ,
97- desc : Desc ,
98- }
99-
100- // This is: ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .quad ram32_start)
101- #[ cfg( not( test) ) ]
102- #[ link_section = ".note" ]
103- #[ used]
104- static PVH_NOTE : Note = Note {
105- name_size : size_of :: < Name > ( ) as u32 ,
106- desc_size : size_of :: < Desc > ( ) as u32 ,
107- kind : XEN_ELFNOTE_PHYS32_ENTRY ,
108- name : * b"Xen\0 " ,
109- desc : ram32_start,
110- } ;
58+ pvh:: xen_elfnote_phys32_entry!( ram32_start) ;
0 commit comments