From 5d7d50a01de8282a0e910beb0a9f151e526dcb62 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 10 Aug 2009 17:30:25 -0700 Subject: core: remove assembly definition of Files in iso/pxelinux Remove the assembly definition of Files in isolinux and pxelinux. Still to do: remove dependencies on Files living in .bss16 space. Signed-off-by: H. Peter Anvin --- core/include/pxe.h | 4 +++- core/init.inc | 13 ----------- core/isolinux.asm | 5 ---- core/ldlinux.asm | 2 +- core/pxe.c | 67 +++++++++++++++++++++++++++++++----------------------- core/pxelinux.asm | 4 ---- 6 files changed, 42 insertions(+), 53 deletions(-) diff --git a/core/include/pxe.h b/core/include/pxe.h index 76fcf14a..06cea0a3 100644 --- a/core/include/pxe.h +++ b/core/include/pxe.h @@ -234,7 +234,9 @@ struct open_file_t { uint16_t tftp_lastpkt; /* Sequence number of last packet (NBO) */ uint16_t tftp_dataptr; /* Pointer to available data */ uint8_t tftp_goteof; /* 1 if the EOF packet received */ - uint8_t tftp_unused[3]; /* Currently unused */ + uint8_t tftp_unused; /* Currently unused */ + /* These values are preinitialized and not zeroed on close */ + uint16_t tftp_nextport; /* Next port number for this slot (HBO) */ uint16_t tftp_pktbuf; /* Packet buffer offset */ } __attribute__ ((packed)); diff --git a/core/init.inc b/core/init.inc index ec8c7b3b..5617a697 100644 --- a/core/init.inc +++ b/core/init.inc @@ -33,19 +33,6 @@ common_init: ; call reset_config -; -; Initialize Files structures (other than zeroing) -; -%if IS_PXELINUX - mov di,Files+tftp_pktbuf - mov cx,MAX_OPEN -.setbufptr: - mov [di],ax - add di,open_file_t_size - add ax,PKTBUF_SIZE - loop .setbufptr -%endif - ; ; Set up the COMBOOT APIs ; diff --git a/core/isolinux.asm b/core/isolinux.asm index 21e74740..91541bc6 100644 --- a/core/isolinux.asm +++ b/core/isolinux.asm @@ -191,11 +191,6 @@ dsp_dummy: resb 1 ; Scratch, safe to overwrite _spec_end equ $ _spec_len equ _spec_end - _spec_start - section .bss16 - global Files - alignb open_file_t_size -Files resb MAX_OPEN*open_file_t_size - section .init ;; ;; Primary entry point. Because BIOSes are buggy, we only load the first diff --git a/core/ldlinux.asm b/core/ldlinux.asm index b8b86b2e..f57b2390 100644 --- a/core/ldlinux.asm +++ b/core/ldlinux.asm @@ -29,7 +29,7 @@ ; Some semi-configurable constants... change on your own risk. ; my_id equ syslinux_id -FILENAME_MAX_LG2 equ 6 ; log2(Max filename size Including final null) +FILENAME_MAX_LG2 equ 8 ; log2(Max filename size Including final null) extern vfat_fs_ops ROOT_FS_OPS equ vfat_fs_ops diff --git a/core/pxe.c b/core/pxe.c index f4e872e8..f4afc087 100644 --- a/core/pxe.c +++ b/core/pxe.c @@ -24,8 +24,6 @@ static char *err_udpinit = "Failed to initialize UDP stack\n"; static char *tftpprefix_msg = "TFTP prefix: "; static char *get_packet_msg = "Getting cached packet "; -static uint16_t NextSocket = 49152; - static int has_gpxe; static uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0}; int HaveUUID = 0; @@ -44,7 +42,24 @@ static int blksize_len = 8; static char *asciidec = "1408"; - +/* + * Initialize the Files structure + */ +static void files_init(void) +{ + int i; + struct open_file_t *socket = Files; + uint16_t pktbuf = 0; + uint16_t nextport = 49152; + + for (i = 0; i < MAX_OPEN; i++) { + socket->tftp_pktbuf = pktbuf; + socket->tftp_nextport = nextport; + pktbuf += PKTBUF_SIZE; + nextport++; + socket++; + } +} /* * Allocate a local UDP port structure. @@ -53,37 +68,28 @@ static char *asciidec = "1408"; */ static struct open_file_t *allocate_socket(void) { - extern uint16_t NextSocket; - uint16_t i = MAX_OPEN; + int i; struct open_file_t *socket = Files; + uint16_t nextport; - for (; i > 0; i--) { - if (*(uint16_t*)socket == 0) - break; + for (i = 0; i < MAX_OPEN; i++) { + if (!socket->tftp_localport) + break; socket++; } - /* Not found */ - if (i == 0) - return NULL; - + if (i == MAX_OPEN) + return NULL; + /* - * Allocate a socket number. Socket numbers are made guaranteed unique - * by including the socket slot number(inverted, because we use the loop - * counter cx; add a counter value to keep the numbers from being likely - * to get immediately reused. - * - * The NextSocket variable also contains the top two bits set. This - * generates a value in the range 49152 to 57343. - * + * Allocate a socket number. Socket numbers are made guaranteed + * unique by including the socket slot number; add a counter value + * to keep the numbers from being likely to get immediately + * reused. The mask enforces wraparound to the range 49152-57343. */ - i--; - NextSocket = ((NextSocket + 1) & ((1 << (13-MAX_OPEN_LG2))-1)) | 0xc000; - i <<= 13-MAX_OPEN_LG2; - i += NextSocket; - i = ntohs(i) ; /* convet to network byte order, little to big */ - *(uint16_t*)socket = i; /* socket in use */ - + nextport = socket->tftp_nextport; + socket->tftp_nextport = (nextport + (1 << MAX_OPEN_LG2)) & 0xdfff; + socket->tftp_localport = htons(nextport); /* Socket now in use */ return socket; } @@ -93,7 +99,7 @@ static struct open_file_t *allocate_socket(void) static void free_socket(struct open_file_t *file) { /* tftp_pktbuf is not cleared */ - memset(file, 0, sizeof(struct open_file_t) - 2); + memset(file, 0, offsetof(struct open_file_t, tftp_nextport)); } /** @@ -1546,8 +1552,11 @@ static void network_init(void) */ static int pxe_fs_init(struct fs_info *fs) { - fs = NULL; /* drop the compile warning message */ + (void)fs; /* drop the compile warning message */ + /* Initialize the Files structure */ + files_init(); + /* do the pxe initialize */ pxe_init(); diff --git a/core/pxelinux.asm b/core/pxelinux.asm index cfaf5db6..b8077fd9 100644 --- a/core/pxelinux.asm +++ b/core/pxelinux.asm @@ -172,10 +172,6 @@ trackbuf resb trackbufsize ; Track buffer goes here InitStack resd 1 section .bss16 - global Files - alignb open_file_t_size -Files resb MAX_OPEN*open_file_t_size - alignb FILENAME_MAX global BootFile, PathPrefix, DotQuadBuf, IPOption BootFile resb 256 ; Boot file from DHCP packet -- cgit v1.2.1