From 76f1e96f8dc1882f9e992bdf80489929aa746a88 Mon Sep 17 00:00:00 2001 From: kpfleming Date: Tue, 16 Jan 2007 01:28:54 +0000 Subject: eliminate the fw2h tool, and instead use objcopy to directly make object files from the firmware binary files pass HOTPLUG_FIRMWARE down to the module build so that we can avoid various compiler warnings git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@1818 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wct4xxp/Kbuild | 23 ++++++++++---------- wct4xxp/Makefile | 22 +++++++++---------- wct4xxp/base.c | 5 +++++ wct4xxp/fw2h.c | 64 ------------------------------------------------------- wct4xxp/vpm450m.c | 14 ++++++------ wct4xxp/vpm450m.h | 3 --- 6 files changed, 34 insertions(+), 97 deletions(-) delete mode 100644 wct4xxp/fw2h.c (limited to 'wct4xxp') diff --git a/wct4xxp/Kbuild b/wct4xxp/Kbuild index 218eaf5..ea6148b 100644 --- a/wct4xxp/Kbuild +++ b/wct4xxp/Kbuild @@ -1,24 +1,23 @@ -# yes, this is redundant... the Kbuild system is changing to hostprogs-y, -# but we need to be able to support older verions as well -host-progs := fw2h -hostprogs-y := fw2h - obj-m += wct4xxp.o EXTRA_CFLAGS := -I$(src)/.. $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef wct4xxp-objs := base.o vpm450m.o $(shell $(src)/../oct612x/octasic-helper objects ../oct612x) +ifneq ($(HOTPLUG_FIRMWARE),yes) +wct4xxp-objs += firmware_oct6114-64d.o firmware_oct6114-128d.o +endif + $(obj)/base.o: $(src)/vpm450m.h $(src)/wct4xxp.h $(obj)/base.o: $(src)/../zaptel.h -$(obj)/vpm450m.o: $(obj)/vpmoct128_fw.h $(obj)/vpmoct064_fw.h $(src)/vpm450m.h +$(obj)/vpm450m.o: $(src)/vpm450m.h $(obj)/vpm450m.o: $(src)/../oct612x/include/oct6100api/oct6100_api.h -$(obj)/vpmoct128_fw.h: $(src)/OCT6114-128D.ima $(obj)/fw2h - $(obj)/fw2h $< $@ - -$(obj)/vpmoct064_fw.h: $(src)/OCT6114-64D.ima $(obj)/fw2h - $(obj)/fw2h $< $@ +$(obj)/firmware_oct6114-64d.o: $(src)/OCT6114-64D.ima $(obj)/base.o + @echo Making firmware object file for $(notdir $<) + @cd $(src) && ../build_tools/make_firmware_object $(notdir $<) $@ $(obj)/base.o -clean-files := vpmoct128_fw.h vpmoct064_fw.h +$(obj)/firmware_oct6114-128d.o: $(src)/OCT6114-128D.ima $(obj)/base.o + @echo Making firmware object file for $(notdir $<) + @cd $(src) && ../build_tools/make_firmware_object $(notdir $<) $@ $(obj)/base.o diff --git a/wct4xxp/Makefile b/wct4xxp/Makefile index f6c8173..7fe2869 100644 --- a/wct4xxp/Makefile +++ b/wct4xxp/Makefile @@ -14,23 +14,21 @@ all: wct4xxp.o base.o: ../zaptel.h vpm450m.h wct4xxp.h -vpm450m.o: vpm450m.h vpmoct128_fw.h vpmoct064_fw.h ../oct612x/include/oct6100api/oct6100_api.h +vpm450m.o: vpm450m.h ../oct612x/include/oct6100api/oct6100_api.h -wct4xxp.o: base.o vpm450m.o $(OCTASIC_OBJS) - $(LD) -r -o $@ $^ - -fw2h: CFLAGS= +firmware_oct6114-64d.o: OCT6114-64D.ima base.o + @echo Making firmware object file for $< + ../build_tools/make_firmware_object $< $@ base.o -vpmoct128_fw.h: OCT6114-128D.ima fw2h - ./fw2h $< $@ +firmware_oct6114-128d.o: OCT6114-128D.ima base.o + @echo Making firmware object file for $< + ../build_tools/make_firmware_object $< $@ base.o -vpmoct064_fw.h: OCT6114-64D.ima fw2h - ./fw2h $< $@ +wct4xxp.o: base.o vpm450m.o $(OCTASIC_OBJS) firmware_oct6114-64d.o firmware_oct6114-128d.o + $(LD) -r -o $@ $^ clean: - rm -f *.o fw2h - rm -f vpmoct128_fw.h - rm -f vpmoct064_fw.h + rm -f *.o rm -f $(OCTASIC_OBJS) endif diff --git a/wct4xxp/base.c b/wct4xxp/base.c index 68200be..73453fa 100644 --- a/wct4xxp/base.c +++ b/wct4xxp/base.c @@ -47,6 +47,11 @@ #include "wct4xxp.h" #include "vpm450m.h" +#ifdef HOTPLUG_FIRMWARE +static const char *oct064_firmware = "OCT6114-64D.ima"; +static const char *oct128_firmware = "OCT6114-128D.ima"; +#endif + /* * Tasklets provide better system interactive response at the cost of the * possibility of losing a frame of data at very infrequent intervals. If diff --git a/wct4xxp/fw2h.c b/wct4xxp/fw2h.c deleted file mode 100644 index 61ff53a..0000000 --- a/wct4xxp/fw2h.c +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - char *c = NULL, *fw_hdr_name = NULL; - int fd, res, x; - FILE *f = NULL; - unsigned char buf[1024]; - - /* Make sure we have the right amount of arguments */ - if (argc != 3) { - fprintf(stderr, "Usage: fw2h \n"); - exit(1); - } - - /* Make sure we can open the firmware in file */ - if ((fd = open(argv[1], O_RDONLY)) < 0) { - fprintf(stderr, "Unable to open '%s': %s\n", argv[1], strerror(errno)); - exit(1); - } - - /* Make sure we can write out the firmware header file */ - if (!(f = fopen(argv[2], "w+"))) { - fprintf(stderr, "Unable to open '%s' for writing: %s\n", argv[2], strerror(errno)); - exit(1); - } - - /* Strip file extension */ - c = strrchr(argv[2], '.'); - if (c) - *c = '\0'; - - /* Now determine the firmware header name */ - c = strrchr(argv[2], '/'); - if (c) - fw_hdr_name = ++c; - else - fw_hdr_name = argv[2]; - - /* Write out the firmware as a header file */ - fprintf(f, "static unsigned char %s[] = {\t", fw_hdr_name); - while ((res = read(fd, buf, sizeof(buf))) > 0) { - for (x = 0; x < res; x++) { - if (!(x % 16)) - fprintf(f, "\n\t"); - fprintf(f, "0x%02x, ", buf[x]); - } - } - fprintf(f, "\n};\n"); - - if (res < 0) { - fprintf(stderr, "Error reading file: %s\n", strerror(errno)); - exit(1); - } - - fclose(f); - close(fd); - exit(0); -} diff --git a/wct4xxp/vpm450m.c b/wct4xxp/vpm450m.c index 8c3ac83..5eb40eb 100644 --- a/wct4xxp/vpm450m.c +++ b/wct4xxp/vpm450m.c @@ -13,8 +13,10 @@ #ifdef HOTPLUG_FIRMWARE #include #else -#include "vpmoct128_fw.h" -#include "vpmoct064_fw.h" +extern unsigned char _binary_OCT6114_64D_ima_start; +extern unsigned int _binary_OCT6114_64D_ima_size; +extern unsigned char _binary_OCT6114_128D_ima_start; +extern unsigned int _binary_OCT6114_128D_ima_size; #endif #include "oct6100api/oct6100_api.h" @@ -409,11 +411,11 @@ struct vpm450m *init_vpm450m(void *wc, int *isalaw, int numspans) ChipOpen.ulImageSize = firmware->size; #else if (vpm450m->numchans > 64) { - ChipOpen.pbyImageFile = vpmoct128_fw; - ChipOpen.ulImageSize = sizeof(vpmoct128_fw); + ChipOpen.pbyImageFile = &_binary_OCT6114_128D_ima_start; + ChipOpen.ulImageSize = _binary_OCT6114_128D_ima_size; } else { - ChipOpen.pbyImageFile = vpmoct064_fw; - ChipOpen.ulImageSize = sizeof(vpmoct064_fw); + ChipOpen.pbyImageFile = &_binary_OCT6114_64D_ima_start; + ChipOpen.ulImageSize = _binary_OCT6114_64D_ima_size; } #endif diff --git a/wct4xxp/vpm450m.h b/wct4xxp/vpm450m.h index 50205db..adf5b90 100644 --- a/wct4xxp/vpm450m.h +++ b/wct4xxp/vpm450m.h @@ -30,9 +30,6 @@ struct vpm450m; struct firmware; #endif -static const char *oct064_firmware = "OCT6114-64D.ima"; -static const char *oct128_firmware = "OCT6114-128D.ima"; - /* From driver */ unsigned int oct_get_reg(void *data, unsigned int reg); void oct_set_reg(void *data, unsigned int reg, unsigned int val); -- cgit v1.2.3