aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@localhost.localdomain>2009-07-27 15:52:39 +0800
committerroot <root@localhost.localdomain>2009-07-27 15:52:39 +0800
commit7c381cc0b8d4ff3431b40aafddaefbfbb9b6eeb8 (patch)
treecf59b0a3b07a14ca2f5069ccec923a6b26127e84
parent48bd1ee59aaf764a359e17c995b37ba5439a832a (diff)
downloadpxelinux-7c381cc0b8d4ff3431b40aafddaefbfbb9b6eeb8.tar.gz
pxelinux-7c381cc0b8d4ff3431b40aafddaefbfbb9b6eeb8.tar.xz
pxelinux-7c381cc0b8d4ff3431b40aafddaefbfbb9b6eeb8.zip
Core:PXELINUX: get_prefix converted
-rw-r--r--core/comboot.inc2
-rw-r--r--core/debug.c3
-rw-r--r--core/extern.inc2
-rw-r--r--core/pxe.c46
-rw-r--r--core/pxelinux.asm44
5 files changed, 51 insertions, 46 deletions
diff --git a/core/comboot.inc b/core/comboot.inc
index 5c9ffc87..5a3d149f 100644
--- a/core/comboot.inc
+++ b/core/comboot.inc
@@ -1049,7 +1049,7 @@ err_notdos db ': attempted DOS system call INT ',0
err_comlarge db 'COMBOOT image too large.', CR, LF, 0
section .bss16
- global ConfigName
+ global ConfigName, CurrentDirName
alignb 4
DOSErrTramp resd 33 ; Error trampolines
ConfigName resb FILENAME_MAX
diff --git a/core/debug.c b/core/debug.c
index eef453d0..dde42e77 100644
--- a/core/debug.c
+++ b/core/debug.c
@@ -3,7 +3,8 @@
void debug(void)
{
- printf("go there?\n");for(;;);
+ extern char BootFile[];
+ printf("Boot file name: %s\n",BootFile);
}
diff --git a/core/extern.inc b/core/extern.inc
index 53aed715..a9d81767 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -17,7 +17,7 @@
extern memory_scan_for_pxe_struct, memory_scan_for_pxenv_struct
extern gendotquad, pxe_load_config, try_load, allocate_socket
extern free_socket, ip_ok, mangle_name, ack_packet, pxe_get_cached_info
- extern udp_init
+ extern udp_init, get_prefix
; debug.c
extern debug, print_reg
diff --git a/core/pxe.c b/core/pxe.c
index 84f5fcb1..5262453b 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -61,11 +61,17 @@ extern uint32_t MyIP;
extern uint32_t Netmask;
extern uint32_t Gateway;
+extern uint8_t DHCPMagic;
+
+
/* TFTP ACK packet */
extern uint16_t ack_packet_buf[];
extern void kaboom();
extern char trackbuf[];
+extern char BootFile[];
+extern char PathPrefix[];
+extern char CurrentDirName[];
char *err_nopxe = "No !PXE or PXENV+ API found; we're dead...\n";
char *err_pxefailed = "PXE API call failed, error ";
@@ -73,6 +79,8 @@ char *err_udpinit = "Failed to initialize UDP stack\n";
char *err_noconfig = "Unable to locate configuration file\n";
char *err_damage = "TFTP server sent an incomprehesible reply\n";
+char *tftpprefix_msg = "TFTP prefix: ";
+
uint16_t NextSocket = 49152;
@@ -494,7 +502,6 @@ void pxe_load_config(com32sys_t *regs)
extern char ConfigName[FILENAME_MAX];
extern char UUID[];
extern char MACStr[];
- extern uint8_t DHCPMagic;
extern void no_config();
char *cfgprefix = "pxelinux.cfg/";
char *default_str = "default";
@@ -762,3 +769,40 @@ void udp_init()
}
+/*
+ * Store standard filename prefix
+ */
+void get_prefix()
+{
+ int len;
+ char *p;
+ char c;
+
+ if (DHCPMagic & 0x04) /* Did we get a path prefix option */
+ goto got_prefix;
+
+ strcpy(PathPrefix, BootFile);
+ len = strlen(PathPrefix);
+ p = &PathPrefix[len - 1];
+
+ while (len--) {
+ c = *p--;
+ c |= 0x20;
+
+ c = (c >= '0' && c <= '9') ||
+ (c >= 'a' && c <= 'z') ||
+ (c == '.' || c == '-');
+ if (!c)
+ break;
+ };
+
+ if (len < 0)
+ p --;
+
+ *(p + 2) = 0; /* Zero-terminate after delimiter */
+
+ got_prefix:
+ printf("%s%s\n", tftpprefix_msg, PathPrefix);
+ strcpy(CurrentDirName, PathPrefix);
+}
+
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 167a06a2..7017cf51 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -172,6 +172,7 @@ trackbuf resb trackbufsize ; Track buffer goes here
Files resb MAX_OPEN*open_file_t_size
alignb FILENAME_MAX
+ global BootFile, PathPrefix
BootFile resb 256 ; Boot file from DHCP packet
PathPrefix resb 256 ; Path prefix derived from boot file
DotQuadBuf resb 16 ; Buffer for dotted-quad IP address
@@ -622,48 +623,7 @@ check_dhcp_magic:
;
; Store standard filename prefix
;
-prefix: test byte [DHCPMagic], 04h ; Did we get a path prefix option
- jnz .got_prefix
- mov si,BootFile
- mov di,PathPrefix
- cld
- call strcpy
- mov cx,di
- sub cx,PathPrefix+1
- std
- lea si,[di-2] ; Skip final null!
-.find_alnum: lodsb
- or al,20h
- cmp al,'.' ; Count . or - as alphanum
- je .alnum
- cmp al,'-'
- je .alnum
- cmp al,'0'
- jb .notalnum
- cmp al,'9'
- jbe .alnum
- cmp al,'a'
- jb .notalnum
- cmp al,'z'
- ja .notalnum
-.alnum: loop .find_alnum
- dec si
-.notalnum: mov byte [si+2],0 ; Zero-terminate after delimiter
- cld
-.got_prefix:
- mov si,tftpprefix_msg
- call writestr_early
- mov si,PathPrefix
- call writestr_early
- call crlf
-
- ; Set CurrentDirName
- push di
- mov si,PathPrefix
- mov di,CurrentDirName
- call strcpy
- pop di
-
+ pm_call get_prefix
;
; Load configuration file
;