mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
vm
This commit is contained in:
parent
59fbf66cfe
commit
b890d67ff4
@ -239,6 +239,7 @@ def parse():
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
escape_dict = {
|
||||
'0': '\0',
|
||||
'n': '\n',
|
||||
't': '\t',
|
||||
'r': '\r',
|
||||
|
@ -40,9 +40,10 @@ include "sys/drv/cpudev.k"
|
||||
include "sys/drv/memdev.k"
|
||||
include "sys/drv/diskdev.k"
|
||||
|
||||
include "sys/intr/excepts.k"
|
||||
include "sys/intr/common.k"
|
||||
include "sys/intr/trap0.k"
|
||||
|
||||
include "sys/main.k"
|
||||
include "sys/dumprf.k"
|
||||
include "sys/main.k"
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
; See the LICENSE file in the project root for more information.
|
||||
|
||||
TrapHandlers.prolog:
|
||||
mov rbp, rsp
|
||||
mov rbp, zero
|
||||
|
||||
; rax = caller's cr2
|
||||
call RFS.LoadReg, r14, $cr2
|
||||
@ -34,7 +34,9 @@ ScreenOfDeath:
|
||||
prn PRN_CLEAR
|
||||
prn PRN_FLUSH
|
||||
|
||||
call print, .scr1
|
||||
push ax1
|
||||
call printf, .scr1
|
||||
pop zero
|
||||
|
||||
b.nz r14, zero, .not_con
|
||||
push .scr2_con
|
||||
@ -66,15 +68,15 @@ ScreenOfDeath:
|
||||
scan rax
|
||||
jmp.axz .loop
|
||||
|
||||
b.z rax, 0x0A, trap0_handler.handle_Exit
|
||||
b.z rax, 0x1B, trap0_handler.handle_Shutdown
|
||||
b.z rax, 0x0A, DefaultTrapHandler.handle_Exit
|
||||
b.z rax, 0x1B, DefaultTrapHandler.handle_Shutdown
|
||||
|
||||
jmp .loop
|
||||
|
||||
crash
|
||||
|
||||
.scr1 = "-------- Unhandled EXCEPTION, TRAP/SYSCALL or INTERRUPT\n"
|
||||
.scr2 = "Offense description: %s\nOffending frame: %d (%s)\n\n"
|
||||
.scr1 = "-------- Unhandled EXCEPTION, TRAP/SYSCALL or INTERRUPT (code %d)\n"
|
||||
.scr2 = "Description: %s\nFrame: %d (%s)\n\n"
|
||||
.scr3 = "Press:\n ENTER to procede to COMMAND.COM\n ESCAPE to shutdown machine\n\n"
|
||||
|
||||
.scr2_con = "dedicated command.com frame"
|
||||
|
29
ka/sys/intr/excepts.k
Normal file
29
ka/sys/intr/excepts.k
Normal file
@ -0,0 +1,29 @@
|
||||
; The OS/K Team licenses this file to you under the MIT license.
|
||||
; See the LICENSE file in the project root for more information.
|
||||
|
||||
DefaultExceptionHandler:
|
||||
mov rsp, EXCT0_STACK
|
||||
mov ax1, r12
|
||||
|
||||
b.z r12, zero, DefaultTrapHandler.handle_Shutdown
|
||||
b.a r12, 11, .unknown
|
||||
|
||||
mov rsi, .err_ukn
|
||||
lea ax0, b[rsi + r12 * 32]
|
||||
call ScreenOfDeath
|
||||
|
||||
.unknown:
|
||||
call ScreenOfDeath, .err_ukn
|
||||
crash
|
||||
|
||||
.err_ukn = "Unknown exception number\0\0\0\0\0\0\0"
|
||||
.err_udf = "Undefined behaviour exception\0\0"
|
||||
.err_ill = "Ill-formed exception exception\0"
|
||||
.err_acc = "Invalid memory access exception"
|
||||
.err_sys = "Supervisor-only exception used\0"
|
||||
.err_dbf = "Double fault exception~~~~~~~~\0"
|
||||
.err_imp = "Feat. not implemented exception"
|
||||
.err_ali = "Misalignmed address exception\0\0"
|
||||
.err_brk = "BREAK key (Ctrl+C) exception\0\0\0"
|
||||
.err_ovf = "Overflow flag raised exception\0"
|
||||
.err_div = "Division by zero exception\0\0\0\0\0"
|
@ -1,7 +1,7 @@
|
||||
; The OS/K Team licenses this file to you under the MIT license.
|
||||
; See the LICENSE file in the project root for more information.
|
||||
|
||||
trap0_handler:
|
||||
DefaultTrapHandler:
|
||||
|
||||
.init:
|
||||
mov rcx, .text
|
||||
@ -23,7 +23,7 @@ trap0_handler:
|
||||
b.z rax, Sys.FindFirst, .handle_FindFirst
|
||||
b.z rax, Sys.EnterHaltMode, .handle_HaltMode
|
||||
|
||||
call ScreenOfDeath, .badsyscall
|
||||
call ScreenOfDeath, .badsyscall, r13
|
||||
|
||||
.fini.savecx:
|
||||
mov ax2, rcx
|
||||
@ -83,7 +83,7 @@ trap0_handler:
|
||||
call RFS.StoreReg, zero, $cr2
|
||||
|
||||
; Return frame
|
||||
mov q[rbp-16], zero
|
||||
mov r14, zero
|
||||
|
||||
jmp .fini
|
||||
|
||||
@ -130,6 +130,9 @@ trap0_handler:
|
||||
; Misc.
|
||||
;
|
||||
.handle_Shutdown:
|
||||
mov ax0, zero
|
||||
call IDT.DelHandler
|
||||
|
||||
stop
|
||||
|
||||
.handle_HaltMode:
|
||||
|
@ -12,20 +12,30 @@ PrintBootMsg:
|
||||
;
|
||||
InitSyscalls:
|
||||
mov ax0, 1
|
||||
|
||||
.prepare_next:
|
||||
call RFS.ActivateFrame
|
||||
|
||||
mov ax1, $rip
|
||||
mov ax2, trap0_handler
|
||||
mov ax2, DefaultTrapHandler
|
||||
call RFS.StoreReg
|
||||
|
||||
mov ax1, ax0
|
||||
inc ax0, 255 # TRAP no. (ax0 - 1)
|
||||
|
||||
mov ax0, 256
|
||||
mov ax1, 1
|
||||
call IDT.AddHandler
|
||||
|
||||
ret
|
||||
|
||||
InitExcepts:
|
||||
mov ax0, 2
|
||||
call RFS.ActivateFrame
|
||||
|
||||
mov ax1, $rip
|
||||
mov ax2, DefaultExceptionHandler
|
||||
call RFS.StoreReg
|
||||
|
||||
mov ax0, zero
|
||||
mov ax1, 2
|
||||
call IDT.AddHandler
|
||||
|
||||
SwitchToCMD:
|
||||
mov rax, Sys.Exit
|
||||
trap 0
|
||||
@ -36,6 +46,7 @@ SwitchToCMD:
|
||||
main:
|
||||
call PrintBootMsg
|
||||
call InitSyscalls
|
||||
call InitExcepts
|
||||
call SwitchToCMD
|
||||
ret
|
||||
|
||||
|
@ -40,6 +40,9 @@ main:
|
||||
scan rax
|
||||
jmp.axz .input_loop
|
||||
|
||||
; ESC key pressed?
|
||||
b.z rax, 0x1B, .handle_EXIT
|
||||
|
||||
; backspace character?
|
||||
b.nz rax, 8, .handle_input
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user