This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yang, Longlong <[email protected]>
- Loading branch information
1 parent
1cdaa66
commit 3b822ff
Showing
64 changed files
with
3,891 additions
and
3,326 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "tdisp" | ||
license = "BSD-2-Clause-Patent" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
authors = [ | ||
"Jiewen Yao <[email protected]>", | ||
"Xiaoyu Lu <[email protected]>", | ||
|
@@ -12,12 +12,15 @@ edition = "2018" | |
[dev-dependencies] | ||
|
||
[build-dependencies] | ||
serde_json = "1.0" | ||
serde = { version = "1.0", features = ["derive"] } | ||
spin = { version = "0.9.8", optional = true } | ||
|
||
[dependencies] | ||
codec = { path = "../codec" } | ||
bitflags = "1.2.1" | ||
zeroize = { version = "1.5.0", features = ["zeroize_derive"]} | ||
spdmlib = { path = "../spdmlib", default-features = false, features = ["spdm-ring"]} | ||
|
||
conquer-once = { version = "0.3.2", default-features = false } | ||
spin = { version = "0.9.8" } | ||
|
||
[features] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright (c) 2023 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
use serde::Deserialize; | ||
use std::env; | ||
use std::io::Write; | ||
use std::path::Path; | ||
use std::{fs, fs::File}; | ||
|
||
#[derive(Debug, PartialEq, Deserialize)] | ||
struct TdispConfig { | ||
max_mmio_range_count: usize, | ||
max_device_report_buffer_size: usize, | ||
max_report_portion_length: usize, | ||
max_device_specific_info_size: usize, | ||
} | ||
|
||
impl TdispConfig { | ||
fn validate_content(&self) { | ||
// All rust fixed-size arrays require non-negative compile-time constant sizes. | ||
// This will be checked by the compiler thus no need to check again here. | ||
|
||
// TODO: add more sanity checks if needed. | ||
} | ||
} | ||
|
||
macro_rules! TEMPLATE { | ||
() => { | ||
"// Copyright (c) 2023 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
// | ||
// Automatically generated by build scripts. | ||
// It is not intended for manual editing. | ||
// Please kindly configure via etc/config.json instead. | ||
pub const MAX_MMIO_RANGE_COUNT: usize = {max_mmio_range_count}; | ||
pub const MAX_DEVICE_SPECIFIC_INFO_LEN: usize = {max_device_specific_info_len}; | ||
pub const MAX_PORTION_LENGTH: usize = {max_portion_length}; | ||
pub const MAX_DEVICE_REPORT_BUFFER: usize = {max_device_report_buffer}; | ||
" | ||
}; | ||
} | ||
|
||
const TDISP_CONFIG_ENV: &str = "TDISP_CONFIG"; | ||
const TDISP_CONFIG_JSON_DEFAULT_PATH: &str = "etc/config.json"; | ||
const TDISP_CONFIG_RS_OUT_DIR: &str = "src"; | ||
const TDISP_CONFIG_RS_OUT_FILE_NAME: &str = "config.rs"; | ||
|
||
fn main() { | ||
// Read and parse the TDISP configuration file. | ||
let tdisp_config_json_file_path = | ||
env::var(TDISP_CONFIG_ENV).unwrap_or_else(|_| TDISP_CONFIG_JSON_DEFAULT_PATH.to_string()); | ||
let tdisp_config_json_file = File::open(tdisp_config_json_file_path) | ||
.expect("The TDISP configuration file does not exist"); | ||
let tdisp_config: TdispConfig = serde_json::from_reader(tdisp_config_json_file) | ||
.expect("It is not a valid SPDM configuration file."); | ||
|
||
// Do sanity checks. | ||
tdisp_config.validate_content(); | ||
|
||
// Generate config .rs file from the template and JSON inputs, then write to fs. | ||
let mut to_generate = Vec::new(); | ||
write!( | ||
&mut to_generate, | ||
TEMPLATE!(), | ||
max_mmio_range_count = tdisp_config.max_mmio_range_count, | ||
max_device_specific_info_len = tdisp_config.max_device_specific_info_size, | ||
max_portion_length = tdisp_config.max_report_portion_length, | ||
max_device_report_buffer = tdisp_config.max_device_report_buffer_size, | ||
) | ||
.expect("Failed to generate configuration code from the template and JSON config"); | ||
|
||
let dest_path = Path::new(TDISP_CONFIG_RS_OUT_DIR).join(TDISP_CONFIG_RS_OUT_FILE_NAME); | ||
fs::write(dest_path, to_generate).unwrap(); | ||
|
||
// Re-run the build script if the files at the given paths or envs have changed. | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=../Cargo.lock"); | ||
println!("cargo:rerun-if-changed={}", TDISP_CONFIG_JSON_DEFAULT_PATH); | ||
println!("cargo:rerun-if-env-changed={}", TDISP_CONFIG_ENV); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"__usage": "This helps generate compile-time constant sizes for TDISP arrays. See src/config.rs generated for details.", | ||
"max_mmio_range_count": 4, | ||
"max_device_report_buffer_size": 1024, | ||
"max_report_portion_length": 256, | ||
"max_device_specific_info_size": 256 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
// Copyright (c) 2022 Intel Corporation | ||
// Copyright (c) 2023 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
// | ||
// Automatically generated by build scripts. | ||
// It is not intended for manual editing. | ||
// Please kindly configure via etc/config.json instead. | ||
|
||
pub const MAX_MMIO_RANGE_COUNT: usize = 4; | ||
|
||
pub const MAX_DEVICE_SPECIFIC_INFO_LEN: usize = 256; | ||
|
||
pub const MAX_PORTION_LENGTH: usize = 256; | ||
|
||
pub const MAX_VERSION_COUNT: usize = 2; | ||
pub const MAX_MESSAGE_INTERNAL_BUFFER_SIZE: usize = 0xA000; | ||
pub const MAX_MMIO_RANGE_COUNT: usize = 2; | ||
pub const MAX_DEVICE_SPECIFIC_INFORMATION_LENGTH: usize = 0xA000; | ||
pub const MAX_EXTENDED_ERROR_DATA_LENGTH: usize = 0xA000; | ||
pub const MAX_VENDOR_ID_LEN: usize = 0x20; | ||
pub const MAX_VENDOR_DATA_LENGTH: usize = 0xA000; | ||
pub const MAX_TDISP_MESSAGE_SIZE: usize = 0x1000; | ||
pub const MAX_DEVICE_REPORT_BUFFER: usize = 1024; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
// Copyright (c) 2022 Intel Corporation | ||
// Copyright (c) 2023 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 or MIT | ||
|
||
#![forbid(unsafe_code)] | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
#[macro_use] | ||
extern crate bitflags; | ||
|
||
pub mod common; | ||
pub mod config; | ||
pub mod context; | ||
pub mod device; | ||
pub mod message; | ||
pub mod state_machine; | ||
pub mod tdisp_codec; | ||
pub mod tdisp_requester; | ||
pub mod tdisp_responder; | ||
pub mod pci_tdisp; | ||
pub mod pci_tdisp_requester; | ||
pub mod pci_tdisp_responder; |
Oops, something went wrong.