-SUBDIRS = tools lib gpllib libutil modules mboot menu samples rosh cmenu \
+SUBDIRS = libupload tools lib gpllib libutil modules mboot menu samples rosh cmenu \
hdt gfxboot sysdump lua/src
all tidy dist clean spotless install:
--- /dev/null
+# Include configuration rules
+topdir = ../..
+include ../lib/MCONFIG
+
+REQFLAGS += -I./
+
+SUBDIRS := .
+LIBOBJS := $(foreach dir,$(SUBDIRS),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
+
+BINDIR = /usr/bin
+LIBDIR = /usr/lib
+DATADIR = /usr/share
+AUXDIR = $(DATADIR)/syslinux
+INCDIR = /usr/include
+COM32DIR = $(AUXDIR)/com32
+
+all: libcom32upload.a
+
+libcom32upload.a : $(LIBOBJS)
+ rm -f $@
+ $(AR) cq $@ $^
+ $(RANLIB) $@
+
+tidy dist clean:
+ find . \( -name \*.o -o -name \*.a -o -name .\*.d -o -name \*.tmp \) -print0 | \
+ xargs -0r rm -f
+
+spotless: clean
+ rm -f *.a
+ rm -f *~ \#* */*~ */\#*
+
+install: all
+ mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
+ install -m 644 libcom32upload.a $(INSTALLROOT)$(COM32DIR)
+ mkdir -p $(INSTALLROOT)$(COM32DIR)/include/
+ cp -r *.h $(INSTALLROOT)$(COM32DIR)/include/
+
+-include .*.d */.*.d */*/.*.d
#include <inttypes.h>
#include <stdbool.h>
#include <zlib.h>
-#include "backend.h"
+#include "upload_backend.h"
#include "ctime.h"
-int cpio_pad(struct backend *be)
+int cpio_pad(struct upload_backend *be)
{
static char pad[4]; /* Up to 4 zero bytes */
if (be->dbytes & 3)
return 0;
}
-int cpio_hdr(struct backend *be, uint32_t mode, size_t datalen,
+int cpio_hdr(struct upload_backend *be, uint32_t mode, size_t datalen,
const char *filename)
{
static uint32_t inode = 2;
return rv;
}
-int cpio_mkdir(struct backend *be, const char *filename)
+int cpio_mkdir(struct upload_backend *be, const char *filename)
{
return cpio_hdr(be, MODE_DIR, 0, filename);
}
-int cpio_writefile(struct backend *be, const char *filename,
+int cpio_writefile(struct upload_backend *be, const char *filename,
const void *data, size_t len)
{
int rv;
return rv;
}
-int cpio_close(struct backend *be)
+int cpio_close(struct upload_backend *be)
{
return cpio_hdr(be, 0, 0, "TRAILER!!!");
}
--- /dev/null
+#ifndef BACKEND_H
+#define BACKEND_H
+
+#include <stddef.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <zlib.h>
+#include "serial.h"
+
+/* Backend flags */
+#define BE_NEEDLEN 0x01
+
+struct upload_backend {
+ const char *name;
+ const char *helpmsg;
+ int minargs;
+
+ size_t dbytes;
+ size_t zbytes;
+ const char **argv;
+
+ uint32_t now;
+
+ int (*write)(struct upload_backend *);
+
+ z_stream zstream;
+ char *outbuf;
+ size_t alloc;
+};
+
+/* zout.c */
+int init_data(struct upload_backend *be, const char *argv[]);
+int write_data(struct upload_backend *be, const void *buf, size_t len);
+int flush_data(struct upload_backend *be);
+
+/* cpio.c */
+#define cpio_init init_data
+int cpio_hdr(struct upload_backend *be, uint32_t mode, size_t datalen,
+ const char *filename);
+int cpio_mkdir(struct upload_backend *be, const char *filename);
+int cpio_writefile(struct upload_backend *be, const char *filename,
+ const void *data, size_t len);
+int cpio_close(struct upload_backend *be);
+#define MODE_FILE 0100644
+#define MODE_DIR 0040755
+
+/* backends.c */
+struct upload_backend *get_upload_backend(const char *name);
+
+/* backends */
+extern struct upload_backend upload_tftp;
+extern struct upload_backend upload_ymodem;
+extern struct upload_backend upload_srec;
+
+#endif /* BACKEND_H */
#include <stdio.h>
#include <inttypes.h>
#include <minmax.h>
-#include "backend.h"
+#include "upload_backend.h"
/* Write a single S-record */
static int write_srecord(unsigned int len, unsigned int alen,
return 0;
}
-static int be_srec_write(struct backend *be)
+static int upload_srec_write(struct upload_backend *be)
{
char name[33];
const char *buf;
return 0;
}
-struct backend be_srec = {
+struct upload_backend upload_srec = {
.name = "srec",
.helpmsg = "[filename]",
.minargs = 0,
- .write = be_srec_write,
+ .write = upload_srec_write,
};
#include <netinet/in.h>
#include <sys/times.h>
-#include "backend.h"
+#include "upload_backend.h"
enum tftp_opcode {
TFTP_RRQ = 1,
return err;
}
-static int be_tftp_write(struct backend *be)
+static int upload_tftp_write(struct upload_backend *be)
{
static uint16_t local_port = 0x4000;
struct tftp_state tftp;
return 0;
}
-struct backend be_tftp = {
+struct upload_backend upload_tftp = {
.name = "tftp",
.helpmsg = "filename [tftp_server]",
.minargs = 1,
- .write = be_tftp_write,
+ .write = upload_tftp_write,
};
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
-#include "backend.h"
+#include "upload_backend.h"
#include "serial.h"
enum {
} while (ack_buf == NAK);
}
-static int be_ymodem_write(struct backend *be)
+static int upload_ymodem_write(struct upload_backend *be)
{
static const uint8_t eot_buf = EOT;
uint8_t ack_buf;
return 0;
}
-struct backend be_ymodem = {
+struct upload_backend upload_ymodem = {
.name = "ymodem",
.helpmsg = "filename [port [speed]]",
.minargs = 1,
- .write = be_ymodem_write,
+ .write = upload_ymodem_write,
};
#include <inttypes.h>
#include <stdbool.h>
#include <zlib.h>
-#include "backend.h"
+#include "upload_backend.h"
#include "ctime.h"
#define ALLOC_CHUNK 65536
-int init_data(struct backend *be, const char *argv[])
+int init_data(struct upload_backend *be, const char *argv[])
{
be->now = posix_time();
be->argv = argv;
return 0;
}
-static int do_deflate(struct backend *be, int flush)
+static int do_deflate(struct upload_backend *be, int flush)
{
int rv;
char *buf;
}
-int write_data(struct backend *be, const void *buf, size_t len)
+int write_data(struct upload_backend *be, const void *buf, size_t len)
{
int rv = Z_OK;
}
/* Output the data and shut down the stream */
-int flush_data(struct backend *be)
+int flush_data(struct upload_backend *be)
{
int rv = Z_OK;
include ../MCONFIG
-include $(topdir)/version.mk
-LIBS = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
+LIBS = ../libutil/libutil_com.a ../lib/libcom32.a ../libupload/libcom32upload.a $(LIBGCC)
LNXLIBS = ../libutil/libutil_lnx.a
MODULES = sysdump.c32
#include <string.h>
#include <stdlib.h>
#include "sysdump.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
#include "rbtree.h"
struct acpi_rsdp {
return scan_for_rsdp(0xe0000, 0x100000);
}
-static void dump_table(struct backend *be,
+static void dump_table(struct upload_backend *be,
const char name[], const void *ptr, uint32_t len)
{
char namebuf[64];
write_data(be, ptr, len);
}
-static void dump_rsdt(struct backend *be, const struct acpi_rsdp *rsdp)
+static void dump_rsdt(struct upload_backend *be, const struct acpi_rsdp *rsdp)
{
const struct acpi_rsdt *rsdt;
uint32_t i, n;
}
}
-static void dump_xsdt(struct backend *be, const struct acpi_rsdp *rsdp)
+static void dump_xsdt(struct upload_backend *be, const struct acpi_rsdp *rsdp)
{
const struct acpi_xsdt *xsdt;
uint32_t rsdp_len = rsdp->rev > 0 ? rsdp->len : 20;
}
}
-void dump_acpi(struct backend *be)
+void dump_acpi(struct upload_backend *be)
{
const struct acpi_rsdp *rsdp;
uint32_t rsdp_len;
+++ /dev/null
-#ifndef BACKEND_H
-#define BACKEND_H
-
-#include <stddef.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <zlib.h>
-#include "serial.h"
-
-/* Backend flags */
-#define BE_NEEDLEN 0x01
-
-struct backend {
- const char *name;
- const char *helpmsg;
- int minargs;
-
- size_t dbytes;
- size_t zbytes;
- const char **argv;
-
- uint32_t now;
-
- int (*write)(struct backend *);
-
- z_stream zstream;
- char *outbuf;
- size_t alloc;
-};
-
-/* zout.c */
-int init_data(struct backend *be, const char *argv[]);
-int write_data(struct backend *be, const void *buf, size_t len);
-int flush_data(struct backend *be);
-
-/* cpio.c */
-#define cpio_init init_data
-int cpio_hdr(struct backend *be, uint32_t mode, size_t datalen,
- const char *filename);
-int cpio_mkdir(struct backend *be, const char *filename);
-int cpio_writefile(struct backend *be, const char *filename,
- const void *data, size_t len);
-int cpio_close(struct backend *be);
-#define MODE_FILE 0100644
-#define MODE_DIR 0040755
-
-/* backends.c */
-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 */
#include <com32.h>
#include <sys/cpu.h>
#include "sysdump.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
struct cpuid_data {
uint32_t eax, ebx, ecx, edx;
#define CPUID_CHUNK 128
-void dump_cpuid(struct backend *be)
+void dump_cpuid(struct upload_backend *be)
{
struct cpuid_info *buf = NULL;
int nentry, nalloc;
#include <string.h>
#include <stdlib.h>
#include "sysdump.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
struct dmi_header {
char signature[5];
is_old_dmi(dptr+16);
}
-static void dump_smbios(struct backend *be, size_t dptr)
+static void dump_smbios(struct upload_backend *be, size_t dptr)
{
const struct smbios_header *smb = (void *)dptr;
struct smbios_header smx = *smb;
write_data(be, (const void *)smb->dmi.tbladdr, smb->dmi.tbllen);
}
-static void dump_old_dmi(struct backend *be, size_t dptr)
+static void dump_old_dmi(struct upload_backend *be, size_t dptr)
{
const struct dmi_header *dmi = (void *)dptr;
struct fake {
write_data(be, (const void *)dmi->tbladdr, dmi->tbllen);
}
-void dump_dmi(struct backend *be)
+void dump_dmi(struct upload_backend *be)
{
size_t dptr;
#include <console.h>
#include <sys/cpu.h>
#include "../../version.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
#include "sysdump.h"
const char program[] = "sysdump";
exit(1);
}
-static void dump_all(struct backend *be, const char *argv[])
+static void dump_all(struct upload_backend *be, const char *argv[])
{
cpio_init(be, argv);
flush_data(be);
}
-static struct backend *backends[] =
+static struct upload_backend *upload_backends[] =
{
- &be_tftp,
- &be_ymodem,
- &be_srec,
+ &upload_tftp,
+ &upload_ymodem,
+ &upload_srec,
NULL
};
__noreturn usage(void)
{
- struct backend **bep, *be;
+ struct upload_backend **bep, *be;
printf("Usage:\n");
- for (bep = backends ; (be = *bep) ; bep++)
+ for (bep = upload_backends ; (be = *bep) ; bep++)
printf(" %s %s %s\n", program, be->name, be->helpmsg);
exit(1);
int main(int argc, char *argv[])
{
- struct backend **bep, *be;
+ struct upload_backend **bep, *be;
openconsole(&dev_null_r, &dev_stdcon_w);
fputs(version, stdout);
if (argc < 2)
usage();
- for (bep = backends ; (be = *bep) ; bep++) {
+ for (bep = upload_backends ; (be = *bep) ; bep++) {
if (!strcmp(be->name, argv[1]))
break;
}
#include <stdlib.h>
#include <com32.h>
#include "sysdump.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
#define E820_CHUNK 128
struct e820_info {
uint8_t data[24];
};
-static void dump_e820(struct backend *be)
+static void dump_e820(struct upload_backend *be)
{
com32sys_t ireg, oreg;
struct e820_info *curr;
lfree(curr);
}
-void dump_memory_map(struct backend *be)
+void dump_memory_map(struct upload_backend *be)
{
com32sys_t ireg, oreg;
#include <stdlib.h>
#include <sys/cpu.h>
#include "sysdump.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
static char *lowmem;
static size_t lowmem_len;
}
}
-static void dump_memory_range(struct backend *be, const void *where,
+static void dump_memory_range(struct upload_backend *be, const void *where,
const void *addr, size_t len)
{
char filename[32];
cpio_writefile(be, filename, where, len);
}
-void dump_memory(struct backend *be)
+void dump_memory(struct upload_backend *be)
{
printf("Dumping memory... ");
#include <stdlib.h>
#include <sys/pci.h>
#include "sysdump.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
-static void dump_pci_device(struct backend *be, pciaddr_t a, uint8_t hdrtype)
+static void dump_pci_device(struct upload_backend *be, pciaddr_t a, uint8_t hdrtype)
{
unsigned int bus = pci_bus(a);
unsigned int dev = pci_dev(a);
cpio_writefile(be, filename, data, sizeof data);
}
-void dump_pci(struct backend *be)
+void dump_pci(struct upload_backend *be)
{
int cfgtype;
unsigned int nbus, ndev, nfunc, maxfunc;
#ifndef SYSDUMP_H
#define SYSDUMP_H
-struct backend;
+struct upload_backend;
-void dump_memory_map(struct backend *);
+void dump_memory_map(struct upload_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 *);
+void dump_memory(struct upload_backend *);
+void dump_dmi(struct upload_backend *);
+void dump_acpi(struct upload_backend *);
+void dump_cpuid(struct upload_backend *);
+void dump_pci(struct upload_backend *);
+void dump_vesa_tables(struct upload_backend *);
#endif /* SYSDUMP_H */
#include <string.h>
#include <stdio.h>
#include "../lib/sys/vesa/vesa.h"
-#include "backend.h"
+#include "../libupload/upload_backend.h"
#include "sysdump.h"
-void dump_vesa_tables(struct backend *be)
+void dump_vesa_tables(struct upload_backend *be)
{
com32sys_t rm;
struct vesa_info *vip;