From b0680c2669579c845b308a9dc187d9d5dd578b80 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 15 Oct 2020 01:04:23 +0800 Subject: [PATCH 1/7] update to make dest dir easier to chaneg --- buildpush.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/buildpush.sh b/buildpush.sh index 15ba0247a..a4438af06 100755 --- a/buildpush.sh +++ b/buildpush.sh @@ -10,6 +10,8 @@ then exit 0 fi +DESTDIR=code/bin + # notes: # xous-stage1.bin written to 0x2050_0000 (64k erase block size) # xous-kernel.bin written to 0x2051_0000 => passed as a0 arg to xous-stage1.bin @@ -29,13 +31,13 @@ if [ $# -gt 0 ] then if [ -z "$2" ] then - scp target/riscv32imac-unknown-none-elf/release/xous.img $1:code/betrusted-scripts/ - scp ../betrusted-soc/build/gateware/encrypted.bin $1:code/betrusted-scripts/ - scp ../betrusted-soc/build/csr.csv $1:code/betrusted-scripts/soc-csr.csv + scp target/riscv32imac-unknown-none-elf/release/xous.img $1:$DESTDIR/ + scp ../betrusted-soc/build/gateware/encrypted.bin $1:$DESTDIR/ + scp ../betrusted-soc/build/csr.csv $1:$DESTDIR/soc-csr.csv else - scp -i $2 target/riscv32imac-unknown-none-elf/release/xous.img $1:code/betrusted-scripts/ - scp -i $2 ../betrusted-soc/build/gateware/encrypted.bin $1:code/betrusted-scripts/ - scp -i $2 ../betrusted-soc/build/csr.csv $1:code/betrusted-scripts/soc-csr.csv + scp -i $2 target/riscv32imac-unknown-none-elf/release/xous.img $1:$DESTDIR/ + scp -i $2 ../betrusted-soc/build/gateware/encrypted.bin $1:$DESTDIR/ + scp -i $2 ../betrusted-soc/build/csr.csv $1:$DESTDIR/soc-csr.csv fi else echo "Copy to target with $0 " From 710abce418625ba373f62a001937ccf9e15abb2f Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 22 Nov 2020 03:45:44 +0800 Subject: [PATCH 2/7] fixup to latest soc.svd register documentation standard --- Cargo.lock | 92 +++++++++++++++++++++++--- buildpush.sh | 2 +- kernel/src/debug.rs | 4 +- services/graphics-server/src/debug.rs | 4 +- services/log-server/src/debug.rs | 4 +- services/shell/src/debug.rs | 4 +- services/shell/src/timer.rs | 4 +- services/ticktimer-server/src/debug.rs | 4 +- 8 files changed, 95 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e10482edd..bbe4eee10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,6 +39,18 @@ version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c" +[[package]] +name = "as-slice" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb4d1c23475b74e3672afa8c2be22040b8b7783ad9b461021144ed10a46bb0e6" +dependencies = [ + "generic-array 0.12.3", + "generic-array 0.13.2", + "generic-array 0.14.4", + "stable_deref_trait", +] + [[package]] name = "atty" version = "0.2.14" @@ -214,15 +226,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" -[[package]] -name = "embedded-graphics" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a69991ceb896bd4810a0cf2bcc46fc94b7860573c71f965d8e5b3d66942fed" -dependencies = [ - "byteorder", -] - [[package]] name = "env_logger" version = "0.7.1" @@ -251,6 +254,34 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd" +dependencies = [ + "typenum", +] + +[[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]] name = "getrandom" version = "0.1.14" @@ -279,6 +310,27 @@ dependencies = [ "xous", ] +[[package]] +name = "hash32" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc" +dependencies = [ + "byteorder", +] + +[[package]] +name = "heapless" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1" +dependencies = [ + "as-slice", + "generic-array 0.13.2", + "hash32", + "stable_deref_trait", +] + [[package]] name = "hermit-abi" version = "0.1.15" @@ -819,6 +871,12 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.8.0" @@ -890,7 +948,9 @@ dependencies = [ name = "ticktimer-server" version = "0.1.0" dependencies = [ - "embedded-graphics", + "heapless", + "log", + "log-server", "utralib", "xous", ] @@ -909,6 +969,12 @@ dependencies = [ "xmas-elf", ] +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + [[package]] name = "unicode-width" version = "0.1.8" @@ -934,6 +1000,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + [[package]] name = "void" version = "1.0.2" diff --git a/buildpush.sh b/buildpush.sh index a4438af06..18d144038 100755 --- a/buildpush.sh +++ b/buildpush.sh @@ -10,7 +10,7 @@ then exit 0 fi -DESTDIR=code/bin +DESTDIR=code/precursors # notes: # xous-stage1.bin written to 0x2050_0000 (64k erase block size) diff --git a/kernel/src/debug.rs b/kernel/src/debug.rs index effe0826e..10b44fb04 100644 --- a/kernel/src/debug.rs +++ b/kernel/src/debug.rs @@ -51,7 +51,7 @@ impl Uart { #[allow(dead_code)] pub fn enable_rx(self) { let mut uart_csr = CSR::new(self.base as *mut u32); - uart_csr.wfo(utra::uart::EV_ENABLE_ENABLE, uart_csr.rf(utra::uart::EV_ENABLE_ENABLE) | 2); + uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1); } pub fn putc(&self, c: u8) { @@ -68,7 +68,7 @@ impl Uart { let mut uart_csr = CSR::new(self.base as *mut u32); // If EV_PENDING_RX is 1, return the pending character. // Otherwise, return None. - match uart_csr.r(utra::uart::EV_PENDING) & 2 { + match uart_csr.rf(utra::uart::EV_PENDING_RX) { 0 => None, ack => { let c = Some(uart_csr.r(utra::uart::RXTX) as u8); diff --git a/services/graphics-server/src/debug.rs b/services/graphics-server/src/debug.rs index 4dbf34c86..65b20fb87 100644 --- a/services/graphics-server/src/debug.rs +++ b/services/graphics-server/src/debug.rs @@ -79,7 +79,7 @@ impl Uart { pub fn enable_rx(&self) { if cfg!(feature = "debugprint") { let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - uart_csr.wfo(utra::uart::EV_ENABLE_ENABLE, uart_csr.rf(utra::uart::EV_ENABLE_ENABLE) | 2 ); + uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1); } } @@ -89,7 +89,7 @@ impl Uart { self.map_uart(); } let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - match uart_csr.rf(utra::uart::EV_PENDING_PENDING) & 2 { + match uart_csr.rf(utra::uart::EV_PENDING_RX) { 0 => None, ack => { let c = Some(uart_csr.rf(utra::uart::RXTX_RXTX) as u8); diff --git a/services/log-server/src/debug.rs b/services/log-server/src/debug.rs index 1f678026a..6527495cb 100644 --- a/services/log-server/src/debug.rs +++ b/services/log-server/src/debug.rs @@ -76,7 +76,7 @@ impl Uart { pub fn enable_rx(&self) { let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - uart_csr.wfo(utra::uart::EV_ENABLE_ENABLE, uart_csr.rf(utra::uart::EV_ENABLE_ENABLE) | 2 ); + uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1 ); } pub fn getc(&self) -> Option { @@ -84,7 +84,7 @@ impl Uart { self.map_uart(); } let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - match uart_csr.rf(utra::uart::EV_PENDING_PENDING) & 2 { + match uart_csr.rf(utra::uart::EV_PENDING_RX) { 0 => None, ack => { let c = Some(uart_csr.rf(utra::uart::RXTX_RXTX) as u8); diff --git a/services/shell/src/debug.rs b/services/shell/src/debug.rs index 567e02c4c..122969211 100644 --- a/services/shell/src/debug.rs +++ b/services/shell/src/debug.rs @@ -79,7 +79,7 @@ impl Uart { pub fn enable_rx(&self) { if cfg!(feature = "debugprint") { let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - uart_csr.wfo(utra::uart::EV_ENABLE_ENABLE, uart_csr.rf(utra::uart::EV_ENABLE_ENABLE) | 2 ); + uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1 ); } } @@ -89,7 +89,7 @@ impl Uart { self.map_uart(); } let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - match uart_csr.rf(utra::uart::EV_PENDING_PENDING) & 2 { + match uart_csr.rf(utra::uart::EV_PENDING_RX) { 0 => None, ack => { let c = Some(uart_csr.rf(utra::uart::RXTX_RXTX) as u8); diff --git a/services/shell/src/timer.rs b/services/shell/src/timer.rs index 417387323..ff22221db 100644 --- a/services/shell/src/timer.rs +++ b/services/shell/src/timer.rs @@ -14,7 +14,7 @@ fn timer_tick(_irq_no: usize, _arg: *mut usize) { xous::rsyscall(xous::SysCall::ReturnToParent(xous::PID::new(1).unwrap(), 0)).expect("couldn't return to parent"); // acknowledge the timer - timer.wfo(utra::timer0::EV_PENDING_PENDING, 0b1); + timer.wfo(utra::timer0::EV_PENDING_ZERO, 0b1); //println!("<<< Returning from timer_tick()"); } @@ -45,7 +45,7 @@ pub fn init() { // Set EV_ENABLE let mut timer = CSR::new(TIMER_BASE as *mut u32); - timer.wfo(utra::timer0::EV_ENABLE_ENABLE, 0b1); + timer.wfo(utra::timer0::EV_ENABLE_ZERO, 0b1); } #[cfg(not(baremetal))] diff --git a/services/ticktimer-server/src/debug.rs b/services/ticktimer-server/src/debug.rs index 8c2c155d8..b1274560b 100644 --- a/services/ticktimer-server/src/debug.rs +++ b/services/ticktimer-server/src/debug.rs @@ -79,7 +79,7 @@ impl Uart { pub fn enable_rx(&self) { if cfg!(feature = "debugprint") { let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - uart_csr.wfo(utra::uart::EV_ENABLE_ENABLE, uart_csr.rf(utra::uart::EV_ENABLE_ENABLE) | 2 ); + uart_csr.rmwf(utra::uart::EV_ENABLE_RX, 1); } } @@ -89,7 +89,7 @@ impl Uart { self.map_uart(); } let mut uart_csr = CSR::new(unsafe{DEFAULT_UART_ADDR as *mut u32}); - match uart_csr.rf(utra::uart::EV_PENDING_PENDING) & 2 { + match uart_csr.rf(utra::uart::EV_PENDING_RX) { 0 => None, ack => { let c = Some(uart_csr.rf(utra::uart::RXTX_RXTX) as u8); From f61ae8ee2ad1fa7ff9c864d7964712de3120eab3 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 22 Nov 2020 03:46:42 +0800 Subject: [PATCH 3/7] update soc.svd example --- svd2utra/examples/soc.svd | 1048 ++++++++++++++++++++++++------------- 1 file changed, 691 insertions(+), 357 deletions(-) diff --git a/svd2utra/examples/soc.svd b/svd2utra/examples/soc.svd index 8e593f540..740dff62c 100644 --- a/svd2utra/examples/soc.svd +++ b/svd2utra/examples/soc.svd @@ -2,7 +2,7 @@ litex - JTAG + SOC 8 32 @@ -23,7 +23,6 @@ 0x0000 0x00 32 - read-write reset @@ -41,7 +40,6 @@ to the Wishbone/CSR bus are working correctly. The initial reset value of 0x0004 0x12345678 32 - read-write scratch @@ -57,7 +55,6 @@ to the Wishbone/CSR bus are working correctly. The initial reset value of 0x0008 0x00 32 - read-only bus_errors @@ -85,7 +82,6 @@ to the Wishbone/CSR bus are working correctly. The initial reset value of 0x0000 0x00 32 - read-write identifier_mem @@ -114,7 +110,6 @@ this register specifies the Timer's duration in clock cycles.]]> 0x0000 0x00 32 - read-write load @@ -131,7 +126,6 @@ this register specify the Timer's period in clock cycles.]]> 0x0004 0x00 32 - read-write reload @@ -148,7 +142,6 @@ to ``0`` to disable the Timer.]]> 0x0008 0x00 32 - read-write en @@ -165,7 +158,6 @@ the current countdown value to ``value`` register.]]> 0x000c 0x00 32 - read-write update_value @@ -181,7 +173,6 @@ the current countdown value to ``value`` register.]]> 0x0010 0x00 32 - read-only value @@ -193,46 +184,52 @@ the current countdown value to ``value`` register.]]> EV_STATUS + 0x0014 0x00 32 - read-write - status + zero 0 [0:0] 0 + EV_PENDING + 0x0018 0x00 32 - read-write - pending + zero 0 [0:0] 0 + EV_ENABLE + 0x001c 0x00 32 - read-write - enable + zero 0 [0:0] 0 + @@ -257,7 +254,6 @@ the current countdown value to ``value`` register.]]> 0x0000 0x00 32 - read-write ctrl @@ -272,7 +268,6 @@ the current countdown value to ``value`` register.]]> 0x0004 0x00 32 - read-write addr @@ -299,7 +294,6 @@ the current countdown value to ``value`` register.]]> 0x0000 0x00 32 - read-write mmcm_drp_reset @@ -314,7 +308,6 @@ the current countdown value to ``value`` register.]]> 0x0004 0x00 32 - read-only mmcm_drp_locked @@ -329,7 +322,6 @@ the current countdown value to ``value`` register.]]> 0x0008 0x00 32 - read-write mmcm_drp_read @@ -344,7 +336,6 @@ the current countdown value to ``value`` register.]]> 0x000c 0x00 32 - read-write mmcm_drp_write @@ -359,7 +350,6 @@ the current countdown value to ``value`` register.]]> 0x0010 0x00 32 - read-only mmcm_drp_drdy @@ -374,7 +364,6 @@ the current countdown value to ``value`` register.]]> 0x0014 0x00 32 - read-write mmcm_drp_adr @@ -389,7 +378,6 @@ the current countdown value to ``value`` register.]]> 0x0018 0x00 32 - read-write mmcm_drp_dat_w @@ -404,7 +392,6 @@ the current countdown value to ``value`` register.]]> 0x001c 0x00 32 - read-only mmcm_drp_dat_r @@ -432,7 +419,6 @@ the current countdown value to ``value`` register.]]> 0x0000 0x00 32 - read-write output @@ -448,7 +434,6 @@ the current countdown value to ``value`` register.]]> 0x0004 0x00 32 - read-only input @@ -464,7 +449,6 @@ the current countdown value to ``value`` register.]]> 0x0008 0x00 32 - read-write drive @@ -480,7 +464,6 @@ the current countdown value to ``value`` register.]]> 0x000c 0x00 32 - read-only intena @@ -497,7 +480,6 @@ interrupts.]]> 0x0010 0x00 32 - read-only intpol @@ -514,7 +496,6 @@ console, others undefined]]> 0x0014 0x00 32 - read-write uartsel @@ -526,46 +507,207 @@ console, others undefined]]> EV_STATUS + 0x0018 0x00 32 - read-write - status - 7 - [7:0] + event0 + 0 + [0:0] 0 + + + + event1 + 1 + [1:1] + 1 + + + + event2 + 2 + [2:2] + 2 + + + + event3 + 3 + [3:3] + 3 + + + + event4 + 4 + [4:4] + 4 + + + + event5 + 5 + [5:5] + 5 + + + + event6 + 6 + [6:6] + 6 + + + + event7 + 7 + [7:7] + 7 + EV_PENDING + 0x001c 0x00 32 - read-write - pending - 7 - [7:0] + event0 + 0 + [0:0] 0 + + + + event1 + 1 + [1:1] + 1 + + + + event2 + 2 + [2:2] + 2 + + + + event3 + 3 + [3:3] + 3 + + + + event4 + 4 + [4:4] + 4 + + + + event5 + 5 + [5:5] + 5 + + + + event6 + 6 + [6:6] + 6 + + + + event7 + 7 + [7:7] + 7 + EV_ENABLE + 0x0020 0x00 32 - read-write - enable - 7 - [7:0] + event0 + 0 + [0:0] 0 + + + + event1 + 1 + [1:1] + 1 + + + + event2 + 2 + [2:2] + 2 + + + + event3 + 3 + [3:3] + 3 + + + + event4 + 4 + [4:4] + 4 + + + + event5 + 5 + [5:5] + 5 + + + + event6 + 6 + [6:6] + 6 + + + + event7 + 7 + [7:7] + 7 + @@ -590,7 +732,6 @@ console, others undefined]]> 0x0000 0x4b7f5a 32 - read-write tuning_word @@ -617,7 +758,6 @@ console, others undefined]]> 0x0000 0x00 32 - read-write rxtx @@ -632,7 +772,6 @@ console, others undefined]]> 0x0004 0x00 32 - read-only txfull @@ -647,7 +786,6 @@ console, others undefined]]> 0x0008 0x00 32 - read-only rxempty @@ -659,46 +797,73 @@ console, others undefined]]> EV_STATUS + 0x000c 0x00 32 - read-write - status - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_PENDING + 0x0010 0x00 32 - read-write - pending - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_ENABLE + 0x0014 0x00 32 - read-write - enable - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + @@ -707,7 +872,6 @@ console, others undefined]]> 0x0018 0x00 32 - read-only txempty @@ -722,7 +886,6 @@ console, others undefined]]> 0x001c 0x00 32 - read-only rxfull @@ -753,7 +916,6 @@ console, others undefined]]> 0x0000 0x4b7f5a 32 - read-write tuning_word @@ -780,7 +942,6 @@ console, others undefined]]> 0x0000 0x00 32 - read-write rxtx @@ -795,7 +956,6 @@ console, others undefined]]> 0x0004 0x00 32 - read-only txfull @@ -810,7 +970,6 @@ console, others undefined]]> 0x0008 0x00 32 - read-only rxempty @@ -822,46 +981,73 @@ console, others undefined]]> EV_STATUS + 0x000c 0x00 32 - read-write - status - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_PENDING + 0x0010 0x00 32 - read-write - pending - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_ENABLE + 0x0014 0x00 32 - read-write - enable - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + @@ -870,7 +1056,6 @@ console, others undefined]]> 0x0018 0x00 32 - read-only txempty @@ -885,7 +1070,6 @@ console, others undefined]]> 0x001c 0x00 32 - read-only rxfull @@ -916,7 +1100,6 @@ console, others undefined]]> 0x0000 0x4b7f5a 32 - read-write tuning_word @@ -943,7 +1126,6 @@ console, others undefined]]> 0x0000 0x00 32 - read-write rxtx @@ -958,7 +1140,6 @@ console, others undefined]]> 0x0004 0x00 32 - read-only txfull @@ -973,7 +1154,6 @@ console, others undefined]]> 0x0008 0x00 32 - read-only rxempty @@ -985,46 +1165,73 @@ console, others undefined]]> EV_STATUS + 0x000c 0x00 32 - read-write - status - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_PENDING + 0x0010 0x00 32 - read-write - pending - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_ENABLE + 0x0014 0x00 32 - read-write - enable - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + @@ -1033,7 +1240,6 @@ console, others undefined]]> 0x0018 0x00 32 - read-only txempty @@ -1048,7 +1254,6 @@ console, others undefined]]> 0x001c 0x00 32 - read-only rxfull @@ -1079,7 +1284,6 @@ console, others undefined]]> 0x0000 0x4b7f5a 32 - read-write tuning_word @@ -1106,7 +1310,6 @@ console, others undefined]]> 0x0000 0x00 32 - read-write rxtx @@ -1121,7 +1324,6 @@ console, others undefined]]> 0x0004 0x00 32 - read-only txfull @@ -1136,7 +1338,6 @@ console, others undefined]]> 0x0008 0x00 32 - read-only rxempty @@ -1148,46 +1349,73 @@ console, others undefined]]> EV_STATUS + 0x000c 0x00 32 - read-write - status - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_PENDING + 0x0010 0x00 32 - read-write - pending - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + EV_ENABLE + 0x0014 0x00 32 - read-write - enable - 1 - [1:0] + tx + 0 + [0:0] 0 + + + + rx + 1 + [1:1] + 1 + @@ -1196,7 +1424,6 @@ console, others undefined]]> 0x0018 0x00 32 - read-only txempty @@ -1211,7 +1438,6 @@ console, others undefined]]> 0x001c 0x00 32 - read-only rxfull @@ -1243,7 +1469,6 @@ console, others undefined]]> 0x0000 0x00 32 - read-only dna_id @@ -1259,7 +1484,6 @@ console, others undefined]]> 0x0004 0x00 32 - read-only dna_id @@ -1276,7 +1500,6 @@ console, others undefined]]> 0x0008 0x00 32 - read-only git_major @@ -1293,7 +1516,6 @@ console, others undefined]]> 0x000c 0x00 32 - read-only git_minor @@ -1310,7 +1532,6 @@ console, others undefined]]> 0x0010 0x00 32 - read-only git_revision @@ -1328,7 +1549,6 @@ git version used to build this firmware.]]> 0x0014 0x00 32 - read-only git_gitrev @@ -1346,7 +1566,6 @@ beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x0018 0x00 32 - read-only git_gitextra @@ -1361,7 +1580,6 @@ beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x001c 0x00 32 - read-only dirty @@ -1379,7 +1597,6 @@ modifications.]]> 0x0020 0x00 32 - read-only platform_platform @@ -1395,7 +1612,6 @@ modifications.]]> 0x0024 0x00 32 - read-only platform_platform @@ -1411,7 +1627,6 @@ modifications.]]> 0x0028 0x00 32 - read-only platform_target @@ -1427,7 +1642,6 @@ modifications.]]> 0x002c 0x00 32 - read-only platform_target @@ -1445,7 +1659,6 @@ Temperature (°C) = ``Value`` x 503.975 / 4096 - 273.15.]]> 0x0030 0x00 32 - read-only xadc_temperature @@ -1463,7 +1676,6 @@ VCCINT (V) = ``Value`` x 3 / 4096.]]> 0x0034 0x00 32 - read-only xadc_vccint @@ -1481,7 +1693,6 @@ VCCAUX (V) = ``Value`` x 3 / 4096.]]> 0x0038 0x00 32 - read-only xadc_vccaux @@ -1499,7 +1710,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x003c 0x00 32 - read-only xadc_vccbram @@ -1515,7 +1725,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0040 0x00 32 - read-only xadc_eoc @@ -1531,7 +1740,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0044 0x00 32 - read-only xadc_eos @@ -1546,7 +1754,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0048 0x00 32 - read-write xadc_drp_enable @@ -1561,7 +1768,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x004c 0x00 32 - read-write xadc_drp_read @@ -1576,7 +1782,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0050 0x00 32 - read-write xadc_drp_write @@ -1591,7 +1796,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0054 0x00 32 - read-only xadc_drp_drdy @@ -1606,7 +1810,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0058 0x00 32 - read-write xadc_drp_adr @@ -1621,7 +1824,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x005c 0x00 32 - read-write xadc_drp_dat_w @@ -1636,7 +1838,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0060 0x00 32 - read-only xadc_drp_dat_r @@ -1663,7 +1864,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0000 0x00 32 - read-only mode @@ -1679,7 +1879,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0004 0x00 32 - read-write trigger @@ -1707,7 +1906,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0000 0x00 32 - read-write UpdateDirty @@ -1731,7 +1929,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0004 0x00 32 - read-only busy @@ -1748,7 +1945,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0008 0x63 32 - read-write prescaler @@ -1760,46 +1956,52 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> EV_STATUS + 0x000c 0x00 32 - read-write - status + done 0 [0:0] 0 + EV_PENDING + 0x0010 0x00 32 - read-write - pending + done 0 [0:0] 0 + EV_ENABLE + 0x0014 0x00 32 - read-write - enable + done 0 [0:0] 0 + @@ -1821,7 +2023,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0000 0x00 32 - read-write tx @@ -1837,7 +2038,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0004 0x00 32 - read-only rx @@ -1852,7 +2052,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x0008 0x00 32 - read-write intena @@ -1861,6 +2060,13 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0 + + autohold + 1 + [1:1] + 1 + + @@ -1868,7 +2074,6 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0x000c 0x00 32 - read-only tip @@ -1877,50 +2082,86 @@ VCCBRAM (V) = ``Value`` x 3 / 4096.]]> 0 + + hold + 1 + [1:1] + 1 + + EV_STATUS + 0x0010 0x00 32 - read-write - status + spi_int 0 [0:0] 0 + + + + spi_hold + 1 + [1:1] + 1 + EV_PENDING + 0x0014 0x00 32 - read-write - pending + spi_int 0 [0:0] 0 + + + + spi_hold + 1 + [1:1] + 1 + EV_ENABLE + 0x0018 0x00 32 - read-write - enable + spi_int 0 [0:0] 0 + + + + spi_hold + 1 + [1:1] + 1 + @@ -1944,7 +2185,6 @@ prescaler is (100MHz / (5 * 100kHz) - 1) = 199. Reset value: 0xFFFF]]>0x0000 0xffff 32 - read-write prescale @@ -1959,7 +2199,6 @@ prescaler is (100MHz / (5 * 100kHz) - 1) = 199. Reset value: 0xFFFF]]>0x0004 0x00 32 - read-write Resvd @@ -1991,7 +2230,6 @@ prescaler is (100MHz / (5 * 100kHz) - 1) = 199. Reset value: 0xFFFF]]>0x0008 0x00 32 - read-write txr @@ -2007,7 +2245,6 @@ prescaler is (100MHz / (5 * 100kHz) - 1) = 199. Reset value: 0xFFFF]]>0x000c 0x00 32 - read-only rxr @@ -2022,7 +2259,6 @@ prescaler is (100MHz / (5 * 100kHz) - 1) = 199. Reset value: 0xFFFF]]>0x0010 0x00 32 - read-write IACK @@ -2080,7 +2316,6 @@ prescaler is (100MHz / (5 * 100kHz) - 1) = 199. Reset value: 0xFFFF]]>0x0014 0x00 32 - read-only IF @@ -2130,46 +2365,52 @@ upon the completion of one byte of data transfer.]]> EV_STATUS + 0x0018 0x00 32 - read-write - status + i2c_int 0 [0:0] 0 + EV_PENDING + 0x001c 0x00 32 - read-write - pending + i2c_int 0 [0:0] 0 + EV_ENABLE + 0x0020 0x00 32 - read-write - enable + i2c_int 0 [0:0] 0 + @@ -2191,46 +2432,74 @@ upon the completion of one byte of data transfer.]]> EV_STATUS + 0x0000 0x00 32 - read-write - status - 1 - [1:0] + com_int + 0 + [0:0] 0 + + + + rtc_int + 1 + [1:1] + 1 + EV_PENDING + 0x0004 0x00 32 - read-write - pending - 1 - [1:0] + com_int + 0 + [0:0] 0 + + + + rtc_int + 1 + [1:1] + 1 + EV_ENABLE + 0x0008 0x00 32 - read-write - enable - 1 - [1:0] + com_int + 0 + [0:0] 0 + + + + rtc_int + 1 + [1:1] + 1 + @@ -2257,7 +2526,6 @@ advances the write pointer automatically.]]> 0x0000 0x00 32 - read-write in @@ -2274,7 +2542,6 @@ register advances the read pointer automatically.]]> 0x0004 0x00 32 - read-only out @@ -2289,7 +2556,6 @@ register advances the read pointer automatically.]]> 0x0008 0x00 32 - read-only full @@ -2326,7 +2592,6 @@ advances the write pointer automatically.]]> 0x0000 0x00 32 - read-write in @@ -2343,7 +2608,6 @@ register advances the read pointer automatically.]]> 0x0004 0x00 32 - read-only out @@ -2358,7 +2622,6 @@ register advances the read pointer automatically.]]> 0x0008 0x00 32 - read-only full @@ -2393,7 +2656,6 @@ register advances the read pointer automatically.]]> 0x0000 0x00 32 - read-write reset @@ -2417,7 +2679,6 @@ register advances the read pointer automatically.]]> 0x0004 0x00 32 - read-only time @@ -2433,7 +2694,6 @@ register advances the read pointer automatically.]]> 0x0008 0x00 32 - read-only time @@ -2449,7 +2709,6 @@ register advances the read pointer automatically.]]> 0x000c 0x00 32 - read-write msleep_target @@ -2465,7 +2724,6 @@ register advances the read pointer automatically.]]> 0x0010 0x00 32 - read-write msleep_target @@ -2477,46 +2735,53 @@ register advances the read pointer automatically.]]> EV_STATUS + 0x0014 0x00 32 - read-write - status + alarm 0 [0:0] 0 + EV_PENDING + 0x0018 0x00 32 - read-write - pending + alarm 0 [0:0] 0 + EV_ENABLE + 0x001c 0x00 32 - read-write - enable + alarm 0 [0:0] 0 + @@ -2526,6 +2791,10 @@ register advances the read pointer automatically.]]> 0x20 registers + + ticktimer + 8 + POWER @@ -2537,7 +2806,6 @@ register advances the read pointer automatically.]]> 0x0000 0x0a 32 - read-write audio @@ -2623,7 +2891,6 @@ reset fashion]]> 0x0004 0x00 32 - read-write vibe @@ -2636,46 +2903,49 @@ reset fashion]]> EV_STATUS + 0x0008 0x00 32 - read-write - status + usb_attach 0 [0:0] 0 + EV_PENDING + 0x000c 0x00 32 - read-write - pending + usb_attach 0 [0:0] 0 + EV_ENABLE + 0x0010 0x00 32 - read-write - enable + usb_attach 0 [0:0] 0 + @@ -2696,7 +2966,6 @@ reset fashion]]> 0x0000 0x0a 32 - read-write dummy @@ -2710,9 +2979,8 @@ reset fashion]]> DELAY_CONFIG 0x0004 - 0x1f + 0x00 32 - read-write d @@ -2735,7 +3003,6 @@ reset fashion]]> 0x0008 0x00 32 - read-only q @@ -2753,7 +3020,6 @@ once leads to undefined behavior.]]> 0x000c 0x00 32 - read-write wakeup @@ -2792,16 +3058,16 @@ once leads to undefined behavior.]]> data_words - 22 - [22:16] + 23 + [23:16] 16 lock_reads - 23 - [23:23] - 23 + 24 + [24:24] + 24 @@ -2812,7 +3078,6 @@ once leads to undefined behavior.]]> 0x0010 0x00 32 - read-write cmd_arg @@ -2829,7 +3094,6 @@ once leads to undefined behavior.]]> 0x0014 0x00 32 - read-only cmd_rbk_data @@ -2846,7 +3110,6 @@ once leads to undefined behavior.]]> 0x0018 0x00 32 - read-only wip @@ -2863,59 +3126,69 @@ once leads to undefined behavior.]]> 0x001c 0x00 32 - read-write wdata 15 [15:0] 0 - + EV_STATUS + 0x0020 0x00 32 - read-write - status + ecc_error 0 [0:0] 0 + EV_PENDING + 0x0024 0x00 32 - read-write - pending + ecc_error 0 [0:0] 0 + EV_ENABLE + 0x0028 0x00 32 - read-write - enable + ecc_error 0 [0:0] 0 + @@ -2924,7 +3197,6 @@ once leads to undefined behavior.]]> 0x002c 0x00 32 - read-only ecc_address @@ -2940,7 +3212,6 @@ once leads to undefined behavior.]]> 0x0030 0x00 32 - read-only ecc_error @@ -2977,7 +3248,6 @@ checked]]> 0x0000 0x00 32 - read-only row0dat @@ -2993,7 +3263,6 @@ checked]]> 0x0004 0x00 32 - read-only row1dat @@ -3009,7 +3278,6 @@ checked]]> 0x0008 0x00 32 - read-only row2dat @@ -3025,7 +3293,6 @@ checked]]> 0x000c 0x00 32 - read-only row3dat @@ -3041,7 +3308,6 @@ checked]]> 0x0010 0x00 32 - read-only row4dat @@ -3057,7 +3323,6 @@ checked]]> 0x0014 0x00 32 - read-only row5dat @@ -3073,7 +3338,6 @@ checked]]> 0x0018 0x00 32 - read-only row6dat @@ -3089,7 +3353,6 @@ checked]]> 0x001c 0x00 32 - read-only row7dat @@ -3105,7 +3368,6 @@ checked]]> 0x0020 0x00 32 - read-only row8dat @@ -3117,46 +3379,49 @@ checked]]> EV_STATUS + 0x0024 0x00 32 - read-write - status + keypressed 0 [0:0] 0 + EV_PENDING + 0x0028 0x00 32 - read-write - pending + keypressed 0 [0:0] 0 + EV_ENABLE + 0x002c 0x00 32 - read-write - enable + keypressed 0 [0:0] 0 + @@ -3167,7 +3432,6 @@ again until the interrupt is serviced.]]> 0x0030 0x00 32 - read-only rowchange @@ -3185,7 +3449,7 @@ again until the interrupt is serviced.]]> keyboard - 8 + 9 @@ -3197,9 +3461,8 @@ again until the interrupt is serviced.]]> SEED1 0x0000 - 0x26732071 + 0x20483d3b 32 - read-only seed @@ -3213,9 +3476,8 @@ again until the interrupt is serviced.]]> SEED0 0x0004 - 0x5babc71f + 0x1febda0d 32 - read-only seed @@ -3243,7 +3505,6 @@ again until the interrupt is serviced.]]> 0x0000 0x00 32 - read-write address @@ -3259,7 +3520,6 @@ again until the interrupt is serviced.]]> 0x0004 0x00 32 - read-only data @@ -3283,46 +3543,112 @@ again until the interrupt is serviced.]]> EV_STATUS + 0x0000 0x00 32 - read-write - status - 3 - [3:0] + rx_ready + 0 + [0:0] 0 + + + + rx_error + 1 + [1:1] + 1 + + + + tx_ready + 2 + [2:2] + 2 + + + + tx_error + 3 + [3:3] + 3 + EV_PENDING + 0x0004 0x00 32 - read-write - pending - 3 - [3:0] + rx_ready + 0 + [0:0] 0 + + + + rx_error + 1 + [1:1] + 1 + + + + tx_ready + 2 + [2:2] + 2 + + + + tx_error + 3 + [3:3] + 3 + EV_ENABLE + 0x0008 0x00 32 - read-write - enable - 3 - [3:0] + rx_ready + 0 + [0:0] 0 + + + + rx_error + 1 + [1:1] + 1 + + + + tx_ready + 2 + [2:2] + 2 + + + + tx_error + 3 + [3:3] + 3 + @@ -3332,7 +3658,6 @@ again until the interrupt is serviced.]]> 0x000c 0x00 32 - read-write enable @@ -3356,7 +3681,6 @@ again until the interrupt is serviced.]]> 0x0010 0x80000000 32 - read-only overflow @@ -3422,7 +3746,6 @@ again until the interrupt is serviced.]]> 0x0014 0xac4441 32 - read-only format @@ -3454,7 +3777,6 @@ I2S_FORMAT.I2S_STANDARD is I2S standard]]> 0x0018 0x00 32 - read-write enable @@ -3478,7 +3800,6 @@ I2S_FORMAT.I2S_STANDARD is I2S standard]]> 0x001c 0x1000000 32 - read-only overflow @@ -3551,7 +3872,6 @@ I2S_FORMAT.I2S_STANDARD is I2S standard]]> 0x0020 0xac4441 32 - read-only format @@ -3585,7 +3905,7 @@ I2S_FORMAT.I2S_STANDARD is I2S standard]]> audio - 9 + 10 @@ -3598,7 +3918,6 @@ I2S_FORMAT.I2S_STANDARD is I2S standard]]> 0x0000 0x2000192 32 - read-write ena @@ -3642,7 +3961,6 @@ coupling of the deterministic sysclk noise into the rings.]]> 0x0004 0xdeadbeef 32 - read-only rand @@ -3658,7 +3976,6 @@ coupling of the deterministic sysclk noise into the rings.]]> 0x0008 0x00 32 - read-only fresh @@ -3687,7 +4004,6 @@ reading the `rand` register]]> 0x0000 0x00 32 - read-write key_0 @@ -3703,7 +4019,6 @@ reading the `rand` register]]> 0x0004 0x00 32 - read-write key_1 @@ -3719,7 +4034,6 @@ reading the `rand` register]]> 0x0008 0x00 32 - read-write key_2 @@ -3735,7 +4049,6 @@ reading the `rand` register]]> 0x000c 0x00 32 - read-write key_3 @@ -3751,7 +4064,6 @@ reading the `rand` register]]> 0x0010 0x00 32 - read-write key_4 @@ -3767,7 +4079,6 @@ reading the `rand` register]]> 0x0014 0x00 32 - read-write key_5 @@ -3783,7 +4094,6 @@ reading the `rand` register]]> 0x0018 0x00 32 - read-write key_6 @@ -3799,7 +4109,6 @@ reading the `rand` register]]> 0x001c 0x00 32 - read-write key_7 @@ -3815,7 +4124,6 @@ reading the `rand` register]]> 0x0020 0x00 32 - read-only data_0 @@ -3831,7 +4139,6 @@ reading the `rand` register]]> 0x0024 0x00 32 - read-only data_1 @@ -3847,7 +4154,6 @@ reading the `rand` register]]> 0x0028 0x00 32 - read-only data_2 @@ -3863,7 +4169,6 @@ reading the `rand` register]]> 0x002c 0x00 32 - read-only data_3 @@ -3879,7 +4184,6 @@ reading the `rand` register]]> 0x0030 0x00 32 - read-write data_0 @@ -3895,7 +4199,6 @@ reading the `rand` register]]> 0x0034 0x00 32 - read-write data_1 @@ -3911,7 +4214,6 @@ reading the `rand` register]]> 0x0038 0x00 32 - read-write data_2 @@ -3927,7 +4229,6 @@ reading the `rand` register]]> 0x003c 0x00 32 - read-write data_3 @@ -3943,7 +4244,6 @@ reading the `rand` register]]> 0x0040 0x00 32 - read-write iv_0 @@ -3959,7 +4259,6 @@ reading the `rand` register]]> 0x0044 0x00 32 - read-write iv_1 @@ -3975,7 +4274,6 @@ reading the `rand` register]]> 0x0048 0x00 32 - read-write iv_2 @@ -3991,7 +4289,6 @@ reading the `rand` register]]> 0x004c 0x00 32 - read-write iv_3 @@ -4007,7 +4304,6 @@ reading the `rand` register]]> 0x0050 0x00 32 - read-write mode @@ -4045,7 +4341,6 @@ automatically on data and IV ready]]> 0x0054 0x09 32 - read-only idle @@ -4110,7 +4405,6 @@ automatically on data and IV ready]]> 0x0058 0x00 32 - read-write start @@ -4174,7 +4468,6 @@ automatically on data and IV ready]]> 0x0000 0x00 32 - read-write sha_en @@ -4212,7 +4505,6 @@ automatically on data and IV ready]]> 0x0004 0x00 32 - read-write hash_start @@ -4236,7 +4528,6 @@ automatically on data and IV ready]]> 0x0008 0x00 32 - read-only digest0 @@ -4252,7 +4543,6 @@ automatically on data and IV ready]]> 0x000c 0x00 32 - read-only digest0 @@ -4268,7 +4558,6 @@ automatically on data and IV ready]]> 0x0010 0x00 32 - read-only digest1 @@ -4284,7 +4573,6 @@ automatically on data and IV ready]]> 0x0014 0x00 32 - read-only digest1 @@ -4300,7 +4588,6 @@ automatically on data and IV ready]]> 0x0018 0x00 32 - read-only digest2 @@ -4316,7 +4603,6 @@ automatically on data and IV ready]]> 0x001c 0x00 32 - read-only digest2 @@ -4332,7 +4618,6 @@ automatically on data and IV ready]]> 0x0020 0x00 32 - read-only digest3 @@ -4348,7 +4633,6 @@ automatically on data and IV ready]]> 0x0024 0x00 32 - read-only digest3 @@ -4364,7 +4648,6 @@ automatically on data and IV ready]]> 0x0028 0x00 32 - read-only digest4 @@ -4380,7 +4663,6 @@ automatically on data and IV ready]]> 0x002c 0x00 32 - read-only digest4 @@ -4396,7 +4678,6 @@ automatically on data and IV ready]]> 0x0030 0x00 32 - read-only digest5 @@ -4412,7 +4693,6 @@ automatically on data and IV ready]]> 0x0034 0x00 32 - read-only digest5 @@ -4428,7 +4708,6 @@ automatically on data and IV ready]]> 0x0038 0x00 32 - read-only digest6 @@ -4444,7 +4723,6 @@ automatically on data and IV ready]]> 0x003c 0x00 32 - read-only digest6 @@ -4460,7 +4738,6 @@ automatically on data and IV ready]]> 0x0040 0x00 32 - read-only digest7 @@ -4476,7 +4753,6 @@ automatically on data and IV ready]]> 0x0044 0x00 32 - read-only digest7 @@ -4493,7 +4769,6 @@ in bits]]> 0x0048 0x00 32 - read-only msg_length @@ -4509,7 +4784,6 @@ in bits]]> 0x004c 0x00 32 - read-only msg_length @@ -4521,46 +4795,91 @@ in bits]]> EV_STATUS + 0x0050 0x00 32 - read-write - status - 2 - [2:0] + err_valid + 0 + [0:0] 0 + + + + fifo_full + 1 + [1:1] + 1 + + + + sha512_done + 2 + [2:2] + 2 + EV_PENDING + 0x0054 0x00 32 - read-write - pending - 2 - [2:0] + err_valid + 0 + [0:0] 0 + + + + fifo_full + 1 + [1:1] + 1 + + + + sha512_done + 2 + [2:2] + 2 + EV_ENABLE + 0x0058 0x00 32 - read-write - enable - 2 - [2:0] + err_valid + 0 + [0:0] 0 + + + + fifo_full + 1 + [1:1] + 1 + + + + sha512_done + 2 + [2:2] + 2 + @@ -4570,7 +4889,6 @@ in bits]]> 0x005c 0x00 32 - read-only read_count @@ -4631,7 +4949,7 @@ in bits]]> sha512 - 10 + 11 @@ -4644,7 +4962,6 @@ in bits]]> 0x0000 0x00 32 - read-write window @@ -4660,7 +4977,6 @@ in bits]]> 0x0004 0x00 32 - read-write mpstart @@ -4676,7 +4992,6 @@ in bits]]> 0x0008 0x00 32 - read-write mplen @@ -4693,7 +5008,6 @@ in bits]]> 0x000c 0x00 32 - read-write go @@ -4710,7 +5024,6 @@ microcode instructions starting at mpstart]]> 0x0010 0x00 32 - read-write running @@ -4731,46 +5044,70 @@ microcode memory areas will stall until this bit is clear]]> EV_STATUS + 0x0014 0x00 32 - read-write - status - 1 - [1:0] + finished + 0 + [0:0] 0 + + + + illegal_opcode + 1 + [1:1] + 1 + EV_PENDING + 0x0018 0x00 32 - read-write - pending - 1 - [1:0] + finished + 0 + [0:0] 0 + + + + illegal_opcode + 1 + [1:1] + 1 + EV_ENABLE + 0x001c 0x00 32 - read-write - enable - 1 - [1:0] + finished + 0 + [0:0] 0 + + + + illegal_opcode + 1 + [1:1] + 1 + @@ -4781,7 +5118,6 @@ exactly reflects the binary layout of an Engine instruction.]]> 0x0020 0x00 32 - read-only opcode @@ -4842,7 +5178,7 @@ exactly reflects the binary layout of an Engine instruction.]]> engine - 11 + 12 @@ -4856,7 +5192,6 @@ exactly reflects the binary layout of an Engine instruction.]]> 0x0000 0x00 32 - read-write tdi @@ -4880,7 +5215,6 @@ exactly reflects the binary layout of an Engine instruction.]]> 0x0004 0x00 32 - read-only tdo From 16e9f430157d9ab06751efdf36720e645af54ff8 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 23 Nov 2020 00:40:40 +0800 Subject: [PATCH 4/7] add circle drawing to graphics --- buildpush.sh | 97 +++-- services/graphics-server/src/api.rs | 522 ++++++++++++++++++++++++++- services/graphics-server/src/lib.rs | 7 +- services/graphics-server/src/main.rs | 8 +- services/graphics-server/src/op.rs | 83 ++++- services/shell/src/main.rs | 119 +++++- 6 files changed, 771 insertions(+), 65 deletions(-) diff --git a/buildpush.sh b/buildpush.sh index 18d144038..200637a15 100755 --- a/buildpush.sh +++ b/buildpush.sh @@ -1,23 +1,58 @@ -#!/bin/sh +#!/bin/bash -# argument 1 is the target for copy +set -e # exit on any error -if [ -z "$1" ] -then - echo "Usage: $0 ssh-target [privatekey]" - echo "Missing ssh-target argument." - echo "Assumes betrusted-scripts repo is cloned on ssh-target at ~/code/betrused-scripts/" - exit 0 -fi +UPDATE_FPGA=1 +UPDATE_KERNEL=1 +USE_USB=1 +FPGA_IMAGE=../betrusted-soc/build/gateware/encrypted.bin +KERNEL_IMAGE=target/riscv32imac-unknown-none-elf/release/xous.img +CSR_CSV=../betrusted-soc/build/csr.csv.1 # always use the previous version for the current update! +USE_IDENITY=0 + +POSITIONAL=() +while [[ $# -gt 0 ]] +do + key="$1" + case $key in + -k|--kernel-skip) + UPDATE_KERNEL=0 + shift + ;; + -f|--fpga-skip) + UPDATE_FPGA=0 + shift + ;; + -c|--copy-to) + DEST_HOST=$2 + USE_USB=0 + shift + shift + ;; + -i|--identity) + USE_IDENTITY=1 + IDENTITY=$2 + shift + shift + ;; + -h|--help) + echo "$0 provisions betrusted. --kernel-skip skips the kernel, --fpga-skip skips the FPGA." + echo "Alternatively, using --copy-to copies the files to a remote host and skips provisioning." + echo " --identity supplies an identity file to the scp command." + echo " Copying assumes betrusted-scripts repo is cloned on ssh-target at ~/code/betrused-scripts/" + exit 0 + ;; + *) + POSITIONAL+=("$1") + shift + ;; + esac +done + +set -- "${POSITIONAL[@]}" DESTDIR=code/precursors -# notes: -# xous-stage1.bin written to 0x2050_0000 (64k erase block size) -# xous-kernel.bin written to 0x2051_0000 => passed as a0 arg to xous-stage1.bin -# This is handled in part by betrusted-scripts, with provision-xous.sh -# stage1 and kernel are merged into xous.img by this script. - cargo xtask hw-image ../betrusted-soc/build/software/soc.svd if [ $? -ne 0 ] @@ -26,19 +61,29 @@ then exit 1 fi -echo "Copying to target..." -if [ $# -gt 0 ] +# case of no private key specified +if [ $USE_USB -eq 1 ] then - if [ -z "$2" ] + if [ $UPDATE_FPGA -eq 1 ] then - scp target/riscv32imac-unknown-none-elf/release/xous.img $1:$DESTDIR/ - scp ../betrusted-soc/build/gateware/encrypted.bin $1:$DESTDIR/ - scp ../betrusted-soc/build/csr.csv $1:$DESTDIR/soc-csr.csv - else - scp -i $2 target/riscv32imac-unknown-none-elf/release/xous.img $1:$DESTDIR/ - scp -i $2 ../betrusted-soc/build/gateware/encrypted.bin $1:$DESTDIR/ - scp -i $2 ../betrusted-soc/build/csr.csv $1:$DESTDIR/soc-csr.csv + echo "Burning FPGA image" + sudo wishbone-tool --csr-csv $CSR_CSV --load-name $FPGA_IMAGE --load-address 0x0 --load-flash + echo "*** Manual power cycle required to reload SoC FPGA configuration ***" + echo " -> Either issue a power cycle command, or insert paper clip in the hole on the right hand side!" + fi + if [ $UPDATE_KERNEL -eq 1 ] + then + echo "Burning firmware" + sudo wishbone-tool --csr-csv $CSR_CSV --load-name $KERNEL_IMAGE --load-address 0x500000 --load-flash fi else - echo "Copy to target with $0 " + if [ $USE_IDENTITY -eq 1 ] + then + # there is a private key + scp -i $IDENTITY $KERNEL_IMAGE $FPGA_IMAGE $DEST_HOST:$DESTDIR/ + scp -i $IDENTITY $CSR_CSV $DEST_HOST:$DESTDIR/soc-csr.csv + else + scp $KERNEL_IMAGE $FPGA_IMAGE $CSR_CSV $DEST_HOST:$DESTDIR/ + scp $CSR_CSV $DEST_HOST:$DESTDIR/soc-csr.csv + fi fi diff --git a/services/graphics-server/src/api.rs b/services/graphics-server/src/api.rs index cc68bff24..d6bc0867e 100644 --- a/services/graphics-server/src/api.rs +++ b/services/graphics-server/src/api.rs @@ -1,15 +1,497 @@ +use crate::op::PixelColor; use xous::{Message, ScalarMessage}; +use core::ops::{Add, AddAssign, Index, Neg, Sub, SubAssign}; -#[derive(Copy, Clone, Debug)] +/// 2D size. +/// +/// `Size` is used to define the width and height of an object. +/// +/// [Nalgebra] support can be enabled with the `nalgebra_support` feature. This implements +/// `From>` and `From<&Vector2>` where `N` is `Scalar + Into`. This allows use +/// of Nalgebra's [`Vector2`] with embedded-graphics where `u16`, `u16` or `u8` is used for value +/// storage. +/// +/// # Examples +/// +/// ## Create a `Size` from two integers +/// +/// +/// ```rust +/// use embedded_graphics::geometry::Size; +/// +/// // Create a size using the `new` constructor method +/// let s = Size::new(10, 20); +/// ``` +/// +/// ## Create a `Size` from a Nalgebra `Vector2` +/// +/// _Be sure to enable the `nalgebra_support` feature to get [Nalgebra] integration._ +/// +/// Any `Vector2` can be used where `N: Into + nalgebra::Scalar`. This includes the primitive types `u16`, `u16` and `u8`. +/// +/// ```rust +/// # #[cfg(feature = "nalgebra_support")] { +/// use nalgebra::Vector2; +/// use embedded_graphics::geometry::Size; +/// +/// assert_eq!(Size::from(Vector2::new(10u16, 20)), Size::new(10u16, 20)); +/// assert_eq!(Size::from(Vector2::new(10u16, 20)), Size::new(10u16, 20)); +/// assert_eq!(Size::from(Vector2::new(10u8, 20)), Size::new(10u16, 20)); +/// # } +/// ``` +/// +/// `.into()` can also be used, but may require more type annotations: +/// +/// ```rust +/// # #[cfg(feature = "nalgebra_support")] { +/// use nalgebra::Vector2; +/// use embedded_graphics::geometry::Size; +/// +/// let c: Size = Vector2::new(10u16, 20).into(); +/// +/// assert_eq!(c, Size::new(10u16, 20)); +/// # } +/// ``` +/// +/// [`Drawable`]: ../drawable/trait.Drawable.html +/// [`Point`]: struct.Point.html +/// [`Vector2`]: https://docs.rs/nalgebra/0.18.0/nalgebra/base/type.Vector2.html +/// [`Vector2`]: https://docs.rs/nalgebra/0.18.0/nalgebra/base/type.Vector2.html +/// [Nalgebra]: https://docs.rs/nalgebra +#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)] +pub struct Size { + /// The width. + pub width: u16, + + /// The height. + pub height: u16, +} + +impl Size { + /// Creates a size from a width and a height. + pub const fn new(width: u16, height: u16) -> Self { + Size { width, height } + } + + /// Creates a size with width and height equal to zero. + pub const fn zero() -> Self { + Size { + width: 0, + height: 0, + } + } + + /// Creates a size from two corner points of a bounding box. + pub(crate) fn from_bounding_box(corner_1: Point, corner_2: Point) -> Self { + let width = (corner_1.x - corner_2.x).abs() as u16; + let height = (corner_1.y - corner_2.y).abs() as u16; + + Self { width, height } + } +} + +impl Add for Size { + type Output = Size; + + fn add(self, other: Size) -> Size { + Size::new(self.width + other.width, self.height + other.height) + } +} + +impl AddAssign for Size { + fn add_assign(&mut self, other: Size) { + self.width += other.width; + self.height += other.height; + } +} + +impl Sub for Size { + type Output = Size; + + fn sub(self, other: Size) -> Size { + Size::new(self.width - other.width, self.height - other.height) + } +} + +impl SubAssign for Size { + fn sub_assign(&mut self, other: Size) { + self.width -= other.width; + self.height -= other.height; + } +} + +impl Index for Size { + type Output = u16; + + fn index(&self, idx: usize) -> &u16 { + match idx { + 0 => &self.width, + 1 => &self.height, + _ => panic!("index out of bounds: the len is 2 but the index is {}", idx), + } + } +} + +impl From<(u16, u16)> for Size { + fn from(other: (u16, u16)) -> Self { + Size::new(other.0, other.1) + } +} + +impl From<[u16; 2]> for Size { + fn from(other: [u16; 2]) -> Self { + Size::new(other[0], other[1]) + } +} + +impl From<&[u16; 2]> for Size { + fn from(other: &[u16; 2]) -> Self { + Size::new(other[0], other[1]) + } +} + +impl From for (u16, u16) { + fn from(other: Size) -> (u16, u16) { + (other.width, other.height) + } +} + +impl From<&Size> for (u16, u16) { + fn from(other: &Size) -> (u16, u16) { + (other.width, other.height) + } +} + +#[cfg(feature = "nalgebra_support")] +use nalgebra::{base::Scalar, Vector2}; + +#[cfg(feature = "nalgebra_support")] +impl From> for Size +where + N: Into + Scalar, +{ + fn from(other: Vector2) -> Self { + Self::new(other[0].into(), other[1].into()) + } +} + +#[cfg(feature = "nalgebra_support")] +impl From<&Vector2> for Size +where + N: Into + Scalar, +{ + fn from(other: &Vector2) -> Self { + Self::new(other[0].into(), other[1].into()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn sizes_can_be_added() { + let left = Size::new(10, 20); + let right = Size::new(30, 40); + + assert_eq!(left + right, Size::new(40, 60)); + } + + #[test] + fn sizes_can_be_subtracted() { + let left = Size::new(30, 40); + let right = Size::new(10, 20); + + assert_eq!(left - right, Size::new(20, 20)); + } + + #[test] + fn from_tuple() { + assert_eq!(Size::from((20, 30)), Size::new(20, 30)); + } + + #[test] + fn from_array() { + assert_eq!(Size::from([20, 30]), Size::new(20, 30)); + } + + #[test] + fn from_array_ref() { + assert_eq!(Size::from(&[20, 30]), Size::new(20, 30)); + } + + #[test] + fn index() { + let size = Size::new(1, 2); + + assert_eq!(size.width, size[0]); + assert_eq!(size.height, size[1]); + } + + #[test] + #[should_panic] + fn index_out_of_bounds() { + let size = Size::new(1, 2); + let _ = size[2]; + } + + #[test] + #[cfg(feature = "nalgebra_support")] + fn nalgebra_support() { + let left = nalgebra::Vector2::new(30u16, 40); + let right = nalgebra::Vector2::new(10, 20); + + assert_eq!(Size::from(left - right), Size::new(20, 20)); + } +} + + + +/// Style properties for an object +#[derive(Debug, Copy, Clone)] +pub struct Style { + /// Fill colour of the object + /// + /// For fonts, this is the background colour of the text + pub fill_color: Option, + + /// Stroke (border/line) color of the object + /// + /// For fonts, this is the foreground colour of the text + pub stroke_color: Option, + + /// Stroke width + /// + /// Set the stroke width for an object. Has no effect on fonts. + pub stroke_width: i16, +} + +impl Style +{ + /// Create a new style with a given stroke value and defaults for everything else + pub fn stroke_color(stroke_color: PixelColor) -> Self { + Self { + stroke_color: Some(stroke_color), + ..Style::default() + } + } + + /// Returns the stroke width as an `i16`. + /// + /// If the stroke width is too large to fit into an `i16` the maximum value + /// for an `i16` is returned instead. + pub(crate) fn stroke_width_i16(&self) -> i16 { + self.stroke_width + } +} + +impl Default for Style +{ + fn default() -> Self { + Self { + fill_color: None, + stroke_color: None, + stroke_width: 1, + } + } +} + +/// Add a style to an object +pub trait WithStyle +{ + /// Add a complete style to the object + fn style(self, style: Style) -> Self; + + /// Set the stroke colour for the object + /// + /// This can be a noop + fn stroke_color(self, color: Option) -> Self; + + /// Set the stroke width for the object + /// + /// A stroke with a width of zero will not be rendered + fn stroke_width(self, width: u16) -> Self; + + /// Set the fill property of the object's style + /// + /// This can be a noop + fn fill_color(self, color: Option) -> Self; +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Point { - pub x: u16, - pub y: u16, + pub x: i16, + pub y: i16, } impl Point { - pub fn new(x: u16, y: u16) -> Point { + pub fn new(x: i16, y: i16) -> Point { Point { x, y } } + + /// Creates a point with X and Y equal to zero. + pub const fn zero() -> Self { + Point { x: 0, y: 0 } + } +} + + +impl Add for Point { + type Output = Point; + + fn add(self, other: Point) -> Point { + Point::new(self.x + other.x, self.y + other.y) + } +} + +impl Add for Point { + type Output = Point; + + /// Offsets a point by adding a size. + /// + /// # Panics + /// + /// This function will panic if `width` or `height` are too large to be represented as an `i16` + /// and debug assertions are enabled. + fn add(self, other: Size) -> Point { + let width = other.width as i16; + let height = other.height as i16; + + debug_assert!(width >= 0, "width is too large"); + debug_assert!(height >= 0, "height is too large"); + + Point::new(self.x + width, self.y + height) + } +} + +impl AddAssign for Point { + fn add_assign(&mut self, other: Point) { + self.x += other.x; + self.y += other.y; + } +} + +impl AddAssign for Point { + /// Offsets a point by adding a size. + /// + /// # Panics + /// + /// This function will panic if `width` or `height` are too large to be represented as an `i16` + /// and debug assertions are enabled. + fn add_assign(&mut self, other: Size) { + let width = other.width as i16; + let height = other.height as i16; + + debug_assert!(width >= 0, "width is too large"); + debug_assert!(height >= 0, "height is too large"); + + self.x += width; + self.y += height; + } +} + +impl Sub for Point { + type Output = Point; + + fn sub(self, other: Point) -> Point { + Point::new(self.x - other.x, self.y - other.y) + } +} + +impl Sub for Point { + type Output = Point; + + /// Offsets a point by subtracting a size. + /// + /// # Panics + /// + /// This function will panic if `width` or `height` are too large to be represented as an `i16` + /// and debug assertions are enabled. + fn sub(self, other: Size) -> Point { + let width = other.width as i16; + let height = other.height as i16; + + debug_assert!(width >= 0, "width is too large"); + debug_assert!(height >= 0, "height is too large"); + + Point::new(self.x - width, self.y - height) + } +} + +impl SubAssign for Point { + fn sub_assign(&mut self, other: Point) { + self.x -= other.x; + self.y -= other.y; + } +} + +impl SubAssign for Point { + /// Offsets a point by subtracting a size. + /// + /// # Panics + /// + /// This function will panic if `width` or `height` are too large to be represented as an `i16` + /// and debug assertions are enabled. + fn sub_assign(&mut self, other: Size) { + let width = other.width as i16; + let height = other.height as i16; + + debug_assert!(width >= 0, "width is too large"); + debug_assert!(height >= 0, "height is too large"); + + self.x -= width; + self.y -= height; + } +} + +impl Index for Point { + type Output = i16; + + fn index(&self, idx: usize) -> &i16 { + match idx { + 0 => &self.x, + 1 => &self.y, + _ => panic!("index out of bounds: the len is 2 but the index is {}", idx), + } + } +} + +impl Neg for Point { + type Output = Point; + + fn neg(self) -> Self::Output { + Point::new(-self.x, -self.y) + } +} + +impl From<(i16, i16)> for Point { + fn from(other: (i16, i16)) -> Self { + Point::new(other.0, other.1) + } +} + +impl From<[i16; 2]> for Point { + fn from(other: [i16; 2]) -> Self { + Point::new(other[0], other[1]) + } +} + +impl From<&[i16; 2]> for Point { + fn from(other: &[i16; 2]) -> Self { + Point::new(other[0], other[1]) + } +} + +impl From for (i16, i16) { + fn from(other: Point) -> (i16, i16) { + (other.x, other.y) + } +} + +impl From<&Point> for (i16, i16) { + fn from(other: &Point) -> (i16, i16) { + (other.x, other.y) + } } impl Into for Point { @@ -18,16 +500,20 @@ impl Into for Point { } } +/// A single pixel +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct Pixel(pub Point, pub PixelColor); + #[derive(Copy, Clone, Debug)] pub struct Rect { - pub x0: u16, - pub y0: u16, - pub x1: u16, - pub y1: u16, + pub x0: i16, + pub y0: i16, + pub x1: i16, + pub y1: i16, } impl Rect { - pub fn new(x0: u16, y0: u16, x1: u16, y1: u16) -> Self { + pub fn new(x0: i16, y0: i16, x1: i16, y1: i16) -> Self { Self { x0, y0, x1, y1 } } } @@ -49,7 +535,7 @@ impl From for Point { #[derive(Copy, Clone, Debug)] pub struct Color { - pub color: u32, + pub color: u16, } impl From for Color { @@ -58,6 +544,18 @@ impl From for Color { } } +#[derive(Debug, Clone, Copy)] +pub struct Rectangle { + /// Top left point of the rect + pub top_left: Point, + + /// Bottom right point of the rect + pub bottom_right: Point, + + /// Object style + pub style: PixelColor, +} + #[derive(Debug)] pub enum Opcode<'a> { /// Flush the buffer to the screen @@ -73,11 +571,11 @@ pub enum Opcode<'a> { Rectangle(Point /* upper-left */, Point /* lower-right */), /// Draw a circle with a specified radius - Circle(Point, u32 /* radius */), + Circle(Point, u16 /* radius */), /// Change the style of the current pen Style( - u32, /* stroke width */ + u16, /* stroke width */ Color, /* stroke color */ Color, /* fill color */ ), diff --git a/services/graphics-server/src/lib.rs b/services/graphics-server/src/lib.rs index 82553865b..57606bae0 100644 --- a/services/graphics-server/src/lib.rs +++ b/services/graphics-server/src/lib.rs @@ -1,8 +1,11 @@ #![cfg_attr(target_os = "none", no_std)] +// pub mod size; pub mod api; pub use api::{Point, Color, Rect}; use xous::String; +pub mod op; +pub mod fonts; use xous::{send_message, CID}; @@ -10,7 +13,7 @@ pub fn draw_line(cid: CID, start: Point, end: Point) -> Result<(), xous::Error> send_message(cid, api::Opcode::Line(start, end).into()).map(|_| ()) } -pub fn draw_circle(cid: CID, center: Point, radius: u32) -> Result<(), xous::Error> { +pub fn draw_circle(cid: CID, center: Point, radius: u16) -> Result<(), xous::Error> { send_message(cid, api::Opcode::Circle(center, radius).into()).map(|_| ()) } @@ -18,7 +21,7 @@ pub fn draw_rectangle(cid: CID, start: Point, end: Point) -> Result<(), xous::Er send_message(cid, api::Opcode::Rectangle(start, end).into()).map(|_| ()) } -pub fn set_style(cid: CID, width: u32, stroke: Color, fill: Color) -> Result<(), xous::Error> { +pub fn set_style(cid: CID, width: u16, stroke: Color, fill: Color) -> Result<(), xous::Error> { send_message(cid, api::Opcode::Style(width, stroke, fill).into()).map(|_| ()) } diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index 98f7ecace..9f37fa901 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -56,7 +56,6 @@ fn xmain() -> ! { Opcode::Line(start, end) => { info!("GFX: Drawing line from {:?} to {:?}", start, end); op::line(display.native_buffer(), start.x as _, start.y as _, end.x as _, end.y as _, if current_color.color == 0 { op::PixelColor::Off } else {op::PixelColor::On }); - // todo!(); } Opcode::Rectangle(start, end) => { todo!(); @@ -66,11 +65,8 @@ fn xmain() -> ! { // .ok(); } Opcode::Circle(mid, radius) => { - todo!(); - // Circle::new(mid.into(), radius) - // .into_styled(current_style) - // .draw(&mut display) - // .unwrap(); + info!("GFX: Drawing cicrle at {:?} radius {:?}", mid, radius); + op::circle(display.native_buffer(), mid.x as _, mid.y as _, radius as _, 1, op::PixelColor::On); } Opcode::Style(stroke_width, stroke_color, fill_color) => { current_color = stroke_color; diff --git a/services/graphics-server/src/op.rs b/services/graphics-server/src/op.rs index a70b62b31..c20fc73cc 100644 --- a/services/graphics-server/src/op.rs +++ b/services/graphics-server/src/op.rs @@ -1,5 +1,6 @@ use super::fonts; use super::fonts::{Font, GlyphHeader}; +use crate::api::{Point, Style, Pixel}; /// LCD Frame buffer bounds pub const LCD_WORDS_PER_LINE: usize = 11; @@ -10,7 +11,7 @@ pub const LCD_FRAME_BUF_SIZE: usize = LCD_WORDS_PER_LINE * LCD_LINES; const WIDTH: usize = 336; const HEIGHT: usize = 536; -#[derive(Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum PixelColor { On, Off, @@ -338,6 +339,86 @@ pub fn line(fb: &mut LcdFB, x0: usize, y0: usize, x1: usize, y1: usize, color: P } } + +/// Pixel iterator for each pixel in the circle border +#[derive(Debug, Copy, Clone)] +pub struct CircleIterator { + center: Point, + radius: u16, + style: Style, + p: Point, +} + +impl Iterator for CircleIterator +{ + type Item = Pixel; + + // https://stackoverflow.com/questions/1201200/fast-algorithm-for-drawing-filled-circles + fn next(&mut self) -> Option { + // If border or stroke colour is `None`, treat entire object as transparent and exit early + if self.style.stroke_color.is_none() && self.style.fill_color.is_none() { + return None; + } + + let radius = self.radius as i16 - self.style.stroke_width_i16() + 1; + let outer_radius = self.radius as i16; + + let radius_sq = radius * radius; + let outer_radius_sq = outer_radius * outer_radius; + + loop { + let t = self.p; + let len = t.x * t.x + t.y * t.y; + + let is_border = len > radius_sq - radius && len < outer_radius_sq + radius; + + let is_fill = len <= outer_radius_sq + 1; + + let item = if is_border && self.style.stroke_color.is_some() { + Some(Pixel( + self.center + t, + self.style.stroke_color.expect("Border color not defined"), + )) + } else if is_fill && self.style.fill_color.is_some() { + Some(Pixel( + self.center + t, + self.style.fill_color.expect("Fill color not defined"), + )) + } else { + None + }; + + self.p.x += 1; + + if self.p.x > self.radius as i16 { + self.p.x = -(self.radius as i16); + self.p.y += 1; + } + + if self.p.y > self.radius as i16 { + break None; + } + + if item.is_some() { + break item; + } + } + } +} + +pub fn circle(fb: &mut LcdFB, x: usize, y: usize, r: usize, stroke_width: usize, color: PixelColor) { + let c = CircleIterator { + center: Point{x: x as i16, y: y as i16}, + radius: r as u16, + style: Style{ fill_color: Some(color), stroke_color: Some(color), stroke_width: stroke_width as i16}, + p: Point::zero(), + }; + + for pixel in c { + put_pixel(fb, pixel.0.x as usize, pixel.0.y as usize, pixel.1); + } +} + #[cfg(test)] mod tests { use super::fonts; diff --git a/services/shell/src/main.rs b/services/shell/src/main.rs index 80746b54a..b5241bae6 100644 --- a/services/shell/src/main.rs +++ b/services/shell/src/main.rs @@ -10,6 +10,7 @@ mod timer; use core::fmt::Write; use log::{error, info}; use xous::String; +use graphics_server::Point; // fn print_and_yield(index: *mut usize) -> ! { // let num = index as usize; @@ -19,6 +20,29 @@ use xous::String; // } // } +#[derive(Debug, Clone, Copy)] +pub struct Rectangle { + /// Top left point of the rect + pub top_left: Point, + /// Bottom right point of the rect + pub bottom_right: Point, +} + +impl Rectangle { + pub fn top_left(&self) -> Point { + self.top_left + } + pub fn bottom_right(&self) -> Point { + self.bottom_right + } + pub fn new(top_left: Point, bottom_right: Point) -> Self { + Rectangle { + top_left, + bottom_right, + } + } +} + #[cfg(baremetal)] use utralib::generated::*; @@ -38,6 +62,68 @@ fn ensure_connection(server: xous::SID) -> xous::CID { } } +pub struct Bounce { + vector: Point, + radius: u16, + bounds: Rectangle, + loc: Point, + lfsr: u32, +} + +impl Bounce { + pub fn new(radius: u16, bounds: Rectangle) -> Bounce { + Bounce { + vector: Point::new(2,3), + radius: radius, + bounds: bounds, + loc: Point::new((bounds.bottom_right.x - bounds.top_left.x)/2, (bounds.bottom_right.y - bounds.top_left.y)/2), + lfsr: 0xace1u32, + } + } + + pub fn next_rand(&mut self) -> i16 { + let ret = move_lfsr(self.lfsr); + self.lfsr = ret; + + (ret % 8) as i16 + } + + pub fn update(&mut self) -> &mut Self { + let mut x: i16; + let mut y: i16; + // update the new ball location + x = self.loc.x + self.vector.x; y = self.loc.y + self.vector.y; + + let r: i16 = self.radius as i16; + if (x >= (self.bounds.bottom_right().x - r)) || + (x <= (self.bounds.top_left().x + r)) || + (y >= (self.bounds.bottom_right().y - r)) || + (y <= (self.bounds.top_left().y + r)) { + if x >= (self.bounds.bottom_right().x - r - 1) { + self.vector.x = -self.next_rand(); + x = self.bounds.bottom_right().x - r; + } + if x <= self.bounds.top_left().x + r + 1 { + self.vector.x = self.next_rand(); + x = self.bounds.top_left().x + r; + } + if y >= (self.bounds.bottom_right().y - r - 1) { + self.vector.y = -self.next_rand(); + y = self.bounds.bottom_right().y - r; + } + if y <= (self.bounds.top_left().y + r + 1) { + self.vector.y = self.next_rand(); + y = self.bounds.top_left().y + r; + } + } + + self.loc.x = x; + self.loc.y = y; + + self + } +} + #[xous::xous_main] fn shell_main() -> ! { timer::init(); @@ -71,9 +157,11 @@ fn shell_main() -> ! { // let mut counter: usize = 0; let mut ls = logstr::LogStr::new(); - let mut lfsr = 0xace1u32; let dark = graphics_server::Color::from(0); let light = graphics_server::Color::from(!0); + let mut bouncyball = Bounce::new(14, + Rectangle::new(Point::new(0, 18 * 21), + Point::new(336, 536-1))); // TODO: make API call to get screen size #[cfg(baremetal)] { @@ -88,6 +176,14 @@ fn shell_main() -> ! { gpio.wfo(utra::gpio::UARTSEL_UARTSEL, 2); } + graphics_server::set_style( + graphics_conn, + 1, + dark, + dark, + ) + .expect("unable to draw to screen: {:?}"); + let mut last_time: u64 = 0; let mut string_buffer = String::new(4096); loop { @@ -123,24 +219,10 @@ fn shell_main() -> ! { error!("error requesting ticktimer!") } - graphics_server::set_style( + graphics_server::draw_circle( graphics_conn, - 5, - if lfsr & 1 == 0 { dark } else { light }, - if lfsr & 1 == 0 { dark } else { light }, - ) - .expect("unable to draw to screen: {:?}"); - - let x1 = move_lfsr(lfsr); - let y1 = move_lfsr(x1); - let x2 = move_lfsr(y1); - let y2 = move_lfsr(x2); - lfsr = y2; - - graphics_server::draw_line( - graphics_conn, - graphics_server::Point::new((x1 % 336) as _, (y1 % 536) as _), - graphics_server::Point::new((x2 % 336) as _, (y2 % 536) as _), + bouncyball.loc, + bouncyball.radius as u16, ) .expect("unable to draw to screen"); @@ -154,5 +236,6 @@ fn shell_main() -> ! { ticktimer_server::sleep_ms(ticktimer_conn, 2000 + loops).expect("couldn't sleep"); loops += 1; + bouncyball.update(); } } From 2d5bd20c166eddd43cd3820caba05ed577d7fda4 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 23 Nov 2020 03:18:43 +0800 Subject: [PATCH 5/7] =?UTF-8?q?bouncing=20ball=20"=E6=8B=9B=E8=B4=A2?= =?UTF-8?q?=E7=8C=AB"-like=20totem=20now=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildpush.sh | 8 ++++++-- kernel/Cargo.toml | 3 ++- loader/Cargo.toml | 3 ++- services/graphics-server/src/op.rs | 2 +- services/shell/src/main.rs | 27 +++++++++++++++++---------- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/buildpush.sh b/buildpush.sh index 200637a15..c13a34fa4 100755 --- a/buildpush.sh +++ b/buildpush.sh @@ -7,7 +7,7 @@ UPDATE_KERNEL=1 USE_USB=1 FPGA_IMAGE=../betrusted-soc/build/gateware/encrypted.bin KERNEL_IMAGE=target/riscv32imac-unknown-none-elf/release/xous.img -CSR_CSV=../betrusted-soc/build/csr.csv.1 # always use the previous version for the current update! +CSR_CSV=../betrusted-soc/build/csr.csv.1 USE_IDENITY=0 POSITIONAL=() @@ -35,8 +35,12 @@ do shift shift ;; + --current-csr) + CSR_CSV=../betrusted-soc/build/csr.csv + shift + ;; -h|--help) - echo "$0 provisions betrusted. --kernel-skip skips the kernel, --fpga-skip skips the FPGA." + echo "$0 provisions betrusted. --kernel-skip skips the kernel, --fpga-skip skips the FPGA. --current-csr indicates to use the CSR for the new FPGA image to do the update (normally you want to use the one corresponding to the older, currently installed version)." echo "Alternatively, using --copy-to copies the files to a remote host and skips provisioning." echo " --identity supplies an identity file to the scp command." echo " Copying assumes betrusted-scripts repo is cloned on ssh-target at ~/code/betrused-scripts/" diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index f87c73480..6bb7cc32f 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -21,7 +21,8 @@ riscv = "0.5.6" debug-print = [] print-panics = [] report-memory = ["stats_alloc"] -default = ["print-panics", "debug-print"] +#default = ["print-panics", "debug-print"] +default = [] [target.'cfg(any(windows, unix))'.dependencies] lazy_static = "1.4" diff --git a/loader/Cargo.toml b/loader/Cargo.toml index 587c12fcd..c33ab911f 100644 --- a/loader/Cargo.toml +++ b/loader/Cargo.toml @@ -14,7 +14,8 @@ rand = "0.7.3" [features] debug-print = [] earlyprintk = [] -default = ["debug-print"] +#default = ["debug-print"] +default = [] [profile.release] codegen-units = 1 # 1 better optimizations diff --git a/services/graphics-server/src/op.rs b/services/graphics-server/src/op.rs index c20fc73cc..2fac527fb 100644 --- a/services/graphics-server/src/op.rs +++ b/services/graphics-server/src/op.rs @@ -411,7 +411,7 @@ pub fn circle(fb: &mut LcdFB, x: usize, y: usize, r: usize, stroke_width: usize, center: Point{x: x as i16, y: y as i16}, radius: r as u16, style: Style{ fill_color: Some(color), stroke_color: Some(color), stroke_width: stroke_width as i16}, - p: Point::zero(), + p: Point::new(-(r as i16), -(r as i16)), }; for pixel in c { diff --git a/services/shell/src/main.rs b/services/shell/src/main.rs index b5241bae6..3804813ea 100644 --- a/services/shell/src/main.rs +++ b/services/shell/src/main.rs @@ -162,6 +162,7 @@ fn shell_main() -> ! { let mut bouncyball = Bounce::new(14, Rectangle::new(Point::new(0, 18 * 21), Point::new(336, 536-1))); // TODO: make API call to get screen size + bouncyball.update(); #[cfg(baremetal)] { @@ -219,6 +220,22 @@ fn shell_main() -> ! { error!("error requesting ticktimer!") } + string_buffer.clear(); + write!(&mut string_buffer, "Elapsed time: {}ms", last_time).expect("Can't write"); + graphics_server::clear_region(graphics_conn, 0, 0, 300, 40) + .expect("unable to clear region"); + info!("drawing string: {}", string_buffer); + graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string"); + + //ticktimer_server::sleep_ms(ticktimer_conn, 2000 + loops).expect("couldn't sleep"); + loops += 1; + + // draw the ball + bouncyball.update(); + graphics_server::clear_region(graphics_conn, + bouncyball.bounds.top_left().x as _, bouncyball.bounds.top_left().y as _, + bouncyball.bounds.bottom_right().x as _, bouncyball.bounds.bottom_right().y as _) + .expect("unable to clear region"); graphics_server::draw_circle( graphics_conn, bouncyball.loc, @@ -226,16 +243,6 @@ fn shell_main() -> ! { ) .expect("unable to draw to screen"); - string_buffer.clear(); - write!(&mut string_buffer, "Elapsed time: {}ms", last_time).expect("Can't write"); - graphics_server::clear_region(graphics_conn, 0, 0, 300, 40) - .expect("unable to clear region"); - info!("drawing string: {}", string_buffer); - graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string"); graphics_server::flush(graphics_conn).expect("unable to draw to screen"); - - ticktimer_server::sleep_ms(ticktimer_conn, 2000 + loops).expect("couldn't sleep"); - loops += 1; - bouncyball.update(); } } From a2670a7537e627cc80bd937bcc67583d42fb0a21 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 23 Nov 2020 03:49:09 +0800 Subject: [PATCH 6/7] minor tweaks to improve the rendering of the bouncyball --- services/graphics-server/src/main.rs | 2 +- services/shell/src/main.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index 9f37fa901..c39f49e1f 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -66,7 +66,7 @@ fn xmain() -> ! { } Opcode::Circle(mid, radius) => { info!("GFX: Drawing cicrle at {:?} radius {:?}", mid, radius); - op::circle(display.native_buffer(), mid.x as _, mid.y as _, radius as _, 1, op::PixelColor::On); + op::circle(display.native_buffer(), mid.x as _, mid.y as _, radius as _, 0, op::PixelColor::On); } Opcode::Style(stroke_width, stroke_color, fill_color) => { current_color = stroke_color; diff --git a/services/shell/src/main.rs b/services/shell/src/main.rs index 3804813ea..0912e2779 100644 --- a/services/shell/src/main.rs +++ b/services/shell/src/main.rs @@ -128,7 +128,6 @@ impl Bounce { fn shell_main() -> ! { timer::init(); log_server::init_wait().unwrap(); - let mut loops = 0; // let log_server_id = xous::SID::from_bytes(b"xous-logs-output").unwrap(); let graphics_server_id = xous::SID::from_bytes(b"graphics-server ").unwrap(); @@ -227,14 +226,13 @@ fn shell_main() -> ! { info!("drawing string: {}", string_buffer); graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string"); - //ticktimer_server::sleep_ms(ticktimer_conn, 2000 + loops).expect("couldn't sleep"); - loops += 1; + ticktimer_server::sleep_ms(ticktimer_conn, 2000).expect("couldn't sleep"); // draw the ball bouncyball.update(); graphics_server::clear_region(graphics_conn, bouncyball.bounds.top_left().x as _, bouncyball.bounds.top_left().y as _, - bouncyball.bounds.bottom_right().x as _, bouncyball.bounds.bottom_right().y as _) + bouncyball.bounds.bottom_right().x as _, bouncyball.bounds.bottom_right().y as usize + 1) .expect("unable to clear region"); graphics_server::draw_circle( graphics_conn, From 48720dc6a7fdb737d373d23d02fc529c0ad530f6 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 23 Nov 2020 03:52:40 +0800 Subject: [PATCH 7/7] right, comment out the offending line --- services/shell/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/shell/src/main.rs b/services/shell/src/main.rs index 0912e2779..8b776c75c 100644 --- a/services/shell/src/main.rs +++ b/services/shell/src/main.rs @@ -226,7 +226,7 @@ fn shell_main() -> ! { info!("drawing string: {}", string_buffer); graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string"); - ticktimer_server::sleep_ms(ticktimer_conn, 2000).expect("couldn't sleep"); + // ticktimer_server::sleep_ms(ticktimer_conn, 2000).expect("couldn't sleep"); // draw the ball bouncyball.update();