Browse Source

first xex-file has now been executed and returned to safe kernel state

master
Jørn Guldberg 5 years ago
parent
commit
27c47ff744
2 changed files with 79 additions and 9 deletions
  1. +1
    -1
      filesystems/lsfs/test_lsfs.nasm
  2. +78
    -8
      lib/xex.nasm

+ 1
- 1
filesystems/lsfs/test_lsfs.nasm View File

@ -13,7 +13,7 @@ lfsf_systemcall:
int 0x16
mov ah, 0x0e
mov al, 65 ; backspace
mov al, 66 ; backspace
int 0x10 ; print char
ret

+ 78
- 8
lib/xex.nasm View File

@ -2,8 +2,11 @@
; This is the "program" to execute a program
xex:
pusha ; save state before program
sub sp, 2048
mov [.program_executable_buffer], sp
;sub sp, 2048
;mov [.program_executable_buffer], sp
;mov [.program_executable_buffer], sp
call os_clear_screen
call lsfs_list_files_command
@ -72,24 +75,91 @@ xex:
mov BYTE [bx], 0
mov si, [.program_executable_buffer]
call zstring_to_integer ; ax now contain the interger index for the file
mov ax, 3
call dumpax
mov [.fileindex_for_open_file], ax ; save the file index
mov ax, [.fileindex_for_open_file]
mov bx, [.program_executable_buffer]
call lsfs_read_file
.xex_lsfs_read_file:
; INPUT ax = file index
; INPUT bx = filebuffer
pusha ; save all register state
; We need to find the data pointers for the file.
push bx
mov [.program_executable_buffer], ax
mov dx, 24 ; LSFS_magic_start_sector
add ax, dx ; senctor number, into the master Table.
call dumpax
mov WORD [XEXPACK.db_addr_offset], xex_lsfs_loading_buffer
mov WORD [XEXPACK.lba_addr_dw_low], ax
mov WORD [XEXPACK.blkcnt], 0x1 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [XEXPACK.db_addr_segment], 0x50
mov si, XEXPACK ; address of "disk address packet"
mov ah, 0x42 ; READ
mov dl, [global_disk_identifier]
int 0x13
pop bx
; Save the buffer addr
mov bx, [xex_lsfs_loading_buffer + 288] ; this is the first data pointer
mov ax, bx
call dumpax
mov WORD [XEXPACK.lba_addr_dw_low], bx
mov WORD [XEXPACK.blkcnt], 0x4 ; Read to sectors, that is what the space is for the buffer in svim
mov WORD [XEXPACK.db_addr_segment], 0x2000
mov WORD [XEXPACK.db_addr_offset], 0x0
mov si, XEXPACK ; address of "disk address packet"
mov ah, 0x42 ; READ
mov dl, [global_disk_identifier]
int 0x13
popa
mov ax, [xex_lsfs_loading_buffer + 264]
; I guess we should have something like
call ax ; here. We want to execute the file that we just have benn loaded in memory
; The executable should make use of the global systemcall table.
; That is what we are trying to get to work here.
push cs ; this gives us the correct code segment for the kernel
push .this_place ; this gives the correct adress to come back from the program.
push 0x2000
push 0x0
;push 0x0050
;push 0x0512
retf
.this_place:
;mov bx, ss
;call bx:ax ; here. We want to execute the file that we just have benn loaded in memory
; The executable should make use of the global systemcall table.
; That is what we are trying to get to work here.
;add sp, 2048
popa ; retore
ret
.welcome_xex_enter_fileindex db 'Enter program index to execute: ', 0
.fileindex_for_open_file dw 0
.program_executable_buffer db 0
.program_executable_buffer dw 0
align 2
xex_lsfs_loading_buffer times 512 db 0
XEXPACK:
.dap_Size: db 0x10 ; This is always 16 bytes (0x10)
.rev_byte: db 0x0 ; reserved byte, should always be zero
.blkcnt: dw 0x0 ; int 13 resets this to # of blocks actually read/written
.db_addr_offset: dw 0x0 ; memory buffer destination address (0:7c00)
.db_addr_segment: dw 0x0 ; in memory page zero
.lba_addr_dw_low: dd 0x0 ; put the lba to read in this spot
.lba_addr_dw_high: dd 0x0 ; more storage bytes only for big lba's ( > 4 bytes )

Loading…
Cancel
Save