From: Liu Aleaxander Date: Sat, 29 Aug 2009 20:13:40 +0000 (+0800) Subject: Core:pxelinux: code clean--removes the unused variables in ASM file X-Git-Tag: syslinux-4.00-pre4~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca319d3cda6d40d38150c89fb0510069649f4fd1;p=platform%2Fupstream%2Fsyslinux.git Core:pxelinux: code clean--removes the unused variables in ASM file And also converts some asm-variables to c-variables. Signed-off-by: Liu Aleaxander --- diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c index 8adcb15..8c006fe 100644 --- a/core/fs/pxe/pxe.c +++ b/core/fs/pxe/pxe.c @@ -8,6 +8,11 @@ #define GPXE 1 +uint32_t ServerIP = 0; /* IP address of boot server */ +uint32_t Netmask = 0; /* Netmask of this subnet */ +uint32_t Gateway = 0; /* Default router */ +uint16_t ServerPort = TFTP_PORT; /* TFTP server port */ + static struct open_file_t Files[MAX_OPEN]; static int has_gpxe; static uint8_t uuid_dashes[] = {4, 2, 2, 2, 6, 0}; @@ -255,16 +260,18 @@ int pxe_call(int opcode, void *data) static void ack_packet(struct open_file_t *file, uint16_t ack_num) { int err; + static __lowmem uint16_t ack_packet_buf[2]; static __lowmem struct s_PXENV_UDP_WRITE udp_write; /* Packet number to ack */ + ack_packet_buf[0] = TFTP_ACK; ack_packet_buf[1] = ack_num; udp_write.src_port = file->tftp_localport; udp_write.dst_port = file->tftp_remoteport; udp_write.ip = file->tftp_remoteip; udp_write.gw = ((udp_write.ip ^ MyIP) & Netmask) ? Gateway : 0; - udp_write.buffer.offs = OFFS_WRT(ack_packet_buf, 0); - udp_write.buffer.seg = 0; + udp_write.buffer.offs = OFFS(ack_packet_buf); + udp_write.buffer.seg = SEG(ack_packet_buf); udp_write.buffer_size = 4; err = pxe_call(PXENV_UDP_WRITE, &udp_write); @@ -664,7 +671,7 @@ static int fill_tail(char *dst) */ static void pxe_searchdir(char *filename, struct file *file) { - extern char tftp_proto_err[]; + static __lowmem char tftp_proto_err[32]; char *buf = packet_buf; char *p = filename; char *options; @@ -931,9 +938,17 @@ done: return; err_reply: + /* Build the TFTP error packet */ + p = tftp_proto_err; + *(uint16_t *)p = TFTP_ERROR; + p += 2; + *(uint16_t *)p = TFTP_EOPTNEG; + p += 2; + strcat(p, "TFTP_protocol error"); + udp_write.dst_port = open_file->tftp_remoteport; - udp_write.buffer.offs = OFFS_WRT(tftp_proto_err, 0); - udp_write.buffer.seg = 0; + udp_write.buffer.offs = OFFS(tftp_proto_err); + udp_write.buffer.seg = SEG(tftp_proto_err); udp_write.buffer_size = 24; pxe_call(PXENV_UDP_WRITE, &udp_write); printf("TFTP server sent an incomprehesible reply\n"); diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h index dc1a52f..864815b 100644 --- a/core/fs/pxe/pxe.h +++ b/core/fs/pxe/pxe.h @@ -24,11 +24,11 @@ /* * Some basic defines... */ -#define PKTBUF_SIZE (65536 / MAX_OPEN) - +#define TFTP_PORT htons(69) /* Default TFTP port */ #define TFTP_BLOCKSIZE_LG2 9 #define TFTP_BLOCKSIZE (1 << TFTP_BLOCKSIZE_LG2) #define PKTBUF_SEG 0x4000 +#define PKTBUF_SIZE (65536 / MAX_OPEN) #define is_digit(c) (((c) >= '0') && ((c) <= '9')) @@ -55,6 +55,7 @@ #define TFTP_ENOUSER htons(7) // No such user #define TFTP_EOPTNEG htons(8) // Option negotiation failure + #define BOOTP_OPTION_MAGIC htonl(0x63825363) #define MAC_MAX 32 diff --git a/core/include/core.h b/core/include/core.h index f8be691..52a35d4 100644 --- a/core/include/core.h +++ b/core/include/core.h @@ -48,7 +48,7 @@ extern uint32_t ServerIP; extern uint32_t MyIP; extern uint32_t Netmask; extern uint32_t Gateway; -extern uint32_t ServerPort; +extern uint16_t ServerPort; extern char MACStr[]; /* MAC address as a string */ extern char MAC[]; /* Actual MAC address */ @@ -59,8 +59,6 @@ extern uint8_t MACType; /* MAC address type */ extern uint8_t DHCPMagic; extern uint8_t OverLoad; extern uint32_t RebootTime; -/* TFTP ACK packet */ -extern uint16_t ack_packet_buf[]; extern char BootFile[]; extern char PathPrefix[]; diff --git a/core/pxelinux.asm b/core/pxelinux.asm index ed67518..8f0b7ac 100644 --- a/core/pxelinux.asm +++ b/core/pxelinux.asm @@ -33,7 +33,6 @@ NULLFILE equ 0 ; Zero byte == null file name NULLOFFSET equ 4 ; Position in which to look REBOOT_TIME equ 5*60 ; If failure, time until full reset %assign HIGHMEM_SLOP 128*1024 ; Avoid this much memory near the top -TFTP_PORT equ htons(69) ; Default TFTP port TFTP_BLOCKSIZE_LG2 equ 9 ; log2(bytes/block) TFTP_BLOCKSIZE equ (1 << TFTP_BLOCKSIZE_LG2) @@ -399,19 +398,6 @@ pxe_int1a: ret ; -; TimeoutTable: list of timeouts (in 18.2 Hz timer ticks) -; -; This is roughly an exponential backoff... -; - section .data16 -TimeoutTable: - db 2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 12, 15, 18 - db 21, 26, 31, 37, 44, 53, 64, 77, 92, 110, 132 - db 159, 191, 229, 255, 255, 255, 255 -TimeoutTableEnd equ $ - - section .text16 -; ; unload_pxe: ; ; This function unloads the PXE and UNDI stacks and unclaims @@ -598,30 +584,10 @@ BaseStack dd StackTop ; ESP of base stack dw 0 ; SS of base stack KeepPXE db 0 ; Should PXE be kept around? - alignz 2 -; -; Error packet to return on TFTP protocol error -; Most of our errors are OACK parsing errors, so use that error code -; - global tftp_proto_err, tftp_proto_err_len -tftp_proto_err dw TFTP_ERROR ; ERROR packet - dw TFTP_EOPTNEG ; ERROR 8: OACK error - db 'TFTP protocol error', 0 ; Error message -tftp_proto_err_len equ ($-tftp_proto_err) - - alignz 4 - global ack_packet_buf -ack_packet_buf: dw TFTP_ACK, 0 ; TFTP ACK packet - ; ; IP information (initialized to "unknown" values) - global MyIP, ServerIP, Netmask, Gateway, ServerPort -MyIP dd 0 ; My IP address -ServerIP dd 0 ; IP address of boot server -Netmask dd 0 ; Netmask of this subnet -Gateway dd 0 ; Default router -ServerPort dw TFTP_PORT ; TFTP server port - + global MyIP +MyIP dd 0 ; My IP address ; ; Variables that are uninitialized in SYSLINUX but initialized here ;