fix bios call, return register values to caller
This commit is contained in:
1 parent
766a9c981c
commit
1880e89194
2 files changed
+22
-5
No files matched your search
+20
-3
@@ -12,7 +12,7 @@ section .text
|
|||||||
[bits 32]
|
[bits 32]
|
||||||
|
|
||||||
; FIXME: use a separate stack for real mode
|
; FIXME: use a separate stack for real mode
|
||||||
bios_call:
|
_bios_call:
|
||||||
.PARAMS_START equ 36
|
.PARAMS_START equ 36
|
||||||
.PARAM_BIOS_INTR_NUM equ .PARAMS_START
|
.PARAM_BIOS_INTR_NUM equ .PARAMS_START
|
||||||
.PARAM_BIOS_INTR_ARGS_PTR equ .PARAMS_START + 4
|
.PARAM_BIOS_INTR_ARGS_PTR equ .PARAMS_START + 4
|
||||||
@@ -83,13 +83,30 @@ bios_call:
|
|||||||
call [bp + 2]
|
call [bp + 2]
|
||||||
pop bp
|
pop bp
|
||||||
|
|
||||||
; TODO: return resulting registers to the caller
|
; Copy the resulting register values back into the `BiosIntr` struct provided by the caller.
|
||||||
|
pushfd
|
||||||
|
push es
|
||||||
|
push ds
|
||||||
|
push edi
|
||||||
|
push esi
|
||||||
|
push edx
|
||||||
|
push ecx
|
||||||
|
push ebx
|
||||||
|
push eax
|
||||||
|
mov cx, 32
|
||||||
|
mov si, sp
|
||||||
|
mov di, [bp + .PARAM_BIOS_INTR_ARGS_PTR]
|
||||||
|
rep movsb
|
||||||
|
add sp, 32
|
||||||
|
|
||||||
; Reset the segment registers that were changed to the caller-provided values.
|
; Reset the segment registers that were changed to the caller-provided values.
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
|
; Pop the `int` function off the stack.
|
||||||
|
add sp, 4
|
||||||
|
|
||||||
; Reload the GDT in case the BIOS call changed it.
|
; Reload the GDT in case the BIOS call changed it.
|
||||||
mov bx, sp
|
mov bx, sp
|
||||||
lgdt [bx]
|
lgdt [bx]
|
||||||
@@ -116,7 +133,7 @@ bios_call:
|
|||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
global bios_call
|
global _bios_call
|
||||||
|
|
||||||
|
|
||||||
%macro int_fn 1
|
%macro int_fn 1
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ struct BiosIntr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" {
|
unsafe extern "C" {
|
||||||
unsafe fn bios_call(intr: u32, args: *mut BiosIntr);
|
unsafe fn _bios_call(intr: u32, args: *mut BiosIntr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
@@ -54,7 +54,7 @@ pub extern "C" fn _start() -> ! {
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
bios_call(0x15, &raw mut args);
|
_bios_call(0x15, &raw mut args);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, b) in STR.iter().copied().enumerate() {
|
for (i, b) in STR.iter().copied().enumerate() {
|
||||||
|
|||||||
Reference in new issue
Block a user