aboutsummaryrefslogtreecommitdiffstats
path: root/com32/sysdump
diff options
context:
space:
mode:
Diffstat (limited to 'com32/sysdump')
-rw-r--r--com32/sysdump/backend.h1
-rw-r--r--com32/sysdump/be_tftp.c53
-rw-r--r--com32/sysdump/main.c2
-rw-r--r--com32/sysdump/memmap.c6
-rw-r--r--com32/sysdump/sysdump.h1
-rw-r--r--com32/sysdump/vesa.c7
6 files changed, 58 insertions, 12 deletions
diff --git a/com32/sysdump/backend.h b/com32/sysdump/backend.h
index 0926c8d5..f2b3bc25 100644
--- a/com32/sysdump/backend.h
+++ b/com32/sysdump/backend.h
@@ -50,5 +50,6 @@ struct backend *get_backend(const char *name);
/* backends */
extern struct backend be_tftp;
extern struct backend be_ymodem;
+extern struct backend be_srec;
#endif /* BACKEND_H */
diff --git a/com32/sysdump/be_tftp.c b/com32/sysdump/be_tftp.c
index 07fdb084..36a91eb8 100644
--- a/com32/sysdump/be_tftp.c
+++ b/com32/sysdump/be_tftp.c
@@ -3,6 +3,7 @@
*/
#include <string.h>
+#include <stdio.h>
#include <syslinux/pxe.h>
#include <syslinux/config.h>
#include <netinet/in.h>
@@ -21,23 +22,30 @@ enum tftp_opcode {
struct tftp_state {
uint32_t my_ip;
uint32_t srv_ip;
+ uint32_t srv_gw;
uint16_t my_port;
uint16_t srv_port;
uint16_t seq;
};
+#define RCV_BUF 2048
+
static int send_ack_packet(struct tftp_state *tftp,
const void *pkt, size_t len)
{
com32sys_t ireg, oreg;
- t_PXENV_UDP_WRITE *uw = __com32.cs_bounce;
- t_PXENV_UDP_READ *ur = __com32.cs_bounce;
+ t_PXENV_UDP_WRITE *uw;
+ t_PXENV_UDP_READ *ur;
clock_t start;
static const clock_t timeouts[] = {
2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 12, 15, 18, 21, 26, 31,
37, 44, 53, 64, 77, 92, 110, 132, 159, 191, 229, 0
};
const clock_t *timeout;
+ int err = -1;
+
+ uw = lmalloc(sizeof *uw + len);
+ ur = lmalloc(sizeof *ur + RCV_BUF);
memset(&ireg, 0, sizeof ireg);
ireg.eax.w[0] = 0x0009;
@@ -46,6 +54,7 @@ static int send_ack_packet(struct tftp_state *tftp,
memset(uw, 0, sizeof uw);
memcpy(uw+1, pkt, len);
uw->ip = tftp->srv_ip;
+ uw->gw = tftp->srv_gw;
uw->src_port = tftp->my_port;
uw->dst_port = tftp->srv_port ? tftp->srv_port : htons(69);
uw->buffer_size = len;
@@ -65,7 +74,7 @@ static int send_ack_packet(struct tftp_state *tftp,
ur->dest_ip = tftp->my_ip;
ur->s_port = tftp->srv_port;
ur->d_port = tftp->my_port;
- ur->buffer_size = __com32.cs_bounce_size - sizeof *ur;
+ ur->buffer_size = RCV_BUF;
ur->buffer = FAR_PTR(ur+1);
ireg.ebx.w[0] = PXENV_UDP_READ;
@@ -82,15 +91,20 @@ static int send_ack_packet(struct tftp_state *tftp,
if (ntohs(xb[0]) == TFTP_ACK &&
ntohs(xb[1]) == tftp->seq) {
tftp->srv_port = ur->s_port;
- return 0; /* All good! */
+ err = 0; /* All good! */
+ goto done;
} else if (ntohs(xb[1]) == TFTP_ERROR) {
- return -1; /* All bad! */
+ goto done;
}
}
} while ((clock_t)(times(NULL) - start) < *timeout);
}
- return -1; /* No success... */
+done:
+ lfree(ur);
+ lfree(uw);
+
+ return err;
}
static int be_tftp_write(struct backend *be)
@@ -107,10 +121,31 @@ static int be_tftp_write(struct backend *be)
tftp.my_ip = sdi->pxe.myip;
tftp.my_port = htons(local_port++);
- tftp.srv_ip = pxe_dns(be->argv[1]);
+ tftp.srv_gw = ((tftp.srv_ip ^ tftp.my_ip) & sdi->pxe.ipinfo->netmask)
+ ? sdi->pxe.ipinfo->gateway : 0;
tftp.srv_port = 0;
tftp.seq = 0;
+ if (be->argv[1]) {
+ tftp.srv_ip = pxe_dns(be->argv[1]);
+ if (!tftp.srv_ip) {
+ printf("\nUnable to resolve hostname: %s\n", be->argv[1]);
+ return -1;
+ }
+ } else {
+ tftp.srv_ip = sdi->pxe.ipinfo->serverip;
+ if (!tftp.srv_ip) {
+ printf("\nNo server IP address\n");
+ return -1;
+ }
+ }
+
+ printf("server %u.%u.%u.%u... ",
+ ((uint8_t *)&tftp.srv_ip)[0],
+ ((uint8_t *)&tftp.srv_ip)[1],
+ ((uint8_t *)&tftp.srv_ip)[2],
+ ((uint8_t *)&tftp.srv_ip)[3]);
+
buffer[0] = 0;
buffer[1] = TFTP_WRQ;
nlen = strlcpy(buffer+2, be->argv[0], 512);
@@ -137,7 +172,7 @@ static int be_tftp_write(struct backend *be)
struct backend be_tftp = {
.name = "tftp",
- .helpmsg = "filename tftp_server",
- .minargs = 2,
+ .helpmsg = "filename [tftp_server]",
+ .minargs = 1,
.write = be_tftp_write,
};
diff --git a/com32/sysdump/main.c b/com32/sysdump/main.c
index d4a0320e..d0d40a7b 100644
--- a/com32/sysdump/main.c
+++ b/com32/sysdump/main.c
@@ -41,6 +41,7 @@ static void dump_all(struct backend *be, const char *argv[])
dump_memory_map(be);
dump_memory(be);
dump_dmi(be);
+ dump_acpi(be);
dump_cpuid(be);
dump_pci(be);
dump_vesa_tables(be);
@@ -53,6 +54,7 @@ static struct backend *backends[] =
{
&be_tftp,
&be_ymodem,
+ &be_srec,
NULL
};
diff --git a/com32/sysdump/memmap.c b/com32/sysdump/memmap.c
index a85f0925..251107d5 100644
--- a/com32/sysdump/memmap.c
+++ b/com32/sysdump/memmap.c
@@ -19,10 +19,12 @@ struct e820_info {
static void dump_e820(struct backend *be)
{
com32sys_t ireg, oreg;
- struct e820_info *curr = __com32.cs_bounce;
+ struct e820_info *curr;
struct e820_info *buf, *p;
int nentry, nalloc;
+ curr = lmalloc(sizeof *curr);
+
buf = p = NULL;
nentry = nalloc = 0;
memset(&ireg, 0, sizeof ireg);
@@ -56,7 +58,9 @@ static void dump_e820(struct backend *be)
if (nentry)
cpio_writefile(be, "memmap/15e820", buf, nentry*sizeof *buf);
+
free(buf);
+ lfree(curr);
}
void dump_memory_map(struct backend *be)
diff --git a/com32/sysdump/sysdump.h b/com32/sysdump/sysdump.h
index 61a04a2b..a5b963f8 100644
--- a/com32/sysdump/sysdump.h
+++ b/com32/sysdump/sysdump.h
@@ -7,6 +7,7 @@ void dump_memory_map(struct backend *);
void snapshot_lowmem(void);
void dump_memory(struct backend *);
void dump_dmi(struct backend *);
+void dump_acpi(struct backend *);
void dump_cpuid(struct backend *);
void dump_pci(struct backend *);
void dump_vesa_tables(struct backend *);
diff --git a/com32/sysdump/vesa.c b/com32/sysdump/vesa.c
index 9bdc7153..017f9e4f 100644
--- a/com32/sysdump/vesa.c
+++ b/com32/sysdump/vesa.c
@@ -7,6 +7,7 @@
void dump_vesa_tables(struct backend *be)
{
com32sys_t rm;
+ struct vesa_info *vip;
struct vesa_general_info *gip, gi;
struct vesa_mode_info *mip, mi;
uint16_t mode, *mode_ptr;
@@ -15,8 +16,9 @@ void dump_vesa_tables(struct backend *be)
printf("Scanning VESA BIOS... ");
/* Allocate space in the bounce buffer for these structures */
- gip = &((struct vesa_info *)__com32.cs_bounce)->gi;
- mip = &((struct vesa_info *)__com32.cs_bounce)->mi;
+ vip = lmalloc(sizeof *vip);
+ gip = &vip->gi;
+ mip = &vip->mi;
memset(&rm, 0, sizeof rm);
memset(gip, 0, sizeof *gip);
@@ -56,5 +58,6 @@ void dump_vesa_tables(struct backend *be)
cpio_writefile(be, modefile, &mi, sizeof mi);
}
+ lfree(vip);
printf("done.\n");
}