1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4 ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin
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
22 ; "default" or "ui" command, with level (1 = default, 2 = ui)
24 pc_default: cmp ax,[DefaultLevel]
25 jb skipline ; == call skipline + ret
29 mov byte [di-1],0 ; null-terminate
35 pc_ontimeout: mov di,Ontimeout
37 sub di,Ontimeout+1 ; Don't need final space
44 pc_onerror: mov di,Onerror
53 pc_append: cmp byte [VKernel],0
58 .app1: mov [AppendLen],di
60 .vk: mov di,VKernelBuf+vk_append ; "append" command (vkernel)
62 sub di,VKernelBuf+vk_append
65 cmp byte [VKernelBuf+vk_append],'-'
67 xor di,di ; If "append -" -> null string
68 .app2: mov [VKernelBuf+vk_appendlen],di
72 ; "ipappend" command (PXELINUX only)
75 pc_ipappend: call getint
81 .vk: mov [VKernelBuf+vk_ipappend],bl
90 pc_localboot: call getint
91 cmp byte [VKernel],0 ; ("label" section only)
93 mov [VKernelBuf+vk_rname],bx
94 mov byte [VKernelBuf+vk_type],VK_LOCALBOOT
97 %endif ; HAS_LOCALBOOT
100 ; "kernel", "config", ... command
102 pc_kernel: cmp byte [VKernel],0
103 je .err ; ("label" section only)
104 mov [VKernelBuf+vk_type],al
106 mov di,VKernelBuf+vk_rname
107 pm_call pm_mangle_name
111 ; "timeout", "totaltimeout" command
113 ; N.B. 1/10 s ~ 1.D2162AABh clock ticks
120 mul ebx ; clock ticks per 1/10 s
127 ; "totaltimeout" command
132 ; Generic integer variable setting commands:
133 ; "prompt", "implicit"
144 ; Generic file-processing commands:
147 pc_filecmd: push ax ; Function to tailcall
150 pm_call pm_mangle_name
153 pop ax ; Drop the successor function
154 .ok: ret ; Tailcall if OK, error return
157 ; Commands that expect the file to be opened on top of the getc stack.
158 ; "display", "include"
160 pc_opencmd: push ax ; Function to tailcall
163 pm_call pm_mangle_name
166 pop ax ; Drop the successor function
167 .ok: ret ; Tailcall if OK, error return
170 ; "include" command (invoked from pc_opencmd)
172 pc_include: inc word [IncludeLevel]
178 pc_serial: call getint
180 push bx ; Serial port #
182 mov [FlowControl],eax ; Default to no flow control
193 call getint ; Hardware flow control?
196 xor bx,bx ; Default -> no flow control
198 and bh,0Fh ; FlowIgnore
202 and bx,0F00Bh ; Valid bits
205 jmp short .parse_baud
207 mov ebx,DEFAULT_BAUD ; No baud rate given
209 pop di ; Serial port #
211 jb .err ; < 75 baud == bogus
216 push ax ; Baud rate divisor
218 ja .port_is_io ; If port > 3 then port is I/O addr
220 mov di,[di+serial_base] ; Get the I/O port from the BIOS
225 ; Begin code to actually set up the serial port
227 call sirq_cleanup_nowipe ; Cleanup existing IRQ handler
229 lea dx,[di+3] ; DX -> LCR
230 mov al,83h ; Enable DLAB
241 mov al,03h ; Disable DLAB
246 in al,dx ; Read back LCR (detect missing hw)
247 cmp al,03h ; If nothing here we'll read 00 or FF
248 jne .err ; Assume serial port busted
249 dec dx ; DX -> IIR/FCR
251 slow_out dx,al ; Enable FIFOs if present
253 cmp al,0C0h ; FIFOs enabled and usable?
255 xor ax,ax ; Disable FIFO if unusable
261 mov al,[FlowOutput] ; Assert bits
264 ; Enable interrupts if requested
271 cmp byte [SerialNotice],0
273 mov byte [SerialNotice],0
275 mov si,syslinux_banner
276 call write_serial_str
278 call write_serial_str
283 mov [SerialPort], word 0
287 ; Store mangled filename command (F-keys, "initrd")
292 pm_call pm_mangle_name ; Mangle file name
298 pc_label: call commit_vk ; Commit any current vkernel
299 mov byte [InitRD+NULLOFFSET],NULLFILE ; No "initrd" statement
300 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
301 mov cx,(vk_size >> 1)
305 mov di,VKernelBuf+vk_vname
306 mov cx,FILENAME_MAX-1
314 mov byte [VKernel],1 ; We've seen a "label" statement
315 mov si,VKernelBuf+vk_vname ; By default, rname == mangled vname
316 mov di,VKernelBuf+vk_rname
317 pm_call pm_mangle_name
318 mov si,AppendBuf ; Default append==global append
319 mov di,VKernelBuf+vk_append
321 mov [VKernelBuf+vk_appendlen],cx
323 %if IS_PXELINUX ; PXELINUX only
324 mov al,[IPAppend] ; Default ipappend==global ipappend
325 mov [VKernelBuf+vk_ipappend],al
332 pc_say: call pc_getline ; "say" command
337 ; "text" command; ignore everything until we get an "endtext" line
339 pc_text: call skipline ; Ignore rest of line
344 ; Leading spaces are already removed...
346 and eax,0xdfdfdfdf ; Upper case
350 and eax,0x00dfdfdf ; Upper case and mask
353 ; If we get here we hit ENDTEXT
360 pc_comment: ; Fall into pc_getline
363 ; Common subroutine: load line into trackbuf; returns with SI -> trackbuf
366 pc_getline: mov di,trackbuf
369 mov byte [di],0 ; Null-terminate
374 ; Main loop for configuration file parsing
377 mov di,VKernelBuf ; Clear VKernelBuf at start
383 call getcommand ; Parse one command
384 jnc .again ; If not EOF...
386 dec word [IncludeLevel] ; Still parsing?
390 ; The fall through to commit_vk to commit any final
394 ; commit_vk: Store the current VKernelBuf into buffer segment
398 jz .nolabel ; Nothing to commit...
400 mov di,VKernelBuf+vk_append
401 add di,[VKernelBuf+vk_appendlen]
403 ; If we have an initrd statement, append it to the
405 cmp byte [InitRD+NULLOFFSET],NULLFILE
413 mov byte [es:di-1],' '
415 ; For better compression, clean up the append field
418 sub ax,VKernelBuf+vk_append
419 mov [VKernelBuf+vk_appendlen],ax
425 ; Pack into high memory
434 mov si,vk_overflow_msg
439 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
440 SerialNotice db 1 ; Only print this once
444 VKernelEnd resd 1 ; Lowest high memory address used
446 ; This symbol should be used by loaders to indicate
447 ; the highest address *they* are allowed to use.
448 HighMemRsvd equ VKernelEnd
452 KbdTimeout dd 0 ; Keyboard timeout (if any)
453 TotalTimeout dd 0 ; Total timeout (if any)
454 AppendLen dw 0 ; Bytes in append= command
455 OntimeoutLen dw 0 ; Bytes in ontimeout command
456 OnerrorLen dw 0 ; Bytes in onerror command
457 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
458 ForcePrompt dw 0 ; Force prompt
459 NoEscape dw 0 ; No escape
460 NoComplete dw 0 ; No label completion on TAB key
461 AllowImplicit dw 1 ; Allow implicit kernels
462 AllowOptions dw 1 ; User-specified options allowed
463 IncludeLevel dw 1 ; Nesting level
464 DefaultLevel dw 0 ; The current level of default
466 PXERetry dw 0 ; Extra PXE retries
467 VKernel db 0 ; Have we seen any "label" statements?
470 IPAppend db 0 ; Default IPAPPEND option
474 alignb 4 ; For the good of REP MOVSD
475 command_line resb max_cmd_len+2 ; Command line buffer
477 default_cmd resb max_cmd_len+1 ; "default" command line