Don't use the generic relocator code for DSCs.
The structure is simple enough and is fixed, so a specific code can be
used. This saves a few bytes off each DSC file.
diff --git a/contiki-cpc/Makefile.programs b/contiki-cpc/Makefile.programs
index 9c30e19..79b8e4e 100644
--- a/contiki-cpc/Makefile.programs
+++ b/contiki-cpc/Makefile.programs
@@ -86,7 +86,7 @@
# conversion of intel hex record to binary, cpc binary with header, then inject into disc image
define MAKE_DSC
-echo -ihn $(@:.dsc=.ihx) > $@.lnk
+echo -in $(@:.dsc=.ihx) > $@.lnk
echo arch/crt0-dsc.o >> $@.lnk
echo $< >> $@.lnk
echo -e >> $@.lnk
diff --git a/contiki-cpc/arch/crt0-dsc.s b/contiki-cpc/arch/crt0-dsc.s
index b7b3974..381bc27 100644
--- a/contiki-cpc/arch/crt0-dsc.s
+++ b/contiki-cpc/arch/crt0-dsc.s
@@ -11,7 +11,6 @@
;; Ordering of segments for the linker.
.area _HOME (REL)
.area _CODE (REL)
- .dw 0 ; Will be replaced by relocation data
.area _GSINIT (REL)
.area _GSFINAL (REL)
diff --git a/contiki-cpc/loader/loader-arch-cpc.c b/contiki-cpc/loader/loader-arch-cpc.c
index 33ca988..34936ca 100644
--- a/contiki-cpc/loader/loader-arch-cpc.c
+++ b/contiki-cpc/loader/loader-arch-cpc.c
@@ -1,5 +1,6 @@
#include "loader.h"
#include "rel.h"
+#include "log.h"
#include <stddef.h>
#include <malloc.h>
@@ -12,11 +13,6 @@
char initfunc[1];
};
-struct dsc_hdr {
- char *relocatedata;
- struct dsc dscdata;
-};
-
unsigned char loader_arch_load(const char *name, char *arg)
{
char *loadaddr;
@@ -46,10 +42,23 @@
return LOADER_OK;
}
+
+static void relocate_dsc(struct dsc* data, int loadaddr)
+{
+ data->description += loadaddr;
+ data->prgname += loadaddr;
+ data->icon = (struct ctk_icon*)(((char*)data->icon)+ loadaddr);
+
+ data->icon->title += loadaddr;
+ //data->icon->bitmap += loadaddr;
+ data->icon->textmap += loadaddr;
+}
+
+
struct dsc *loader_arch_load_dsc(const char *name)
{
char *loadaddr;
- struct dsc_hdr *dschdr;
+ struct dsc *dschdr;
int length;
/* get length of file */
@@ -65,11 +74,11 @@
/* load the file */
load_file(name, loadaddr);
- dschdr = (struct dsc_hdr *)loadaddr;
+ dschdr = (struct dsc *)loadaddr;
/* relocate it */
- relocate(dschdr->relocatedata, loadaddr);
+ relocate_dsc(dschdr, (int)loadaddr);
- return &dschdr->dscdata;
+ return dschdr;
}
void loader_arch_free(void *loadaddr)
@@ -83,11 +92,6 @@
void loader_arch_free_dsc(struct dsc *dscdata)
{
- /* we're given the start of 'dsc' member of the dsc_hdr,
- calculate the real start address and then free the block */
- void *header = (void *)((char *)dscdata - 2);
-//offsetof(struct
-//dsc_hdr,dscdata));
- free(header);
+ free(dscdata);
}