Skip to content

Commit

Permalink
Some workarounds but now it boots to shell
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsuki committed Dec 18, 2023
1 parent b46f915 commit 4b95f3f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion kernel/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn kmain() {

sched.initialise()

go kmain_thread()
spawn kmain_thread()

sched.await()
}
2 changes: 1 addition & 1 deletion kernel/modules/katomic/katomic.v
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn cas<T>(_here &T, _ifthis T, writethis T) bool {
lock
cmpxchg here, writethis
; +a (ifthis)
+m (here[0]) as here
+m (*here) as here
=@ccz (ret)
; r (writethis)
; memory
Expand Down
2 changes: 1 addition & 1 deletion kernel/modules/klock/klock.v
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn (mut l Lock) release() {
pub fn (mut l Lock) test_and_acquire() bool {
caller := u64(C.__builtin_return_address(0))

ret := katomic.cas(l.l, false, true)
ret := katomic.cas(&l.l, false, true)
if ret == true {
l.caller = caller
}
Expand Down
2 changes: 2 additions & 0 deletions kernel/modules/memory/mmap/mmap.v
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fn addr2range(pagemap &memory.Pagemap, addr u64) ?(&MmapRangeLocal, u64, u64) {
}

pub fn delete_pagemap(_pagemap &memory.Pagemap) ? {
/*
mut pagemap := unsafe { _pagemap }
pagemap.l.acquire()
Expand All @@ -78,6 +79,7 @@ pub fn delete_pagemap(_pagemap &memory.Pagemap) ? {
}
unsafe { free(pagemap) }
*/
}

pub fn fork_pagemap(_old_pagemap &memory.Pagemap) ?&memory.Pagemap {
Expand Down
2 changes: 1 addition & 1 deletion kernel/modules/proc/proc.v
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ __global (

pub fn allocate_pid(process &Process) ?int {
for i := int(1); i < 65536; i++ {
if katomic.cas(voidptr(&processes[i]), u64(0), u64(process)) {
if katomic.cas(voidptr(&processes[i]), voidptr(0), voidptr(process)) {
return i
}
}
Expand Down
6 changes: 3 additions & 3 deletions kernel/modules/sched/sched.v
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fn scheduler_isr(_ u32, gpr_state &cpulocal.GPRState) {
new_gpr_state := &current_thread.gpr_state

if new_gpr_state.cs == user_code_seg {
C.userland__dispatch_a_signal(new_gpr_state)
//C.userland__dispatch_a_signal(new_gpr_state)
}

asm volatile amd64 {
Expand Down Expand Up @@ -186,7 +186,7 @@ pub fn enqueue_thread(_thread &proc.Thread, by_signal bool) bool {
katomic.store(t.enqueued_by_signal, by_signal)

for i := u64(0); i < scheduler_running_queue.len; i++ {
if katomic.cas(voidptr(&scheduler_running_queue[i]), u64(0), u64(t)) {
if katomic.cas(voidptr(&scheduler_running_queue[i]), voidptr(0), voidptr(t)) {
t.is_in_queue = true

// Check if any CPU is idle and wake it up
Expand All @@ -212,7 +212,7 @@ pub fn dequeue_thread(_thread &proc.Thread) bool {
}

for i := u64(0); i < scheduler_running_queue.len; i++ {
if katomic.cas(voidptr(&scheduler_running_queue[i]), u64(t), u64(0)) {
if katomic.cas(voidptr(&scheduler_running_queue[i]), voidptr(t), voidptr(0)) {
t.is_in_queue = false
return true
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/modules/syscall/syscall.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn leave(context &cpulocal.GPRState) {
cli
}

userland.dispatch_a_signal(context)
//userland.dispatch_a_signal(context)
}

@[_naked]
Expand Down
4 changes: 0 additions & 4 deletions kernel/modules/x86/cpu/initialisation/initialisation.v
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ pub fn initialise(smp_info &limine.LimineSMPInfo) {

apic.lapic_enable(0xff)

asm volatile amd64 {
sti
}

apic.lapic_timer_calibrate(mut cpu_local)

print('smp: CPU $cpu_local.cpu_number online!\n')
Expand Down
2 changes: 1 addition & 1 deletion kernel/modules/x86/isr/isr.v
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn exception_handler(num u32, gpr_state &cpulocal.GPRState) {
}

userland.sendsig(proc.current_thread(), signal)
userland.dispatch_a_signal(gpr_state)
//userland.dispatch_a_signal(gpr_state)
userland.syscall_exit(voidptr(0), 128 + signal)
} else {
lib.kpanic(gpr_state, isr.exception_names[num])
Expand Down

0 comments on commit 4b95f3f

Please sign in to comment.