|
;; $Id: parsecmd.inc,v 1.1 2007-09-01 22:44:05 niro Exp $ |
|
1 |
;; ----------------------------------------------------------------------- |
;; ----------------------------------------------------------------------- |
2 |
;; |
;; |
3 |
;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved |
;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved |
4 |
|
;; Copyright 2009 Intel Corporation; author: H. Peter Anvin |
5 |
;; |
;; |
6 |
;; This program is free software; you can redistribute it and/or modify |
;; 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 |
;; it under the terms of the GNU General Public License as published by |
30 |
; with CF = 1. |
; with CF = 1. |
31 |
; ------------------------------------------------------------------------- |
; ------------------------------------------------------------------------- |
32 |
|
|
33 |
|
getcommand.skipline: |
34 |
|
call skipline |
35 |
|
|
36 |
getcommand: |
getcommand: |
37 |
.find: |
.find: |
38 |
call skipspace ; Skip leading whitespace |
call skipspace ; Skip leading whitespace |
43 |
cmp al,'#' ; Leading hash mark -> comment |
cmp al,'#' ; Leading hash mark -> comment |
44 |
je .skipline |
je .skipline |
45 |
|
|
46 |
|
; Abuse the trackbuf by putting the keyword there for |
47 |
|
; possible error messaging... |
48 |
|
mov di,trackbuf |
49 |
|
stosb |
50 |
or al,20h ; Convert to lower case |
or al,20h ; Convert to lower case |
51 |
movzx ebx,al ; Hash for a one-char keyword |
movzx ebx,al ; Hash for a one-char keyword |
52 |
.read_loop: |
.read_loop: |
|
push ebx |
|
53 |
call getc |
call getc |
|
pop ebx |
|
54 |
jc .eof |
jc .eof |
55 |
cmp al,' ' ; Whitespace |
cmp al,' ' ; Whitespace |
56 |
jbe .done |
jbe .done |
57 |
|
stosb |
58 |
or al,20h |
or al,20h |
59 |
rol ebx,5 |
rol ebx,5 |
60 |
xor bl,al |
xor bl,al |
61 |
jmp short .read_loop |
jmp short .read_loop |
62 |
.done: call ungetc |
.done: call ungetc |
63 |
|
xor ax,ax |
64 |
|
stosb ; Null-terminate the trackbuf |
65 |
call skipspace |
call skipspace |
66 |
jz .eof |
jz .eof |
67 |
jc .noparm |
jc .noparm |
77 |
|
|
78 |
; Otherwise unrecognized keyword |
; Otherwise unrecognized keyword |
79 |
mov si,err_badcfg |
mov si,err_badcfg |
80 |
jmp short .error |
call writestr |
81 |
|
mov si,trackbuf |
82 |
|
call writestr |
83 |
|
call crlf |
84 |
|
jmp .skipline |
85 |
|
|
86 |
; No parameter |
; No parameter |
87 |
.noparm: |
.noparm: |
88 |
mov si,err_noparm |
mov si,err_noparm |
89 |
mov al,10 ; Already at EOL |
call writestr |
90 |
.error: |
mov si,trackbuf |
91 |
call cwritestr |
call writestr |
92 |
jmp short .skipline |
call crlf |
93 |
|
jmp .find |
94 |
|
|
95 |
.found_keywd: lodsw ; Load argument into ax |
.found_keywd: lodsw ; Load argument into ax |
96 |
call [si] |
call [si] |
100 |
.eof: stc |
.eof: stc |
101 |
ret |
ret |
102 |
|
|
103 |
.skipline: cmp al,10 ; Search for LF |
skipline: cmp al,10 ; Search for LF |
104 |
je .find |
je .end |
105 |
call getc |
call getc |
106 |
jc .eof |
jnc skipline |
107 |
jmp short .skipline |
.end: ret |
108 |
|
|
109 |
|
section .data |
110 |
|
err_badcfg db 'Unknown keyword in configuration file: ',0 |
111 |
|
err_noparm db 'Missing parameter in configuration file. Keyword: ',0 |
112 |
|
|
113 |
section .latebss |
section .uibss |
114 |
alignb 4 |
alignb 4 |
115 |
vk_size equ (vk_end + 3) & ~3 |
vk_size equ (vk_end + 3) & ~3 |
116 |
VKernelBuf: resb vk_size ; "Current" vkernel |
VKernelBuf: resb vk_size ; "Current" vkernel |
117 |
AppendBuf resb max_cmd_len+1 ; append= |
AppendBuf resb max_cmd_len+1 ; append= |
118 |
Ontimeout resb max_cmd_len+1 ; ontimeout |
Ontimeout resb max_cmd_len+1 ; ontimeout |
119 |
Onerror resb max_cmd_len+1 ; onerror |
Onerror resb max_cmd_len+1 ; onerror |
120 |
|
; This could be in .uibss but that makes PXELINUX overflow |
121 |
|
section .bss |
122 |
KbdMap resb 256 ; Keyboard map |
KbdMap resb 256 ; Keyboard map |
123 |
FKeyName resb 10*FILENAME_MAX ; File names for F-key help |
FKeyName resb MAX_FKEYS*FILENAME_MAX ; File names for F-key help |
124 |
KernelCNameLen resw 1 ; Length of unmangled kernel name |
KernelCNameLen resw 1 ; Length of unmangled kernel name |
125 |
InitRDCNameLen resw 1 ; Length of unmangled initrd name |
InitRDCNameLen resw 1 ; Length of unmangled initrd name |
126 |
%if IS_SYSLINUX |
%if IS_SYSLINUX |