File: realmode_callback.asm

package info (click to toggle)
syslinux 2%3A4.05%2Bdfsg-6%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 25,684 kB
  • sloc: ansic: 276,159; asm: 9,973; pascal: 9,907; perl: 3,492; makefile: 1,736; sh: 626; python: 266; xml: 39
file content (190 lines) | stat: -rw-r--r-- 2,890 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
		bits 16

		section .text

		; must be filled in
f_buf_size	dw 0
f_buf_seg	dw 0


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
gfx_cb:
		push cs
		pop ds

		cmp al,cb_len
		jae gfx_cb_80

		movzx bx,al
		add bx,bx
		call word [bx+cb_table]
		jmp gfx_cb_90

gfx_cb_80:
		mov al,0ffh
gfx_cb_90:
		retf


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Return status info.
;
; return:
;  edx		filename buffer (64 bytes)
;
cb_status:
		mov edx,cs
		shl edx,4
		add edx,f_name
		xor al,al
		ret


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Open file.
;
; return:
;    al		0: ok, 1: file not found
;   ecx		file length (al = 0)
;
cb_fopen:
		mov si,f_name
		push ds
		pop es
		mov ax,6
		int 22h
		xchg edx,eax
		mov al,1
		jc cb_fopen_90
		cmp cx,[f_buf_size]
		ja cb_fopen_90
		or cx,cx
		jz cb_fopen_90
		mov [f_block_size],cx
		or edx,edx
		jz cb_fopen_90
		mov [f_handle],si
		mov [f_size],edx
		mov ecx,edx
		mov ax,[f_buf_size]
		cwd
		div word [f_block_size]
		mov [f_blocks],ax

		xor al,al
cb_fopen_90:
		ret


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Read next chunk.
;
; return:
;   edx		buffer address (linear)
;   ecx		data length (< 64k)
;
cb_fread:
		xor ecx,ecx
		mov si,[f_handle]
		or si,si
		jz cb_fread_80
		mov cx,[f_blocks]
		mov es,[f_buf_seg]
		xor bx,bx
		mov ax,7
		int 22h
		mov [f_handle],si
		mov al,1
		jc cb_fread_90
cb_fread_80:
		xor al,al
cb_fread_90:
		movzx edx,word [f_buf_seg]
		shl edx,4
		ret


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Return current working directory.
;
; return:
;  edx		filename
;
cb_getcwd:
		mov ax,1fh
		int 22h
		mov edx,es
		shl edx,4
		movzx ebx,bx
		add edx,ebx
		xor al,al
		ret


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Set current working directory.
;
cb_chdir:
		mov bx,f_name
		push ds
		pop es
		mov ax,25h
		int 22h
		xor al,al
		ret


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; read sector
;
;  edx		sector
;
; return:
;  edx		buffer (linear address)
;
;  Note: does not return on error!
;
cb_readsector:
		xor edi,edi
		xor esi,esi
		mov cx,1
		mov es,[f_buf_seg]
		xor bx,bx
		mov ax,19h
		int 22h
		movzx edx,word [f_buf_seg]
		shl edx,4
		xor al,al
		ret


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Re-read fs structures.
;
cb_mount:
		mov ax,26h
		int 22h
		setc al
		ret


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
		align 2, db 0

cb_table	dw cb_status
		dw cb_fopen
		dw cb_fread
		dw cb_getcwd
		dw cb_chdir
		dw cb_readsector
		dw cb_mount
cb_len		equ ($-cb_table)/2

f_handle	dw 0
f_block_size	dw 0
f_blocks	dw 0
f_size		dd 0
f_name		times 64 db 0
f_name_len	equ $ - f_name