And also converts some asm-variables to c-variables.
Signed-off-by: Liu Aleaxander <Aleaxander@gmail.com>
#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};
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);
*/
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;
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");
/*
* 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'))
#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
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 */
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[];
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)
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
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
;