Compare commits

...

3 Commits

Author SHA1 Message Date
4f55d765b4 ulib Fix volatile 2025-11-24 17:14:45 +01:00
ec732d4627 Make SpinLock IRQ_CTX irq_flags volatile 2025-11-24 17:14:28 +01:00
3f3795df3c Fix stack alignment 2025-11-24 17:04:33 +01:00
5 changed files with 13 additions and 9 deletions

View File

@ -66,7 +66,9 @@
_push_regs _push_regs
cld cld
movq %rsp, %rdi movq %rsp, %rdi
sub $0x8, %rsp
call intr_handleintr call intr_handleintr
add $0x8, %rsp
_pop_regs _pop_regs
add $0x10, %rsp add $0x10, %rsp
iretq iretq

View File

@ -2,10 +2,7 @@
.global proc_switch .global proc_switch
proc_switch: proc_switch:
testq %rsi, %rsi
je 1f
movq %rsi, %cr3 movq %rsi, %cr3
1:
mov %rdi, %rsp mov %rdi, %rsp
_pop_regs _pop_regs
add $0x10, %rsp add $0x10, %rsp

View File

@ -6,8 +6,8 @@
#define SPINLOCK_HINT() asm volatile("pause") #define SPINLOCK_HINT() asm volatile("pause")
struct { static struct {
uint64_t irq_flags; volatile uint64_t irq_flags;
atomic_int irq_nest; atomic_int irq_nest;
} IRQ_CTX = {0}; } IRQ_CTX = {0};

View File

@ -9,8 +9,8 @@
#include <umalloc/umalloc.h> #include <umalloc/umalloc.h>
extern void main(void); extern void main(void);
extern uint8_t _bss_start[]; extern volatile uint8_t _bss_start[];
extern uint8_t _bss_end[]; extern volatile uint8_t _bss_end[];
void clearbss(void) { void clearbss(void) {
uint8_t *p = _bss_start; uint8_t *p = _bss_start;
@ -20,7 +20,7 @@ void clearbss(void) {
} }
#define MAX_ARGS 25 #define MAX_ARGS 25
static char *_args[MAX_ARGS]; static volatile char *_args[MAX_ARGS];
size_t _argslen; size_t _argslen;
@ -40,7 +40,7 @@ void _premain(void) {
_args[i] = umalloc(PROC_ARG_MAX); _args[i] = umalloc(PROC_ARG_MAX);
} }
proc_argv(-1, &_argslen, _args, MAX_ARGS); proc_argv(-1, &_argslen, (char **)_args, MAX_ARGS);
main(); main();
proc_kill(proc_getpid()); proc_kill(proc_getpid());

View File

@ -4,4 +4,9 @@
.global _start .global _start
_start: _start:
xor %rbp, %rbp
mov %rsp, %rbp
and $-0x10, %rsp
sub $0x8, %rsp
call _premain call _premain