kernel/syscalls.68k

96 lines
2.2 KiB
Plaintext

include tasking.i
include vmem.i
include term.i
section .text,text
; Handle a syscall
; Syscall number in d0
public handle_syscall
handle_syscall:
; Get the d0th entry in the syscall table
move.l #syscall_table, a6
lsl.l #2, d0
adda.l d0, a6
move.l (a6), a6
; Call the entry
jsr (a6)
rts
syscall_exit:
jmp tasking_exit
syscall_yield:
jmp tasking_yield
syscall_print:
jmp term_print
syscall_println:
jmp term_println
; Maps the range of pages starting at address a0 with length d1 to free physical frames
; Permission flags in d2
syscall_vmem_map:
move.l d1, d0
move.l #0, d1
ori.l #$4, d2
jmp vmem_map
; Map a free range of pages with length d1 to free physical frames
; Returns the range start in a0
; Permission flags in d2
syscall_vmem_map_free:
move.l d1, d0
move.l #2, d1
ori.l #$4, d2
jmp vmem_map_free
; Maps a free range of virtual pages with length d2 to the range of physical frames starting at d1
; Returns the range start in a0
; Permission flags in d3
syscall_vmem_map_free_to:
move.l d1, d0
move.l d2, d1
move.l #2, d2
ori.l #$4, d3
jmp vmem_map_free_to
; Sets the permission flags of the range of virtual pages starting at address a0 with length d2 to d1
syscall_vmem_set_flags:
move.l d1, d0
move.l d2, d1
move.l #0, d2
jmp vmem_set_flags
; Copies the range of page mappings at address a0 in the primary space with length d1 to the secondary space starting at address a1
syscall_vmem_copy_to_secondary:
movem.l a0/a1/d1, -(a7)
jsr tasking_get_secondary_addr_space
jsr vmem_set_secondary_addr_space
movem.l (a7)+, a0/a1/d1
move.l d1, d0
jsr vmem_copy_to_secondary
rts
; Creates a new process using the secondary address space of the current process and entry in a0
syscall_new_process:
move.l a0, -(a7)
jsr tasking_get_secondary_addr_space
move.l (a7)+, a1
jsr tasking_new_process
rts
section .data,data
syscall_table:
align 1
dc.l syscall_exit
dc.l syscall_yield
dc.l syscall_print
dc.l syscall_println
dc.l syscall_vmem_map
dc.l syscall_vmem_map_free
dc.l syscall_vmem_map_free_to
dc.l syscall_vmem_set_flags
dc.l syscall_vmem_copy_to_secondary
dc.l syscall_new_process