a semblance of sanity, finally

This commit is contained in:
bunnie 2021-07-09 23:01:50 +08:00
parent 3ac17a99db
commit 1949c1bbc9
19 changed files with 370 additions and 228 deletions

215
loader/Cargo.lock generated
View file

@ -33,10 +33,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]] [[package]]
name = "cfg-if" name = "block-buffer"
version = "0.1.10" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"generic-array",
]
[[package]]
name = "byteorder"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
@ -60,14 +75,65 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]] [[package]]
name = "getrandom" name = "cpufeatures"
version = "0.1.14" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef"
dependencies = [ dependencies = [
"cfg-if",
"libc", "libc",
"wasi", ]
[[package]]
name = "curve25519-dalek"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3"
dependencies = [
"byteorder",
"digest",
"rand_core",
"subtle",
"zeroize",
]
[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array",
]
[[package]]
name = "ed25519"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6"
dependencies = [
"signature",
]
[[package]]
name = "ed25519-dalek"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d"
dependencies = [
"curve25519-dalek",
"ed25519",
"sha2",
"zeroize",
]
[[package]]
name = "generic-array"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
dependencies = [
"typenum",
"version_check",
] ]
[[package]] [[package]]
@ -87,16 +153,17 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.74" version = "0.2.97"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
[[package]] [[package]]
name = "loader" name = "loader"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"curve25519-dalek",
"ed25519-dalek",
"lazy_static", "lazy_static",
"rand",
"utralib", "utralib",
] ]
@ -107,10 +174,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]] [[package]]
name = "ppv-lite86" name = "opaque-debug"
version = "0.2.8" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "proc-macro2"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
dependencies = [
"unicode-xid",
]
[[package]] [[package]]
name = "quick-xml" name = "quick-xml"
@ -122,26 +198,12 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rand" name = "quote"
version = "0.7.3" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [ dependencies = [
"getrandom", "proc-macro2",
"libc",
"rand_chacha",
"rand_core",
"rand_hc",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core",
] ]
[[package]] [[package]]
@ -149,18 +211,25 @@ name = "rand_core"
version = "0.5.1" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
[[package]]
name = "sha2"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12"
dependencies = [ dependencies = [
"getrandom", "block-buffer",
"cfg-if",
"cpufeatures",
"digest",
"opaque-debug",
] ]
[[package]] [[package]]
name = "rand_hc" name = "signature"
version = "0.2.0" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" checksum = "c19772be3c4dd2ceaacf03cb41d5885f2a02c4d8804884918e3a258480803335"
dependencies = [
"rand_core",
]
[[package]] [[package]]
name = "strsim" name = "strsim"
@ -168,6 +237,12 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "subtle"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
[[package]] [[package]]
name = "svd2utra" name = "svd2utra"
version = "0.1.0" version = "0.1.0"
@ -178,6 +253,29 @@ dependencies = [
"quick-xml", "quick-xml",
] ]
[[package]]
name = "syn"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "synstructure"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
dependencies = [
"proc-macro2",
"quote",
"syn",
"unicode-xid",
]
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.11.0" version = "0.11.0"
@ -187,12 +285,24 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "typenum"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.8" version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]] [[package]]
name = "utralib" name = "utralib"
version = "0.1.0" version = "0.1.0"
@ -207,10 +317,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "wasi" name = "version_check"
version = "0.9.0+wasi-snapshot-preview1" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]] [[package]]
name = "winapi" name = "winapi"
@ -233,3 +343,24 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "zeroize"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd"
dependencies = [
"zeroize_derive",
]
[[package]]
name = "zeroize_derive"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]

View file

@ -8,15 +8,25 @@ description = "Initial kernel loader for Xous"
[dependencies] [dependencies]
utralib = {path = "../utralib"} utralib = {path = "../utralib"}
[dependencies.curve25519-dalek]
version = "3.1.0"
default-features = false
features = ["u32_backend"]
[dependencies.ed25519-dalek]
version="1.0.1"
default-features = false
features = ["u32_backend"]
[dev-dependencies] [dev-dependencies]
lazy_static = "1.4.0" lazy_static = "1.4.0"
rand = "0.7.3" #rand = "0.7.3"
[features] [features]
debug-print = [] debug-print = []
earlyprintk = [] earlyprintk = []
#default = ["debug-print"] default = ["debug-print"]
default = [] #default = []
[profile.release] [profile.release]
codegen-units = 1 # 1 better optimizations codegen-units = 1 # 1 better optimizations

BIN
loader/bin/riscv32i-unknown-none-elf.a Normal file → Executable file

Binary file not shown.

BIN
loader/bin/riscv32imac-unknown-none-elf.a Normal file → Executable file

Binary file not shown.

BIN
loader/bin/riscv32imc-unknown-none-elf.a Normal file → Executable file

Binary file not shown.

BIN
loader/bin/riscv64gc-unknown-none-elf.a Normal file → Executable file

Binary file not shown.

BIN
loader/bin/riscv64imac-unknown-none-elf.a Normal file → Executable file

Binary file not shown.

View file

@ -1,7 +1,7 @@
MEMORY MEMORY
{ {
RAM : ORIGIN = 0x40000000, LENGTH = 16M RAM : ORIGIN = 0x40000000, LENGTH = 16M
FLASH : ORIGIN = 0x20500000, LENGTH = 4608k FLASH : ORIGIN = 0x20501000, LENGTH = 4604k
MEMLCD: ORIGIN = 0xB0000000, LENGTH = 32k MEMLCD: ORIGIN = 0xB0000000, LENGTH = 32k
} }
/* /*

View file

@ -7,8 +7,8 @@ _start:
csrw medeleg, t0 csrw medeleg, t0
// Place the stack pointer at the end of RAM // Place the stack pointer at the end of RAM
lw t0, 16(a0) // SRAM start li t0, 0x40000000 // SRAM start hard-coded into loader -- don't trust kernel boot args to tell us where RAM is, we haven't validated them yet!
lw t1, 20(a0) // SRAM length li t1, 0x01000000 // SRAM length
add sp, t0, t1 add sp, t0, t1
// Install a machine mode trap handler // Install a machine mode trap handler

View file

@ -43,6 +43,8 @@ mod debug;
mod fonts; mod fonts;
use ed25519_dalek::*;
// Install a panic handler when not running tests. // Install a panic handler when not running tests.
#[cfg(not(test))] #[cfg(not(test))]
mod panic_handler { mod panic_handler {
@ -1245,7 +1247,7 @@ fn boot_sequence(args: KernelArguments, _signature: u32) -> ! {
// so that attempts to mess with the args during a resume can't lead to overwriting // so that attempts to mess with the args during a resume can't lead to overwriting
// critical parameters like these kernel arguments. // critical parameters like these kernel arguments.
unsafe { unsafe {
let backup_args: *mut [u32; 7] = 0x40FF_F000 as *mut[u32; 7]; let backup_args: *mut [u32; 7] = 0x40FF_E000 as *mut[u32; 7];
(*backup_args)[0] = arg_offset as u32; (*backup_args)[0] = arg_offset as u32;
(*backup_args)[1] = ip_offset as u32; (*backup_args)[1] = ip_offset as u32;
(*backup_args)[2] = rpt_offset as u32; (*backup_args)[2] = rpt_offset as u32;
@ -1275,7 +1277,7 @@ fn boot_sequence(args: KernelArguments, _signature: u32) -> ! {
} }
} else { } else {
unsafe { unsafe {
let backup_args: *mut [u32; 7] = 0x40FF_F000 as *mut[u32; 7]; let backup_args: *mut [u32; 7] = 0x40FF_E000 as *mut[u32; 7];
#[cfg(feature="debug-print")] #[cfg(feature="debug-print")]
{ {
println!("Using backed up kernel args:"); println!("Using backed up kernel args:");
@ -1313,7 +1315,7 @@ fn check_resume(cfg: &mut BootConfig) -> (bool, bool, u32) {
const NUM_SECTORS: usize = 8; const NUM_SECTORS: usize = 8;
const WORDS_PER_PAGE: usize = PAGE_SIZE / 4; const WORDS_PER_PAGE: usize = PAGE_SIZE / 4;
let suspend_marker = cfg.sram_start as usize + cfg.sram_size - PAGE_SIZE * 2; let suspend_marker = cfg.sram_start as usize + cfg.sram_size - PAGE_SIZE * 3;
let marker: *mut[u32; WORDS_PER_PAGE] = suspend_marker as *mut[u32; WORDS_PER_PAGE]; let marker: *mut[u32; WORDS_PER_PAGE] = suspend_marker as *mut[u32; WORDS_PER_PAGE];
let boot_seed = CSR::new(utra::seed::HW_SEED_BASE as *mut u32); let boot_seed = CSR::new(utra::seed::HW_SEED_BASE as *mut u32);
@ -1395,13 +1397,14 @@ fn phase_1(cfg: &mut BootConfig) {
// Mark all pages as in-use by the kernel. // Mark all pages as in-use by the kernel.
// NOTE: This causes the .text section to be owned by the kernel! This // NOTE: This causes the .text section to be owned by the kernel! This
// will require us to transfer ownership in `stage3`. // will require us to transfer ownership in `stage3`.
// Note also that we skip the first index, causing the stack to be // Note also that we skip the first four indices, causing the stack to be
// returned to the process pool. // returned to the process pool.
// We also skip the second index as that is the clean suspend page. This
// We also skip the an additional index as that is the clean suspend page. This
// needs to be claimed by the susres server before the kernel allocates it. // needs to be claimed by the susres server before the kernel allocates it.
// Lower numbered indices corresponding to higher address pages. // Lower numbered indices corresponding to higher address pages.
println!("Marking pages as in-use"); println!("Marking pages as in-use");
for i in 3..(cfg.init_size / PAGE_SIZE) { for i in 4..(cfg.init_size / PAGE_SIZE) {
cfg.runtime_page_tracker[cfg.sram_size / PAGE_SIZE - i] = 1; cfg.runtime_page_tracker[cfg.sram_size / PAGE_SIZE - i] = 1;
} }
} }
@ -1481,5 +1484,6 @@ pub fn phase_2(cfg: &mut BootConfig) {
); );
// mark pages used by suspend/resume according to their needs // mark pages used by suspend/resume according to their needs
cfg.runtime_page_tracker[cfg.sram_size / PAGE_SIZE - 1] = 1; // claim the loader stack -- do not allow tampering, as it contains backup kernel args cfg.runtime_page_tracker[cfg.sram_size / PAGE_SIZE - 1] = 1; // claim the loader stack -- do not allow tampering, as it contains backup kernel args
cfg.runtime_page_tracker[cfg.sram_size / PAGE_SIZE - 2] = 0; // allow clean suspend page to be mapped in Xous cfg.runtime_page_tracker[cfg.sram_size / PAGE_SIZE - 2] = 1; // 8k in total (to allow for digital signatures to be computed)
cfg.runtime_page_tracker[cfg.sram_size / PAGE_SIZE - 3] = 0; // allow clean suspend page to be mapped in Xous
} }

View file

@ -3,7 +3,7 @@
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" > <device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
<vendor>litex</vendor> <vendor>litex</vendor>
<name>SOC</name> <name>SOC</name>
<description><![CDATA[Litex SoC 2021-07-06 01:34:24]]></description> <description><![CDATA[Litex SoC 2021-07-09 22:07:11]]></description>
<addressUnitBits>8</addressUnitBits> <addressUnitBits>8</addressUnitBits>
<width>32</width> <width>32</width>
@ -38,7 +38,7 @@ peripherals]]></description>
<name>ADDR</name> <name>ADDR</name>
<description><![CDATA[The address written here will be used as the next reset vector]]></description> <description><![CDATA[The address written here will be used as the next reset vector]]></description>
<addressOffset>0x0004</addressOffset> <addressOffset>0x0004</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x80000000</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
@ -1222,10 +1222,10 @@ register to disable individual events.]]></description>
<register> <register>
<name>GIT_GITREV</name> <name>GIT_GITREV</name>
<description><![CDATA[First 32-bits of the git revision. This documentation was built from git rev <description><![CDATA[First 32-bits of the git revision. This documentation was built from git rev
``afcc1323``, so this value is 2949387043, which should be enough to check out ``68fd49d7``, so this value is 1761429975, which should be enough to check out
the exact git version used to build this firmware.]]></description> the exact git version used to build this firmware.]]></description>
<addressOffset>0x0014</addressOffset> <addressOffset>0x0014</addressOffset>
<resetValue>0xafcc1323</resetValue> <resetValue>0x68fd49d7</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
@ -1242,7 +1242,7 @@ the exact git version used to build this firmware.]]></description>
is ``1``, then the repository this was built from has one additional commit is ``1``, then the repository this was built from has one additional commit
beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]></description> beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]></description>
<addressOffset>0x0018</addressOffset> <addressOffset>0x0018</addressOffset>
<resetValue>0x2a</resetValue> <resetValue>0x31</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
@ -3467,7 +3467,7 @@ inject too fast.]]></description>
<name>SEED1</name> <name>SEED1</name>
<description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description> <description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description>
<addressOffset>0x0000</addressOffset> <addressOffset>0x0000</addressOffset>
<resetValue>0x3cbf0070</resetValue> <resetValue>0x8004bf8</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
@ -3482,7 +3482,7 @@ inject too fast.]]></description>
<name>SEED0</name> <name>SEED0</name>
<description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description> <description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description>
<addressOffset>0x0004</addressOffset> <addressOffset>0x0004</addressOffset>
<resetValue>0x57a58b0</resetValue> <resetValue>0x56fa5c4d</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
@ -4698,31 +4698,9 @@ generators]]></description>
</field> </field>
</fields> </fields>
</register> </register>
<register>
<name>RO_RUNSLIMIT5</name>
<addressOffset>0x004c</addressOffset>
<resetValue>0x1c807</resetValue>
<size>32</size>
<fields>
<field>
<name>min</name>
<msb>10</msb>
<bitRange>[10:0]</bitRange>
<lsb>0</lsb>
<description><![CDATA[Minimum runs limit for runs of length 5]]></description>
</field>
<field>
<name>max</name>
<msb>21</msb>
<bitRange>[21:11]</bitRange>
<lsb>11</lsb>
<description><![CDATA[Minimum runs limit for runs of length 5]]></description>
</field>
</fields>
</register>
<register> <register>
<name>RO_RUN0_CTRL</name> <name>RO_RUN0_CTRL</name>
<addressOffset>0x0050</addressOffset> <addressOffset>0x004c</addressOffset>
<resetValue>0x3ff</resetValue> <resetValue>0x3ff</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4740,14 +4718,14 @@ undefined behavior occurs]]></description>
<name>RO_RUN0_FRESH</name> <name>RO_RUN0_FRESH</name>
<description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been <description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been
updated at least once since the last readout of any register]]></description> updated at least once since the last readout of any register]]></description>
<addressOffset>0x0054</addressOffset> <addressOffset>0x0050</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
<name>ro_run0_fresh</name> <name>ro_run0_fresh</name>
<msb>4</msb> <msb>3</msb>
<bitRange>[4:0]</bitRange> <bitRange>[3:0]</bitRange>
<lsb>0</lsb> <lsb>0</lsb>
</field> </field>
</fields> </fields>
@ -4755,7 +4733,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN0_COUNT1</name> <name>RO_RUN0_COUNT1</name>
<description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description>
<addressOffset>0x0058</addressOffset> <addressOffset>0x0054</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4770,7 +4748,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN0_COUNT2</name> <name>RO_RUN0_COUNT2</name>
<description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description>
<addressOffset>0x005c</addressOffset> <addressOffset>0x0058</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4785,7 +4763,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN0_COUNT3</name> <name>RO_RUN0_COUNT3</name>
<description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description>
<addressOffset>0x0060</addressOffset> <addressOffset>0x005c</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4800,7 +4778,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN0_COUNT4</name> <name>RO_RUN0_COUNT4</name>
<description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description>
<addressOffset>0x0064</addressOffset> <addressOffset>0x0060</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4812,24 +4790,9 @@ updated at least once since the last readout of any register]]></description>
</field> </field>
</fields> </fields>
</register> </register>
<register>
<name>RO_RUN0_COUNT5</name>
<description><![CDATA[Count of sequence length 5 runs seen in the past window]]></description>
<addressOffset>0x0068</addressOffset>
<resetValue>0x00</resetValue>
<size>32</size>
<fields>
<field>
<name>ro_run0_count5</name>
<msb>10</msb>
<bitRange>[10:0]</bitRange>
<lsb>0</lsb>
</field>
</fields>
</register>
<register> <register>
<name>RO_RUN1_CTRL</name> <name>RO_RUN1_CTRL</name>
<addressOffset>0x006c</addressOffset> <addressOffset>0x0064</addressOffset>
<resetValue>0x3ff</resetValue> <resetValue>0x3ff</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4847,14 +4810,14 @@ undefined behavior occurs]]></description>
<name>RO_RUN1_FRESH</name> <name>RO_RUN1_FRESH</name>
<description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been <description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been
updated at least once since the last readout of any register]]></description> updated at least once since the last readout of any register]]></description>
<addressOffset>0x0070</addressOffset> <addressOffset>0x0068</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
<name>ro_run1_fresh</name> <name>ro_run1_fresh</name>
<msb>4</msb> <msb>3</msb>
<bitRange>[4:0]</bitRange> <bitRange>[3:0]</bitRange>
<lsb>0</lsb> <lsb>0</lsb>
</field> </field>
</fields> </fields>
@ -4862,7 +4825,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN1_COUNT1</name> <name>RO_RUN1_COUNT1</name>
<description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description>
<addressOffset>0x0074</addressOffset> <addressOffset>0x006c</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4877,7 +4840,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN1_COUNT2</name> <name>RO_RUN1_COUNT2</name>
<description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description>
<addressOffset>0x0078</addressOffset> <addressOffset>0x0070</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4892,7 +4855,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN1_COUNT3</name> <name>RO_RUN1_COUNT3</name>
<description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description>
<addressOffset>0x007c</addressOffset> <addressOffset>0x0074</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4907,7 +4870,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN1_COUNT4</name> <name>RO_RUN1_COUNT4</name>
<description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description>
<addressOffset>0x0080</addressOffset> <addressOffset>0x0078</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4919,24 +4882,9 @@ updated at least once since the last readout of any register]]></description>
</field> </field>
</fields> </fields>
</register> </register>
<register>
<name>RO_RUN1_COUNT5</name>
<description><![CDATA[Count of sequence length 5 runs seen in the past window]]></description>
<addressOffset>0x0084</addressOffset>
<resetValue>0x00</resetValue>
<size>32</size>
<fields>
<field>
<name>ro_run1_count5</name>
<msb>10</msb>
<bitRange>[10:0]</bitRange>
<lsb>0</lsb>
</field>
</fields>
</register>
<register> <register>
<name>RO_RUN2_CTRL</name> <name>RO_RUN2_CTRL</name>
<addressOffset>0x0088</addressOffset> <addressOffset>0x007c</addressOffset>
<resetValue>0x3ff</resetValue> <resetValue>0x3ff</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4954,14 +4902,14 @@ undefined behavior occurs]]></description>
<name>RO_RUN2_FRESH</name> <name>RO_RUN2_FRESH</name>
<description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been <description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been
updated at least once since the last readout of any register]]></description> updated at least once since the last readout of any register]]></description>
<addressOffset>0x008c</addressOffset> <addressOffset>0x0080</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
<name>ro_run2_fresh</name> <name>ro_run2_fresh</name>
<msb>4</msb> <msb>3</msb>
<bitRange>[4:0]</bitRange> <bitRange>[3:0]</bitRange>
<lsb>0</lsb> <lsb>0</lsb>
</field> </field>
</fields> </fields>
@ -4969,7 +4917,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN2_COUNT1</name> <name>RO_RUN2_COUNT1</name>
<description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description>
<addressOffset>0x0090</addressOffset> <addressOffset>0x0084</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4984,7 +4932,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN2_COUNT2</name> <name>RO_RUN2_COUNT2</name>
<description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description>
<addressOffset>0x0094</addressOffset> <addressOffset>0x0088</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -4999,7 +4947,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN2_COUNT3</name> <name>RO_RUN2_COUNT3</name>
<description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description>
<addressOffset>0x0098</addressOffset> <addressOffset>0x008c</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5014,7 +4962,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN2_COUNT4</name> <name>RO_RUN2_COUNT4</name>
<description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description>
<addressOffset>0x009c</addressOffset> <addressOffset>0x0090</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5026,24 +4974,9 @@ updated at least once since the last readout of any register]]></description>
</field> </field>
</fields> </fields>
</register> </register>
<register>
<name>RO_RUN2_COUNT5</name>
<description><![CDATA[Count of sequence length 5 runs seen in the past window]]></description>
<addressOffset>0x00a0</addressOffset>
<resetValue>0x00</resetValue>
<size>32</size>
<fields>
<field>
<name>ro_run2_count5</name>
<msb>10</msb>
<bitRange>[10:0]</bitRange>
<lsb>0</lsb>
</field>
</fields>
</register>
<register> <register>
<name>RO_RUN3_CTRL</name> <name>RO_RUN3_CTRL</name>
<addressOffset>0x00a4</addressOffset> <addressOffset>0x0094</addressOffset>
<resetValue>0x3ff</resetValue> <resetValue>0x3ff</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5061,14 +4994,14 @@ undefined behavior occurs]]></description>
<name>RO_RUN3_FRESH</name> <name>RO_RUN3_FRESH</name>
<description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been <description><![CDATA[The current data corresponding to a runlength of (bitposition +1) has been
updated at least once since the last readout of any register]]></description> updated at least once since the last readout of any register]]></description>
<addressOffset>0x00a8</addressOffset> <addressOffset>0x0098</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
<field> <field>
<name>ro_run3_fresh</name> <name>ro_run3_fresh</name>
<msb>4</msb> <msb>3</msb>
<bitRange>[4:0]</bitRange> <bitRange>[3:0]</bitRange>
<lsb>0</lsb> <lsb>0</lsb>
</field> </field>
</fields> </fields>
@ -5076,7 +5009,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN3_COUNT1</name> <name>RO_RUN3_COUNT1</name>
<description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 1 runs seen in the past window]]></description>
<addressOffset>0x00ac</addressOffset> <addressOffset>0x009c</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5091,7 +5024,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN3_COUNT2</name> <name>RO_RUN3_COUNT2</name>
<description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 2 runs seen in the past window]]></description>
<addressOffset>0x00b0</addressOffset> <addressOffset>0x00a0</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5106,7 +5039,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN3_COUNT3</name> <name>RO_RUN3_COUNT3</name>
<description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 3 runs seen in the past window]]></description>
<addressOffset>0x00b4</addressOffset> <addressOffset>0x00a4</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5121,7 +5054,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>RO_RUN3_COUNT4</name> <name>RO_RUN3_COUNT4</name>
<description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description> <description><![CDATA[Count of sequence length 4 runs seen in the past window]]></description>
<addressOffset>0x00b8</addressOffset> <addressOffset>0x00a8</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5133,24 +5066,9 @@ updated at least once since the last readout of any register]]></description>
</field> </field>
</fields> </fields>
</register> </register>
<register>
<name>RO_RUN3_COUNT5</name>
<description><![CDATA[Count of sequence length 5 runs seen in the past window]]></description>
<addressOffset>0x00bc</addressOffset>
<resetValue>0x00</resetValue>
<size>32</size>
<fields>
<field>
<name>ro_run3_count5</name>
<msb>10</msb>
<bitRange>[10:0]</bitRange>
<lsb>0</lsb>
</field>
</fields>
</register>
<register> <register>
<name>AV_EXCURSION0_CTRL</name> <name>AV_EXCURSION0_CTRL</name>
<addressOffset>0x00c0</addressOffset> <addressOffset>0x00ac</addressOffset>
<resetValue>0x190140</resetValue> <resetValue>0x190140</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5179,7 +5097,7 @@ updated at least once since the last readout of any register]]></description>
</register> </register>
<register> <register>
<name>AV_EXCURSION0_STAT</name> <name>AV_EXCURSION0_STAT</name>
<addressOffset>0x00c4</addressOffset> <addressOffset>0x00b0</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5201,7 +5119,7 @@ updated at least once since the last readout of any register]]></description>
</register> </register>
<register> <register>
<name>AV_EXCURSION0_LAST_ERR</name> <name>AV_EXCURSION0_LAST_ERR</name>
<addressOffset>0x00c8</addressOffset> <addressOffset>0x00b4</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5223,7 +5141,7 @@ updated at least once since the last readout of any register]]></description>
</register> </register>
<register> <register>
<name>AV_EXCURSION1_CTRL</name> <name>AV_EXCURSION1_CTRL</name>
<addressOffset>0x00cc</addressOffset> <addressOffset>0x00b8</addressOffset>
<resetValue>0x190140</resetValue> <resetValue>0x190140</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5252,7 +5170,7 @@ updated at least once since the last readout of any register]]></description>
</register> </register>
<register> <register>
<name>AV_EXCURSION1_STAT</name> <name>AV_EXCURSION1_STAT</name>
<addressOffset>0x00d0</addressOffset> <addressOffset>0x00bc</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5274,7 +5192,7 @@ updated at least once since the last readout of any register]]></description>
</register> </register>
<register> <register>
<name>AV_EXCURSION1_LAST_ERR</name> <name>AV_EXCURSION1_LAST_ERR</name>
<addressOffset>0x00d4</addressOffset> <addressOffset>0x00c0</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5296,7 +5214,7 @@ updated at least once since the last readout of any register]]></description>
</register> </register>
<register> <register>
<name>READY</name> <name>READY</name>
<addressOffset>0x00d8</addressOffset> <addressOffset>0x00c4</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5326,7 +5244,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>EV_STATUS</name> <name>EV_STATUS</name>
<description><![CDATA[Triggered by a failure in the avalanche generator core 1 on-line excursion test]]></description> <description><![CDATA[Triggered by a failure in the avalanche generator core 1 on-line excursion test]]></description>
<addressOffset>0x00dc</addressOffset> <addressOffset>0x00c8</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5370,7 +5288,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>EV_PENDING</name> <name>EV_PENDING</name>
<description><![CDATA[Triggered by a failure in the avalanche generator core 1 on-line excursion test]]></description> <description><![CDATA[Triggered by a failure in the avalanche generator core 1 on-line excursion test]]></description>
<addressOffset>0x00e0</addressOffset> <addressOffset>0x00cc</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5414,7 +5332,7 @@ updated at least once since the last readout of any register]]></description>
<register> <register>
<name>EV_ENABLE</name> <name>EV_ENABLE</name>
<description><![CDATA[Triggered by a failure in the avalanche generator core 1 on-line excursion test]]></description> <description><![CDATA[Triggered by a failure in the avalanche generator core 1 on-line excursion test]]></description>
<addressOffset>0x00e4</addressOffset> <addressOffset>0x00d0</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5457,7 +5375,7 @@ updated at least once since the last readout of any register]]></description>
</register> </register>
<register> <register>
<name>CHACHA</name> <name>CHACHA</name>
<addressOffset>0x00e8</addressOffset> <addressOffset>0x00d4</addressOffset>
<resetValue>0x100c8002</resetValue> <resetValue>0x100c8002</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5490,7 +5408,7 @@ standby power)]]></description>
<description><![CDATA[Extra data to be rotated into the seed pool. This is supplemental to the <description><![CDATA[Extra data to be rotated into the seed pool. This is supplemental to the
automatically seeded TRNG data. Data is committed to the pool immediately upon automatically seeded TRNG data. Data is committed to the pool immediately upon
write.]]></description> write.]]></description>
<addressOffset>0x00ec</addressOffset> <addressOffset>0x00d8</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5506,7 +5424,7 @@ write.]]></description>
<name>URANDOM</name> <name>URANDOM</name>
<description><![CDATA[Unlimited random numbers, output from the ChaCha conditioner. Generally, you <description><![CDATA[Unlimited random numbers, output from the ChaCha conditioner. Generally, you
want to use this.]]></description> want to use this.]]></description>
<addressOffset>0x00f0</addressOffset> <addressOffset>0x00dc</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5521,7 +5439,7 @@ want to use this.]]></description>
<register> <register>
<name>URANDOM_VALID</name> <name>URANDOM_VALID</name>
<description><![CDATA[Set when `urandom` is valid. Always check before taking `urandom`]]></description> <description><![CDATA[Set when `urandom` is valid. Always check before taking `urandom`]]></description>
<addressOffset>0x00f4</addressOffset> <addressOffset>0x00e0</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5535,7 +5453,7 @@ want to use this.]]></description>
</register> </register>
<register> <register>
<name>TEST</name> <name>TEST</name>
<addressOffset>0x00f8</addressOffset> <addressOffset>0x00e4</addressOffset>
<resetValue>0x00</resetValue> <resetValue>0x00</resetValue>
<size>32</size> <size>32</size>
<fields> <fields>
@ -5552,7 +5470,7 @@ case in testing. Not harmful in production, just wasteful.]]></description>
</registers> </registers>
<addressBlock> <addressBlock>
<offset>0</offset> <offset>0</offset>
<size>0xfc</size> <size>0xe8</size>
<usage>registers</usage> <usage>registers</usage>
</addressBlock> </addressBlock>
<interrupt> <interrupt>
@ -6997,13 +6915,8 @@ of the PLL]]></description>
<memoryRegions> <memoryRegions>
<memoryRegion> <memoryRegion>
<name>ROM</name> <name>ROM</name>
<baseAddress>0x00000000</baseAddress> <baseAddress>0x80000000</baseAddress>
<size>0x0000000C</size> <size>0x00010000</size>
</memoryRegion>
<memoryRegion>
<name>SRAM</name>
<baseAddress>0x10000000</baseAddress>
<size>0x00004000</size>
</memoryRegion> </memoryRegion>
<memoryRegion> <memoryRegion>
<name>VEXRISCV_DEBUG</name> <name>VEXRISCV_DEBUG</name>
@ -7049,7 +6962,7 @@ of the PLL]]></description>
<constants> <constants>
<constant name="CONFIG_CLOCK_FREQUENCY" value="100000000" /> <constant name="CONFIG_CLOCK_FREQUENCY" value="100000000" />
<constant name="CONFIG_CPU_HAS_INTERRUPT" value="None" /> <constant name="CONFIG_CPU_HAS_INTERRUPT" value="None" />
<constant name="CONFIG_CPU_RESET_ADDR" value="0" /> <constant name="CONFIG_CPU_RESET_ADDR" value="2147483648" />
<constant name="CONFIG_CPU_TYPE_VEXRISCV" value="None" /> <constant name="CONFIG_CPU_TYPE_VEXRISCV" value="None" />
<constant name="CONFIG_CPU_VARIANT_STANDARD" value="None" /> <constant name="CONFIG_CPU_VARIANT_STANDARD" value="None" />
<constant name="CONFIG_CPU_HUMAN_NAME" value="VexRiscv" /> <constant name="CONFIG_CPU_HUMAN_NAME" value="VexRiscv" />

Binary file not shown.

View file

@ -135,9 +135,13 @@ software: -151mA @ 100% CPU usage, 158.36us/block enc+dec AES128 (500 iters, 819
hardware: -148mA @ 100% CPU usage, 103.73us/block enc+dec AES256 (500 iters, 8192 len) hardware: -148mA @ 100% CPU usage, 103.73us/block enc+dec AES256 (500 iters, 8192 len)
software: -149mA @ 100% CPU usage, 217.95us/block enc+dec AES256 (500 iters, 8192 len) software: -149mA @ 100% CPU usage, 217.95us/block enc+dec AES256 (500 iters, 8192 len)
with L2 cache on: with L2 cache on (128k):
hardware 92.24us/block enc+dec aes256 (500 iters, 8192 len) hardware 92.24us/block enc+dec aes256 (500 iters, 8192 len)
software 158.48us/block enc+dec aes256 (500 iters, 8192 len) software 158.48us/block enc+dec aes256 (500 iters, 8192 len)
with L2 cache on (64k):
hardware 92.24us/block enc+dec aes256 (500 iters, 8192 len)
software 154.05us/block enc+dec aes256 (500 iters, 8192 len)
*/ */
pub fn benchmark_thread(sid0: usize, sid1: usize, sid2: usize, sid3: usize) { pub fn benchmark_thread(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
let sid = xous::SID::from_u32(sid0 as u32, sid1 as u32, sid2 as u32, sid3 as u32); let sid = xous::SID::from_u32(sid0 as u32, sid1 as u32, sid2 as u32, sid3 as u32);

View file

@ -159,7 +159,8 @@ pub fn benchmark_thread(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
26ms/2xop (200 iters -hw) -- affine done in hardware 26ms/2xop (200 iters -hw) -- affine done in hardware
13.54ms/2xop (200 iters -hw) -- microcode pre-loaded, minimal registers transferred using MontgomeryJob call 13.54ms/2xop (200 iters -hw) -- microcode pre-loaded, minimal registers transferred using MontgomeryJob call
12.2ms/2xop (200 iters -hw) -- with L2 cache on 12.2ms/2xop (200 iters -hw) -- with L2 cache on (128k)
12.29ms/2xop (200 iters -hw) -- with L2 cache on (64k)
*/ */
Some(BenchOp::StartDh) => { Some(BenchOp::StartDh) => {
let mut passes = 0; let mut passes = 0;

View file

@ -35,8 +35,10 @@ TEST_MAX_LEN = 1024 (fixed length) / TEST_ITERS = 1000: hw 7.257ms/hash, sw 11.6
TEST_MAX_LEN = 8192 (random length) / TEST_ITERS = 1000: hw 10.528ms/hash, sw 40.631ms/hash TEST_MAX_LEN = 8192 (random length) / TEST_ITERS = 1000: hw 10.528ms/hash, sw 40.631ms/hash
TEST_MAX_LEN = 8192 (fixed length) / TEST_ITERS = 1000: hw 17.035ms/hash, sw 78.633ms/hash TEST_MAX_LEN = 8192 (fixed length) / TEST_ITERS = 1000: hw 17.035ms/hash, sw 78.633ms/hash
with L2 cache on: with 128k L2 cache on:
TEST_MAX_LEN = 8192 (fixed length) / TEST_ITERS = 1000: hw 13.798ms/hash, sw 29.034ms/hash TEST_MAX_LEN = 8192 (fixed length) / TEST_ITERS = 1000: hw 13.798ms/hash, sw 29.034ms/hash
with 64k L2 cache on:
TEST_MAX_LEN = 8192 (fixed length) / TEST_ITERS = 1000: hw 13.798ms/hash, sw 30.029ms/hash
power consumption - power consumption -
4.1V system voltage 4.1V system voltage

View file

@ -141,7 +141,7 @@ mod implementation {
// note that mapping a page zeroes it out. Plus, this should have been zero'd by the bootloader. // note that mapping a page zeroes it out. Plus, this should have been zero'd by the bootloader.
let marker = xous::syscall::map_memory( let marker = xous::syscall::map_memory(
xous::MemoryAddress::new(0x40FFE000), // this is a special, hard-coded location xous::MemoryAddress::new(0x4100_0000 - 0x3000), // this is a special, hard-coded location; 0x2000 is the size of the bootloader's stack area
None, None,
4096, 4096,
xous::MemoryFlags::R | xous::MemoryFlags::W, xous::MemoryFlags::R | xous::MemoryFlags::W,

View file

@ -9,10 +9,13 @@ import os.path
import binascii import binascii
DEVKEY_PATH='../devkey/dev.key' DEVKEY_PATH='../devkey/dev.key'
LOADER_VERSION=1
def loader_sign(source, output, key): def loader_sign(source, output, key, defile=False):
global LOADER_VERSION
with open(source, "rb") as source_f: with open(source, "rb") as source_f:
source = list(source_f.read()) source = list(source_f.read())
source += int(LOADER_VERSION).to_bytes(4, 'little') # protect the version number
source += len(source).to_bytes(4, 'little') # append the length to the image, and sign that source += len(source).to_bytes(4, 'little') # append the length to the image, and sign that
# NOTE NOTE NOTE # NOTE NOTE NOTE
@ -23,11 +26,15 @@ def loader_sign(source, output, key):
with open(output, "wb") as output_f: with open(output, "wb") as output_f:
written = 0 written = 0
written += output_f.write(int(1).to_bytes(4, 'little')) # version number 1 record written += output_f.write(int(LOADER_VERSION).to_bytes(4, 'little')) # version number record - mirrored inside the signed data, too
written += output_f.write(len(source).to_bytes(4, 'little')) # record the length of the final signed record (which /also/ includes a length) written += output_f.write(len(source).to_bytes(4, 'little')) # record the length of the final signed record (which /also/ includes a length)
written += output_f.write(signature.signature) written += output_f.write(signature.signature)
output_f.write(bytearray([0] * (4096 - written))) # pad out to one page beyond output_f.write(bytearray([0] * (4096 - written))) # pad out to one page beyond
output_f.write(signature.message) # the actual signed message message = bytearray(signature.message)
if defile is True:
print("WARNING: defiling the loader image. This corrupts the binary and should cause it to fail the signature check.")
message[16778] ^= 0x1 # flip one bit at some random offset
output_f.write(message) # the actual signed message
def main(): def main():
global DEVKEY_PATH global DEVKEY_PATH
@ -45,17 +52,25 @@ def main():
parser.add_argument( parser.add_argument(
"--kernel-key", required=False, help="kernel signing key", type=str, nargs='?', metavar=('kernel signing key'), const=DEVKEY_PATH "--kernel-key", required=False, help="kernel signing key", type=str, nargs='?', metavar=('kernel signing key'), const=DEVKEY_PATH
) )
parser.add_argument(
"--loader-output", required=False, help="loader output image", type=str, nargs='?', metavar=('loader output image'), const='../target/riscv32imac-unknown-none-elf/release/loader.bin'
)
parser.add_argument(
"--defile", help="patch the resulting image, to create a test file to catch signature failure", default=False, action="store_true"
)
args = parser.parse_args() args = parser.parse_args()
if not len(sys.argv) > 1:
print("No arguments specified, doing nothing. Use --help for more information.")
exit(1)
if args.loader_image and (args.loader_key is None): if args.loader_image and (args.loader_key is None):
loader_key = DEVKEY_PATH loader_key = DEVKEY_PATH
else: else:
loader_key = args.loader_key loader_key = args.loader_key
if args.loader_image and (args.loader_output is None):
if args.kernel_image and (args.kernel_key is None): loader_output = '../target/riscv32imac-unknown-none-elf/release/loader.bin'
kernel_key = DEVKEY_PATH
else: else:
kernel_key = args.kernel_key loader_output = args.loader_output
if loader_key is not None and loader_key is not DEVKEY_PATH: if loader_key is not None and loader_key is not DEVKEY_PATH:
with open(loader_key) as loader_f: with open(loader_key) as loader_f:
@ -73,6 +88,17 @@ def main():
else: else:
loader_pkey = None loader_pkey = None
if loader_pkey != None:
loader_sign(args.loader_image, loader_output, loader_pkey, defile=args.defile)
if args.kernel_image and (args.kernel_key is None):
kernel_key = DEVKEY_PATH
else:
kernel_key = args.kernel_key
if kernel_key is not None and kernel_key is not DEVKEY_PATH: if kernel_key is not None and kernel_key is not DEVKEY_PATH:
kernel_pass = input("Enter loader key passphrase, enter if none: ") kernel_pass = input("Enter loader key passphrase, enter if none: ")
with open(kernel_key) as kernel_f: with open(kernel_key) as kernel_f:
@ -90,15 +116,6 @@ def main():
else: else:
kernel_pkey = None kernel_pkey = None
if loader_pkey != None:
output_image = os.path.dirname(os.path.abspath(args.loader_image)) + "{}loader.bin".format(os.path.sep)
loader_sign(args.loader_image, output_image, loader_pkey)
if not len(sys.argv) > 1:
print("No arguments specified, doing nothing. Use --help for more information.")
exit(1)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
exit(0) exit(0)

View file

@ -7,3 +7,5 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
#"ed25519-dalek" = "1"
#"pem" = "0.8"

View file

@ -5,6 +5,11 @@ use std::{
path::{Path, PathBuf, MAIN_SEPARATOR}, path::{Path, PathBuf, MAIN_SEPARATOR},
process::Command, process::Command,
}; };
/*
extern crate ed25519_dalek;
extern crate pem;
use ed25519_dalek::{Keypair, Signature, PublicKey, PrivateKey};
*/
type DynError = Box<dyn std::error::Error>; type DynError = Box<dyn std::error::Error>;
@ -109,6 +114,8 @@ fn try_main() -> Result<(), DynError> {
let aestest_pkgs = ["ticktimer-server", "log-server", "aes-test"]; let aestest_pkgs = ["ticktimer-server", "log-server", "aes-test"];
let mut args = env::args(); let mut args = env::args();
let task = args.nth(1); let task = args.nth(1);
let lkey = args.nth(3);
let kkey = args.nth(4);
match task.as_deref() { match task.as_deref() {
Some("renode-image") => renode_image(false, &hw_pkgs)?, Some("renode-image") => renode_image(false, &hw_pkgs)?,
Some("renode-test") => renode_image(false, &cbtest_pkgs)?, Some("renode-test") => renode_image(false, &cbtest_pkgs)?,
@ -116,29 +123,32 @@ fn try_main() -> Result<(), DynError> {
Some("renode-aes-test") => renode_image(false, &aestest_pkgs)?, Some("renode-aes-test") => renode_image(false, &aestest_pkgs)?,
Some("renode-image-debug") => renode_image(true, &hw_pkgs)?, Some("renode-image-debug") => renode_image(true, &hw_pkgs)?,
Some("run") => run(false, &hw_pkgs)?, Some("run") => run(false, &hw_pkgs)?,
Some("hw-image") => build_hw_image(false, env::args().nth(2), &hw_pkgs, None)?, Some("hw-image") => build_hw_image(false, env::args().nth(2), &hw_pkgs, lkey, kkey, None)?,
Some("benchmark") => build_hw_image(false, env::args().nth(2), &benchmark_pkgs, None)?, Some("benchmark") => build_hw_image(false, env::args().nth(2), &benchmark_pkgs, lkey, kkey, None)?,
Some("minimal") => build_hw_image(false, env::args().nth(2), &minimal_pkgs, None)?, Some("minimal") => build_hw_image(false, env::args().nth(2), &minimal_pkgs, lkey, kkey, None)?,
Some("cbtest") => build_hw_image(false, env::args().nth(2), &cbtest_pkgs, None)?, Some("cbtest") => build_hw_image(false, env::args().nth(2), &cbtest_pkgs, lkey, kkey, None)?,
Some("trng-test") => build_hw_image( Some("trng-test") => build_hw_image(
false, false,
env::args().nth(2), env::args().nth(2),
&hw_pkgs, &hw_pkgs,
lkey, kkey,
Some(&["--features", "urandomtest"]), Some(&["--features", "urandomtest"]),
)?, )?,
Some("ro-test") => build_hw_image( Some("ro-test") => build_hw_image(
false, false,
env::args().nth(2), env::args().nth(2),
&hw_pkgs, &hw_pkgs,
lkey, kkey,
Some(&["--features", "ringosctest"]), Some(&["--features", "ringosctest"]),
)?, )?,
Some("av-test") => build_hw_image( Some("av-test") => build_hw_image(
false, false,
env::args().nth(2), env::args().nth(2),
&hw_pkgs, &hw_pkgs,
lkey, kkey,
Some(&["--features", "avalanchetest"]), Some(&["--features", "avalanchetest"]),
)?, )?,
Some("sr-test") => build_hw_image(false, env::args().nth(2), &sr_pkgs, None)?, Some("sr-test") => build_hw_image(false, env::args().nth(2), &sr_pkgs, lkey, kkey, None)?,
Some("debug") => run(true, &hw_pkgs)?, Some("debug") => run(true, &hw_pkgs)?,
Some("burn-kernel") => update_usb(true, false, false)?, Some("burn-kernel") => update_usb(true, false, false)?,
Some("burn-loader") => update_usb(false, true, false)?, Some("burn-loader") => update_usb(false, true, false)?,
@ -156,7 +166,7 @@ renode-test builds a test image for renode
renode-image-debug builds a test image for renode in debug mode renode-image-debug builds a test image for renode in debug mode
libstd-test [pkg1] [..] builds a test image that includes the minimum packages, plus those libstd-test [pkg1] [..] builds a test image that includes the minimum packages, plus those
specified on the command line (e.g. built externally) specified on the command line (e.g. built externally)
hw-image [soc.svd] builds an image for real hardware hw-image [soc.svd] [loader.key] [kernel.key] builds an image for real hardware
run runs a release build using a hosted environment run runs a release build using a hosted environment
debug runs a debug build using a hosted environment debug runs a debug build using a hosted environment
benchmark [soc.svd] builds a benchmarking image for real hardware benchmark [soc.svd] builds a benchmarking image for real hardware
@ -235,6 +245,8 @@ fn build_hw_image(
debug: bool, debug: bool,
svd: Option<String>, svd: Option<String>,
packages: &[&str], packages: &[&str],
lkey: Option<String>,
kkey: Option<String>,
extra_args: Option<&[&str]>, extra_args: Option<&[&str]>,
) -> Result<(), DynError> { ) -> Result<(), DynError> {
let svd_file = match svd { let svd_file = match svd {
@ -250,7 +262,24 @@ fn build_hw_image(
// Tools use this environment variable to know when to rebuild the UTRA crate. // Tools use this environment variable to know when to rebuild the UTRA crate.
std::env::set_var("XOUS_SVD_FILE", path.canonicalize().unwrap()); std::env::set_var("XOUS_SVD_FILE", path.canonicalize().unwrap());
// std::fs::copy(path, std::path::Path::new("emulation/soc/renode.svd"))?; // extract key file names; replace with defaults if not specified
let loaderkey_file = if let Some(lkf) = lkey {
lkf
} else {
String::from("../devkey/dev.key")
};
let kernelkey_file = if let Some(kkf) = kkey {
kkf
} else {
String::from("../devkey/dev.key")
};
/*
let mut lkf = File::open(loaderkey_file)?;
let mut lk_str = Vec::<u8>::new();
lkf.read_to_end(&mut lk_str);
let lk_pems = pem::parse(lk_str);
println!("lk_pems: {:?}", lk_pems);
*/
let kernel = build_kernel(debug)?; let kernel = build_kernel(debug)?;
let mut init = vec![]; let mut init = vec![];
@ -278,6 +307,8 @@ fn build_hw_image(
let mut loader_bin = output_bundle.parent().unwrap().to_owned(); let mut loader_bin = output_bundle.parent().unwrap().to_owned();
loader_bin.push("loader.bin"); loader_bin.push("loader.bin");
let mut loader_presign = output_bundle.parent().unwrap().to_owned();
loader_presign.push("loader_presign.bin");
let status = Command::new(cargo()) let status = Command::new(cargo())
.current_dir(project_root()) .current_dir(project_root())
.args(&[ .args(&[
@ -288,12 +319,28 @@ fn build_hw_image(
"copy-object", "copy-object",
"--", "--",
loader.as_os_str().to_str().unwrap(), loader.as_os_str().to_str().unwrap(),
loader_bin.as_os_str().to_str().unwrap(), loader_presign.as_os_str().to_str().unwrap(),
]) ])
.status()?; .status()?;
if !status.success() { if !status.success() {
return Err("cargo build failed".into()); return Err("cargo build failed".into());
} }
// sign_loader(loader_presign, loader_bin, loader_signing_key)?;
let status = Command::new("python3")
.current_dir(project_root().join("tools"))
.args(&[
"sign_image.py",
"--loader-image",
loader_presign.to_str().unwrap(),
"--loader-key",
loaderkey_file.as_str(),
"--loader-output",
loader_bin.to_str().unwrap(),
]).status()?;
if !status.success() {
return Err("loader image sign failed".into())
}
println!("Signed loader at {}", loader_bin.to_str().unwrap());
let mut xous_img_path = output_bundle.parent().unwrap().to_owned(); let mut xous_img_path = output_bundle.parent().unwrap().to_owned();
xous_img_path.push("xous.img"); xous_img_path.push("xous.img");
@ -313,6 +360,17 @@ fn build_hw_image(
Ok(()) Ok(())
} }
/*
fn sign_loader(in_path: Pathbuf, out_path: Pathbuf) -> Result<(), DynError> {
let mut in_file = File::open(in_path)?;
let mut out_file = File::open(out_path)?;
let mut loader = Vec::<u8>::new();
in_file.read_to_end(&mut loader);
}*/
fn renode_image(debug: bool, packages: &[&str]) -> Result<(), DynError> { fn renode_image(debug: bool, packages: &[&str]) -> Result<(), DynError> {
let path = std::path::Path::new("emulation/soc/renode.svd"); let path = std::path::Path::new("emulation/soc/renode.svd");
std::env::set_var("XOUS_SVD_FILE", path.canonicalize().unwrap()); std::env::set_var("XOUS_SVD_FILE", path.canonicalize().unwrap());