syslinux/com32/gfxboot/realmode_callback.asm
<<
>>
Prefs
   1                bits 16
   2
   3                section .text
   4
   5                ; must be filled in
   6f_buf_size      dw 0
   7f_buf_seg       dw 0
   8
   9
  10; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  11gfx_cb:
  12                push cs
  13                pop ds
  14
  15                cmp al,cb_len
  16                jae gfx_cb_80
  17
  18                movzx bx,al
  19                add bx,bx
  20                call word [bx+cb_table]
  21                jmp gfx_cb_90
  22
  23gfx_cb_80:
  24                mov al,0ffh
  25gfx_cb_90:
  26                retf
  27
  28
  29; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  30; Return status info.
  31;
  32; return:
  33;  edx          filename buffer (64 bytes)
  34;
  35cb_status:
  36                mov edx,cs
  37                shl edx,4
  38                add edx,f_name
  39                xor al,al
  40                ret
  41
  42
  43; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  44; Open file.
  45;
  46; return:
  47;    al         0: ok, 1: file not found
  48;   ecx         file length (al = 0)
  49;
  50cb_fopen:
  51                mov si,f_name
  52                push ds
  53                pop es
  54                mov ax,6
  55                int 22h
  56                xchg edx,eax
  57                mov al,1
  58                jc cb_fopen_90
  59                cmp cx,[f_buf_size]
  60                ja cb_fopen_90
  61                or cx,cx
  62                jz cb_fopen_90
  63                mov [f_block_size],cx
  64                or edx,edx
  65                jz cb_fopen_90
  66                mov [f_handle],si
  67                mov [f_size],edx
  68                mov ecx,edx
  69                mov ax,[f_buf_size]
  70                cwd
  71                div word [f_block_size]
  72                mov [f_blocks],ax
  73
  74                xor al,al
  75cb_fopen_90:
  76                ret
  77
  78
  79; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  80; Read next chunk.
  81;
  82; return:
  83;   edx         buffer address (linear)
  84;   ecx         data length (< 64k)
  85;
  86cb_fread:
  87                xor ecx,ecx
  88                mov si,[f_handle]
  89                or si,si
  90                jz cb_fread_80
  91                mov cx,[f_blocks]
  92                mov es,[f_buf_seg]
  93                xor bx,bx
  94                mov ax,7
  95                int 22h
  96                mov [f_handle],si
  97                mov al,1
  98                jc cb_fread_90
  99cb_fread_80:
 100                xor al,al
 101cb_fread_90:
 102                movzx edx,word [f_buf_seg]
 103                shl edx,4
 104                ret
 105
 106
 107; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 108; Return current working directory.
 109;
 110; return:
 111;  edx          filename
 112;
 113cb_getcwd:
 114                mov ax,1fh
 115                int 22h
 116                mov edx,es
 117                shl edx,4
 118                movzx ebx,bx
 119                add edx,ebx
 120                xor al,al
 121                ret
 122
 123
 124; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 125; Set current working directory.
 126;
 127cb_chdir:
 128                mov bx,f_name
 129                push ds
 130                pop es
 131                mov ax,25h
 132                int 22h
 133                xor al,al
 134                ret
 135
 136
 137; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 138; read sector
 139;
 140;  edx          sector
 141;
 142; return:
 143;  edx          buffer (linear address)
 144;
 145;  Note: does not return on error!
 146;
 147cb_readsector:
 148                xor edi,edi
 149                xor esi,esi
 150                mov cx,1
 151                mov es,[f_buf_seg]
 152                xor bx,bx
 153                mov ax,19h
 154                int 22h
 155                movzx edx,word [f_buf_seg]
 156                shl edx,4
 157                xor al,al
 158                ret
 159
 160
 161; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 162; Re-read fs structures.
 163;
 164cb_mount:
 165                mov ax,26h
 166                int 22h
 167                setc al
 168                ret
 169
 170
 171; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 172;
 173                align 2, db 0
 174
 175cb_table        dw cb_status
 176                dw cb_fopen
 177                dw cb_fread
 178                dw cb_getcwd
 179                dw cb_chdir
 180                dw cb_readsector
 181                dw cb_mount
 182cb_len          equ ($-cb_table)/2
 183
 184f_handle        dw 0
 185f_block_size    dw 0
 186f_blocks        dw 0
 187f_size          dd 0
 188f_name          times 64 db 0
 189f_name_len      equ $ - f_name
 190
 191
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.