diff --git a/docs/flash.md b/docs/flash.md index c3e1f863f..710f0d4fa 100644 --- a/docs/flash.md +++ b/docs/flash.md @@ -64,6 +64,37 @@ of wear leveling, however. +-----------+----------------------------------------+ ``` +The EC update block is further structured as follows: +``` ++-----------+----------------------------------------+ ++ 27F8_0000 | wf200 firmware control page | ++ +1000 | | ++-----------+----------------------------------------+ ++ 27F8_1000 | up to 311k for wf200 firmware | ++ +4_D000 | padded with trailing 0xFF | ++-----------+----------------------------------------+ ++ 27FC_E000 | EC firmware control page | ++ +1000 | | ++-----------+----------------------------------------+ ++ 27FC_F000 | up to 199k EC fw | ++ +3_1000 | padded with trailing 0xFF | ++-----------+----------------------------------------+ + +``` + +The firmware control pages have the following structure: +``` +base + 0x0000: [u8; 32] = SHA-512/256 hash from base+0x20 to last byte of firmware +base + 0x0020: [u8; 4] = EC: [0x70, 0x72, 0x65, 0x63]; // signature 'cerp' ('prec' in big endian) or WF200: [0x77, 0x66, 0x32, 0x30]; // 'wf20' +base + 0x0024: u32 = firmware control page version number (currently 1) +base + 0x0028: u32 = length of firmware in bytes, computed from start of first firmware page +base + 0x002c: [u8; 4052] = [0xff as u8; 4052] 0xff padding to start of first firmware page +base + 0x1000: [u8; FW_LEN] = actual firmware + +remainder of unused sectors are 0xff pad. The 0xff pad is not hashed for performance reasons, and should +be considered insecure/untrusted. +``` + The csr.csv block is further structured as follows: diff --git a/docs/memory.md b/docs/memory.md index 9b9a5c5ca..9e43fbf93 100644 --- a/docs/memory.md +++ b/docs/memory.md @@ -44,6 +44,7 @@ the need from ever switching back to process 1. Note that the kernel takes up a single 4 MB megapage, so it can be assigned to every process simply by mapping megapage 1023 (`0xffc00000`). +``` | Address | Description | ---------- | ----------- | 0x00100000 | Default entrypoint for riscv64-unknown-elf-ld (as shown by `riscv64-unknown-elf-ld --verbose`) @@ -54,12 +55,14 @@ assigned to every process simply by mapping megapage 1023 (`0xffc00000`). | 0xff801000 | Context data (registers, etc.) | 0xff802000 | Return address from syscalls (never allocated) | 0xffc00000 | Kernel arguments, allocation tables +| 0xffcd0000 | Kernel WFI CSR page | 0xffce0000 | Kernel TRNG CSR page | 0xffcf0000 | Supervisor UART CSR page | 0xffd00000 | Kernel binary image and data section | 0xfffefffc | "default" stack pointer (used by interrupt handlers) | 0xffff0000 | Kernel stack top | 0xfff00000 | {unused} +``` Note that the stack pointer is not necessarily fixed, and may be changed in a later revision.