mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
it's a trap!
This commit is contained in:
parent
622fcdfde7
commit
6954e4311e
20
ka/crt/sys.k
20
ka/crt/sys.k
@ -1,10 +1,22 @@
|
|||||||
; The OS/K Team licenses this file to you under the MIT license.
|
; The OS/K Team licenses this file to you under the MIT license.
|
||||||
; See the LICENSE file in the project root for more information.
|
; See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
; FIND syscalls
|
||||||
|
;
|
||||||
|
; Find file on disk
|
||||||
|
;
|
||||||
|
; IN
|
||||||
|
; ax0 = address of name buffer
|
||||||
|
; ax1 = size of name buffer
|
||||||
|
;
|
||||||
|
; OUT
|
||||||
|
; rax = # of bytes written in name buffer
|
||||||
|
; rdx = size of file
|
||||||
|
;
|
||||||
|
;
|
||||||
|
Sys.FindFirst := 0x20
|
||||||
|
Sys.FindNext := 0x21
|
||||||
|
|
||||||
; Halt mode
|
; Halt mode
|
||||||
Sys.HLT := 0x99
|
Sys.HLT := 0x99
|
||||||
|
|
||||||
; DIR syscall
|
|
||||||
Sys.DIR := 0x100
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,10 +16,9 @@ start:
|
|||||||
|
|
||||||
call main
|
call main
|
||||||
|
|
||||||
mov ax0, Sys.DIR
|
call CMD.builtins.dir
|
||||||
trap 0
|
|
||||||
|
|
||||||
mov ax0, Sys.HLT
|
mov rax, Sys.HLT
|
||||||
trap 0
|
trap 0
|
||||||
|
|
||||||
crash
|
crash
|
||||||
|
@ -6,14 +6,25 @@ TrapHandlers.prolog:
|
|||||||
mov q[rbp-8], r11
|
mov q[rbp-8], r11
|
||||||
mov q[rbp-16], r12
|
mov q[rbp-16], r12
|
||||||
mov q[rbp-24], r13
|
mov q[rbp-24], r13
|
||||||
|
xor rdx, rdx
|
||||||
|
|
||||||
jmp rax ; go back
|
jmp rcx ; go back
|
||||||
|
|
||||||
TrapHandlers.epilog:
|
TrapHandlers.epilog:
|
||||||
mov r13, q[rbp-24]
|
mov r13, q[rbp-24]
|
||||||
mov r12, q[rbp-16]
|
mov r12, q[rbp-16]
|
||||||
mov r11, q[rbp-8]
|
mov r11, q[rbp-8]
|
||||||
|
|
||||||
|
; TRAP return values: RAX-RDX
|
||||||
|
|
||||||
|
mov ax0, r12
|
||||||
|
mov ax1, $rax
|
||||||
|
mov ax2, rax
|
||||||
|
call RFS.StoreReg
|
||||||
|
mov ax1, $rdx
|
||||||
|
mov ax2, rdx
|
||||||
|
call RFS.StoreReg
|
||||||
|
|
||||||
mov ax0, r11
|
mov ax0, r11
|
||||||
call IDT.DoneHandling
|
call IDT.DoneHandling
|
||||||
iret
|
iret
|
||||||
|
@ -6,16 +6,19 @@ TRAP0_STACK := 0x300000
|
|||||||
trap0_handler:
|
trap0_handler:
|
||||||
|
|
||||||
.init:
|
.init:
|
||||||
mov rax, .impl
|
mov rcx, .impl
|
||||||
mov rbp, TRAP0_STACK
|
mov rbp, TRAP0_STACK
|
||||||
jmp TrapHandlers.prolog
|
jmp TrapHandlers.prolog
|
||||||
|
|
||||||
.impl:
|
.impl:
|
||||||
mov ax0, r12
|
mov ax0, r12
|
||||||
|
mov ax1, $rax
|
||||||
|
call RFS.LoadReg
|
||||||
call RFS.LoadArgs
|
call RFS.LoadArgs
|
||||||
|
|
||||||
b.z ax0, Sys.HLT, .handle_HLT
|
b.z rax, Sys.HLT, .handle_HLT
|
||||||
b.z ax0, Sys.DIR, .handle_DIR
|
b.z rax, Sys.FindNext, .handle_FindNext
|
||||||
|
b.z rax, Sys.FindFirst, .handle_FindFirst
|
||||||
|
|
||||||
.fini:
|
.fini:
|
||||||
jmp TrapHandlers.epilog
|
jmp TrapHandlers.epilog
|
||||||
@ -24,8 +27,12 @@ trap0_handler:
|
|||||||
; Syscall implementations
|
; Syscall implementations
|
||||||
;
|
;
|
||||||
|
|
||||||
.handle_DIR:
|
.handle_FindFirst:
|
||||||
call CMD.builtins.dir
|
call DISK.FindFirst
|
||||||
|
jmp .fini
|
||||||
|
|
||||||
|
.handle_FindNext:
|
||||||
|
call DISK.FindNext
|
||||||
jmp .fini
|
jmp .fini
|
||||||
|
|
||||||
.handle_HLT:
|
.handle_HLT:
|
||||||
|
@ -12,15 +12,18 @@ CMD.builtins.dir:
|
|||||||
.dirmsg = "Directory of C:\\\n\n"
|
.dirmsg = "Directory of C:\\\n\n"
|
||||||
|
|
||||||
.first:
|
.first:
|
||||||
|
mov rax, Sys.FindFirst
|
||||||
mov ax0, .buf
|
mov ax0, .buf
|
||||||
mov ax1, NAME_MAX
|
mov ax1, NAME_MAX
|
||||||
call DISK.FindFirst
|
trap 0
|
||||||
|
|
||||||
jmp .list
|
jmp .list
|
||||||
|
|
||||||
.next:
|
.next:
|
||||||
|
mov rax, Sys.FindNext
|
||||||
mov ax0, .buf
|
mov ax0, .buf
|
||||||
mov ax1, NAME_MAX
|
mov ax1, NAME_MAX
|
||||||
call DISK.FindNext
|
trap 0
|
||||||
|
|
||||||
.list:
|
.list:
|
||||||
b.z rax, 0, .end
|
b.z rax, 0, .end
|
||||||
|
Loading…
Reference in New Issue
Block a user