1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2007 H. Peter Anvin - All Rights Reserved
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
9 ;; (at your option) any later version; incorporated herein by reference.
11 ;; -----------------------------------------------------------------------
16 ;; Configuration file operations
23 pc_default: mov di,default_cmd
25 mov byte [di-1],0 ; null-terminate
31 pc_ontimeout: mov di,Ontimeout
33 sub di,Ontimeout+1 ; Don't need final space
40 pc_onerror: mov di,Onerror
49 pc_append: cmp byte [VKernel],0
54 .app1: mov [AppendLen],di
56 .vk: mov di,VKernelBuf+vk_append ; "append" command (vkernel)
58 sub di,VKernelBuf+vk_append
61 cmp byte [VKernelBuf+vk_append],'-'
63 xor di,di ; If "append -" -> null string
64 .app2: mov [VKernelBuf+vk_appendlen],di
68 ; "ipappend" command (PXELINUX only)
71 pc_ipappend: call getint
77 .vk: mov [VKernelBuf+vk_ipappend],bl
82 ; "localboot" command (PXELINUX, ISOLINUX)
84 %if IS_PXELINUX || IS_ISOLINUX
85 pc_localboot: call getint
86 cmp byte [VKernel],0 ; ("label" section only)
88 mov di,VKernelBuf+vk_rname
91 rep stosb ; Null kernel name
93 ; PXELINUX uses the first 4 bytes of vk_rname for the
95 mov [VKernelBuf+vk_rname+5], bx ; Return type
97 mov [VKernelBuf+vk_rname+1], bx ; Return type
103 ; "kernel", "config", ... command
105 pc_kernel: cmp byte [VKernel],0
106 je .err ; ("label" section only)
107 mov [VKernelBuf+vk_type],al
109 mov di,VKernelBuf+vk_rname
114 ; "timeout", "totaltimeout" command
116 ; N.B. 1/10 s ~ 1.D2162AABh clock ticks
123 mul ebx ; clock ticks per 1/10 s
130 ; "totaltimeout" command
135 ; Generic integer variable setting commands:
136 ; "prompt", "implicit"
147 ; Generic file-processing commands:
148 ; "display", "font", "kbdmap", "include"
150 pc_filecmd: push ax ; Function to tailcall
154 call searchdir ; tailcall
156 pop ax ; Drop the successor function
157 .ok: ret ; Tailcall if OK, error return
160 ; "include" command (invoked from pc_filecmd)
162 pc_include: call openfd
164 inc word [IncludeLevel]
170 pc_serial: call getint
172 push bx ; Serial port #
180 mov [FlowControl], word 0 ; Default to no flow control
187 call getint ; Hardware flow control?
190 xor bx,bx ; Default -> no flow control
192 and bh,0Fh ; FlowIgnore
196 and bx,0F003h ; Valid bits
199 jmp short .parse_baud
201 mov ebx,DEFAULT_BAUD ; No baud rate given
203 pop di ; Serial port #
205 jb .err ; < 75 baud == bogus
210 push ax ; Baud rate divisor
212 ja .port_is_io ; If port > 3 then port is I/O addr
214 mov di,[di+serial_base] ; Get the I/O port from the BIOS
219 ; Begin code to actually set up the serial port
221 lea dx,[di+3] ; DX -> LCR
222 mov al,83h ; Enable DLAB
233 mov al,03h ; Disable DLAB
238 in al,dx ; Read back LCR (detect missing hw)
239 cmp al,03h ; If nothing here we'll read 00 or FF
240 jne .serial_port_bad ; Assume serial port busted
243 xor al,al ; IRQ disable
246 inc dx ; DX -> FCR/IIR
248 call slow_out ; Enable FIFOs if present
250 cmp al,0C0h ; FIFOs enabled and usable?
252 xor ax,ax ; Disable FIFO if unusable
259 or al,[FlowOutput] ; Assert bits
263 cmp byte [SerialNotice],0
265 mov byte [SerialNotice],0
267 mov si,syslinux_banner
268 call write_serial_str
270 call write_serial_str
275 mov [SerialPort], word 0
284 call mangle_name ; Mangle file name
290 pc_label: call commit_vk ; Commit any current vkernel
291 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
292 mov cx,(vk_size >> 1)
296 mov di,VKernelBuf+vk_vname
297 call mangle_name ; Mangle virtual name
298 mov byte [VKernel],1 ; We've seen a "label" statement
299 mov si,VKernelBuf+vk_vname ; By default, rname == vname
300 ; mov di,VKernelBuf+vk_rname ; -- already set
303 mov si,AppendBuf ; Default append==global append
304 mov di,VKernelBuf+vk_append
306 mov [VKernelBuf+vk_appendlen],cx
308 %if IS_PXELINUX ; PXELINUX only
309 mov al,[IPAppend] ; Default ipappend==global ipappend
310 mov [VKernelBuf+vk_ipappend],al
317 pc_say: call pc_getline ; "say" command
322 ; "text" command; ignore everything until we get an "endtext" line
324 pc_text: call pc_getline ; Ignore rest of line
329 ; Leading spaces are already removed...
331 and eax,0xdfdfdfdf ; Upper case
335 and eax,0x00dfdfdf ; Upper case and mask
338 ; If we get here we hit ENDTEXT
345 pc_comment: ; Fall into pc_getline
348 ; Common subroutine: load line into trackbuf; returns with SI -> trackbuf
351 pc_getline: mov di,trackbuf
354 mov byte [di],0 ; Null-terminate
359 ; Main loop for configuration file parsing
362 mov di,VKernelBuf ; Clear VKernelBuf at start
368 call getcommand ; Parse one command
369 jnc .again ; If not EOF...
371 dec word [IncludeLevel] ; Still parsing?
375 ; The fall through to commit_vk to commit any final
379 ; commit_vk: Store the current VKernelBuf into buffer segment
382 ; For better compression, clean up the append field
383 mov ax,[VKernelBuf+vk_appendlen]
384 mov di,VKernelBuf+vk_append
391 ; Pack temporarily into trackbuf
396 ; Now DX = number of bytes
397 mov di,[VKernelBytes]
400 jc .overflow ; If > 1 segment
401 mov [VKernelBytes],dx
410 mov si,vk_overflow_msg
415 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
416 SerialNotice db 1 ; Only print this once
420 KbdTimeout dd 0 ; Keyboard timeout (if any)
421 TotalTimeout dd 0 ; Total timeout (if any)
422 AppendLen dw 0 ; Bytes in append= command
423 OntimeoutLen dw 0 ; Bytes in ontimeout command
424 OnerrorLen dw 0 ; Bytes in onerror command
425 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
426 ForcePrompt dw 0 ; Force prompt
427 NoEscape dw 0 ; No escape
428 AllowImplicit dw 1 ; Allow implicit kernels
429 AllowOptions dw 1 ; User-specified options allowed
430 IncludeLevel dw 1 ; Nesting level
431 SerialPort dw 0 ; Serial port base (or 0 for no serial port)
432 VKernelBytes dw 0 ; Number of bytes used by vkernels
433 VKernel db 0 ; Have we seen any "label" statements?
436 IPAppend db 0 ; Default IPAPPEND option
440 alignb 4 ; For the good of REP MOVSD
441 command_line resb max_cmd_len+2 ; Command line buffer
443 default_cmd resb max_cmd_len+1 ; "default" command line
445 %include "rllpack.inc"