1 /* $NetBSD: dos_file.S,v 1.6 2009/11/21 11:52:57 dsl Exp $ */
3 /* extracted from Tor Egge's patches for NetBSD boot */
5 #include <machine/asm.h>
8 # MSDOS call "INT 0x21 Function 0x3d" to open a file.
10 # %al = 0x0 (access and sharing modes)
11 # %ds:%dx = ASCIZ filename
12 # %cl = attribute mask of files to look for
15 .globl _C_LABEL(doserrno)
16 _C_LABEL(doserrno): .long 1
27 movl 0x8(%ebp), %edx # File name.
29 call _C_LABEL(prot_to_real) # enter real mode
40 movb $0x3d, %ah # Open existing file.
49 mov %ax, _C_LABEL(doserrno)
56 calll _C_LABEL(real_to_prot) # back to protected mode
59 movl %edx, %eax # return value in %eax
78 movl 0x8(%ebp), %ebx # File handle
79 movl 0xc(%ebp), %edx # Buffer.
80 movl 0x10(%ebp), %ecx # Bytes to read
82 call _C_LABEL(prot_to_real) # enter real mode
93 movb $0x3f, %ah # Read from file or device
101 mov %ax, _C_LABEL(doserrno)
108 calll _C_LABEL(real_to_prot) # back to protected mode
111 movl %edx, %eax # return value in %eax
129 movl 0x8(%ebp), %ebx # File handle
131 call _C_LABEL(prot_to_real) # enter real mode
134 movb $0x3e, %ah # Close file.
141 mov %ax, _C_LABEL(doserrno)
147 calll _C_LABEL(real_to_prot) # back to protected mode
150 movl %ebx, %eax # return value in %eax
168 movl 0x8(%ebp), %ebx # File handle
169 movl 0xc(%ebp), %ecx # Offset
170 movl 0x10(%ebp) , %edx # whence
172 call _C_LABEL(prot_to_real) # enter real mode
175 movb $0x42, %ah # Seek
176 movb %dl, %al # whence
177 mov %cx, %dx #offs lo
178 shrl $0x10, %ecx #offs hi
185 mov %ax, _C_LABEL(doserrno)
189 shll $0x10, %edx #new ofs hi
190 mov %ax, %dx #new ofs lo
192 calll _C_LABEL(real_to_prot) # back to protected mode
195 movl %edx, %eax # return value in %eax