diff --git a/plat/msdos/libsys/sys_seterrno.c b/plat/msdos/libsys/sys_seterrno.c index b135aea33..54b4e5af0 100644 --- a/plat/msdos/libsys/sys_seterrno.c +++ b/plat/msdos/libsys/sys_seterrno.c @@ -35,7 +35,7 @@ static const signed char err_map[] = * Map an MS-DOS 2+ system error code to an `errno' value and store that in * `errno'. Return a longword -1. */ -long _sys_seterrno(unsigned dos_err) +long _sys_seterrno(unsigned short dos_err) { if (dos_err < sizeof(err_map) / sizeof(err_map[0])) errno = err_map[dos_err]; diff --git a/plat/msdos386/libsys/getpid.s b/plat/msdos386/libsys/getpid.s index d2a250491..fd8706379 100644 --- a/plat/msdos386/libsys/getpid.s +++ b/plat/msdos386/libsys/getpid.s @@ -38,8 +38,9 @@ _getpid: int 0x21 jnc .eur_dos movb ah, 0x51 - int 0x21 + mov ebx, 0x210000 + callf (interrupt_ptr) xchg ebx, eax .eur_dos: - xor edx, edx + movzx eax, ax ret diff --git a/plat/msdos386/libsys/rename.s b/plat/msdos386/libsys/rename.s index 4b43a0d48..cfde5305e 100644 --- a/plat/msdos386/libsys/rename.s +++ b/plat/msdos386/libsys/rename.s @@ -23,9 +23,9 @@ _rename: ! Source filename. mov esi, 4(ebx) - movzx edi, (transfer_buffer_ptr) - mov es, (pmode_ds) - cld + movzx edi, (transfer_buffer_ptr) + mov es, (pmode_ds) + cld 1: lodsb stosb @@ -47,8 +47,10 @@ _rename: o16 mov dx, (transfer_buffer_ptr) o16 mov di, ax movb ah, 0x56 - or ebx, 0x210000 + mov ebx, 0x210000 callf (interrupt_ptr) pop edi pop esi + push ss + pop es jmp .sys_zret diff --git a/plat/msdos386/libsys/sys_exists.s b/plat/msdos386/libsys/sys_exists.s index f57d28b3e..8dc1dc18c 100644 --- a/plat/msdos386/libsys/sys_exists.s +++ b/plat/msdos386/libsys/sys_exists.s @@ -16,10 +16,22 @@ .define __sys_exists __sys_exists: - mov ebx, esp - mov edx, 4(ebx) + push esi + mov esi, 4+4(esp) + movzx edi, (transfer_buffer_ptr) + mov edx, edi + mov es, (pmode_ds) + cld +1: + lodsb + stosb + testb al, al + jnz 1b mov eax, 0x4300 - int 0x21 + mov ebx, 0x210000 + callf (interrupt_ptr) + push ss + pop es sbb eax, eax inc eax ret diff --git a/plat/msdos386/libsys/sys_gettime.s b/plat/msdos386/libsys/sys_gettime.s index 733ad58ac..1d43d5f46 100644 --- a/plat/msdos386/libsys/sys_gettime.s +++ b/plat/msdos386/libsys/sys_gettime.s @@ -16,7 +16,6 @@ .define __sys_gettime __sys_gettime: - int 3 movb ah, 0x2c int 0x21 mov ebx, esp diff --git a/plat/msdos386/libsys/sys_isopen.s b/plat/msdos386/libsys/sys_isopen.s index 5a5fed07c..5f990f1c1 100644 --- a/plat/msdos386/libsys/sys_isopen.s +++ b/plat/msdos386/libsys/sys_isopen.s @@ -17,8 +17,7 @@ .define __sys_isopen __sys_isopen: - mov ebx, esp - mov ebx, 4(bx) + mov ebx, 4(esp) mov eax, 0x4400 int 0x21 sbb eax, eax diff --git a/plat/msdos386/libsys/sys_rawcreat.s b/plat/msdos386/libsys/sys_rawcreat.s index b15df3f4f..ce48d9d7c 100644 --- a/plat/msdos386/libsys/sys_rawcreat.s +++ b/plat/msdos386/libsys/sys_rawcreat.s @@ -36,10 +36,12 @@ __sys_rawcreat: movb ah, 0x3c movzx edx, (transfer_buffer_ptr) movb al, 8(ebx) - or ebx, 0x210000 + mov ebx, 0x210000 callf (interrupt_ptr) pop edi pop esi + push ss + pop es jmp .sys_axret diff --git a/plat/msdos386/libsys/sys_rawlseek.s b/plat/msdos386/libsys/sys_rawlseek.s index c38a1e0b1..8ff4bc1db 100644 --- a/plat/msdos386/libsys/sys_rawlseek.s +++ b/plat/msdos386/libsys/sys_rawlseek.s @@ -18,9 +18,10 @@ __sys_rawlseek: movb ah, 0x42 mov ebx, esp - mov edx, 8(bx) - mov ecx, 12(bx) - movb al, 16(bx) - mov ebx, 4(bx) + mov edx, 8(ebx) + mov ecx, edx + shr ecx, 16 + movb al, 12(ebx) + mov ebx, 4(ebx) int 0x21 jmp .sys_dxaxret diff --git a/plat/msdos386/libsys/sys_rawopen.s b/plat/msdos386/libsys/sys_rawopen.s index bb4ff5acb..3c8f2bf17 100644 --- a/plat/msdos386/libsys/sys_rawopen.s +++ b/plat/msdos386/libsys/sys_rawopen.s @@ -37,9 +37,11 @@ __sys_rawopen: movb ah, 0x3d o16 mov dx, (transfer_buffer_ptr) movb al, 8(ebx) - or ebx, 0x210000 + mov ebx, 0x210000 callf (interrupt_ptr) pop edi pop esi + push ss + pop es jmp .sys_axret diff --git a/plat/msdos386/libsys/sys_rawread.s b/plat/msdos386/libsys/sys_rawread.s index f5b0c1a35..ef71bf915 100644 --- a/plat/msdos386/libsys/sys_rawread.s +++ b/plat/msdos386/libsys/sys_rawread.s @@ -38,8 +38,9 @@ amount_to_read = 4*4 movb ah, 0x3f o16 mov dx, (transfer_buffer_ptr) + movzx esi, dx + mov ebx, 0x210000 o16 mov bx, file_handle(ebp) - or ebx, 0x210000 callf (interrupt_ptr) jnc success @@ -53,9 +54,10 @@ success: ! Copy eax bytes out of the transfer buffer. - push eax + movzx eax, ax mov ecx, eax - movzx esi, (transfer_buffer_ptr) + jcxz exit + push eax mov edi, write_buffer(ebp) mov es, (pmode_ds) cld @@ -69,6 +71,8 @@ success: exit: pop edi pop esi + push ss + pop es leave ret diff --git a/plat/msdos386/libsys/sys_rawwrite.s b/plat/msdos386/libsys/sys_rawwrite.s index 3ac3a7e16..56976b53b 100644 --- a/plat/msdos386/libsys/sys_rawwrite.s +++ b/plat/msdos386/libsys/sys_rawwrite.s @@ -48,8 +48,8 @@ amount_to_write = 4*4 movb ah, 0x40 o16 mov dx, (transfer_buffer_ptr) + mov ebx, 0x210000 o16 mov bx, file_handle(ebp) - or ebx, 0x210000 callf (interrupt_ptr) jnc exit @@ -59,6 +59,8 @@ amount_to_write = 4*4 exit: pop edi pop esi + push ss + pop es leave ret diff --git a/plat/msdos386/libsys/sys_xret.s b/plat/msdos386/libsys/sys_xret.s index 20c2b454b..e9b9017c9 100644 --- a/plat/msdos386/libsys/sys_xret.s +++ b/plat/msdos386/libsys/sys_xret.s @@ -20,7 +20,8 @@ ! code in ax, and return a shortword -1. If the carry flag is clear, just ! return ax as a return value. ! -! .sys_dxaxret: same as .sys_axret, but return -1 or dx:ax as a return value. +! .sys_dxaxret: same as .sys_axret, but return -1 or eax := dx:ax as a +! return value. .extern .sys_zret .extern .sys_axret diff --git a/plat/msdos386/libsys/unlink.s b/plat/msdos386/libsys/unlink.s index 7d023ad48..d2289e3c4 100644 --- a/plat/msdos386/libsys/unlink.s +++ b/plat/msdos386/libsys/unlink.s @@ -34,11 +34,13 @@ _unlink: ! Make the DOS call. - movzx edi, (transfer_buffer_ptr) + mov dx, (transfer_buffer_ptr) movb ah, 0x41 or ebx, 0x210000 callf (interrupt_ptr) pop edi pop esi + push ss + pop es jmp .sys_zret