fidl_data_zbi/
memory.rs

1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// DO NOT EDIT.
6// Generated from FIDL library `zbi` by zither, a Fuchsia platform tool.
7
8#![allow(unused_imports)]
9
10use zerocopy::{FromBytes, IntoBytes};
11
12/// Unknown values should be treated as RESERVED to allow forwards compatibility.
13#[repr(u32)]
14#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
15pub enum MemType {
16    /// Standard RAM.
17    Ram = 1,
18
19    /// Device memory.
20    Peripheral = 2,
21
22    /// Represents memory that should not be used by the system. Reserved ranges may
23    /// overlap other RAM or PERIPHERAL regions, in which case the reserved range
24    /// should take precedence.
25    Reserved = 3,
26}
27
28impl MemType {
29    pub fn from_raw(raw: u32) -> Option<Self> {
30        match raw {
31            1 => Some(Self::Ram),
32
33            2 => Some(Self::Peripheral),
34
35            3 => Some(Self::Reserved),
36
37            _ => None,
38        }
39    }
40}
41
42/// The ZBI_TYPE_MEM_CONFIG payload consist of one or more `zbi_mem_range_t`
43/// entries.
44///
45/// The length of the item is `sizeof(zbi_mem_range_t)` times the number of
46/// entries. Each entry describes a contiguous range of memory
47///
48/// Entries in the table may be in any order, and only a single item of type
49/// ZBI_TYPE_MEM_CONFIG should be present in the ZBI.
50#[repr(C)]
51#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
52pub struct MemRange {
53    pub paddr: u64,
54    pub length: u64,
55    pub r#type: MemType,
56    pub reserved: u32,
57}
58
59/// ZBI_TYPE_NVRAM payload.
60#[repr(C)]
61#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
62pub struct Nvram {
63    pub base: u64,
64    pub length: u64,
65}