mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
kernel: asm: align kernel stack to 16 bytes
The kernel stack offset should be aligned to 16 bytes. Previously it was aligned to 8 bytes. It's unclear if this was the cause of any issues, but it is best practice to keep things aligned to 16 bytes. As part of this, key the atomic instructions off of the CPP macro presence of atomic instructions. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
8e3b3bc1e8
commit
124040bbb3
9 changed files with 22 additions and 20 deletions
|
|
@ -13,17 +13,17 @@ Switch ($Arch) {
|
||||||
# remove existing blobs because otherwise this will append object files to the old blobs
|
# remove existing blobs because otherwise this will append object files to the old blobs
|
||||||
Remove-Item -Force bin/riscv*.a
|
Remove-Item -Force bin/riscv*.a
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac src/arch/riscv/asm.S -o bin/$crate.o
|
riscv-none-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac_zicsr_zifencei src/arch/riscv/asm.S -o bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
riscv-none-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-xous-elf.a bin/$crate.o
|
riscv-none-elf-ar crs bin/riscv32imac-unknown-xous-elf.a bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
riscv-none-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i src/arch/riscv/asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
riscv-none-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i_zicsr_zifencei src/arch/riscv/asm.S -o bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
|
riscv-none-elf-ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=lp64 -march=rv64imac src/arch/riscv/asm.S -o bin/$crate.o
|
riscv-none-elf-gcc -ggdb3 -c -mabi=lp64 -march=rv64imac_zicsr_zifencei src/arch/riscv/asm.S -o bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
riscv-none-elf-ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
riscv-none-elf-ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
||||||
}
|
}
|
||||||
"arm" {
|
"arm" {
|
||||||
Remove-Item -Force bin/arm*.a
|
Remove-Item -Force bin/arm*.a
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,15 @@ case $arch in
|
||||||
# files to the old blobs
|
# files to the old blobs
|
||||||
rm -f bin/riscv*.a
|
rm -f bin/riscv*.a
|
||||||
|
|
||||||
riscv-none-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac src/arch/riscv/asm.S -o bin/$crate.o
|
riscv-none-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac_zicsr src/arch/riscv/asm.S -o bin/$crate.o
|
||||||
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
||||||
ar crs bin/riscv32imac-unknown-xous-elf.a bin/$crate.o
|
ar crs bin/riscv32imac-unknown-xous-elf.a bin/$crate.o
|
||||||
ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
riscv-none-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i src/arch/riscv/asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
riscv-none-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i_zicsr src/arch/riscv/asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
||||||
ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv32i-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
riscv-none-elf-gcc -ggdb3 -c -mabi=lp64 -march=rv64imac src/arch/riscv/asm.S -o bin/$crate.o
|
riscv-none-elf-gcc -ggdb3 -c -mabi=lp64 -march=rv64imac_zicsr src/arch/riscv/asm.S -o bin/$crate.o
|
||||||
ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv64imac-unknown-none-elf.a bin/$crate.o
|
||||||
ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv64gc-unknown-none-elf.a bin/$crate.o
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -40,7 +40,7 @@ _start:
|
||||||
handler to set up the remainder of the resume tasks.
|
handler to set up the remainder of the resume tasks.
|
||||||
*/
|
*/
|
||||||
// Restore a default stack pointer - used by interrupt handlers and considered temporary/smashable
|
// Restore a default stack pointer - used by interrupt handlers and considered temporary/smashable
|
||||||
li sp, 0xfffefffc
|
li sp, 0xfffefff0
|
||||||
|
|
||||||
// setup sie [ssoft, sext]. This corresponds to bits 1 and 9, or 0b10_0000_0010
|
// setup sie [ssoft, sext]. This corresponds to bits 1 and 9, or 0b10_0000_0010
|
||||||
li t0, 0x202
|
li t0, 0x202
|
||||||
|
|
@ -49,7 +49,7 @@ _start:
|
||||||
// restore the SIM with the value previously socked away by the interrupt handler routine during the suspend half
|
// restore the SIM with the value previously socked away by the interrupt handler routine during the suspend half
|
||||||
jal ra, _enable_all_irqs
|
jal ra, _enable_all_irqs
|
||||||
|
|
||||||
// set scause to simulate an interrupt's occurence -- this makes the resume "feel like" an interrupt
|
// set scause to simulate an interrupt's occurrence -- this makes the resume "feel like" an interrupt
|
||||||
// vectored into the same routine that caused the suspend, but without having gone through the typical
|
// vectored into the same routine that caused the suspend, but without having gone through the typical
|
||||||
// interrupt handler mechanisms
|
// interrupt handler mechanisms
|
||||||
li t0, 0x80000000
|
li t0, 0x80000000
|
||||||
|
|
@ -137,7 +137,7 @@ _start_trap:
|
||||||
STORE t0, 1*REGBYTES(sp)
|
STORE t0, 1*REGBYTES(sp)
|
||||||
|
|
||||||
// Restore a default stack pointer
|
// Restore a default stack pointer
|
||||||
li sp, 0xfffefffc
|
li sp, 0xfffefff0
|
||||||
|
|
||||||
// Note that registers $a0-$a7 still contain the arguments
|
// Note that registers $a0-$a7 still contain the arguments
|
||||||
j _start_trap_rust
|
j _start_trap_rust
|
||||||
|
|
@ -155,8 +155,8 @@ _xous_resume_context:
|
||||||
|
|
||||||
LOAD x1, 0*REGBYTES(sp)
|
LOAD x1, 0*REGBYTES(sp)
|
||||||
// Clear any reservations, invalidating any atomic operations
|
// Clear any reservations, invalidating any atomic operations
|
||||||
#ifndef SKIP_MULTICORE
|
#ifdef __riscv_atomic
|
||||||
sc.w zero, x1, 0*REGBYTES(sp)
|
sc.w.rl zero, x1, (sp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Skip SP for now
|
// Skip SP for now
|
||||||
|
|
@ -222,8 +222,8 @@ _xous_syscall_return_result:
|
||||||
// one bit, and we can clear the bit by performing a dummy `sc`
|
// one bit, and we can clear the bit by performing a dummy `sc`
|
||||||
// here. This will cause a failure in any atomic operation in the
|
// here. This will cause a failure in any atomic operation in the
|
||||||
// program we're switching to.
|
// program we're switching to.
|
||||||
#ifndef SKIP_MULTICORE
|
#ifdef __riscv_atomic
|
||||||
sc.w zero, x1, 0*REGBYTES(sp)
|
sc.w.rl zero, x1, (sp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Skip SP for now
|
// Skip SP for now
|
||||||
|
|
@ -261,8 +261,10 @@ _xous_syscall_return_result:
|
||||||
LOAD x30, 29*REGBYTES(sp)
|
LOAD x30, 29*REGBYTES(sp)
|
||||||
LOAD x31, 30*REGBYTES(sp)
|
LOAD x31, 30*REGBYTES(sp)
|
||||||
|
|
||||||
|
fence
|
||||||
|
|
||||||
// Restore SP
|
// Restore SP
|
||||||
//csrr t0, sscratch
|
//csrr t0, sscratch
|
||||||
LOAD x2, 1*REGBYTES(sp)
|
LOAD x2, 1*REGBYTES(sp)
|
||||||
sret
|
sret
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue