Get rid of syscall thunks
This commit is contained in:
parent
d675597120
commit
5c3580e9b5
|
@ -1,2 +1,3 @@
|
||||||
*.bin
|
*.bin
|
||||||
*.img
|
*.img
|
||||||
|
ponydos.inc
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -11,7 +11,10 @@ FS_FILES = wallpaper.bin shell.bin
|
||||||
ponydos.img: ponydos.bin $(FS_FILES)
|
ponydos.img: ponydos.bin $(FS_FILES)
|
||||||
$(PYTHON) assemble_floppy.py $@ ponydos.bin $(FS_FILES)
|
$(PYTHON) assemble_floppy.py $@ ponydos.bin $(FS_FILES)
|
||||||
|
|
||||||
ponydos.bin: ponydos.inc
|
ponydos.inc: ponydos.asm ponydos_nosyscall.inc
|
||||||
|
$(NASM) -fbin -d SYMBOLS -o /dev/null ponydos.asm | $(PYTHON) add_syscalls.py $@ ponydos_nosyscall.inc
|
||||||
|
|
||||||
|
ponydos.bin: ponydos_nosyscall.inc
|
||||||
|
|
||||||
shell.bin: ponydos.inc
|
shell.bin: ponydos.inc
|
||||||
|
|
||||||
|
@ -19,13 +22,13 @@ shell.bin: ponydos.inc
|
||||||
$(NASM) -fbin -o $@ $<
|
$(NASM) -fbin -o $@ $<
|
||||||
|
|
||||||
.ansi.bin:
|
.ansi.bin:
|
||||||
$(PYTHON) process_wallpaper.py $< $@ 7 0 0 0
|
$(PYTHON) process_wallpaper.py $@ $< 7 0 0 0
|
||||||
|
|
||||||
run: ponydos.img
|
run: ponydos.img
|
||||||
qemu-system-i386 -fda $<
|
qemu-system-i386 -fda $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.bin *.img
|
rm -f *.bin *.img ponydos.inc
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
syscalls = {
|
||||||
|
'open_file': None,
|
||||||
|
'read_sectors': None,
|
||||||
|
'draw_rect': None,
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print(f'Usage: {sys.argv[0]} outfile infile', file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
outfile = sys.argv[1]
|
||||||
|
infile = sys.argv[2]
|
||||||
|
|
||||||
|
with open(infile, 'r') as f:
|
||||||
|
header = f.read()
|
||||||
|
header = f'; This is from {infile}\n' + header
|
||||||
|
|
||||||
|
mapfile = []
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
line = input()
|
||||||
|
except EOFError:
|
||||||
|
break
|
||||||
|
mapfile.append(line)
|
||||||
|
|
||||||
|
section = None
|
||||||
|
for line in mapfile:
|
||||||
|
line = line.split()
|
||||||
|
if len(line) == 4 and all(c == '-' for c in line[0]) and line[1] == 'Section' and all(c == '-' for c in line[3]):
|
||||||
|
section = line[2]
|
||||||
|
if section == '.text' and len(line) == 3:
|
||||||
|
address, _, name = line
|
||||||
|
if name in syscalls:
|
||||||
|
syscalls[name] = int(address, 16)
|
||||||
|
|
||||||
|
header += f'\n;This was automatically generated\n'
|
||||||
|
|
||||||
|
for syscall, address in syscalls.items():
|
||||||
|
if address is None:
|
||||||
|
print(f'{sys.argv[0]}: Error: syscall {syscall} not found', file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
header += f'SYS_{syscall.upper()} equ 0x{address:x}\n'
|
||||||
|
|
||||||
|
with open(outfile, 'w') as f:
|
||||||
|
f.write(header)
|
29
ponydos.asm
29
ponydos.asm
|
@ -1,4 +1,7 @@
|
||||||
%include "ponydos.inc"
|
%ifdef SYMBOLS
|
||||||
|
[map symbols]
|
||||||
|
%endif
|
||||||
|
%include "ponydos_nosyscall.inc"
|
||||||
|
|
||||||
cpu 286
|
cpu 286
|
||||||
bits 16
|
bits 16
|
||||||
|
@ -14,17 +17,6 @@ FILE_MAX_SIZE equ 128
|
||||||
|
|
||||||
jmp 0:start
|
jmp 0:start
|
||||||
|
|
||||||
; Thunks for application programs to use
|
|
||||||
; 0x7c05 SYS_OPEN_FILE
|
|
||||||
call open_file
|
|
||||||
retf
|
|
||||||
; 0x7c09 SYS_READ_SECTORS
|
|
||||||
call read_sectors
|
|
||||||
retf
|
|
||||||
; 0x7c0d SYS_DRAW_RECT
|
|
||||||
call draw_rect
|
|
||||||
retf
|
|
||||||
|
|
||||||
start:
|
start:
|
||||||
cld
|
cld
|
||||||
|
|
||||||
|
@ -81,9 +73,9 @@ load_shell:
|
||||||
push word 0x1000
|
push word 0x1000
|
||||||
pop es
|
pop es
|
||||||
mov si, shell_name
|
mov si, shell_name
|
||||||
call open_file
|
call 0:open_file
|
||||||
xor bx, bx
|
xor bx, bx
|
||||||
call read_sectors
|
call 0:read_sectors
|
||||||
; TODO: error management? Surely this works...
|
; TODO: error management? Surely this works...
|
||||||
|
|
||||||
xor ax, ax ; WM_INITIALIZE
|
xor ax, ax ; WM_INITIALIZE
|
||||||
|
@ -134,6 +126,7 @@ mainloop:
|
||||||
; ds:si = beginning of source data
|
; ds:si = beginning of source data
|
||||||
; di = X
|
; di = X
|
||||||
; bp = Y
|
; bp = Y
|
||||||
|
; [Far calls only]
|
||||||
draw_rect:
|
draw_rect:
|
||||||
pusha
|
pusha
|
||||||
push es
|
push es
|
||||||
|
@ -173,7 +166,7 @@ draw_rect:
|
||||||
|
|
||||||
pop es
|
pop es
|
||||||
popa
|
popa
|
||||||
ret
|
retf
|
||||||
|
|
||||||
; requires:
|
; requires:
|
||||||
; ds = 0
|
; ds = 0
|
||||||
|
@ -224,6 +217,7 @@ flip_mouse_cursor:
|
||||||
;; bl = drive number
|
;; bl = drive number
|
||||||
; cx = number of sectors to read (must be at least 1)
|
; cx = number of sectors to read (must be at least 1)
|
||||||
; es:bx = output buffer
|
; es:bx = output buffer
|
||||||
|
; [Far calls only]
|
||||||
read_sectors:
|
read_sectors:
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
|
@ -235,7 +229,7 @@ read_sectors:
|
||||||
loop .loop
|
loop .loop
|
||||||
|
|
||||||
popa
|
popa
|
||||||
ret
|
retf
|
||||||
|
|
||||||
; in:
|
; in:
|
||||||
; ax = LBA of first sector
|
; ax = LBA of first sector
|
||||||
|
@ -291,6 +285,7 @@ shell_name db 'shell.bin', 0
|
||||||
; out:
|
; out:
|
||||||
; ax = LBA of first sector, 0 if no space left
|
; ax = LBA of first sector, 0 if no space left
|
||||||
; cx = length in sectors
|
; cx = length in sectors
|
||||||
|
; [Far calls only]
|
||||||
open_file:
|
open_file:
|
||||||
push si
|
push si
|
||||||
push di
|
push di
|
||||||
|
@ -343,7 +338,7 @@ open_file:
|
||||||
pop bx
|
pop bx
|
||||||
pop di
|
pop di
|
||||||
pop si
|
pop si
|
||||||
ret
|
retf
|
||||||
|
|
||||||
.create_file:
|
.create_file:
|
||||||
; TODO: zero out the sector for this file?
|
; TODO: zero out the sector for this file?
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
PONYDOS_SEG equ 0
|
|
||||||
|
|
||||||
SYS_OPEN_FILE equ 0x7c05
|
|
||||||
SYS_READ_SECTORS equ 0x7c09
|
|
||||||
SYS_DRAW_RECT equ 0x7c0d
|
|
||||||
|
|
||||||
GLOBAL_WALLPAPER equ 0x500
|
|
||||||
|
|
||||||
WM_INITIALIZE equ 0
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
PONYDOS_SEG equ 0
|
||||||
|
|
||||||
|
GLOBAL_WALLPAPER equ 0x500
|
||||||
|
|
||||||
|
WM_INITIALIZE equ 0
|
|
@ -7,11 +7,11 @@ HEIGHT = 25
|
||||||
color_map = [0, 4, 2, 6, 1, 5, 3, 7]
|
color_map = [0, 4, 2, 6, 1, 5, 3, 7]
|
||||||
|
|
||||||
if len(sys.argv) != 7:
|
if len(sys.argv) != 7:
|
||||||
print("Usage: {sys.argv[0]} infile outfile default_fgcolor default_bgcolor origin_x origin_y", file=sys.stderr)
|
print("Usage: {sys.argv[0]} outfile infile default_fgcolor default_bgcolor origin_x origin_y", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
infile = sys.argv[1]
|
outfile = sys.argv[1]
|
||||||
outfile = sys.argv[2]
|
infile = sys.argv[2]
|
||||||
|
|
||||||
default_fgcolor = int(sys.argv[3])
|
default_fgcolor = int(sys.argv[3])
|
||||||
assert 0 <= default_fgcolor <= 15
|
assert 0 <= default_fgcolor <= 15
|
||||||
|
|
Loading…
Reference in New Issue