gfxboot: only call gfxboot core if labels are specified
[people/sha0/syslinux.git] / modules / gfxboot.asm
1 ; ****************************************************************************
2 ;
3 ;  gfxboot.asm
4 ;
5 ;   Copyright 2008-2009 Sebastian Herbszt
6 ;
7 ;  This module is based on the gfxboot integration patch by Steffen Winterfeldt:
8 ;
9 ;   Copyright 2001-2008 Steffen Winterfeldt
10 ;
11 ;  Some parts borrowed from Syslinux core:
12 ;
13 ;   Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
14 ;
15 ;  This program is free software; you can redistribute it and/or modify
16 ;  it under the terms of the GNU General Public License as published by
17 ;  the Free Software Foundation, Inc., 53 Temple Place Ste 330,
18 ;  Boston MA 02111-1307, USA; either version 2 of the License, or
19 ;  (at your option) any later version; incorporated herein by reference.
20 ;
21 ; ****************************************************************************
22
23                 [map all gfxboot.map]
24
25                 absolute 0
26 pspInt20:       resw 1
27 pspNextP:       resw 1
28                 resb 124
29 pspCmdLen:      resb 1
30 pspCmdArg:      resb 127
31
32 ;%define DEBUG
33
34                 section .text
35                 org 100h
36
37 _start:
38                 ; Zero memory from the start of .bss to the stack
39                 cld
40                 mov di,section..bss.start
41                 mov cx,sp
42                 sub cx,di
43                 shr cx,2
44                 xor eax,eax
45                 rep stosd
46
47                 mov ax,2
48                 mov bx, msg_progname
49                 int 22h
50
51                 mov ax,2
52                 mov bx, msg_crlf
53                 int 22h
54
55                 push es
56                 mov ax,0ah
57                 mov cl,9
58                 int 22h
59                 pop es
60                 cmp al,32h
61                 jnz not_pxelinux
62
63                 mov dl,0 ; fake drive number
64                 mov cl,11 ; fake sector size 2048 bytes
65
66 not_pxelinux:
67                 mov [derivative_id],al
68                 mov [drivenumber],dl
69                 mov [sectorshift],cl
70                 mov ax,1
71                 shl ax,cl
72                 mov [sectorsize],ax
73                 mov ax,trackbufsize
74                 shr ax,cl
75                 mov [BufSafe],ax
76
77                 xor cx,cx
78                 mov cl,[pspCmdLen]
79                 dec cx
80                 and cx,cx
81                 jne continue
82
83                 mov ax,2
84                 mov bx, msg_usage
85                 int 22h
86                 ret
87 continue:
88                 mov di,pspCmdArg+1
89                 add di,cx
90                 dec di
91                 std
92                 mov al,' '
93                 repe scasb
94                 inc cx
95                 cld
96                 mov [pspCmdLen],cl
97                 mov si,pspCmdArg+1
98                 mov di,si
99                 add di,cx
100                 xor al,al
101                 stosb
102                 mov si,pspCmdArg+1
103
104 ; get config file name
105                 mov ax,0eh
106                 int 22h
107
108 ; open config file
109                 mov si,bx ; es:bx config file name
110                 mov ax,6
111                 int 22h
112                 jc no_config_file
113                 and eax,eax
114                 jz no_config_file
115                 jmp got_config_file
116 no_config_file:
117                 push es
118                 push bx
119                 push cs
120                 pop es
121                 mov bx, msg_config_file
122                 mov ax,2
123                 int 22h
124                 mov bx, msg_space
125                 mov ax,2
126                 int 22h
127                 pop bx
128                 pop es
129                 mov ax,2
130                 int 22h
131                 push cs
132                 pop es
133                 mov bx, msg_space
134                 mov ax,2
135                 int 22h
136                 mov bx, msg_missing
137                 mov ax,2
138                 int 22h
139                 mov ax,2
140                 mov bx, msg_crlf
141                 int 22h
142                 ret
143 got_config_file:
144                 push cs
145                 pop es
146                 call parse_config
147                 cmp word [label_cnt],0
148                 ja labels_defined
149
150                 mov bx,msg_no_labels_defined
151                 mov ax,2
152                 int 22h
153                 ret
154
155 labels_defined:
156 ; get_gfx_file
157                 mov ax,cs
158                 add ax,2000h
159                 mov word [gfx_mem_start_seg],ax
160                 mov ax,[pspNextP]
161                 mov word [gfx_mem_end_seg],ax
162
163                 call gfx_init
164                 jc error
165
166                 call gfx_setup_menu
167                 jc exit
168
169 input:
170                 call gfx_input
171                 jc exit
172
173                 cmp eax,1
174                 jz exit
175
176                 cmp eax,2
177                 jz boot
178
179                 jmp input
180
181 boot:
182                 call far [gfx_bc_done]
183                 mov ax,cs
184                 mov es,ax
185                 mov bx,command_line
186                 mov ax,3
187                 int 22h
188 exit:
189                 call far [gfx_bc_done]
190 error:
191                 ret
192
193 cb_table        dw cb_status            ; 0
194                 dw cb_fopen             ; 1
195                 dw cb_fread             ; 2
196                 dw cb_getcwd            ; 3
197                 dw cb_chdir             ; 4
198                 dw cb_readsector        ; 5
199 cb_len          equ ($-cb_table)/2
200
201 gfx_cb:
202                 push cs
203                 pop ds
204
205                 cmp al,cb_len
206                 jae gfx_cb_error
207
208                 movzx bx,al
209                 add bx,bx
210                 call word [bx+cb_table]
211                 jmp gfx_cb_end
212 gfx_cb_error:
213                 mov al,0ffh
214 gfx_cb_end:
215                 retf
216
217 ; Return status info
218 ;
219 ; return:
220 ;  edx          filename buffer (64 bytes)
221 ;
222 cb_status:
223                 mov edx,cs
224                 shl edx,4
225                 add edx,fname_buf
226
227                 xor al,al
228                 ret
229
230 ; Open file
231 ;
232 ; return:
233 ;    al         0: ok, 1: file not found
234 ;   ecx         file length (al = 0)
235 ;
236 cb_fopen:
237                 push ds
238                 pop es
239                 mov ax,6
240                 mov si,fname_buf
241                 int 22h
242                 jnc cb_fopen_ok
243 cb_fopen_failed:
244                 mov al,1
245                 jmp cb_fopen_end
246 cb_fopen_ok:
247                 mov ecx,eax
248                 mov [f_handle],si
249                 mov [f_size],ecx
250                 xor al,al
251 cb_fopen_end:
252                 ret
253
254 ; Read next chunk
255 ;
256 ; return:
257 ;   edx         buffer address (linear)
258 ;   ecx         data length (< 64k)
259 ;
260 cb_fread:
261                 cmp dword [f_size],0
262                 jz cb_fread_eof
263                 push ds
264                 pop es
265                 mov ax,7
266                 mov si,[f_handle]
267                 mov bx,trackbuf
268                 mov cx,[BufSafe]
269                 int 22h
270                 mov al,1
271                 jc cb_fread_end
272                 sub [f_size], ecx
273                 or si,si
274                 jnz cb_fread_noeof
275                 and dword [f_size],0
276 cb_fread_noeof:
277                 mov edx,cs
278                 shl edx,4
279                 add edx,trackbuf
280                 jmp cb_fread_ok
281 cb_fread_eof:
282                 xor ecx,ecx
283 cb_fread_ok:
284                 xor al,al
285 cb_fread_end:
286                 ret
287
288 ; Return current working directory
289 ;
290 ; return:
291 ;  edx          filename
292 ;
293 cb_getcwd:
294                 mov edx,cs
295                 shl edx,4
296                 add edx,gfx_slash
297                 xor al,al
298                 ret
299
300 ; Set current working directory
301 ;
302 cb_chdir:
303                 xor al,al
304                 ret
305
306 ; Read sector
307 ;
308 ;   edx         sector
309 ;
310 ; return:
311 ;  edx          buffer (linear address)
312 ;
313 ;  Note: does not return on error!
314 ;
315 cb_readsector:
316                 push esi
317                 push edi
318                 push ds
319                 pop es
320                 mov ax,19h
321                 xor esi,esi
322                 xor edi,edi
323                 mov cx,1
324                 mov bx,trackbuf
325                 int 22h
326                 pop edi
327                 pop esi
328                 mov al,1
329                 jc cb_readsector_end
330                 mov edx,ds
331                 shl dx,4
332                 add edx,trackbuf
333                 xor al,al
334 cb_readsector_end:
335                 ret
336
337 gfx_init:
338                 mov ax,0e801h
339                 xor bx,bx
340                 xor cx,cx
341                 xor dx,dx
342                 int 15h
343                 jnc got_e801
344
345                 mov ax,2
346                 mov bx, msg_memory
347                 int 22h
348                 stc
349                 ret
350
351 got_e801:
352                 cmp ax,3c00h
353                 jb mem_below_16mb
354                 shl ebx,6
355                 add eax,ebx
356
357 mem_below_16mb:
358                 shl eax,10
359                 mov [gfx_bios_mem_size],eax
360                 shr eax,20
361                 cmp ax,16
362                 jb skip_extended
363
364                 mov word [gfx_xmem_0],88h       ; 8MB at 8MB
365                 mov dword [gfx_save_area1],7f0000h      ; 8MB-64k
366
367 skip_extended:
368                 movzx ebx,word [gfx_mem_start_seg]
369                 shl ebx,4
370
371                 movzx ecx,word [gfx_mem_end_seg]
372                 shl ecx,4
373
374                 mov dword [gfx_mem],ebx
375                 mov dword [gfx_mem0_start],ebx
376                 mov dword [gfx_mem0_end],ecx
377
378                 call gfx_read_file
379                 jc gfx_init_end
380
381                 call gfx_get_sysconfig
382
383                 ; align 4
384                 mov eax,[gfx_mem0_start]
385                 add eax,3
386                 and eax,~3
387                 mov [gfx_mem0_start],eax
388
389 ; setup jump table
390                 les bx,[gfx_bc_jt]
391
392                 mov ax,[es:bx]
393                 mov [gfx_bc_init],ax
394                 mov [gfx_bc_init+2],es
395
396                 mov ax,[es:bx+2]
397                 mov [gfx_bc_done],ax
398                 mov [gfx_bc_done+2],es
399
400                 mov ax,[es:bx+4]
401                 mov [gfx_bc_input],ax
402                 mov [gfx_bc_input+2],es
403
404                 mov ax,[es:bx+6]
405                 mov [gfx_bc_menu_init],ax
406                 mov [gfx_bc_menu_init+2],es
407
408 ; ...
409
410                 mov esi,cs
411                 shl esi,4
412                 add esi,gfx_sysconfig
413                 call far [gfx_bc_init]
414
415 gfx_init_end:
416                 ret
417
418 gfx_read_file:
419 ; open file
420 ; es:si - file name
421
422                 push cs
423                 pop es
424                 mov ax,6
425                 mov si,pspCmdArg+1
426                 int 22h
427                 jnc gfx_file_read
428
429                 mov ax,2
430                 mov bx,pspCmdArg+1
431                 int 22h
432
433                 mov ax,2
434                 mov bx,msg_not_found
435                 int 22h
436                 stc
437                 ret
438
439 gfx_file_read:
440 ; si - file handle
441 ; eax - length of file in bytes, or -1
442 ; cx - file block size
443
444                 mov edx,[gfx_mem0_end]
445                 sub edx,[gfx_mem0_start]
446                 sub edx,0fh             ; space to allow for aligning later
447                 ; edx: max allowed size
448
449                 cmp eax,-1              ; unknown file size -> set to max allowed size
450                 jnz .has_size
451                 mov eax,edx
452 .has_size:
453                 cmp eax,edx
454                 jbe read_bootlogo
455
456 gfx_file_too_big:
457                 mov ax,2
458                 mov bx,msg_bootlogo_toobig
459                 int 22h
460                 stc
461                 ret
462
463 read_bootlogo:
464                 mov [file_length],eax
465                 mov edi,[gfx_mem]
466
467 ; read file
468 ; si - file handle
469 ; es:bx - buffer
470 ; cx - number of blocks to read
471
472 read:
473                 push eax
474                 mov ax,7
475                 mov bx,trackbuf
476                 mov cx,[BufSafe]
477                 int 22h
478
479                 push edi
480                 push ecx
481                 push si
482                 push es
483
484                 mov si,trackbuf
485                 push edi
486                 call gfx_l2so
487                 pop di
488                 pop es
489
490                 rep movsb ; move ds:si -> es:di, length ecx
491                 pop es
492                 pop si
493                 pop ecx
494                 pop edi
495
496                 pop eax
497
498                 ; si == 0: EOF
499                 or si,si
500                 jz gfx_read_done
501                 add edi,ecx
502                 sub eax,ecx
503                 ja read
504                 jmp gfx_file_too_big
505 gfx_read_done:
506                 sub eax,ecx
507                 mov edx,[file_length]
508                 sub edx,eax
509                 ; edx = real file size
510                 mov [gfx_archive_end],edx
511                 add edx,[gfx_mem0_start]
512                 add edx,0fh             ; for alignment
513                 mov [gfx_mem0_start],edx
514
515 bootlogo_read_done:
516                 call find_file
517                 or eax,eax
518                 jnz found_bootlogo
519                 stc
520                 ret
521
522 found_bootlogo:
523                 push edi
524                 push eax
525                 add eax,edi
526                 push dword [gfx_mem]
527                 pop dword [gfx_archive_start]
528                 neg al
529                 and eax,byte 0fh
530                 jz no_align
531                 add [gfx_archive_start],eax
532
533 no_align:
534                 pop eax
535                 pop edi
536                 sub edi,[gfx_mem]
537                 mov ecx,[gfx_archive_start]
538                 add edi,ecx
539                 mov [gfx_file],edi
540                 add [gfx_archive_end],ecx
541                 add eax,edi
542                 shr eax,4
543                 mov [gfx_bc_jt+2],ax
544                 ret
545
546 gfx_get_sysconfig:
547                 mov ah,0
548                 cmp byte [derivative_id],33h
549                 jnz not_isolinux
550                 mov ah,2
551 not_isolinux:
552                 mov al,[drivenumber]
553                 mov [gfx_boot_drive],al
554                 cmp al,80h      ; floppy ?
555                 jae not_floppy
556                 mov ah,1
557 not_floppy:
558                 mov byte [gfx_media_type],ah
559                 mov ah,[sectorshift]
560                 mov byte [gfx_sector_shift],ah
561                 mov ax,cs
562                 mov [gfx_bootloader_seg],ax
563                 ret
564
565 gfx_setup_menu:
566                 push es
567                 push ds
568                 pop es
569
570                 mov word [menu_desc+menu_ent_list],0
571                 mov di,[menu_seg]
572                 mov [menu_desc+menu_ent_list+2],di
573
574                 mov word [menu_desc+menu_default],dentry_buf
575                 mov [menu_desc+menu_default+2],cs
576
577                 mov di,256
578                 mov [menu_desc+menu_arg_list],di
579                 mov di,[menu_seg]
580                 mov [menu_desc+menu_arg_list+2],di
581
582                 mov cx,[label_cnt]
583                 mov [menu_desc+menu_entries],cx
584
585                 mov cx,256*2
586                 mov [menu_desc+menu_ent_size],cx
587                 mov [menu_desc+menu_arg_size],cx
588
589                 mov esi,ds
590                 shl esi,4
591                 add esi,menu_desc
592
593                 call far [gfx_bc_menu_init]
594                 pop es
595                 ret
596
597 magic_ok:
598                 xor eax,eax
599                 cmp dword [es:bx],0b2d97f00h    ; header.magic_id
600                 jnz magic_ok_end
601                 cmp byte [es:bx+4],8            ; header.version
602                 jnz magic_ok_end
603                 mov eax,[es:bx+8]
604 magic_ok_end:
605                 ret
606
607 find_file:
608                 mov edi,[gfx_mem]
609                 push edi
610                 call gfx_l2so
611                 pop bx
612                 pop es
613                 call magic_ok
614                 or eax,eax
615                 jnz find_file_end
616
617 find_file_loop:
618                 mov ecx,[gfx_mem0_start]
619                 sub ecx,26 + 12                 ; min cpio header + gfx header
620                 cmp edi,ecx
621                 jae find_file_end
622                 push edi
623                 call gfx_l2so
624                 pop bx
625                 pop es
626                 cmp word [es:bx],71c7h
627                 jnz find_file_end
628                 mov ax,[es:bx+20]               ; file name size
629                 movzx esi,ax
630
631                 inc si
632                 and si,~1                       ; align
633
634                 mov eax,[es:bx+22]              ; data size
635                 rol eax,16                      ; get word order right
636                 mov ecx,eax
637
638                 inc ecx
639                 and ecx,byte ~1                 ; align
640
641                 add si,26                       ; skip header
642
643                 add edi,esi
644                 add bx,si
645                 call magic_ok
646                 or eax,eax
647                 jnz find_file_end
648
649                 add edi,ecx
650                 jmp find_file_loop
651
652 find_file_end:
653                 ret
654
655 gfx_input:
656                 mov edi,cs
657                 shl edi,4
658                 add edi, command_line ; buffer (0: no buffer)
659                 mov ecx, max_cmd_len ; buffer size
660 ;               xor eax,eax ; timeout value (0: no timeout)
661                 mov eax,100 ; timeout value (0: no timeout)
662
663                 call far [gfx_bc_input]
664                 ret
665
666 gfx_l2so:
667                 push eax
668                 mov eax,[esp + 6]
669                 shr eax,4
670                 mov [esp + 8],ax
671                 and word [esp + 6],byte 0fh
672                 pop eax
673                 ret
674
675 parse_config:
676                 mov [f_handle],si
677                 push es
678                 mov ax,cs
679                 add ax,1000h
680                 mov es,ax
681                 mov word [menu_seg],ax
682                 xor eax,eax
683                 mov cx,4000h
684                 mov di,0
685                 rep stosd
686                 pop es
687 .read:
688                 call skipspace
689                 jz .eof
690                 jc .read
691                 cmp al,'#'
692                 je .nextline
693                 or al,20h ; convert to lower case
694                 mov di,configbuf
695                 stosb
696 .read_loop:
697                 call getc
698                 jc .eof
699                 cmp al,' '
700                 jbe .done
701                 or al,20h ; convert to lower case
702                 stosb
703                 jmp .read_loop
704 .done:
705                 call ungetc
706
707                 xor ax,ax
708                 stosb
709 %ifdef DEBUG
710                 mov ax,2
711                 mov bx, configbuf
712                 int 22h
713
714                 mov ax,2
715                 mov bx, msg_crlf
716                 int 22h
717 %endif
718                 mov bx,keywords
719                 mov cx,[keyword_cnt]
720 .keywords_loop:
721                 push cx
722                 push si
723                 push di
724                 xor cx,cx
725                 mov si,configbuf
726                 mov di,[bx]
727                 mov cl,byte [di]
728                 inc di
729                 call memcmp
730                 pop di
731                 pop si
732                 jnz .not_found
733                 pop cx
734                 call [bx+2] ; call keyword handler
735                 jmp .read
736
737 .not_found:
738                 add bx,4
739                 pop cx
740                 loop .keywords_loop
741
742 .nextline:
743                 call skipline
744                 jmp .read
745
746 .eof:
747 .noparm:
748                 ret
749
750 do_label:
751                 call skipspace
752                 jz .eof
753                 jc .noparm
754                 call ungetc
755                 push es
756                 push di
757                 mov ax,[menu_seg]
758                 mov es,ax
759                 mov di,[menu_off]
760                 call getline
761                 mov di,[menu_off]
762                 add di,512
763                 mov [menu_off],di
764                 pop di
765                 pop es
766                 inc word [label_cnt]
767 .eof:
768 .noparm:
769                 ret
770
771 do_default:
772                 call skipspace
773                 jz .eof
774                 jc .noparm
775                 call ungetc
776                 push es
777                 push di
778                 push cs
779                 pop es
780                 mov di,dentry_buf
781                 call getline
782                 pop di
783                 pop es
784
785 .eof:
786 .noparm:
787                 ret
788
789 skipline:
790                 cmp al,10
791                 je .end
792                 call getc
793                 jc .end
794                 jmp skipline
795 .end:
796                 ret
797
798 skipspace:
799 .loop:
800                 call getc
801                 jc .eof
802                 cmp al,0Ah
803                 je .eoln
804                 cmp al,' '
805                 jbe .loop
806                 ret
807 .eof:
808                 cmp al,al
809                 stc
810                 ret
811 .eoln:
812                 add al,0FFh
813                 ret
814
815 ungetc:
816                 mov byte [ungetc_cnt],1
817                 mov byte [ungetcdata],al
818                 ret
819
820 getc:
821                 cmp byte [ungetc_cnt],1
822                 jne .noungetc
823                 mov byte [ungetc_cnt],0
824                 mov al,[ungetcdata]
825                 clc
826                 ret
827 .noungetc:
828                 sub word [bufbytes],1
829                 jc .get_data
830                 mov si,trackbuf
831                 add si,[bufdata]
832                 mov al,[si]
833                 inc word [bufdata]
834                 clc
835                 ret
836 .get_data:
837                 mov si,[f_handle]
838                 and si,si
839                 jz .empty
840                 mov ax,7
841                 mov bx,trackbuf
842                 mov cx,[BufSafe]
843                 int 22h
844                 mov word [bufdata],0
845                 jc .empty
846                 mov [f_handle],si
847                 mov [bufbytes],cx
848                 jmp getc
849 .empty:
850                 mov word [f_handle],0
851                 mov word [bufbytes],0
852                 stc
853                 ret
854
855 getline:
856                 call skipspace
857                 jz .eof
858                 jc .eoln
859                 call ungetc
860 .loop:
861                 call getc
862                 jc .ret
863                 cmp al,' '
864                 jna .ctrl
865 .store:
866                 stosb
867                 jmp .loop
868 .ctrl:
869                 cmp al,10
870                 je .ret
871                 mov al,' '
872                 jmp .store
873 .eoln:
874                 clc
875                 jmp .ret
876 .eof:
877                 stc
878 .ret:
879                 xor al,al
880                 stosb
881                 ret
882
883
884 memcmp:
885                 push si
886                 push di
887                 push ax
888 .loop:
889                 mov al,[si]
890                 mov ah,[di]
891                 inc si
892                 inc di
893                 cmp al,ah
894                 loope .loop
895                 pop ax
896                 pop di
897                 pop si
898                 ret
899
900                 section .data
901 msg_progname            db 'gfxboot: ',0
902 msg_config_file         db 'Configuration file',0
903 msg_missing             db 'missing',0
904 msg_usage               db 'Usage: gfxboot.com <bootlogo>',0dh,0ah,0
905 msg_memory              db 'Could not detect available memory size',0dh,0ah,0
906 msg_bootlogo_toobig     db 'bootlogo file too big',0dh,0ah,0
907 msg_pxelinux            db 'pxelinux is not supported',0dh,0ah,0
908 msg_unknown_file_size   db 'unknown file size',0dh,0ah,0
909 msg_not_found           db ' not found',0dh,0ah,0
910 msg_no_labels_defined   db 'No labels defined in config file',0dh,0ah,0
911 msg_space               db ' ',0
912 msg_crlf                db 0dh,0ah,0
913
914 gfx_slash               db '/', 0
915 db0                     db 0
916
917 keyword_text_label      db 6,'label',0
918 keyword_text_default    db 7,'default',0
919 keywords                equ $
920                         dw keyword_text_label
921                         dw do_label
922                         dw keyword_text_default
923                         dw do_default
924 keyword_cnt             dw ($-keywords)/4
925
926 ; menu entry descriptor
927 menu_entries            equ 0
928 menu_default            equ 2           ; seg:ofs
929 menu_ent_list           equ 6           ; seg:ofs
930 menu_ent_size           equ 10
931 menu_arg_list           equ 12          ; seg:ofs
932 menu_arg_size           equ 16
933 sizeof_menu_desc        equ 18
934
935 ; system config data (52 bytes)
936 gfx_sysconfig           equ $
937 gfx_bootloader          db 1                    ;  0: boot loader type (0: lilo, 1: syslinux, 2: grub)
938 gfx_sector_shift        db 9                    ;  1: sector shift
939 gfx_media_type          db 0                    ;  2: media type (0: disk, 1: floppy, 2: cdrom)
940 gfx_failsafe            db 0                    ;  3: turn on failsafe mode (bitmask)
941                                                 ;     0: SHIFT pressed
942                                                 ;     1: skip gfxboot
943                                                 ;     2: skip monitor detection
944 gfx_sysconfig_size      db gfx_sysconfig_end-gfx_sysconfig      ;  4: size of sysconfig data
945 gfx_boot_drive          db 0                    ;  5: BIOS boot drive
946 gfx_callback            dw gfx_cb               ;  6: offset to callback handler
947 gfx_bootloader_seg      dw 0                    ;  8: code/data segment used by bootloader; must follow gfx_callback
948 gfx_reserved_1          dw 0                    ; 10
949 gfx_user_info_0         dd 0                    ; 12: data for info box
950 gfx_user_info_1         dd 0                    ; 16: data for info box
951 gfx_bios_mem_size       dd 0                    ; 20: BIOS memory size (in bytes)
952 gfx_xmem_0              dw 0                    ; 24: extended mem area 0 (start:size in MB; 12:4 bits)
953 gfx_xmem_1              dw 0                    ; 26: extended mem area 1
954 gfx_xmem_2              dw 0                    ; 28: extended mem area 2
955 gfx_xmem_3              dw 0                    ; 20: extended mem area 3
956 gfx_file                dd 0                    ; 32: start of gfx file
957 gfx_archive_start       dd 0                    ; 36: start of cpio archive
958 gfx_archive_end         dd 0                    ; 40: end of cpio archive
959 gfx_mem0_start          dd 0                    ; 44: low free memory start
960 gfx_mem0_end            dd 0                    ; 48: low free memory end
961 gfx_sysconfig_end       equ $
962
963                         section .bss align=4096
964 trackbufsize            equ 16384
965 trackbuf                resb trackbufsize
966 configbuf               resb trackbufsize
967
968 dentry_buf              resb 512
969 dentry_buf_len          equ $ - dentry_buf
970
971 max_cmd_len             equ 2047
972 command_line            resb max_cmd_len+2
973
974                         alignb 4
975 derivative_id           resb 1
976 drivenumber             resb 1
977 sectorshift             resb 1
978                         resb 1                  ; Pad
979 sectorsize              resw 1
980 BufSafe                 resw 1
981 file_length             resd 1
982
983 bufbytes                resw 1
984 bufdata                 resw 1
985 ungetc_cnt              resb 1
986 ungetcdata              resb 1
987
988 f_handle                resw 1
989 f_size                  resd 1
990 fname_buf               resb 64
991 fname_buf_len           equ $ - fname_buf
992
993 label_cnt               resw 1
994
995 menu_desc               resb sizeof_menu_desc
996 menu_seg                resw 1
997 menu_off                resw 1
998
999 gfx_mem_start_seg       resw 1
1000 gfx_mem_end_seg         resw 1
1001
1002                         alignb 4
1003 gfx_mem                 resd 1          ; linear address
1004 gfx_save_area1          resd 1          ; 64k
1005 gfx_save_area1_used     resb 1          ; != 0 if area1 is in use
1006
1007                         alignb 4
1008 ; interface to loadable gfx extension (seg:ofs values)
1009 gfx_bc_jt               resd 1
1010
1011 gfx_bc_init             resd 1
1012 gfx_bc_done             resd 1
1013 gfx_bc_input            resd 1
1014 gfx_bc_menu_init        resd 1