2 ;; -----------------------------------------------------------------------
4 ;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
6 ;; This program is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
10 ;; (at your option) any later version; incorporated herein by reference.
12 ;; -----------------------------------------------------------------------
17 ;; Configuration file operations
24 pc_default: mov di,default_cmd
26 mov byte [di-1],0 ; null-terminate
32 pc_ontimeout: mov di,Ontimeout
34 sub di,Ontimeout+1 ; Don't need final space
41 pc_onerror: mov di,Onerror
50 pc_append: cmp byte [VKernel],0
55 .app1: mov [AppendLen],di
57 .vk: mov di,VKernelBuf+vk_append ; "append" command (vkernel)
59 sub di,VKernelBuf+vk_append
62 cmp byte [VKernelBuf+vk_append],'-'
64 xor di,di ; If "append -" -> null string
65 .app2: mov [VKernelBuf+vk_appendlen],di
69 ; "ipappend" command (PXELINUX only)
72 pc_ipappend: call getint
78 .vk: mov [VKernelBuf+vk_ipappend],bl
83 ; "localboot" command (PXELINUX, ISOLINUX)
85 %if IS_PXELINUX || IS_ISOLINUX
86 pc_localboot: call getint
87 cmp byte [VKernel],0 ; ("label" section only)
89 mov di,VKernelBuf+vk_rname
92 rep stosb ; Null kernel name
94 ; PXELINUX uses the first 4 bytes of vk_rname for the
96 mov [VKernelBuf+vk_rname+5], bx ; Return type
98 mov [VKernelBuf+vk_rname+1], bx ; Return type
105 pc_kernel: cmp byte [VKernel],0
106 je .err ; ("label" section only)
108 mov di,VKernelBuf+vk_rname
113 ; "timeout", "totaltimeout" command
115 ; N.B. 1/10 s ~ 1.D2162AABh clock ticks
122 mul ebx ; clock ticks per 1/10 s
129 ; "totaltimeout" command
134 ; Generic integer variable setting commands:
135 ; "prompt", "implicit"
146 ; Generic file-processing commands:
147 ; "display", "font", "kbdmap"
149 pc_filecmd: push ax ; Function to tailcall
155 call searchdir ; tailcall
157 pop ax ; Drop the successor function
158 .ok: ret ; Tailcall if OK, error return
163 pc_serial: call getint
165 push bx ; Serial port #
173 mov [FlowControl], word 0 ; Default to no flow control
180 call getint ; Hardware flow control?
183 xor bx,bx ; Default -> no flow control
185 and bh,0Fh ; FlowIgnore
189 and bx,0F003h ; Valid bits
192 jmp short .parse_baud
194 mov ebx,DEFAULT_BAUD ; No baud rate given
196 pop di ; Serial port #
198 jb .err ; < 75 baud == bogus
203 push ax ; Baud rate divisor
205 ja .port_is_io ; If port > 3 then port is I/O addr
207 mov di,[di+serial_base] ; Get the I/O port from the BIOS
212 ; Begin code to actually set up the serial port
214 lea dx,[di+3] ; DX -> LCR
215 mov al,83h ; Enable DLAB
226 mov al,03h ; Disable DLAB
231 in al,dx ; Read back LCR (detect missing hw)
232 cmp al,03h ; If nothing here we'll read 00 or FF
233 jne .serial_port_bad ; Assume serial port busted
236 xor al,al ; IRQ disable
239 inc dx ; DX -> FCR/IIR
241 call slow_out ; Enable FIFOs if present
243 cmp al,0C0h ; FIFOs enabled and usable?
245 xor ax,ax ; Disable FIFO if unusable
252 or al,[FlowOutput] ; Assert bits
256 mov si,syslinux_banner
257 call write_serial_str
259 call write_serial_str
263 mov [SerialPort], word 0
272 call mangle_name ; Mangle file name
278 pc_label: call commit_vk ; Commit any current vkernel
279 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
280 mov cx,(vk_size >> 1)
284 mov di,VKernelBuf+vk_vname
285 call mangle_name ; Mangle virtual name
286 mov byte [VKernel],1 ; We've seen a "label" statement
287 mov si,VKernelBuf+vk_vname ; By default, rname == vname
288 mov di,VKernelBuf+vk_rname
291 mov si,AppendBuf ; Default append==global append
292 mov di,VKernelBuf+vk_append
294 mov [VKernelBuf+vk_appendlen],cx
296 %if IS_PXELINUX ; PXELINUX only
297 mov al,[IPAppend] ; Default ipappend==global ipappend
298 mov [VKernelBuf+vk_ipappend],al
305 pc_say: call pc_getline ; "say" command
312 pc_comment: ; Fall into pc_getline
315 ; Common subroutine: load line into trackbuf; returns with SI -> trackbuf
317 pc_getline: mov di,trackbuf
321 stosb ; Null-terminate
326 ; Main loop for configuration file parsing
329 mov di,VKernelBuf ; Clear VKernelBuf at start
335 jnc .again ; If not EOF do it again
337 ; The fall through to commit_vk to commit any final
341 ; commit_vk: Store the current VKernelBuf into buffer segment
344 ; For better compression, clean up the append field
345 mov ax,[VKernelBuf+vk_appendlen]
346 mov di,VKernelBuf+vk_append
353 ; Pack temporarily into trackbuf
358 ; Now DX = number of bytes
359 mov di,[VKernelBytes]
362 jc .overflow ; If > 1 segment
363 mov [VKernelBytes],dx
372 mov si,vk_overflow_msg
377 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
380 KbdTimeout dd 0 ; Keyboard timeout (if any)
381 TotalTimeout dd 0 ; Total timeout (if any)
382 AppendLen dw 0 ; Bytes in append= command
383 OntimeoutLen dw 0 ; Bytes in ontimeout command
384 OnerrorLen dw 0 ; Bytes in onerror command
385 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
386 ForcePrompt dw 0 ; Force prompt
387 NoEscape dw 0 ; No escape
388 AllowImplicit dw 1 ; Allow implicit kernels
389 AllowOptions dw 1 ; User-specified options allowed
390 SerialPort dw 0 ; Serial port base (or 0 for no serial port)
391 VKernelBytes dw 0 ; Number of bytes used by vkernels
392 VKernel db 0 ; Have we seen any "label" statements?
395 alignb 4 ; For the good of REP MOVSD
396 command_line resb max_cmd_len+2 ; Command line buffer
398 default_cmd resb max_cmd_len+1 ; "default" command line
400 %include "rllpack.inc"