mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 02:48:11 +01:00
Store the last three CRLF headers with LF
.gitattributes normalises text to LF, but t210/memory_map.h, mmio.h and tegra_bl.h were committed with CRLF before it was added, so any edit to them either rewrote every line or had to be staged around the filter. Line endings only; no content changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
This commit is contained in:
3 files changed
+380
-380
No files matched your search
+266
-266
@@ -1,266 +1,266 @@
|
|||||||
#ifndef T210_MEMORY_MAP_H
|
#ifndef T210_MEMORY_MAP_H
|
||||||
#define T210_MEMORY_MAP_H
|
#define T210_MEMORY_MAP_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tegra X1 (T210) Memory Map for RCM Payload Emulation
|
* Tegra X1 (T210) Memory Map for RCM Payload Emulation
|
||||||
*
|
*
|
||||||
* RCM payloads (hekate, etc.) run ARM32 code on the BPMP.
|
* RCM payloads (hekate, etc.) run ARM32 code on the BPMP.
|
||||||
* They primarily use IRAM and access hardware via MMIO registers.
|
* They primarily use IRAM and access hardware via MMIO registers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ==================== RAM Regions ====================
|
// ==================== RAM Regions ====================
|
||||||
|
|
||||||
// IRAM (Internal SRAM) - 256KB
|
// IRAM (Internal SRAM) - 256KB
|
||||||
constexpr uint64_t IRAM_BASE = 0x40000000;
|
constexpr uint64_t IRAM_BASE = 0x40000000;
|
||||||
constexpr uint64_t IRAM_SIZE = (16 * 1024 * 1024); // 16 MB mapped (actual 512 KB, but hekate needs relocation space)
|
constexpr uint64_t IRAM_SIZE = (16 * 1024 * 1024); // 16 MB mapped (actual 512 KB, but hekate needs relocation space)
|
||||||
|
|
||||||
// DRAM - We allocate a modest amount for framebuffer + heap
|
// DRAM - We allocate a modest amount for framebuffer + heap
|
||||||
constexpr uint64_t DRAM_BASE = 0x80000000;
|
constexpr uint64_t DRAM_BASE = 0x80000000;
|
||||||
// Size of the contiguous DRAM window we map. The BPMP is a 32-bit core, so
|
// Size of the contiguous DRAM window we map. The BPMP is a 32-bit core, so
|
||||||
// everything it can address above DRAM_BASE ends at 0x100000000 - that upper
|
// everything it can address above DRAM_BASE ends at 0x100000000 - that upper
|
||||||
// bound, not the console's physical 4 GB, is what a BPMP-side payload can
|
// bound, not the console's physical 4 GB, is what a BPMP-side payload can
|
||||||
// actually walk. MC_EMEM_CFG still reports the true 4096 MB.
|
// actually walk. MC_EMEM_CFG still reports the true 4096 MB.
|
||||||
constexpr uint64_t DRAM_WINDOW_SIZE = 0x80000000ULL; // 2 GB
|
constexpr uint64_t DRAM_WINDOW_SIZE = 0x80000000ULL; // 2 GB
|
||||||
constexpr uint64_t DRAM_SIZE = 0x80000000; // 2GB (Full T210 DRAM space for FatFs buffers)
|
constexpr uint64_t DRAM_SIZE = 0x80000000; // 2GB (Full T210 DRAM space for FatFs buffers)
|
||||||
|
|
||||||
// Payload load address within IRAM
|
// Payload load address within IRAM
|
||||||
constexpr uint64_t IPL_LOAD_ADDR = 0x40010000;
|
constexpr uint64_t IPL_LOAD_ADDR = 0x40010000;
|
||||||
|
|
||||||
// Stack addresses used by hekate
|
// Stack addresses used by hekate
|
||||||
constexpr uint64_t IPL_STACK_ADDR = 0x4003FF00;
|
constexpr uint64_t IPL_STACK_ADDR = 0x4003FF00;
|
||||||
|
|
||||||
// Heap (in DRAM)
|
// Heap (in DRAM)
|
||||||
constexpr uint64_t IPL_HEAP_START = 0x90000000;
|
constexpr uint64_t IPL_HEAP_START = 0x90000000;
|
||||||
constexpr uint64_t IPL_HEAP_SIZE = 0x02000000; // 32MB
|
constexpr uint64_t IPL_HEAP_SIZE = 0x02000000; // 32MB
|
||||||
|
|
||||||
// ==================== MMIO Regions ====================
|
// ==================== MMIO Regions ====================
|
||||||
// All MMIO is in the 0x50000000-0x7FFFFFFF range on T210
|
// All MMIO is in the 0x50000000-0x7FFFFFFF range on T210
|
||||||
|
|
||||||
// Clock and Reset Controller
|
// Clock and Reset Controller
|
||||||
constexpr uint64_t CLK_RST_BASE = 0x60006000;
|
constexpr uint64_t CLK_RST_BASE = 0x60006000;
|
||||||
constexpr uint64_t CLK_RST_SIZE = 0x1000;
|
constexpr uint64_t CLK_RST_SIZE = 0x1000;
|
||||||
|
|
||||||
// Timer (TMR)
|
// Timer (TMR)
|
||||||
constexpr uint64_t TMR_BASE = 0x60005000;
|
constexpr uint64_t TMR_BASE = 0x60005000;
|
||||||
constexpr uint64_t TMR_SIZE = 0x1000;
|
constexpr uint64_t TMR_SIZE = 0x1000;
|
||||||
|
|
||||||
// GPIO
|
// GPIO
|
||||||
constexpr uint64_t GPIO_BASE = 0x6000D000;
|
constexpr uint64_t GPIO_BASE = 0x6000D000;
|
||||||
constexpr uint64_t GPIO_SIZE = 0x1000;
|
constexpr uint64_t GPIO_SIZE = 0x1000;
|
||||||
|
|
||||||
// PINMUX
|
// PINMUX
|
||||||
constexpr uint64_t PINMUX_BASE = 0x70003000;
|
constexpr uint64_t PINMUX_BASE = 0x70003000;
|
||||||
constexpr uint64_t PINMUX_SIZE = 0x1000;
|
constexpr uint64_t PINMUX_SIZE = 0x1000;
|
||||||
|
|
||||||
// UART
|
// UART
|
||||||
constexpr uint64_t UART_A_BASE = 0x70006000;
|
constexpr uint64_t UART_A_BASE = 0x70006000;
|
||||||
constexpr uint64_t UART_SIZE = 0x1000;
|
constexpr uint64_t UART_SIZE = 0x1000;
|
||||||
|
|
||||||
// I2C controllers
|
// I2C controllers
|
||||||
// Note: Tegra X1 base offsets per Hekate bdk/soc/i2c.c _i2c_base_offsets[]:
|
// Note: Tegra X1 base offsets per Hekate bdk/soc/i2c.c _i2c_base_offsets[]:
|
||||||
// I2C1=0x0, I2C2=0x400, I2C3=0x500, I2C4=0x700, I2C5=0x1000, I2C6=0x1100
|
// I2C1=0x0, I2C2=0x400, I2C3=0x500, I2C4=0x700, I2C5=0x1000, I2C6=0x1100
|
||||||
// All measured from APB I2C base 0x7000C000.
|
// All measured from APB I2C base 0x7000C000.
|
||||||
constexpr uint64_t I2C1_BASE = 0x7000C000;
|
constexpr uint64_t I2C1_BASE = 0x7000C000;
|
||||||
constexpr uint64_t I2C2_BASE = 0x7000C400; // GEN2_I2C, Rohm BH1730 ALS at slave 0x29
|
constexpr uint64_t I2C2_BASE = 0x7000C400; // GEN2_I2C, Rohm BH1730 ALS at slave 0x29
|
||||||
constexpr uint64_t I2C2_SIZE = 0x100;
|
constexpr uint64_t I2C2_SIZE = 0x100;
|
||||||
constexpr uint64_t I2C3_BASE = 0x7000C500; // GEN3_I2C, used by STMFTS touchscreen at slave 0x49
|
constexpr uint64_t I2C3_BASE = 0x7000C500; // GEN3_I2C, used by STMFTS touchscreen at slave 0x49
|
||||||
constexpr uint64_t I2C5_BASE = 0x7000D000;
|
constexpr uint64_t I2C5_BASE = 0x7000D000;
|
||||||
constexpr uint64_t I2C_SIZE = 0x1000; // the MMIO page: I2C5, I2C6, SPI2B
|
constexpr uint64_t I2C_SIZE = 0x1000; // the MMIO page: I2C5, I2C6, SPI2B
|
||||||
constexpr uint64_t I2C_CTRL_SIZE = 0x100; // one controller's registers
|
constexpr uint64_t I2C_CTRL_SIZE = 0x100; // one controller's registers
|
||||||
constexpr uint64_t I2C4_BASE = 0x7000C700;
|
constexpr uint64_t I2C4_BASE = 0x7000C700;
|
||||||
constexpr uint64_t I2C6_BASE = 0x7000D100;
|
constexpr uint64_t I2C6_BASE = 0x7000D100;
|
||||||
constexpr uint64_t I2C3_SIZE = 0x100;
|
constexpr uint64_t I2C3_SIZE = 0x100;
|
||||||
|
|
||||||
// PWM
|
// PWM
|
||||||
constexpr uint64_t PWM_BASE = 0x7000A000;
|
constexpr uint64_t PWM_BASE = 0x7000A000;
|
||||||
constexpr uint64_t PWM_SIZE = 0x1000;
|
constexpr uint64_t PWM_SIZE = 0x1000;
|
||||||
|
|
||||||
// RTC
|
// RTC
|
||||||
constexpr uint64_t RTC_BASE = 0x7000E000;
|
constexpr uint64_t RTC_BASE = 0x7000E000;
|
||||||
// 0x400, NOT 0x1000: the PMC block starts at 0x7000E400, immediately after the
|
// 0x400, NOT 0x1000: the PMC block starts at 0x7000E400, immediately after the
|
||||||
// RTC. A 0x1000-long RTC window swallowed the whole PMC range, and because the
|
// RTC. A 0x1000-long RTC window swallowed the whole PMC range, and because the
|
||||||
// RTC branch is tested first in the MMIO dispatch, every PMC access (reset
|
// RTC branch is tested first in the MMIO dispatch, every PMC access (reset
|
||||||
// status, scratch registers, and the MAIN_RST reboot write) silently went to
|
// status, scratch registers, and the MAIN_RST reboot write) silently went to
|
||||||
// the RTC handler instead.
|
// the RTC handler instead.
|
||||||
constexpr uint64_t RTC_SIZE = 0x400;
|
constexpr uint64_t RTC_SIZE = 0x400;
|
||||||
|
|
||||||
// PMC (Power Management Controller)
|
// PMC (Power Management Controller)
|
||||||
constexpr uint64_t PMC_BASE = 0x7000E400;
|
constexpr uint64_t PMC_BASE = 0x7000E400;
|
||||||
constexpr uint64_t PMC_SIZE = 0x0C00;
|
constexpr uint64_t PMC_SIZE = 0x0C00;
|
||||||
|
|
||||||
// Fuse Controller
|
// Fuse Controller
|
||||||
constexpr uint64_t FUSE_BASE = 0x7000F800;
|
constexpr uint64_t FUSE_BASE = 0x7000F800;
|
||||||
constexpr uint64_t FUSE_SIZE = 0x0400;
|
constexpr uint64_t FUSE_SIZE = 0x0400;
|
||||||
|
|
||||||
// EMC (External Memory Controller). EMC_BASE is the broadcast/control bank;
|
// EMC (External Memory Controller). EMC_BASE is the broadcast/control bank;
|
||||||
// EMC0/EMC1 are the per-channel banks used to read mode-register responses
|
// EMC0/EMC1 are the per-channel banks used to read mode-register responses
|
||||||
// (sdram_read_mrx splits the 16-bit MRR into low byte = ch0, high byte = ch1).
|
// (sdram_read_mrx splits the 16-bit MRR into low byte = ch0, high byte = ch1).
|
||||||
constexpr uint64_t EMC_BASE = 0x7001B000;
|
constexpr uint64_t EMC_BASE = 0x7001B000;
|
||||||
constexpr uint64_t EMC_SIZE = 0x1000;
|
constexpr uint64_t EMC_SIZE = 0x1000;
|
||||||
constexpr uint64_t EMC0_BASE = 0x7001E000;
|
constexpr uint64_t EMC0_BASE = 0x7001E000;
|
||||||
constexpr uint64_t EMC1_BASE = 0x7001F000;
|
constexpr uint64_t EMC1_BASE = 0x7001F000;
|
||||||
|
|
||||||
// MC (Memory Controller)
|
// MC (Memory Controller)
|
||||||
constexpr uint64_t MC_BASE = 0x70019000;
|
constexpr uint64_t MC_BASE = 0x70019000;
|
||||||
constexpr uint64_t MC_SIZE = 0x1000;
|
constexpr uint64_t MC_SIZE = 0x1000;
|
||||||
|
|
||||||
// Display Controller (DC/DSI)
|
// Display Controller (DC/DSI)
|
||||||
constexpr uint64_t DISPLAY_A_BASE = 0x54200000;
|
constexpr uint64_t DISPLAY_A_BASE = 0x54200000;
|
||||||
constexpr uint64_t DISPLAY_SIZE = 0x40000;
|
constexpr uint64_t DISPLAY_SIZE = 0x40000;
|
||||||
|
|
||||||
// DSI Controller
|
// DSI Controller
|
||||||
constexpr uint64_t DSI_BASE = 0x54300000;
|
constexpr uint64_t DSI_BASE = 0x54300000;
|
||||||
constexpr uint64_t DSI_SIZE = 0x1000;
|
constexpr uint64_t DSI_SIZE = 0x1000;
|
||||||
|
|
||||||
// SOC_THERM - on-die thermal sensors (tCPU0-3, tMEM0/1, tGPU, tPLLX).
|
// SOC_THERM - on-die thermal sensors (tCPU0-3, tMEM0/1, tGPU, tPLLX).
|
||||||
// Distinct from the TMP451 (I2C) board sensor: these are the Tegra's own
|
// Distinct from the TMP451 (I2C) board sensor: these are the Tegra's own
|
||||||
// internal sensors, calibrated by fuses, that HOS/HW tests read to spot bad
|
// internal sensors, calibrated by fuses, that HOS/HW tests read to spot bad
|
||||||
// factory thermal-cal fuses.
|
// factory thermal-cal fuses.
|
||||||
constexpr uint64_t SOC_THERM_BASE = 0x700E2000;
|
constexpr uint64_t SOC_THERM_BASE = 0x700E2000;
|
||||||
constexpr uint64_t SOC_THERM_SIZE = 0x1000;
|
constexpr uint64_t SOC_THERM_SIZE = 0x1000;
|
||||||
|
|
||||||
// MIPI CAL
|
// MIPI CAL
|
||||||
constexpr uint64_t MIPI_CAL_BASE = 0x700E3000;
|
constexpr uint64_t MIPI_CAL_BASE = 0x700E3000;
|
||||||
constexpr uint64_t MIPI_CAL_SIZE = 0x1000;
|
constexpr uint64_t MIPI_CAL_SIZE = 0x1000;
|
||||||
|
|
||||||
// SOR (Serial Output Resource) / HDMI
|
// SOR (Serial Output Resource) / HDMI
|
||||||
constexpr uint64_t SOR_BASE = 0x54540000;
|
constexpr uint64_t SOR_BASE = 0x54540000;
|
||||||
constexpr uint64_t SOR_SIZE = 0x1000;
|
constexpr uint64_t SOR_SIZE = 0x1000;
|
||||||
|
|
||||||
// SDMMC controllers
|
// SDMMC controllers
|
||||||
constexpr uint64_t SDMMC1_BASE = 0x700B0000; // SD Card
|
constexpr uint64_t SDMMC1_BASE = 0x700B0000; // SD Card
|
||||||
constexpr uint64_t SDMMC4_BASE = 0x700B0600; // eMMC
|
constexpr uint64_t SDMMC4_BASE = 0x700B0600; // eMMC
|
||||||
constexpr uint64_t SDMMC_SIZE = 0x1000;
|
constexpr uint64_t SDMMC_SIZE = 0x1000;
|
||||||
|
|
||||||
// APB Misc
|
// APB Misc
|
||||||
constexpr uint64_t APB_MISC_BASE = 0x70000000;
|
constexpr uint64_t APB_MISC_BASE = 0x70000000;
|
||||||
constexpr uint64_t APB_MISC_SIZE = 0x1000;
|
constexpr uint64_t APB_MISC_SIZE = 0x1000;
|
||||||
|
|
||||||
// VIC (Video Image Compositor)
|
// VIC (Video Image Compositor)
|
||||||
constexpr uint64_t VIC_BASE = 0x54340000;
|
constexpr uint64_t VIC_BASE = 0x54340000;
|
||||||
constexpr uint64_t VIC_SIZE = 0x40000;
|
constexpr uint64_t VIC_SIZE = 0x40000;
|
||||||
|
|
||||||
// Host1x (display sync)
|
// Host1x (display sync)
|
||||||
constexpr uint64_t HOST1X_BASE = 0x50000000;
|
constexpr uint64_t HOST1X_BASE = 0x50000000;
|
||||||
constexpr uint64_t HOST1X_SIZE = 0x40000;
|
constexpr uint64_t HOST1X_SIZE = 0x40000;
|
||||||
|
|
||||||
// BPMP Cache
|
// BPMP Cache
|
||||||
constexpr uint64_t BPMP_CACHE_BASE = 0x50040000;
|
constexpr uint64_t BPMP_CACHE_BASE = 0x50040000;
|
||||||
constexpr uint64_t BPMP_CACHE_SIZE = 0x1000;
|
constexpr uint64_t BPMP_CACHE_SIZE = 0x1000;
|
||||||
|
|
||||||
// System Registers (SYSREG). SB (secure boot) sits at +0x200 and holds the
|
// System Registers (SYSREG). SB (secure boot) sits at +0x200 and holds the
|
||||||
// CCPLEX's AArch64 reset vector (SB_AA64_RESET_LOW/HIGH, +0x230/+0x234).
|
// CCPLEX's AArch64 reset vector (SB_AA64_RESET_LOW/HIGH, +0x230/+0x234).
|
||||||
constexpr uint64_t SYSREG_BASE = 0x6000C000;
|
constexpr uint64_t SYSREG_BASE = 0x6000C000;
|
||||||
constexpr uint64_t SYSREG_SIZE = 0x1000;
|
constexpr uint64_t SYSREG_SIZE = 0x1000;
|
||||||
|
|
||||||
// Flow controller: BPMP/CPU halt events, cluster control, RAM repair.
|
// Flow controller: BPMP/CPU halt events, cluster control, RAM repair.
|
||||||
constexpr uint64_t FLOW_CTLR_BASE = 0x60007000;
|
constexpr uint64_t FLOW_CTLR_BASE = 0x60007000;
|
||||||
constexpr uint64_t FLOW_CTLR_SIZE = 0x1000;
|
constexpr uint64_t FLOW_CTLR_SIZE = 0x1000;
|
||||||
|
|
||||||
// Exception vectors, incl. EVP_CPU_RESET_VECTOR (+0x100) for AArch32 boot.
|
// Exception vectors, incl. EVP_CPU_RESET_VECTOR (+0x100) for AArch32 boot.
|
||||||
constexpr uint64_t EXCP_VEC_BASE = 0x6000F000;
|
constexpr uint64_t EXCP_VEC_BASE = 0x6000F000;
|
||||||
constexpr uint64_t EXCP_VEC_SIZE = 0x1000;
|
constexpr uint64_t EXCP_VEC_SIZE = 0x1000;
|
||||||
|
|
||||||
// I2S (Audio)
|
// I2S (Audio)
|
||||||
constexpr uint64_t I2S_BASE = 0x702D1000;
|
constexpr uint64_t I2S_BASE = 0x702D1000;
|
||||||
constexpr uint64_t I2S_SIZE = 0x1000;
|
constexpr uint64_t I2S_SIZE = 0x1000;
|
||||||
|
|
||||||
// APE audio hub: ADMAIF (+0x000) and the AXBAR crossbar (+0x800) share one
|
// APE audio hub: ADMAIF (+0x000) and the AXBAR crossbar (+0x800) share one
|
||||||
// 4 KB page directly below I2S. Modelling it is not optional for hwtest: its
|
// 4 KB page directly below I2S. Modelling it is not optional for hwtest: its
|
||||||
// speaker probe pushes ~224k samples through the ADMAIF PIO FIFO one 32-bit
|
// speaker probe pushes ~224k samples through the ADMAIF PIO FIFO one 32-bit
|
||||||
// write at a time, and every write reaching the write-chain's fall-through
|
// write at a time, and every write reaching the write-chain's fall-through
|
||||||
// arm costs a printf + fflush. Unmodelled, the melody alone emits a quarter
|
// arm costs a printf + fflush. Unmodelled, the melody alone emits a quarter
|
||||||
// of a million log lines and the run never reaches the Display / Inputs /
|
// of a million log lines and the run never reaches the Display / Inputs /
|
||||||
// Raw state / Diagnostics pages.
|
// Raw state / Diagnostics pages.
|
||||||
constexpr uint64_t ADMAIF_BASE = 0x702D0000;
|
constexpr uint64_t ADMAIF_BASE = 0x702D0000;
|
||||||
constexpr uint64_t ADMAIF_SIZE = 0x1000;
|
constexpr uint64_t ADMAIF_SIZE = 0x1000;
|
||||||
|
|
||||||
// ADMA, the audio DMA engine. hwtest resets and enables it but never runs a
|
// ADMA, the audio DMA engine. hwtest resets and enables it but never runs a
|
||||||
// channel (the tone goes in by PIO), so only the soft-reset handshake has to
|
// channel (the tone goes in by PIO), so only the soft-reset handshake has to
|
||||||
// be believable.
|
// be believable.
|
||||||
constexpr uint64_t ADMA_BASE = 0x702E2000;
|
constexpr uint64_t ADMA_BASE = 0x702E2000;
|
||||||
constexpr uint64_t ADMA_SIZE = 0x1000;
|
constexpr uint64_t ADMA_SIZE = 0x1000;
|
||||||
|
|
||||||
// SE (Security Engine)
|
// SE (Security Engine)
|
||||||
constexpr uint64_t SE_BASE = 0x70012000;
|
constexpr uint64_t SE_BASE = 0x70012000;
|
||||||
constexpr uint64_t SE_SIZE = 0x2000;
|
constexpr uint64_t SE_SIZE = 0x2000;
|
||||||
|
|
||||||
// MSELECT: the fabric between every master (CCPLEX and BPMP alike) and the
|
// MSELECT: the fabric between every master (CCPLEX and BPMP alike) and the
|
||||||
// AXI slaves, PCIe among them. Modelled because leaving it in reset is the
|
// AXI slaves, PCIe among them. Modelled because leaving it in reset is the
|
||||||
// difference between a register read and a permanently hung console.
|
// difference between a register read and a permanently hung console.
|
||||||
constexpr uint64_t MSELECT_BASE = 0x50060000;
|
constexpr uint64_t MSELECT_BASE = 0x50060000;
|
||||||
constexpr uint64_t MSELECT_SIZE = 0x1000;
|
constexpr uint64_t MSELECT_SIZE = 0x1000;
|
||||||
|
|
||||||
// USB2 controller USB1 ("OTG"): the device controller bdk's usbd.c drives on
|
// USB2 controller USB1 ("OTG"): the device controller bdk's usbd.c drives on
|
||||||
// Erista. Registers, the UTMI PHY at +0x400/+0x800, queue heads at +0x1000.
|
// Erista. Registers, the UTMI PHY at +0x400/+0x800, queue heads at +0x1000.
|
||||||
constexpr uint64_t USB_OTG_BASE = 0x7D000000;
|
constexpr uint64_t USB_OTG_BASE = 0x7D000000;
|
||||||
constexpr uint64_t USB_OTG_SIZE = 0x4000;
|
constexpr uint64_t USB_OTG_SIZE = 0x4000;
|
||||||
|
|
||||||
// XUSB device controller: bdk's xusbd.c on Mariko. XHCI registers, then its
|
// XUSB device controller: bdk's xusbd.c on Mariko. XHCI registers, then its
|
||||||
// PCI configuration space at +0x8000 and device registers at +0x9000.
|
// PCI configuration space at +0x8000 and device registers at +0x9000.
|
||||||
constexpr uint64_t XUSB_DEV_BASE = 0x700D0000;
|
constexpr uint64_t XUSB_DEV_BASE = 0x700D0000;
|
||||||
constexpr uint64_t XUSB_DEV_SIZE = 0xA000;
|
constexpr uint64_t XUSB_DEV_SIZE = 0xA000;
|
||||||
|
|
||||||
// XUSB pad controller. Owns the UPHY SERDES lanes shared by PCIe (pcie-0..4)
|
// XUSB pad controller. Owns the UPHY SERDES lanes shared by PCIe (pcie-0..4)
|
||||||
// and USB 3.0 SuperSpeed (pcie-5/6 on this board), plus UPHY PLL P0.
|
// and USB 3.0 SuperSpeed (pcie-5/6 on this board), plus UPHY PLL P0.
|
||||||
constexpr uint64_t XUSB_PADCTL_BASE = 0x7009F000;
|
constexpr uint64_t XUSB_PADCTL_BASE = 0x7009F000;
|
||||||
constexpr uint64_t XUSB_PADCTL_SIZE = 0x1000;
|
constexpr uint64_t XUSB_PADCTL_SIZE = 0x1000;
|
||||||
|
|
||||||
// ==================== PCIe ====================
|
// ==================== PCIe ====================
|
||||||
//
|
//
|
||||||
// Unlike every other peripheral here, the PCIe apertures live BELOW the
|
// Unlike every other peripheral here, the PCIe apertures live BELOW the
|
||||||
// 0x50000000 MMIO band - T210 puts the whole root complex in the bottom of
|
// 0x50000000 MMIO band - T210 puts the whole root complex in the bottom of
|
||||||
// the address map (tegra210.dtsi pcie@1003000). The BPMP can address it:
|
// the address map (tegra210.dtsi pcie@1003000). The BPMP can address it:
|
||||||
// bdk's MMU table defines DRAM and IRAM entries only and leaves the fallback
|
// bdk's MMU table defines DRAM and IRAM entries only and leaves the fallback
|
||||||
// entry RWX, so PCIe space is reachable and uncached.
|
// entry RWX, so PCIe space is reachable and uncached.
|
||||||
//
|
//
|
||||||
// These are MMIO windows (callbacks, no backing memory), so they are mapped
|
// These are MMIO windows (callbacks, no backing memory), so they are mapped
|
||||||
// at their architectural sizes: the whole 256 MiB configuration aperture -
|
// at their architectural sizes: the whole 256 MiB configuration aperture -
|
||||||
// extended registers sit at AXI[27:24] - and the non-prefetchable memory
|
// extended registers sit at AXI[27:24] - and the non-prefetchable memory
|
||||||
// window to the end of PCIE_A2, wherever software places the endpoint's BARs.
|
// window to the end of PCIE_A2, wherever software places the endpoint's BARs.
|
||||||
// A smaller map left a CPU0 access to, say, config offset 0x100 or BAR0 +
|
// A smaller map left a CPU0 access to, say, config offset 0x100 or BAR0 +
|
||||||
// 0x2000 unmapped: nothing answered and the core wedged, where silicon
|
// 0x2000 unmapped: nothing answered and the core wedged, where silicon
|
||||||
// returns data or all-ones.
|
// returns data or all-ones.
|
||||||
constexpr uint64_t PCIE_RP0_BASE = 0x01000000; // root port 0 registers
|
constexpr uint64_t PCIE_RP0_BASE = 0x01000000; // root port 0 registers
|
||||||
constexpr uint64_t PCIE_RP1_BASE = 0x01001000; // root port 1 registers
|
constexpr uint64_t PCIE_RP1_BASE = 0x01001000; // root port 1 registers
|
||||||
constexpr uint64_t PCIE_PADS_BASE = 0x01003000;
|
constexpr uint64_t PCIE_PADS_BASE = 0x01003000;
|
||||||
constexpr uint64_t PCIE_AFI_BASE = 0x01003800;
|
constexpr uint64_t PCIE_AFI_BASE = 0x01003800;
|
||||||
constexpr uint64_t PCIE_BLOCK_BASE = 0x01000000;
|
constexpr uint64_t PCIE_BLOCK_BASE = 0x01000000;
|
||||||
constexpr uint64_t PCIE_BLOCK_SIZE = 0x4000;
|
constexpr uint64_t PCIE_BLOCK_SIZE = 0x4000;
|
||||||
constexpr uint64_t PCIE_CS_BASE = 0x02000000; // type-1 extended config
|
constexpr uint64_t PCIE_CS_BASE = 0x02000000; // type-1 extended config
|
||||||
constexpr uint64_t PCIE_CS_MODEL_SIZE = 0x10000000; // all of it: 256 MiB
|
constexpr uint64_t PCIE_CS_MODEL_SIZE = 0x10000000; // all of it: 256 MiB
|
||||||
constexpr uint64_t PCIE_MEM_BASE = 0x13000000; // non-prefetchable window
|
constexpr uint64_t PCIE_MEM_BASE = 0x13000000; // non-prefetchable window
|
||||||
constexpr uint64_t PCIE_MEM_MODEL_SIZE = 0x0D000000; // up to the end of A2
|
constexpr uint64_t PCIE_MEM_MODEL_SIZE = 0x0D000000; // up to the end of A2
|
||||||
|
|
||||||
// TSEC (Falcon control regs are in the 0x1000–0x11FF window within TSEC_BASE)
|
// TSEC (Falcon control regs are in the 0x1000–0x11FF window within TSEC_BASE)
|
||||||
constexpr uint64_t TSEC_BASE = 0x54500000;
|
constexpr uint64_t TSEC_BASE = 0x54500000;
|
||||||
constexpr uint64_t TSEC_SIZE = 0x2000;
|
constexpr uint64_t TSEC_SIZE = 0x2000;
|
||||||
|
|
||||||
// TZRAM
|
// TZRAM
|
||||||
constexpr uint64_t TZRAM_BASE = 0x7C010000;
|
constexpr uint64_t TZRAM_BASE = 0x7C010000;
|
||||||
constexpr uint64_t TZRAM_SIZE = 0x10000; // 64KB
|
constexpr uint64_t TZRAM_SIZE = 0x10000; // 64KB
|
||||||
|
|
||||||
// System Registers (SYSCTR0)
|
// System Registers (SYSCTR0)
|
||||||
constexpr uint64_t SYSCTR0_BASE = 0x700F0000;
|
constexpr uint64_t SYSCTR0_BASE = 0x700F0000;
|
||||||
constexpr uint64_t SYSCTR0_SIZE = 0x1000;
|
constexpr uint64_t SYSCTR0_SIZE = 0x1000;
|
||||||
|
|
||||||
// ==================== Framebuffer ====================
|
// ==================== Framebuffer ====================
|
||||||
|
|
||||||
// hekate uses a display window within DRAM for framebuffer
|
// hekate uses a display window within DRAM for framebuffer
|
||||||
// The display init code sets up a linear framebuffer at predefined addresses.
|
// The display init code sets up a linear framebuffer at predefined addresses.
|
||||||
// IPL_FB_ADDRESS is 0xF5A00000, NYX is 0xF6200000.
|
// IPL_FB_ADDRESS is 0xF5A00000, NYX is 0xF6200000.
|
||||||
// We allocate a 16MB block covering 0xF5A00000 - 0xF6A00000
|
// We allocate a 16MB block covering 0xF5A00000 - 0xF6A00000
|
||||||
constexpr uint64_t FB_BASE = 0xF5A00000;
|
constexpr uint64_t FB_BASE = 0xF5A00000;
|
||||||
constexpr uint64_t FB_SIZE = 0x01000000; // 16MB
|
constexpr uint64_t FB_SIZE = 0x01000000; // 16MB
|
||||||
|
|
||||||
// Display dimensions (hekate: 720 width, 1280 height in portrait)
|
// Display dimensions (hekate: 720 width, 1280 height in portrait)
|
||||||
constexpr int DISPLAY_WIDTH = 720;
|
constexpr int DISPLAY_WIDTH = 720;
|
||||||
constexpr int DISPLAY_HEIGHT = 1280;
|
constexpr int DISPLAY_HEIGHT = 1280;
|
||||||
|
|
||||||
// Landscape dimensions for SDL window
|
// Landscape dimensions for SDL window
|
||||||
constexpr int WINDOW_WIDTH = 720;
|
constexpr int WINDOW_WIDTH = 720;
|
||||||
constexpr int WINDOW_HEIGHT = 1280;
|
constexpr int WINDOW_HEIGHT = 1280;
|
||||||
|
|
||||||
#endif // T210_MEMORY_MAP_H
|
#endif // T210_MEMORY_MAP_H
|
||||||
+88
-88
@@ -1,88 +1,88 @@
|
|||||||
#ifndef T210_MMIO_H
|
#ifndef T210_MMIO_H
|
||||||
#define T210_MMIO_H
|
#define T210_MMIO_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <unicorn/unicorn.h>
|
#include <unicorn/unicorn.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tegra X1 MMIO Handler
|
* Tegra X1 MMIO Handler
|
||||||
*
|
*
|
||||||
* Routes memory-mapped IO reads/writes to peripheral handlers.
|
* Routes memory-mapped IO reads/writes to peripheral handlers.
|
||||||
* Unknown registers return 0 / ignore writes (permissive stub).
|
* Unknown registers return 0 / ignore writes (permissive stub).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Forward declarations for peripheral modules.
|
// Forward declarations for peripheral modules.
|
||||||
struct EmuState;
|
struct EmuState;
|
||||||
|
|
||||||
// Which processor issued the access being dispatched. Two masters share one
|
// Which processor issued the access being dispatched. Two masters share one
|
||||||
// register model: the BPMP (the ARM7 every RCM payload runs on) and CPU0 of
|
// register model: the BPMP (the ARM7 every RCM payload runs on) and CPU0 of
|
||||||
// the CCPLEX (Cortex-A57), which a payload can boot through bdk's
|
// the CCPLEX (Cortex-A57), which a payload can boot through bdk's
|
||||||
// ccplex_boot_cpu0(). They do not see the same bus - PCIe and MSELECT answer
|
// ccplex_boot_cpu0(). They do not see the same bus - PCIe and MSELECT answer
|
||||||
// a CPU-complex master only (Tegra X1 TRM ch.16/ch.19) - so the few models
|
// a CPU-complex master only (Tegra X1 TRM ch.16/ch.19) - so the few models
|
||||||
// that care consult this. Both cores run on the emulator's one thread, one
|
// that care consult this. Both cores run on the emulator's one thread, one
|
||||||
// slice at a time, so a global is exact: whoever is running is the master.
|
// slice at a time, so a global is exact: whoever is running is the master.
|
||||||
enum BusMaster : uint8_t {
|
enum BusMaster : uint8_t {
|
||||||
BUS_BPMP = 0,
|
BUS_BPMP = 0,
|
||||||
BUS_CPU0 = 1,
|
BUS_CPU0 = 1,
|
||||||
};
|
};
|
||||||
extern BusMaster g_bus_master;
|
extern BusMaster g_bus_master;
|
||||||
|
|
||||||
// Initialize all MMIO hooks on the Unicorn engine.
|
// Initialize all MMIO hooks on the Unicorn engine.
|
||||||
void mmio_init(uc_engine *uc, EmuState *state);
|
void mmio_init(uc_engine *uc, EmuState *state);
|
||||||
|
|
||||||
// Map the same peripheral windows into another engine (CPU0's), backed by the
|
// Map the same peripheral windows into another engine (CPU0's), backed by the
|
||||||
// same register models. Everything in the 0x50000000..0x7FFFFFFF band plus
|
// same register models. Everything in the 0x50000000..0x7FFFFFFF band plus
|
||||||
// the PCIe apertures low in the map.
|
// the PCIe apertures low in the map.
|
||||||
void mmio_map_bus(uc_engine *uc, EmuState *state);
|
void mmio_map_bus(uc_engine *uc, EmuState *state);
|
||||||
// Forget the windows mapped into `uc`, before that engine is closed.
|
// Forget the windows mapped into `uc`, before that engine is closed.
|
||||||
void mmio_unmap_bus(uc_engine *uc);
|
void mmio_unmap_bus(uc_engine *uc);
|
||||||
|
|
||||||
// The shared dispatch both engines' MMIO callbacks funnel into. `size` is the
|
// The shared dispatch both engines' MMIO callbacks funnel into. `size` is the
|
||||||
// access width in bytes (1, 2 or 4).
|
// access width in bytes (1, 2 or 4).
|
||||||
uint32_t mmio_bus_read(EmuState *state, uint64_t addr, unsigned size);
|
uint32_t mmio_bus_read(EmuState *state, uint64_t addr, unsigned size);
|
||||||
void mmio_bus_write(EmuState *state, uint64_t addr, unsigned size,
|
void mmio_bus_write(EmuState *state, uint64_t addr, unsigned size,
|
||||||
uint64_t value);
|
uint64_t value);
|
||||||
|
|
||||||
// Reset the per-run peripheral state that a soft reboot must not carry over.
|
// Reset the per-run peripheral state that a soft reboot must not carry over.
|
||||||
// `power_cycle`: the PMIC reset too (its register files return to their
|
// `power_cycle`: the PMIC reset too (its register files return to their
|
||||||
// seeds); otherwise only the SoC reset (PMC MAIN_RST) and the PMIC keeps
|
// seeds); otherwise only the SoC reset (PMC MAIN_RST) and the PMIC keeps
|
||||||
// its rails.
|
// its rails.
|
||||||
void mmio_soft_reset(EmuState *state, bool power_cycle);
|
void mmio_soft_reset(EmuState *state, bool power_cycle);
|
||||||
|
|
||||||
// PMC power-partition state (APBDEV_PMC_PWRGATE_STATUS bit `part`).
|
// PMC power-partition state (APBDEV_PMC_PWRGATE_STATUS bit `part`).
|
||||||
bool pmc_partition_on(int part);
|
bool pmc_partition_on(int part);
|
||||||
|
|
||||||
// APBDEV_PMC_SECURE_SCRATCH`n` (n = 0..7), written by hardware: the SE
|
// APBDEV_PMC_SECURE_SCRATCH`n` (n = 0..7), written by hardware: the SE
|
||||||
// deposits its context-save key there.
|
// deposits its context-save key there.
|
||||||
void pmc_secure_scratch_write(unsigned n, uint32_t value);
|
void pmc_secure_scratch_write(unsigned n, uint32_t value);
|
||||||
|
|
||||||
// True when the CCPLEX CPU rail is up: the MAX77621 on Erista (enabled, and
|
// True when the CCPLEX CPU rail is up: the MAX77621 on Erista (enabled, and
|
||||||
// its EN pin driven by MAX77620 GPIO5), the MAX77812 M4 phase on Mariko.
|
// its EN pin driven by MAX77620 GPIO5), the MAX77812 M4 phase on Mariko.
|
||||||
bool cpu_rail_on(EmuState *state);
|
bool cpu_rail_on(EmuState *state);
|
||||||
|
|
||||||
// Individual peripheral handlers.
|
// Individual peripheral handlers.
|
||||||
uint32_t timer_read(EmuState *state, uint64_t addr);
|
uint32_t timer_read(EmuState *state, uint64_t addr);
|
||||||
void timer_write(EmuState *state, uint64_t addr, uint32_t val);
|
void timer_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t gpio_read(EmuState *state, uint64_t addr);
|
uint32_t gpio_read(EmuState *state, uint64_t addr);
|
||||||
void gpio_write(EmuState *state, uint64_t addr, uint32_t val);
|
void gpio_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t i2c_read(EmuState *state, uint64_t addr);
|
uint32_t i2c_read(EmuState *state, uint64_t addr);
|
||||||
void i2c_write(EmuState *state, uint64_t addr, uint32_t val);
|
void i2c_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t display_read(EmuState *state, uint64_t addr);
|
uint32_t display_read(EmuState *state, uint64_t addr);
|
||||||
void display_write(EmuState *state, uint64_t addr, uint32_t val);
|
void display_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t pmc_read(EmuState *state, uint64_t addr);
|
uint32_t pmc_read(EmuState *state, uint64_t addr);
|
||||||
void pmc_write(EmuState *state, uint64_t addr, uint32_t val);
|
void pmc_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t clk_rst_read(EmuState *state, uint64_t addr);
|
uint32_t clk_rst_read(EmuState *state, uint64_t addr);
|
||||||
void clk_rst_write(EmuState *state, uint64_t addr, uint32_t val);
|
void clk_rst_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t fuse_read(EmuState *state, uint64_t addr);
|
uint32_t fuse_read(EmuState *state, uint64_t addr);
|
||||||
void fuse_write(EmuState *state, uint64_t addr, uint32_t val);
|
void fuse_write(EmuState *state, uint64_t addr, uint32_t val);
|
||||||
|
|
||||||
uint32_t misc_read(EmuState *state, uint64_t addr);
|
uint32_t misc_read(EmuState *state, uint64_t addr);
|
||||||
void misc_write(uc_engine *uc, EmuState *state, uint64_t addr, int64_t value, int size);
|
void misc_write(uc_engine *uc, EmuState *state, uint64_t addr, int64_t value, int size);
|
||||||
|
|
||||||
#endif // T210_MMIO_H
|
#endif // T210_MMIO_H
|
||||||
+26
-26
@@ -1,26 +1,26 @@
|
|||||||
#ifndef T210_TEGRA_BL_H
|
#ifndef T210_TEGRA_BL_H
|
||||||
#define T210_TEGRA_BL_H
|
#define T210_TEGRA_BL_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
// Tegra X1-style block-linear byte offset for 32 bpp (RGBA8888 / XRGB in RAM).
|
// Tegra X1-style block-linear byte offset for 32 bpp (RGBA8888 / XRGB in RAM).
|
||||||
// Matches test_img.py "Block Linear / Tegra X1" mode.
|
// Matches test_img.py "Block Linear / Tegra X1" mode.
|
||||||
inline uint32_t tegra_bl_byte_off_rgba8888(uint32_t sx, uint32_t sy,
|
inline uint32_t tegra_bl_byte_off_rgba8888(uint32_t sx, uint32_t sy,
|
||||||
uint32_t width_gobs,
|
uint32_t width_gobs,
|
||||||
uint32_t block_height_gobs) {
|
uint32_t block_height_gobs) {
|
||||||
uint32_t gob_x = sx / 16u;
|
uint32_t gob_x = sx / 16u;
|
||||||
uint32_t pixel_x = sx % 16u;
|
uint32_t pixel_x = sx % 16u;
|
||||||
uint32_t gob_y = sy / 8u;
|
uint32_t gob_y = sy / 8u;
|
||||||
uint32_t line_y = sy % 8u;
|
uint32_t line_y = sy % 8u;
|
||||||
uint32_t block_y = gob_y / block_height_gobs;
|
uint32_t block_y = gob_y / block_height_gobs;
|
||||||
uint32_t gob_in_block_y = gob_y % block_height_gobs;
|
uint32_t gob_in_block_y = gob_y % block_height_gobs;
|
||||||
|
|
||||||
uint32_t idx =
|
uint32_t idx =
|
||||||
(block_y * width_gobs * block_height_gobs * 128u) +
|
(block_y * width_gobs * block_height_gobs * 128u) +
|
||||||
(gob_x * block_height_gobs * 128u) + (gob_in_block_y * 128u) +
|
(gob_x * block_height_gobs * 128u) + (gob_in_block_y * 128u) +
|
||||||
(pixel_x & 3u) + ((line_y & 1u) << 2) + ((pixel_x & 4u) << 1) +
|
(pixel_x & 3u) + ((line_y & 1u) << 2) + ((pixel_x & 4u) << 1) +
|
||||||
((line_y & 2u) << 3) + ((pixel_x & 8u) << 2) + ((line_y & 4u) << 4);
|
((line_y & 2u) << 3) + ((pixel_x & 8u) << 2) + ((line_y & 4u) << 4);
|
||||||
return idx * 4u;
|
return idx * 4u;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user