did some restructuring, got multitasking almost working

This commit is contained in:
2026-06-26 20:05:01 -05:00
parent 57d7d34c6d
commit 43bc0df81a
35 changed files with 481 additions and 307 deletions

123
kernel/common.S Normal file
View File

@@ -0,0 +1,123 @@
.code32
.section .text
.global disable_interrupts
disable_interrupts:
cli
ret
.global enable_interrupts
enable_interrupts:
sti
ret
.global io_wait
io_wait:
outb %al, $0x80
ret
.global liftoff
liftoff:
cli
mov 4(%esp), %ecx
mov 8(%esp), %ebx
mov $0x23, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
push $0x23
push %ebx
push $0x202
push $0x1B
push %ecx
xor %eax, %eax
xor %edx, %edx
iret
.global outb
outb:
push %ebp
mov %esp, %ebp
# 8(%ebp) port
# 12(%ebp) data
mov 8(%ebp), %edx
mov 12(%ebp), %eax
outb %al, %dx
leave
ret
.global inb
inb:
push %ebp
mov %esp, %ebp
# 8(%ebp) port
mov 8(%ebp), %edx
xor %eax, %eax
inb %dx, %al
leave
ret
.global insw
insw:
push %ebp
mov %esp, %ebp
push %edi
push %ecx
push %edx
# 8(%ebp) addr
# 12(%ebp) buf
# 16(%ebp) sz
mov 8(%ebp), %edx
mov 12(%ebp), %edi
mov 16(%ebp), %ecx
cld
rep insw
pop %edx
pop %ecx
pop %edi
leave
ret
.global outsw
outsw:
push %ebp
mov %esp, %ebp
push %esi
push %ecx
push %edx
# 8(%ebp) address
# 12(%ebp) buf
# 16(%ebp) sz
mov 8(%ebp), %edx
mov 12(%ebp), %esi
mov 16(%ebp), %ecx
cld
rep outsw
pop %edx
pop %ecx
pop %esi
leave
ret
.global fetch_cr3
fetch_cr3:
mov %cr3, %eax
ret