aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-08-05 18:03:00 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-08-05 18:03:00 +0800
commitdf3f09687ed7eff6431b640317273aea17b7b87f (patch)
tree252f9e0826724dadaead995aa11d23c491597245
parentc06e14e0253243a56a1ef5c583d271af779f4ee4 (diff)
downloadpxelinux-df3f09687ed7eff6431b640317273aea17b7b87f.tar.gz
pxelinux-df3f09687ed7eff6431b640317273aea17b7b87f.tar.xz
pxelinux-df3f09687ed7eff6431b640317273aea17b7b87f.zip
Core:PXELINUX: code clean -- 4
-rw-r--r--core/pxe.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/core/pxe.c b/core/pxe.c
index 1e12544e..67b7d6bd 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -1234,28 +1234,28 @@ int is_gpxe(char *url)
return 0;
}
-/*
- * Get a fresh packet from a gPXE socket; expectfs -> pktbuf_seg
- * and ds:si -> socket structure
+/**
+ * Get a fresh packet from a gPXE socket
+ * @param: file -> socket structure
*
- * Assumes CS == DS == ES.
*/
-void get_packet_gpxe(com32sys_t *regs)
+void get_packet_gpxe(struct open_file_t *file)
{
struct gpxe_file_read *fr = (struct gpxe_file_read *)gpxe_file_read;
- struct open_file_t *file = (struct open_file_t *)MK_PTR(0, regs->esi.w[0]);
int err;
- again:
- fr->filehandle = file->tftp_remoteport;
- fr->buffer[0] = file->tftp_pktbuf;
- fr->buffer[1] = regs->fs;
- fr->buffersize = PKTBUF_SIZE;
- err = pxe_call(PXENV_FILE_READ, fr);
- if (err) {
+ while (1) {
+ fr->filehandle = file->tftp_remoteport;
+ fr->buffer[0] = file->tftp_pktbuf;
+ fr->buffer[1] = PKTBUF_SEG;
+ fr->buffersize = PKTBUF_SIZE;
+ err = pxe_call(PXENV_FILE_READ, fr);
+ if (!err) /* successed */
+ break;
+
if (fr->status == PXENV_STATUS_TFTP_OPEN)
- goto again;
- call16(kaboom, regs, regs);
+ continue;
+ call16(kaboom, NULL, NULL);
}
file->tftp_bytesleft = fr->buffersize;
@@ -1283,7 +1283,7 @@ void get_packet_gpxe(com32sys_t *regs)
; expects fs -> pktbuf_seg and ds:si -> socket structure
;
*/
-void fill_buffer(com32sys_t *regs)
+void fill_buffer(struct open_file_t *file)
{
int err;
int last_pkt;
@@ -1293,14 +1293,13 @@ void fill_buffer(com32sys_t *regs)
uint16_t old_time;
void *data = NULL;
struct pxe_udp_read_pkt *pkt = (struct pxe_udp_read_pkt *)pxe_udp_read_pkt;
- struct open_file_t *file = (struct open_file_t *)MK_PTR(regs->ds, regs->esi.w[0]);
-
+
if (file->tftp_bytesleft || file->tftp_goteof)
return;
#if GPXE
if (file->tftp_localport == 0xffff) {
- get_packet_gpxe(regs);
+ get_packet_gpxe(file);
return;
}
#endif
@@ -1318,7 +1317,7 @@ void fill_buffer(com32sys_t *regs)
old_time = BIOS_timer;
while (timeout) {
pkt->buffer[0] = file->tftp_pktbuf;
- pkt->buffer[1] = regs->fs;
+ pkt->buffer[1] = PKTBUF_SEG;
pkt->buffersize = PKTBUF_SIZE;
pkt->sip = file->tftp_remoteip;
pkt->dip = MyIP;
@@ -1344,7 +1343,7 @@ void fill_buffer(com32sys_t *regs)
if (pkt->buffersize < 4) /* Bad size for a DATA packet */
continue;
- data = MK_PTR(regs->fs, file->tftp_pktbuf);
+ data = MK_PTR(PKTBUF_SEG, file->tftp_pktbuf);
if (*(uint16_t *)data != TFTP_DATA) /* Not a data packet */
continue;
@@ -1386,8 +1385,6 @@ void fill_buffer(com32sys_t *regs)
file->tftp_filesize = file->tftp_filepos;
file->tftp_goteof = 1;
}
-
- return;
}
@@ -1423,7 +1420,7 @@ void getfssec(com32sys_t *regs)
count <<= TFTP_BLOCKSIZE_LG2;
while (count) {
- fill_buffer(regs); /* If we have no 'fresh' buffer, get it */
+ fill_buffer(file); /* If we have no 'fresh' buffer, get it */
if (! file->tftp_bytesleft)
break;
@@ -1441,7 +1438,7 @@ void getfssec(com32sys_t *regs)
regs->ecx.l = bytes_read; /* number of bytes actually read */
if (file->tftp_bytesleft || (file->tftp_filepos < file->tftp_filesize)) {
- fill_buffer(regs);
+ fill_buffer(file);
regs->eflags.l &= ~EFLAGS_CF;
return;
}
@@ -1458,7 +1455,7 @@ void getfssec(com32sys_t *regs)
}
/* hpa is 99% sure this can't happen, but ... */
- fill_buffer(regs); /* Receive/ACK the EOF packet */
+ fill_buffer(file); /* Receive/ACK the EOF packet */
}