Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
81913dd
kboot: Add USB4 router UUID to thunderbolt-drom
jannau Aug 14, 2026
f41373d
types: Import Linux's __{always,maybe}_unused
jannau Oct 11, 2026
e7cd995
kboot: multi-die: Remove obsolete pre-upstream "/soc%d" names
jannau Nov 17, 2026
59b70c2
kboot: touchbar: Do not use "touchbar0" alias
jannau Nov 17, 2026
510873e
kboot: Factor utility functions out to kboot_utils
jannau Nov 17, 2026
09a2a77
kboot_atc: Do not use "atcphy%d" aliases
jannau Nov 17, 2026
2593e97
devicetree: Add dt_node_is_compatible()
jannau Nov 25, 2026
806a418
kboot: Factor kboot_setup_matching_nodes() out of kboot_setup_atc()
jannau Nov 25, 2026
f538f6d
kboot: acio: Switch tunables copying to ADT/FDT node matching
jannau Nov 25, 2026
35265be
kboot: disable wfi/wfit if wfi loses state
yuyuyureka Nov 29, 2026
25ef4ce
firmware: recognize the Neo macOS 26.6.2 boot firmware
ADevWithAnIdea Oct 29, 2026
bad3cb4
boot: publish image and handoff data before disabling the cache
ADevWithAnIdea Oct 29, 2026
41737a6
memory: cover every cache line intersecting an unaligned range
ADevWithAnIdea Oct 29, 2026
1f21e08
kboot: dapf: reserve ANE and AVE ASC firmware and add fallback DAPF e…
Nov 29, 2026
ba25f03
kboot: atc: add atc-phy,t8130 tunable table
Nov 30, 2026
23ff4d1
dart, kboot: generically export preloaded DART mappings for Linux
Nov 30, 2026
06bc56a
kboot: reserve the iBoot trust cache in the Linux memory map
Nov 30, 2026
3f43628
kboot: export display power-LUT provider properties from ADT
Nov 30, 2026
b178f50
iodev: use non-blocking console writes for dockchannel UART
Nov 30, 2026
0db95fe
pcie: Add initial t8140 support
yuyuyureka Jul 28, 2026
0ca19b4
isp: select heap_top by chip_id instead of probing ISP_ASC_VERSION
Nov 30, 2026
b52d25d
kboot: populate CIO4 PHY and CIO v2 NHI calibration via node matching
Nov 30, 2026
365a328
kboot: forward ISP ACIPHY calibration fuses
Nov 30, 2026
5ad7209
kboot_gpu: replace T8132 handoff with generic G16+ GPU DT population
Dec 1, 2026
81e37ad
kboot: trim trailing firmware segments from DCP data carveouts
Dec 1, 2026
5ad6270
kboot: enable display handoff for T6041
Dec 1, 2026
2b98c94
gapf: clear DART clock-protection slices before booting Linux
Dec 1, 2026
c6f10fa
kboot: skip __OS_LOG segments in dt_reserve_asc_firmware()
Dec 1, 2026
0b223cb
kboot: add T8140 display handoff
Dec 1, 2026
2ee3221
kboot_utils: match unnumbered ADT nodes in adt_device_prefix_addrs()
Dec 1, 2026
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ OBJECTS := \
exception.o exception_asm.o \
fb.o font.o font_retina.o \
firmware.o \
gapf.o \
gxf.o gxf_asm.o \
heapblock.o \
hv.o hv_vm.o hv_exc.o hv_sptm.o \
Expand All @@ -158,7 +159,7 @@ OBJECTS := \
iodev.o \
iova.o \
isp.o \
kboot.o kboot_atc.o \
kboot.o kboot_atc.o kboot_utils.o \
kboot_t6020_compat.o \
main.o \
mitigations.o \
Expand Down
7 changes: 7 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ crate-type = [ "staticlib" ]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fatfs = { git = "https://github.com/rafalh/rust-fatfs", rev = "4eccb50d011146fbed20e133d33b22f3c27292e7", default-features = false, features = ["lfn", "alloc"], optional = true }
sha1_smol = { version = "1.0.1" }
uuid = { version = "1.23", default-features = false, optional = true }
versions = { path = "./versions" }

Expand Down
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub mod gpu;
#[cfg(feature = "chainload")]
pub mod nvme;
pub mod print;
pub mod usb4;

#[cfg(not(test))]
use crate::dlmalloc::DLMalloc;
Expand Down
75 changes: 75 additions & 0 deletions rust/src/usb4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: MIT

use crate::adt::{ADTNode, AdtError};
use crate::println;
use sha1_smol::Sha1;

const PLATFORM_UUID_SALT: [u8; 16] = [
0xa6, 0xdd, 0x4c, 0xcb, 0xb5, 0xe8, 0x4a, 0xf5, 0xac, 0xdd, 0xb6, 0xdc, 0x6a, 0x05, 0x42, 0xb8,
];

const DROM_UUID_SALT: [u8; 16] = [
0x06, 0xbf, 0x07, 0x64, 0x05, 0x78, 0x4a, 0xaa, 0x85, 0xb4, 0x79, 0x08, 0x34, 0x8e, 0xe3, 0x43,
];

fn usb4_router_uuid() -> Result<u64, AdtError> {
let node = ADTNode::from_path("/chosen")?;
let unique_chip_id = node.named_prop("unique-chip-id")?.u64()?;
let chip_id = node.named_prop("chip-id")?.u32()?;

let mut hasher = Sha1::new();
hasher.update(&PLATFORM_UUID_SALT);
hasher.update(&unique_chip_id.to_le_bytes());
hasher.update(&chip_id.to_le_bytes());

let digest = hasher.digest();

let mut uuid: [u8; 16] = digest.bytes()[0..16].try_into().unwrap();

uuid[6] = 0x50 | (uuid[6] & 0xf);
uuid[8] = 0x80 | (uuid[8] & 0x3f);

// println!(
// "IOPlatformUUID: \
// {:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x} \
// {:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
// uuid[0],
// uuid[1],
// uuid[2],
// uuid[3],
// uuid[4],
// uuid[5],
// uuid[6],
// uuid[7],
// uuid[8],
// uuid[9],
// uuid[10],
// uuid[11],
// uuid[12],
// uuid[13],
// uuid[14],
// uuid[15]
// );

let mut drom_sha1 = Sha1::new();
drom_sha1.update(&uuid);
drom_sha1.update(&DROM_UUID_SALT);

let drom_digest = drom_sha1.digest();
let drom_bytes: [u8; 8] = drom_digest.bytes()[0..8].try_into().unwrap();

let mut drom_uuid: u64 = u64::from_le_bytes(drom_bytes);

drom_uuid = (drom_uuid & 0xffff_ffff_fff0u64) | (0x05ac << 48);
// println!("USB4 router UUID: {:#08x}", drom_uuid);

Ok(drom_uuid)
}

#[no_mangle]
pub unsafe extern "C" fn rust_usb4_router_uuid() -> u64 {
match usb4_router_uuid() {
Ok(uuid) => uuid,
Err(_) => 0,
}
}
35 changes: 35 additions & 0 deletions src/atc.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,43 @@ const struct atc_tunable_info atc_tunables_t8122[] = {
{"tunable_LN1_TX_SHM_CIO_DFLT", "apple,tunable-lane1-cio", 0x14000, 0x1000, true},
};

const struct atc_tunable_info atc_tunables_t8130[] = {
{"tunable_ATC0AXI2AF", "apple,tunable-axi2af", 0x0, 0x8000, true},
{"tunable_ATC_FABRIC", "apple,tunable-common-b", 0x44000, 0x4000, true},

{"tunable_ACIOPHY_TOP", "apple,tunable-common-b", 0x0, 0x4000, true},
{"tunable_AUSCMN_DIG", "apple,tunable-common-b", 0x800, 0x200, true},
{"tunable_AUSCMN_SHM", "apple,tunable-common-b", 0xa00, 0x200, true},
{"tunable_ACIOPHY_PLL_TOP", "apple,tunable-common-b", 0x1000, 0x4000, true},
{"tunable_AUSPLL_CORE", "apple,tunable-common-b", 0x2200, 0x4000, true},
{"tunable_CLKMON_CFG", "apple,tunable-common-b", 0x2600, 0x100, false},
{"tunable_CIO3PLL_TOP", "apple,tunable-common-b", 0x2800, 0x200, true},
{"tunable_CIO3PLL_CORE", "apple,tunable-common-b", 0x2a00, 0x200, true},
{"tunable_CIO_SHIM", "apple,tunable-common-b", 0x4000, 0x4000, true},
{"tunable_ACIOPHY_LANE_USBC0", "apple,tunable-common-b", 0x5000, 0x1000, true},
{"tunable_ACIOPHY_LANE_USBC1", "apple,tunable-common-b", 0x7000, 0x1000, true},
{"tunable_AUX_TOP", "apple,tunable-common-b", 0x16000, 0x4000, true},

{"tunable_LN0_RX_TOP_USB_DFLT", "apple,tunable-lane0-usb", 0x9000, 0x1000, true},
{"tunable_LN0_RX_TOP_USB_EQA", "apple,tunable-lane0-usb", 0x9000, 0x1000, false},
{"tunable_LN0_RX_EQ_USB_EQA", "apple,tunable-lane0-usb", 0xa000, 0x1000, true},
{"tunable_LN0_RX_SHM_USB_DFLT", "apple,tunable-lane0-usb", 0xb000, 0x1000, true},
{"tunable_LN0_TX_TOP_USB_DFLT", "apple,tunable-lane0-usb", 0xc000, 0x1000, true},
{"tunable_LN0_TX_SHM_USB_DFLT", "apple,tunable-lane0-usb", 0xd000, 0x1000, true},

{"tunable_LN1_RX_TOP_USB_DFLT", "apple,tunable-lane1-usb", 0x10000, 0x1000, true},
{"tunable_LN1_RX_TOP_USB_EQA", "apple,tunable-lane1-usb", 0x10000, 0x1000, false},
{"tunable_LN1_RX_EQ_USB_EQA", "apple,tunable-lane1-usb", 0x11000, 0x1000, true},
{"tunable_LN1_RX_SHM_USB_DFLT", "apple,tunable-lane1-usb", 0x12000, 0x1000, true},
{"tunable_LN1_TX_TOP_USB_DFLT", "apple,tunable-lane1-usb", 0x13000, 0x1000, true},
{"tunable_LN1_TX_SHM_USB_DFLT", "apple,tunable-lane1-usb", 0x14000, 0x1000, true},

{"tunable_ATC_COMMON_CFG", "apple,tunable-lpdptx", 0x0, 0x8000, true},
};

const size_t atc_tunables_t8103_count = ARRAY_SIZE(atc_tunables_t8103);
const size_t atc_tunables_t8122_count = ARRAY_SIZE(atc_tunables_t8122);
const size_t atc_tunables_t8130_count = ARRAY_SIZE(atc_tunables_t8130);

int atc_get_tunables(int adt_node, const struct atc_tunable_info *info,
const struct atc_tunable **tunables)
Expand Down
2 changes: 2 additions & 0 deletions src/atc.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ extern const struct atc_tunable_info atc_tunables_t8103[];
extern const size_t atc_tunables_t8103_count;
extern const struct atc_tunable_info atc_tunables_t8122[];
extern const size_t atc_tunables_t8122_count;
extern const struct atc_tunable_info atc_tunables_t8130[];
extern const size_t atc_tunables_t8130_count;

/* Return the record count, zero for an absent optional table, or -1 on error. */
int atc_get_tunables(int adt_node, const struct atc_tunable_info *info,
Expand Down
6 changes: 5 additions & 1 deletion src/chainload.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ int chainload_image(void *image, size_t size, char **vars, size_t var_cnt)
// Keep the next heap above both the inherited reservation and the loaded image.
new_boot_args->top_of_kernel_data = max(cur_boot_args.top_of_kernel_data, new_base + image_size);

/* The copy stub reads these buffers after the MMU and caches are disabled. */
dc_civac_range(new_image, image_size);
dc_civac_range(adt, cur_boot_args.devtree_size);

// Copy chainload stub
void *stub = new_image + image_size;
memcpy(stub, _chainload_stub_start, stub_size);
dc_cvau_range(stub, stub_size);
dc_civac_range(stub, stub_size);
ic_ivau_range(stub, stub_size);

// Set up next stage
Expand Down
5 changes: 4 additions & 1 deletion src/chainload_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ _chainload_stub_start:
ldp x5, x6, [x1], #16
stp x5, x6, [x2]
dc cvau, x2
ic ivau, x2
add x2, x2, #16
sub x3, x3, #16
cbnz x3, 1b

dsb sy
ic iallu
dsb sy
isb
br x4
_chainload_stub_end:
4 changes: 3 additions & 1 deletion src/dapf.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ struct entry dapf_entries[] = {
{"/arm-io/dart-pmp", 1}, {"/arm-io/dart-dcp", 1},
{"/arm-io/dart-dcpext0", 1}, {"/arm-io/dart-isp", 5},
{"/arm-io/dart-isp0", 5}, {"/arm-io/dart-ane", 3},
{"/arm-io/dart-ave", 3}, {NULL, -1},
{"/arm-io/dart-ane0", 3}, {"/arm-io/dart-ave", 3},
{"/arm-io/dart-ave0", 3}, {"/arm-io/dart-ave1", 3},
{NULL, -1},
};

static int dapf_table_index(const char *path)
Expand Down
Loading
Loading