it's a trap!

This commit is contained in:
julianb0 2019-07-10 12:26:15 +02:00
parent 622fcdfde7
commit 6954e4311e
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
5 changed files with 47 additions and 15 deletions

View File

@ -1,10 +1,22 @@
; The OS/K Team licenses this file to you under the MIT license.
; 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
Sys.HLT := 0x99
; DIR syscall
Sys.DIR := 0x100

View File

@ -16,10 +16,9 @@ start:
call main
mov ax0, Sys.DIR
trap 0
call CMD.builtins.dir
mov ax0, Sys.HLT
mov rax, Sys.HLT
trap 0
crash

View File

@ -6,14 +6,25 @@ TrapHandlers.prolog:
mov q[rbp-8], r11
mov q[rbp-16], r12
mov q[rbp-24], r13
xor rdx, rdx
jmp rax ; go back
jmp rcx ; go back
TrapHandlers.epilog:
mov r13, q[rbp-24]
mov r12, q[rbp-16]
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
call IDT.DoneHandling
iret

View File

@ -6,16 +6,19 @@ TRAP0_STACK := 0x300000
trap0_handler:
.init:
mov rax, .impl
mov rcx, .impl
mov rbp, TRAP0_STACK
jmp TrapHandlers.prolog
.impl:
mov ax0, r12
mov ax1, $rax
call RFS.LoadReg
call RFS.LoadArgs
b.z ax0, Sys.HLT, .handle_HLT
b.z ax0, Sys.DIR, .handle_DIR
b.z rax, Sys.HLT, .handle_HLT
b.z rax, Sys.FindNext, .handle_FindNext
b.z rax, Sys.FindFirst, .handle_FindFirst
.fini:
jmp TrapHandlers.epilog
@ -24,8 +27,12 @@ trap0_handler:
; Syscall implementations
;
.handle_DIR:
call CMD.builtins.dir
.handle_FindFirst:
call DISK.FindFirst
jmp .fini
.handle_FindNext:
call DISK.FindNext
jmp .fini
.handle_HLT:

View File

@ -12,15 +12,18 @@ CMD.builtins.dir:
.dirmsg = "Directory of C:\\\n\n"
.first:
mov rax, Sys.FindFirst
mov ax0, .buf
mov ax1, NAME_MAX
call DISK.FindFirst
trap 0
jmp .list
.next:
mov rax, Sys.FindNext
mov ax0, .buf
mov ax1, NAME_MAX
call DISK.FindNext
trap 0
.list:
b.z rax, 0, .end