aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-04-08 03:01:26 -0700
committerEric W. Biederman <ebiederm@xmission.com>2011-04-09 01:39:31 -0700
commit7c63aede7f0e9205bd14c28133ae6751d7db0e56 (patch)
tree7a267ae05891777a5770ab1d953c8fd39dc16fad
parent34c55e99c29d68543645825ec240d006b7866eb9 (diff)
downloadsyslinux-devel-syslinux-lwip-checkpoint2.tar.gz
syslinux-devel-syslinux-lwip-checkpoint2.tar.xz
syslinux-devel-syslinux-lwip-checkpoint2.zip
pxe: Move the gpxe url reading code into it's own file.syslinux-lwip-checkpoint2
Now that we have method pointers there is no longer any reason to clutter up pxe.c with tftp specific details. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r--core/fs/pxe/gpxeurl.c85
-rw-r--r--core/fs/pxe/pxe.c89
-rw-r--r--core/fs/pxe/pxe.h4
3 files changed, 89 insertions, 89 deletions
diff --git a/core/fs/pxe/gpxeurl.c b/core/fs/pxe/gpxeurl.c
new file mode 100644
index 00000000..16152818
--- /dev/null
+++ b/core/fs/pxe/gpxeurl.c
@@ -0,0 +1,85 @@
+#include "pxe.h"
+#if GPXE
+
+static void gpxe_close_file(struct inode *inode)
+{
+ struct pxe_pvt_inode *socket = PVT(inode);
+ static __lowmem struct s_PXENV_FILE_CLOSE file_close;
+
+ file_close.FileHandle = socket->tftp_remoteport;
+ pxe_call(PXENV_FILE_CLOSE, &file_close);
+}
+
+/**
+ * Get a fresh packet from a gPXE socket
+ * @param: inode -> Inode pointer
+ *
+ */
+static void gpxe_get_packet(struct inode *inode)
+{
+ struct pxe_pvt_inode *socket = PVT(inode);
+ static __lowmem struct s_PXENV_FILE_READ file_read;
+ int err;
+
+ while (1) {
+ file_read.FileHandle = socket->tftp_remoteport;
+ file_read.Buffer = FAR_PTR(packet_buf);
+ file_read.BufferSize = PKTBUF_SIZE;
+ err = pxe_call(PXENV_FILE_READ, &file_read);
+ if (!err) /* successed */
+ break;
+
+ if (file_read.Status != PXENV_STATUS_TFTP_OPEN)
+ kaboom();
+ }
+
+ memcpy(socket->tftp_pktbuf, packet_buf, file_read.BufferSize);
+
+ socket->tftp_dataptr = socket->tftp_pktbuf;
+ socket->tftp_bytesleft = file_read.BufferSize;
+ socket->tftp_filepos += file_read.BufferSize;
+
+ if (socket->tftp_bytesleft == 0)
+ inode->size = socket->tftp_filepos;
+
+ /* if we're done here, close the file */
+ if (inode->size > socket->tftp_filepos)
+ return;
+
+ /* Got EOF, close it */
+ socket->tftp_goteof = 1;
+ gpxe_close_file(inode);
+}
+
+/**
+ * Open a url using gpxe
+ *
+ * @param:inode, the inode to store our state in
+ * @param:url, the url we want to open
+ *
+ * @out: open_file_t structure, stores in file->open_file
+ * @out: the lenght of this file, stores in file->file_len
+ *
+ */
+void gpxe_open(struct inode *inode, const char *url)
+{
+ static __lowmem struct s_PXENV_FILE_OPEN file_open;
+ static char lowurl[2*FILENAME_MAX];
+ struct pxe_pvt_inode *socket = PVT(inode);
+ int err;
+
+ snprintf(lowurl, sizeof lowurl, "%s", url);
+ file_open.Status = PXENV_STATUS_BAD_FUNC;
+ file_open.FileName = FAR_PTR(lowurl);
+ err = pxe_call(PXENV_FILE_OPEN, &file_open);
+ if (err)
+ return;
+
+ socket->fill_buffer = gpxe_get_packet;
+ socket->close = gpxe_close_file;
+ socket->tftp_remoteport = file_open.FileHandle;
+ inode->size = -1; /* This is not an error */
+}
+
+#endif /* GPXE */
+
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 84d86b02..539ef301 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -7,8 +7,6 @@
#include <sys/cpu.h>
#include "pxe.h"
-#define GPXE 1
-
static uint16_t real_base_mem; /* Amount of DOS memory after freeing */
uint8_t MAC[MAC_MAX]; /* Actual MAC address */
@@ -58,17 +56,6 @@ static void free_socket(struct inode *inode)
free_inode(inode);
}
-#if GPXE
-static void gpxe_close_file(struct inode *inode)
-{
- struct pxe_pvt_inode *socket = PVT(inode);
- static __lowmem struct s_PXENV_FILE_CLOSE file_close;
-
- file_close.FileHandle = socket->tftp_remoteport;
- pxe_call(PXENV_FILE_CLOSE, &file_close);
-}
-#endif
-
static void pxe_close_file(struct file *file)
{
struct inode *inode = file->inode;
@@ -315,51 +302,6 @@ static enum pxe_path_type pxe_path_type(const char *str)
}
}
-#if GPXE
-
-/**
- * Get a fresh packet from a gPXE socket
- * @param: inode -> Inode pointer
- *
- */
-static void gpxe_get_packet(struct inode *inode)
-{
- struct pxe_pvt_inode *socket = PVT(inode);
- static __lowmem struct s_PXENV_FILE_READ file_read;
- int err;
-
- while (1) {
- file_read.FileHandle = socket->tftp_remoteport;
- file_read.Buffer = FAR_PTR(packet_buf);
- file_read.BufferSize = PKTBUF_SIZE;
- err = pxe_call(PXENV_FILE_READ, &file_read);
- if (!err) /* successed */
- break;
-
- if (file_read.Status != PXENV_STATUS_TFTP_OPEN)
- kaboom();
- }
-
- memcpy(socket->tftp_pktbuf, packet_buf, file_read.BufferSize);
-
- socket->tftp_dataptr = socket->tftp_pktbuf;
- socket->tftp_bytesleft = file_read.BufferSize;
- socket->tftp_filepos += file_read.BufferSize;
-
- if (socket->tftp_bytesleft == 0)
- inode->size = socket->tftp_filepos;
-
- /* if we're done here, close the file */
- if (inode->size > socket->tftp_filepos)
- return;
-
- /* Got EOF, close it */
- socket->tftp_goteof = 1;
- gpxe_close_file(inode);
-}
-#endif /* GPXE */
-
-
/*
* mangle a filename pointed to by _src_ into a buffer pointed
* to by _dst_; ends on encountering any whitespace.
@@ -442,37 +384,6 @@ static uint32_t pxe_getfssec(struct file *file, char *buf,
return bytes_read;
}
-#if GPXE
-/**
- * Open a url using gpxe
- *
- * @param:inode, the inode to store our state in
- * @param:url, the url we want to open
- *
- * @out: open_file_t structure, stores in file->open_file
- * @out: the lenght of this file, stores in file->file_len
- *
- */
-static void gpxe_open(struct inode *inode, const char *url)
-{
- static __lowmem struct s_PXENV_FILE_OPEN file_open;
- static char lowurl[2*FILENAME_MAX];
- struct pxe_pvt_inode *socket = PVT(inode);
- int err;
-
- snprintf(lowurl, sizeof lowurl, "%s", url);
- file_open.Status = PXENV_STATUS_BAD_FUNC;
- file_open.FileName = FAR_PTR(lowurl);
- err = pxe_call(PXENV_FILE_OPEN, &file_open);
- if (err)
- return;
-
- socket->fill_buffer = gpxe_get_packet;
- socket->close = gpxe_close_file;
- socket->tftp_remoteport = file_open.FileHandle;
- inode->size = -1; /* This is not an error */
-}
-#endif
/**
* Open the specified connection
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index eaadc63f..60feedb7 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -256,4 +256,8 @@ void free_port(uint16_t port);
void tftp_open(struct inode *inode, uint32_t ip, uint16_t server_port,
const char *filename);
+/* gpxeurl.c */
+void gpxe_open(struct inode *inode, const char *url);
+#define GPXE 1
+
#endif /* pxe.h */