diff --git a/docs/flash.md b/docs/flash.md index 9f4ddee31..7cf3cd021 100644 --- a/docs/flash.md +++ b/docs/flash.md @@ -44,8 +44,8 @@ of wear leveling, however. + 2028_0000 | Reserved for backup bitstream | + 204F_FFFF | | +-----------+----------------------------------------+ -+ 2050_0000 | loader.bin - Xous loader | -+ 2050_FFFF | | ++ 2050_0000 | top 0x1000 is signature record | ++ 2050_FFFF | 0x2050_1000: loader.bin - Xous loader | +-----------+----------------------------------------+ + 2051_0000 | Font planes | + 2097_FFFF | | diff --git a/emulation/peripherals/memlcd.cs b/emulation/peripherals/memlcd.cs index f386857a8..431dceef0 100644 --- a/emulation/peripherals/memlcd.cs +++ b/emulation/peripherals/memlcd.cs @@ -74,15 +74,23 @@ namespace Antmicro.Renode.Peripherals.Video { for (int x = 0; x < Width; x++) { - if (((newbuf[(x + y * 44 * 8) / 8] >> (x % 8)) & 1) > 0) + if ((devBoot) && (y == devBootLine) && ((x >> 1) & 2) != 0) { - buffer[2 * (x + y * Width)] = 0xFF; - buffer[2 * (x + y * Width) + 1] = 0xFF; + buffer[2 * (x + y * Width)] = 0x00; + buffer[2 * (x + y * Width) + 1] = 0x00; } else { - buffer[2 * (x + y * Width)] = 0x0; - buffer[2 * (x + y * Width) + 1] = 0x0; + if (((newbuf[(x + y * 44 * 8) / 8] >> (x % 8)) & 1) > 0) + { + buffer[2 * (x + y * Width)] = 0xFF; + buffer[2 * (x + y * Width) + 1] = 0xFF; + } + else + { + buffer[2 * (x + y * Width)] = 0x0; + buffer[2 * (x + y * Width) + 1] = 0x0; + } } } } @@ -105,8 +113,13 @@ namespace Antmicro.Renode.Peripherals.Video Registers.PRESCALER.Define(this) .WithValueField(0, 32, valueProviderCallback: _ => { return 0; }) ; + Registers.DEVBOOT.Define(this) + .WithFlag(0, name: "DEVBOOT", valueProviderCallback: _ => { return devBoot; }, changeCallback: (_, val) => { if (val) { devBoot = true; } }) + ; } + private const int devBootLine = 12; + private bool devBoot = false; private bool updateDirty = false; private bool updateAll = false; @@ -119,6 +132,7 @@ namespace Antmicro.Renode.Peripherals.Video COMMAND = 0x0, BUSY = 0x04, PRESCALER = 0x08, + DEVBOOT = 0x18, } } } diff --git a/emulation/soc/betrusted-soc.repl b/emulation/soc/betrusted-soc.repl index 39c814f11..c42d14971 100755 --- a/emulation/soc/betrusted-soc.repl +++ b/emulation/soc/betrusted-soc.repl @@ -90,7 +90,7 @@ mem_rom: Memory.MappedMemory @ sysbus 0x00000000 size: 0x00001000 mem_sram: Memory.MappedMemory @ sysbus 0x10000000 - size: 0x00020000 + size: 0x00004000 mem_vexriscv_debug: Memory.MappedMemory @ sysbus 0xefff0000 size: 0x00001000 diff --git a/emulation/soc/renode.svd b/emulation/soc/renode.svd index 9a31026ac..0e00afddd 100644 --- a/emulation/soc/renode.svd +++ b/emulation/soc/renode.svd @@ -3,7 +3,7 @@ litex SOC - + 8 32 @@ -1222,10 +1222,10 @@ register to disable individual events.]]> GIT_GITREV 0x0014 - 0xfce2f15c + 0xafcc1323 32 @@ -1242,7 +1242,7 @@ the exact git version used to build this firmware.]]> is ``1``, then the repository this was built from has one additional commit beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x0018 - 0x21 + 0x2a 32 @@ -1487,10 +1487,26 @@ register to disable individual events.]]> + + DEVBOOT + 0x0018 + 0x00 + 32 + + + devboot + 0 + [0:0] + 0 + + + + 0 - 0x18 + 0x1c registers @@ -3451,7 +3467,7 @@ inject too fast.]]> SEED1 0x0000 - 0x199653c4 + 0x6d48a16e 32 @@ -3466,7 +3482,7 @@ inject too fast.]]> SEED0 0x0004 - 0x5a781786 + 0x71a7a0e3 32 @@ -3519,10 +3535,40 @@ inject too fast.]]> + + LOCKADDR + + 0x0008 + 0x00 + 32 + + + lockaddr + 7 + [7:0] + 0 + + + + + LOCKSTAT + + 0x000c + 0x00 + 32 + + + lockstat + 0 + [0:0] + 0 + + + 0 - 0x8 + 0x10 registers @@ -6957,7 +7003,7 @@ of the PLL]]> SRAM 0x10000000 - 0x00020000 + 0x00004000 VEXRISCV_DEBUG diff --git a/kernel/src/arch/riscv/process.rs b/kernel/src/arch/riscv/process.rs index 385025d5b..e61ab4c4e 100644 --- a/kernel/src/arch/riscv/process.rs +++ b/kernel/src/arch/riscv/process.rs @@ -372,11 +372,15 @@ impl Process { let pid = self.pid.get(); let thread = self.thread_mut(new_tid); // println!("Setting up thread {}, pid {}", new_tid, pid); + let sp = setup.stack.as_ptr() as usize + setup.stack.len(); + if sp <= 16 { + Err(xous_kernel::Error::BadAddress)?; + } crate::arch::syscall::invoke( thread, pid == 1, entrypoint, - setup.stack.as_ptr() as usize + setup.stack.len(), + (sp - 16) & !0xf, EXIT_THREAD, &[setup.arg1, setup.arg2, setup.arg3, setup.arg4], ); diff --git a/loader/src/main.rs b/loader/src/main.rs index 3778eeeca..c297eb986 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -224,7 +224,7 @@ impl MiniElf { // The load offset is the end of this process. Shift it down by one page // so we get the start of the first page. let mut top = load_offset - PAGE_SIZE; - let stack_addr = USER_STACK_TOP - 4; + let stack_addr = USER_STACK_TOP - 16; // Allocate a page to handle the top-level memory translation let satp_address = allocator.alloc() as usize; @@ -411,13 +411,13 @@ impl ProgramDescription { let pid_idx = (pid - 1) as usize; let is_kernel = pid == 1; let flag_defaults = FLG_R | FLG_W | if is_kernel { 0 } else { FLG_U }; - let stack_addr = USER_STACK_TOP - 4; + let stack_addr = USER_STACK_TOP - 16; if is_kernel { assert!(self.text_offset as usize == KERNEL_LOAD_OFFSET); assert!(((self.text_offset + self.text_size) as usize) < EXCEPTION_STACK_TOP); assert!( ((self.data_offset + self.data_size + self.bss_size) as usize) - < EXCEPTION_STACK_TOP - 4 + < EXCEPTION_STACK_TOP - 16 ); assert!(self.data_offset as usize >= KERNEL_LOAD_OFFSET); } else { @@ -465,7 +465,7 @@ impl ProgramDescription { allocator.map_page( satp, sp_page, - (EXCEPTION_STACK_TOP - 4 - PAGE_SIZE * i) & !(PAGE_SIZE - 1), + (EXCEPTION_STACK_TOP - 16 - PAGE_SIZE * i) & !(PAGE_SIZE - 1), flag_defaults, ); allocator.change_owner(pid as XousPid, sp_page);