|
| 1 | +// Copyright 2026 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; |
| 16 | + |
| 17 | +use crate::{bitflags, consts}; |
| 18 | + |
| 19 | +consts! { |
| 20 | + #[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)] |
| 21 | + pub struct HobType(u16) { |
| 22 | + HANDOFF = 0x0001; |
| 23 | + RESOURCE_DESCRIPTOR = 0x0003; |
| 24 | + END_OF_HOB_LIST = 0xffff; |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +#[repr(C)] |
| 29 | +#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)] |
| 30 | +pub struct HobGenericHeader { |
| 31 | + pub r#type: HobType, |
| 32 | + pub length: u16, |
| 33 | + pub reserved: u32, |
| 34 | +} |
| 35 | + |
| 36 | +pub const HOB_HANDOFF_TABLE_VERSION: u32 = 0x9; |
| 37 | + |
| 38 | +#[repr(C)] |
| 39 | +#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)] |
| 40 | +pub struct HobHandoffInfoTable { |
| 41 | + pub hdr: HobGenericHeader, |
| 42 | + pub version: u32, |
| 43 | + pub boot_mode: u32, |
| 44 | + pub memory_top: u64, |
| 45 | + pub memory_bottom: u64, |
| 46 | + pub free_memory_top: u64, |
| 47 | + pub free_memory_bottom: u64, |
| 48 | + pub end_of_hob_list: u64, |
| 49 | +} |
| 50 | + |
| 51 | +consts! { |
| 52 | + #[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)] |
| 53 | + pub struct HobResourceType(u32) { |
| 54 | + SYSTEM_MEMORY = 0x00000000; |
| 55 | + MEMORY_UNACCEPTED = 0x00000007; |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +bitflags! { |
| 60 | + #[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)] |
| 61 | + pub struct ResourceAttr(u32) { |
| 62 | + PRESENT = 1 << 0; |
| 63 | + INIT = 1 << 1; |
| 64 | + TESTED = 1 << 2; |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +#[repr(C)] |
| 69 | +#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)] |
| 70 | +pub struct HobResourceDesc { |
| 71 | + pub hdr: HobGenericHeader, |
| 72 | + pub owner: [u8; 16], |
| 73 | + pub r#type: HobResourceType, |
| 74 | + pub attr: ResourceAttr, |
| 75 | + pub address: u64, |
| 76 | + pub len: u64, |
| 77 | +} |
0 commit comments