summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2004-12-21 02:15:31 +0000
committerhpa <hpa>2004-12-21 02:15:31 +0000
commit844626c1c81bffcc2ea681c256549520cf1d18ae (patch)
treeeea184da6d8329ffc5d8f8ae8ae00616265cdac2
parent8d6c07657b1bb3c990a38af4132a424e5033d5f2 (diff)
downloadsyslinux-844626c1c81bffcc2ea681c256549520cf1d18ae.tar.gz
Add an API function to get the IPAPPEND strings.
Add a dummy MENU command to specify menu-specific options.
-rw-r--r--com32/modules/readconfig.c88
-rw-r--r--comboot.doc11
-rw-r--r--comboot.inc22
-rw-r--r--keywords1
-rw-r--r--keywords.inc1
-rw-r--r--pxelinux.asm14
6 files changed, 111 insertions, 26 deletions
diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c
index dec0ae52..39d3635d 100644
--- a/com32/modules/readconfig.c
+++ b/com32/modules/readconfig.c
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <minmax.h>
#include <alloca.h>
#ifdef __COM32__
# include <com32.h>
@@ -37,7 +38,31 @@ struct menu_entry menu_entries[MAX_ENTRIES];
char *__p = alloca(__n); \
if ( __p ) memcpy(__p, __x, __n); \
__p; })
+
+const char *ipappends[32];
+static void
+get_ipappend(void)
+{
+#ifdef __COM32__
+ static com32sys_t r;
+ uint16_t *ipp;
+ int i;
+ int nipappends;
+
+ r.eax.w[0] = 0x000F;
+ __intcall(0x22, &r, &r);
+
+ nipappends = min(r.ecx.w[0], 32);
+ ipp = MK_PTR(r.es, r.ebx.w[0]);
+ for ( i = 0 ; i < nipappends ; i++ ) {
+ ipappends[i] = MK_PTR(r.es, *ipp++);
+ }
+#else
+ ipappends[0] = "ip=foo:bar:baz:quux";
+ ipappends[1] = "BOOTIF=01-aa-bb-cc-dd-ee-ff";
+#endif
+}
static const char *
get_config(void)
@@ -82,24 +107,42 @@ static int looking_at(const char *line, const char *kwd)
return *p <= ' '; /* Must be EOL or whitespace */
}
-static void record(char *label, char *lkernel, char *lappend, char *append)
+struct labeldata {
+ char *label;
+ char *kernel;
+ char *append;
+ unsigned int ipappend;
+};
+
+static void record(struct labeldata *ld, char *append)
{
- if ( label ) {
+ char ipoptions[256], *ipp;
+ int i;
+
+ if ( ld->label ) {
char *a, *s;
- menu_entries[nentries].displayname = label;
- a = lappend;
+ menu_entries[nentries].displayname = ld->label;
+
+ ipp = ipoptions;
+ *ipp = '\0';
+ for ( i = 0 ; i < 32 ; i++ ) {
+ if ( (ld->ipappend & (1U << i)) && ipappends[i] )
+ ipp += sprintf(ipp, " %s", ipappends[i]);
+ }
+
+ a = ld->append;
if ( !a ) a = append;
if ( !a || (a[0] == '-' && !a[1]) ) a = "";
s = a[0] ? " " : "";
- asprintf(&menu_entries[nentries].cmdline, "%s%s%s", lkernel, s, a);
+ asprintf(&menu_entries[nentries].cmdline, "%s%s%s%s", ld->kernel, ipoptions, s, a);
printf("displayname: %s\n", menu_entries[nentries].displayname);
printf("cmdline: %s\n", menu_entries[nentries].cmdline);
- label = NULL;
- free(lkernel);
- if ( lappend )
- free(lappend);
+ ld->label = NULL;
+ free(ld->kernel);
+ if ( ld->append )
+ free(ld->append);
nentries++;
}
}
@@ -109,7 +152,9 @@ void parse_config(const char *filename)
char line[MAX_LINE], *p;
FILE *f;
char *append = NULL;
- char *label = NULL, *lkernel = NULL, *lappend = NULL;
+ static struct labeldata ld;
+
+ get_ipappend();
if ( !filename )
filename = get_config();
@@ -141,20 +186,21 @@ void parse_config(const char *filename)
}
} else if ( looking_at(p, "append") ) {
char *a = strdup(skipspace(p+6));
- if ( label )
- lappend = a;
+ if ( ld.label )
+ ld.append = a;
else
append = a;
} else if ( looking_at(p, "label") ) {
p = skipspace(p+5);
- record(label, lkernel, lappend, append);
- label = strdup(p);
- lkernel = strdup(p);
- lappend = NULL;
+ record(&ld, append);
+ ld.label = strdup(p);
+ ld.kernel = strdup(p);
+ ld.append = NULL;
+ ld.ipappend = 0;
} else if ( looking_at(p, "kernel") ) {
- if ( label ) {
- free(lkernel);
- lkernel = strdup(skipspace(p+6));
+ if ( ld.label ) {
+ free(ld.kernel);
+ ld.kernel = strdup(skipspace(p+6));
}
} else if ( looking_at(p, "timeout") ) {
timeout = atoi(skipspace(p+7));
@@ -162,9 +208,11 @@ void parse_config(const char *filename)
ontimeout = strdup(skipspace(p+9));
} else if ( looking_at(p, "allowoptions") ) {
allowedit = atoi(skipspace(p+12));
+ } else if ( looking_at(p, "ipappend") ) {
+ ld.ipappend = atoi(skipspace(p+8));
}
}
- record(label, lkernel, lappend, append);
+ record(&ld, append);
fclose(f);
}
diff --git a/comboot.doc b/comboot.doc
index 3426cd8d..70c553d7 100644
--- a/comboot.doc
+++ b/comboot.doc
@@ -486,3 +486,14 @@ AX=000Eh [2.11] Get configuration file name
Returns the name of the configuration file. Note that it is
possible that the configuration file doesn't actually exist.
+AX=000Fh [2.20] Get IPAPPEND strings [PXELINUX]
+ Input: AX 000Fh
+ Output: CX Number of strings (currently 2)
+ ES:BX Pointer to an array of NEAR pointers in
+ the same segment, one for each of the above
+ strings.
+
+ Returns the same strings that the "ipappend" option would have
+ added to the command line, one for each bit of the "ipappend"
+ flag value, so entry 0 is the "ip=" string and entry 1 is the
+ "BOOTIF=" string.
diff --git a/comboot.inc b/comboot.inc
index 00d603c2..9851abe0 100644
--- a/comboot.inc
+++ b/comboot.inc
@@ -563,6 +563,27 @@ comapi_configfile:
clc
ret
+;
+; INT 22h AX=000Fh Get IPAPPEND strings
+;
+%if IS_PXELINUX
+comapi_ipappend:
+ mov P_ES,cs
+ mov P_CX,numIPAppends
+ mov P_BX,IPAppends
+ clc
+ ret
+
+ section .data
+ alignb 2, db 0
+IPAppends dw IPOption
+ dw BOOTIFStr
+numIPAppends equ ($-IPAppends)/2
+
+%else
+comboot_ipappend equ comapi_err
+%endif
+
section .bss
SavedSSSP resd 1 ; Our SS:SP while running a COMBOOT image
@@ -602,6 +623,7 @@ int22_table:
dw comapi_cleanup ; 000C perform final cleanup
dw comapi_chainboot ; 000D clean up then bootstrap
dw comapi_configfile ; 000E get name of config file
+ dw comapi_ipappend ; 000F get ipappend strings
int22_count equ ($-int22_table)/2
APIKeyWait db 0
diff --git a/keywords b/keywords
index 2287c824..2f0ae4f5 100644
--- a/keywords
+++ b/keywords
@@ -1,4 +1,5 @@
# hash
+menu
append
default
display
diff --git a/keywords.inc b/keywords.inc
index b8a2ff20..5fa547d8 100644
--- a/keywords.inc
+++ b/keywords.inc
@@ -45,6 +45,7 @@ keywd_size equ 8 ; Bytes per keyword
keywd_table:
keyword hash, pc_comment
+ keyword menu, pc_comment
keyword append, pc_append
keyword default, pc_default
keyword display, pc_filecmd, get_msg_file
diff --git a/pxelinux.asm b/pxelinux.asm
index c8108d26..4763670b 100644
--- a/pxelinux.asm
+++ b/pxelinux.asm
@@ -209,6 +209,7 @@ OverLoad resb 1 ; Set if DHCP packet uses "overloading"
MACLen resb 1 ; MAC address len
MACType resb 1 ; MAC address type
MAC resb 16 ; Actual MAC address
+BOOTIFStr resb 7 ; Space for "BOOTIF="
MACStr resb 3*17 ; MAC address as a string
;
@@ -550,10 +551,14 @@ query_bootp:
sub cx,di
xor ax,ax
rep stosb
- pop cx
+ mov si,bootif_str
+ mov di,BOOTIFStr
+ mov cx,bootif_str_len
+ rep movsb
+
+ pop cx
mov si,MACType
- mov di,MACStr
inc cx
mov bx,hextbl_lower
.hexify_mac:
@@ -819,10 +824,7 @@ config_scan:
.noipappend1:
test byte [IPAppend],02h
jz .noipappend2
- mov si,bootif_str
- mov cx,bootif_str_len
- rep movsb
- mov si,MACStr
+ mov si,BOOTIFStr
call strcpy
mov byte [es:di-1],' ' ; Replace null with space
.noipappend2: