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. The kernel image and the bootloader-constructed ZBI each
56/// can be loaded anywhere in physical memory. The x0 register
57/// holds the physical address of the bootloader-constructed ZBI.
58/// All other registers are unspecified.
59///
60/// RISCV64
61///
62/// zbi_kernel_t.entry is an offset from the beginning of the image (i.e.,
63/// the ZBI_TYPE_CONTAINER header before the ZBI_TYPE_KERNEL_RISCV64 header)
64/// to the PC location in the image where the kernel will start. The
65/// processor is in S mode, satp is zero, sstatus.SIE is zero. The kernel
66/// image and the bootloader-constructed ZBI each can be loaded anywhere in
67/// physical memory, aligned to 4KiB. The a0 register holds the HART ID,
68/// and the a1 register holds the 4KiB-aligned physical address of the
69/// bootloader-constructed ZBI. All other registers are unspecified.
70#[repr(C)]
71#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
72pub struct Kernel {
73 /// Entry-point address. The interpretation of this differs by machine.
74 pub entry: u64,
75
76 /// Minimum amount (in bytes) of scratch memory that the kernel requires
77 /// immediately after its load image.
78 pub reserve_memory_size: u64,
79}