fidl_data_zbi/
kernel.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/// The kernel image.  In a bootable ZBI this item must always be first,
13/// immediately after the ZBI_TYPE_CONTAINER header.  The contiguous memory
14/// image of the kernel is formed from the ZBI_TYPE_CONTAINER header, the
15/// ZBI_TYPE_KERNEL_{ARCH} header, and the payload.
16///
17/// The boot loader loads the whole image starting with the container header
18/// through to the end of the kernel item's payload into contiguous physical
19/// memory.  It then constructs a partial ZBI elsewhere in memory, which has
20/// a ZBI_TYPE_CONTAINER header of its own followed by all the other items
21/// that were in the booted ZBI plus other items synthesized by the boot
22/// loader to describe the machine.  This partial ZBI must be placed at an
23/// address (where the container header is found) that is aligned to the
24/// machine's page size.  The precise protocol for transferring control to
25/// the kernel's entry point varies by machine.
26///
27/// On all machines, the kernel requires some amount of scratch memory to be
28/// available immediately after the kernel image at boot.  It needs this
29/// space for early setup work before it has a chance to read any memory-map
30/// information from the boot loader.  The `reserve_memory_size` field tells
31/// the boot loader how much space after the kernel's load image it must
32/// leave available for the kernel's use.  The boot loader must place its
33/// constructed ZBI or other reserved areas at least this many bytes after
34/// the kernel image.
35///
36/// x86-64
37///
38///     The kernel assumes it was loaded at a fixed physical address of
39///     0x100000 (1MB).  zbi_kernel_t.entry is the absolute physical address
40///     of the PC location where the kernel will start.
41///     TODO(https://fxbug.dev/42098994): Perhaps this will change??
42///     The processor is in 64-bit mode with direct virtual to physical
43///     mapping covering the physical memory where the kernel and
44///     bootloader-constructed ZBI were loaded.
45///     The %rsi register holds the physical address of the
46///     bootloader-constructed ZBI.
47///     All other registers are unspecified.
48///
49///  ARM64
50///
51///     zbi_kernel_t.entry is an offset from the beginning of the image
52///     (i.e., the ZBI_TYPE_CONTAINER header before the ZBI_TYPE_KERNEL_ARM64
53///     header) to the PC location in the image where the kernel will
54///     start.  The processor is in physical address mode at EL1 or
55///     above (i.e., SCTLR_ELx.M = 0), which in turn necessitates that its
56///     instruction and data caches are also disabled (i.e.,
57///     SCTLR_ELx.{I, D} = 0).  The kernel image and the bootloader-constructed
58///     ZBI each can be loaded anywhere in physical memory.  The x0 register
59///     holds the physical address of the bootloader-constructed ZBI.
60///     All other registers are unspecified.
61///
62///     The address range corresponding to the loaded kernel image must be
63///     cleaned - but not necessarily invalidated - to the point of coherency
64///     in the data cache (reserve memory included) and invalidated in the
65///     instruction cache (reserve memory not necessarily included).
66///
67///  RISCV64
68///
69///     zbi_kernel_t.entry is an offset from the beginning of the image (i.e.,
70///     the ZBI_TYPE_CONTAINER header before the ZBI_TYPE_KERNEL_RISCV64 header)
71///     to the PC location in the image where the kernel will start.  The
72///     processor is in S mode, satp is zero, sstatus.SIE is zero.  The kernel
73///     image and the bootloader-constructed ZBI each can be loaded anywhere in
74///     physical memory, aligned to 4KiB.  The a0 register holds the HART ID,
75///     and the a1 register holds the 4KiB-aligned physical address of the
76///     bootloader-constructed ZBI.  All other registers are unspecified.
77#[repr(C)]
78#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
79pub struct Kernel {
80    /// Entry-point address.  The interpretation of this differs by machine.
81    pub entry: u64,
82
83    /// Minimum amount (in bytes) of scratch memory that the kernel requires
84    /// immediately after its load image.
85    pub reserve_memory_size: u64,
86}