Compare commits
3 Commits
5d672d8132
...
85cf698aae
| Author | SHA1 | Date | |
|---|---|---|---|
| 85cf698aae | |||
| 710772efee | |||
| de822fa48d |
@@ -18,7 +18,7 @@ kernel_sources += files(
|
|||||||
'sched.c',
|
'sched.c',
|
||||||
'serial.c',
|
'serial.c',
|
||||||
'smp.c',
|
'smp.c',
|
||||||
'sys.c',
|
'start.c',
|
||||||
'syscall.c',
|
'syscall.c',
|
||||||
'tsc.c',
|
'tsc.c',
|
||||||
'usercopy.c',
|
'usercopy.c',
|
||||||
|
|||||||
+2
-2
@@ -208,14 +208,14 @@ void arch_sched_jump_to_user(uintptr_t ip, uintptr_t sp, uintptr_t arg) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
uintptr_t percpu = asm_rdmsr(MSR_GS_BASE);
|
uintptr_t percpu = asm_rdmsr(MSR_GS_BASE);
|
||||||
const uint16_t zero = 0;
|
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"mov ds, %0\n"
|
"mov ds, %0\n"
|
||||||
"mov es, %0\n"
|
"mov es, %0\n"
|
||||||
"mov fs, %0\n"
|
"mov fs, %0\n"
|
||||||
"mov gs, %0\n"
|
"mov gs, %0\n"
|
||||||
:
|
:
|
||||||
: "r"(zero)
|
: "a"(0)
|
||||||
|
: "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
asm_wrmsr(MSR_FS_BASE, 0);
|
asm_wrmsr(MSR_FS_BASE, 0);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <zinnia/irq.h>
|
||||||
#include <zinnia/spin.h>
|
#include <zinnia/spin.h>
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ void spin_init(struct spinlock* spin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void spin_lock(struct spinlock* spin) {
|
void spin_lock(struct spinlock* spin) {
|
||||||
|
irq_lock();
|
||||||
uint32_t my = atomic_fetch_add_explicit(&spin->next, 1, memory_order_relaxed);
|
uint32_t my = atomic_fetch_add_explicit(&spin->next, 1, memory_order_relaxed);
|
||||||
|
|
||||||
while (atomic_load_explicit(&spin->owner, memory_order_acquire) != my) {
|
while (atomic_load_explicit(&spin->owner, memory_order_acquire) != my) {
|
||||||
@@ -17,4 +19,5 @@ void spin_lock(struct spinlock* spin) {
|
|||||||
void spin_unlock(struct spinlock* spin) {
|
void spin_unlock(struct spinlock* spin) {
|
||||||
uint32_t val = atomic_load_explicit(&spin->owner, memory_order_relaxed);
|
uint32_t val = atomic_load_explicit(&spin->owner, memory_order_relaxed);
|
||||||
atomic_store_explicit(&spin->owner, val + 1, memory_order_release);
|
atomic_store_explicit(&spin->owner, val + 1, memory_order_release);
|
||||||
|
irq_unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user