Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

td-layout: support large payload #693

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions td-layout/src/build_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/*
Image Layout
+----------------------------------------+ <- 0x0
| LARGE_PAYLOAD | (0x0) 0 B
+----------------------------------------+ <- 0x0
| CONFIG | (0x40000) 256 kB
+----------------------------------------+ <- 0x40000
| MAILBOX | (0x1000) 4 kB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change KB to kB?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is generated with a third-party crate which changes its size format.

Expand All @@ -29,6 +31,10 @@ Image size: 0x1000000 (16 MB)
*/

// Image Layout Configuration
pub const TD_SHIM_FIRMWARE_SIZE: u32 = 0x1000000;

pub const TD_SHIM_LARGE_PAYLOAD_OFFSET: u32 = 0x0;
pub const TD_SHIM_LARGE_PAYLOAD_SIZE: u32 = 0x0; // 0 B

pub const TD_SHIM_CONFIG_OFFSET: u32 = 0x0;
pub const TD_SHIM_CONFIG_SIZE: u32 = 0x40000; // 256 kB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change KB to kB?

Expand Down Expand Up @@ -57,16 +63,14 @@ pub const TD_SHIM_IPL_SIZE: u32 = 0x349000; // 3.29 MB
pub const TD_SHIM_RESET_VECTOR_OFFSET: u32 = 0xFF8000;
pub const TD_SHIM_RESET_VECTOR_SIZE: u32 = 0x8000; // 32 kB

// Offset when Loading into Memory
pub const TD_SHIM_FIRMWARE_BASE: u32 = 0xFF000000;
pub const TD_SHIM_FIRMWARE_SIZE: u32 = 0x1000000;

// TD_SHIM_SEC_INFO_OFFSET equals to firmware size - metadata pointer offset -
// OVMF GUID table size - SEC Core information size.
pub const TD_SHIM_SEC_CORE_INFO_OFFSET: u32 = 0xFFFFAC;
pub const TD_SHIM_SEC_CORE_INFO_BASE: u32 = 0xFFFFFFAC;

// Base Address after Loaded into Memory
// Rom Configuration

pub const TD_SHIM_FIRMWARE_BASE: u32 = 0xFF000000;
pub const TD_SHIM_CONFIG_BASE: u32 = 0xFF000000;
pub const TD_SHIM_MAILBOX_BASE: u32 = 0xFF040000;
pub const TD_SHIM_TEMP_STACK_BASE: u32 = 0xFF041000;
Expand Down
14 changes: 12 additions & 2 deletions td-layout/src/memslice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
//
// SPDX-License-Identifier: BSD-2-Clause-Patent

use crate::build_time::*;
use crate::{
build_time::*,
runtime::exec::{LARGE_PAYLOAD_BASE, LARGE_PAYLOAD_SIZE},
};
use core::fmt::Display;

/// Type of build time and runtime memory regions.
Expand All @@ -16,6 +19,8 @@ pub enum SliceType {
ShimPayload,
/// The `TD_MAILBOX` region in image file
MailBox,
/// The `Large PAYLOAD` region in runtime memory layout
LargePayload,
/// The `PAYLOAD` region in runtime memory layout
Payload,
/// The `Kernel Parameter` region in runtime memory layout
Expand All @@ -41,6 +46,7 @@ impl SliceType {
SliceType::TdHob => "TdHob",
SliceType::ShimPayload => "ShimPayload",
SliceType::MailBox => "MailBox",
SliceType::LargePayload => "LargePayload",
SliceType::Payload => "Payload",
SliceType::PayloadParameter => "PayloadParameter",
SliceType::PayloadHob => "PayloadHob",
Expand Down Expand Up @@ -73,6 +79,10 @@ pub fn get_mem_slice<'a>(t: SliceType) -> &'a [u8] {
TD_SHIM_PAYLOAD_BASE as *const u8,
TD_SHIM_PAYLOAD_SIZE as usize,
),
SliceType::LargePayload => core::slice::from_raw_parts(
LARGE_PAYLOAD_BASE as *const u8,
LARGE_PAYLOAD_SIZE as usize,
),
SliceType::MailBox => core::slice::from_raw_parts(
TD_SHIM_MAILBOX_BASE as *const u8,
TD_SHIM_MAILBOX_SIZE as usize,
Expand All @@ -94,7 +104,7 @@ pub unsafe fn get_mem_slice_mut<'a>(t: SliceType) -> &'a mut [u8] {
TD_SHIM_MAILBOX_BASE as *const u8 as *mut u8,
TD_SHIM_MAILBOX_SIZE as usize,
),
SliceType::Config | SliceType::ShimPayload => {
SliceType::Config | SliceType::ShimPayload | SliceType::LargePayload => {
panic!("get_mem_slice_mut: read only")
}
_ => panic!("get_mem_slice_mut: not support"),
Expand Down
5 changes: 5 additions & 0 deletions td-layout/src/runtime/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Top of Low Memory: 0x80000000
+----------------------------------------+ <- 0x7DDDE000
| FREE | (0x7D5BE000) 1.96 GB
+----------------------------------------+ <- 0x820000
| LARGE_PAYLOAD | (0x0) 0 B
+----------------------------------------+ <- 0x820000
| TD_HOB | (0x20000) 128 kB
+----------------------------------------+ <- 0x800000
| BOOTLOADER | (0x800000) 8 MB
Expand All @@ -34,6 +36,8 @@ pub const BOOTLOADER_BASE: usize = 0x0;
pub const BOOTLOADER_SIZE: usize = 0x800000; // 8 MB
pub const TD_HOB_BASE: usize = 0x800000;
pub const TD_HOB_SIZE: usize = 0x20000; // 128 kB
pub const LARGE_PAYLOAD_BASE: usize = 0x820000;
pub const LARGE_PAYLOAD_SIZE: usize = 0x0; // 0 B
pub const ACPI_SIZE: usize = 0x100000; // 1 MB
pub const PAYLOAD_SIZE: usize = 0x2000000; // 32 MB
pub const PAYLOAD_PAGE_TABLE_SIZE: usize = 0x20000; // 128 kB
Expand All @@ -44,6 +48,7 @@ pub const MEMORY_LAYOUT_CONFIG: &[(&'static str, usize, &'static str)] = &[
// (name of memory region, region size, region type)
("Bootloader", 0x800000, "Memory"),
("TdHob", 0x20000, "Memory"),
("LargePayload", 0x0, "Memory"),
("Acpi", 0x100000, "Acpi"),
("Payload", 0x2000000, "Reserved"),
("PayloadPageTable", 0x20000, "Reserved"),
Expand Down