From 55d61d317bd0e14715c7a1f24a6705c972663ed2 Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Tue, 28 Sep 2010 23:02:16 +0000 Subject: [PATCH] Allow cc65 ethernet drivers to be loaded statically instead of dynamically. This saved quite some space in scenarios without additional cc65 drivers to be loaded for i.e. a mouse because in those scenarios the cc65 module loader isn't necessary. And without the module loader typically the cc65 heap manager isn't necessary. --- cpu/6502/Makefile.6502 | 12 +++++++++++- cpu/6502/net/ethernet.c | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cpu/6502/Makefile.6502 b/cpu/6502/Makefile.6502 index 44e7d1626..4653d60c1 100644 --- a/cpu/6502/Makefile.6502 +++ b/cpu/6502/Makefile.6502 @@ -30,7 +30,7 @@ # # Author: Oliver Schmidt # -# $Id: Makefile.6502,v 1.31 2010/02/04 23:52:30 oliverschmidt Exp $ +# $Id: Makefile.6502,v 1.32 2010/09/28 23:02:16 oliverschmidt Exp $ # ifndef CC65_HOME @@ -52,6 +52,11 @@ CONTIKI_SOURCEFILES += $(CTK) ctk-conio.c petsciiconv.c cfs-posix-dir.c \ TARGET_LIBFILES = $(TARGET).lib +ifdef ETHERNET + CONTIKI_SOURCEFILES += $(ETHERNET)-eth.S + CFLAGS += -DETHERNET=$(ETHERNET) +endif + ### Compiler definitions AS = ca65 @@ -87,3 +92,8 @@ CUSTOM_RULE_C_TO_CO = 1 %.eth: $(OBJECTDIR)/%.o $(LD) -t module -m $@.map $< -o $@ + +ifdef ETHERNET +$(ETHERNET)-eth.S: $(ETHERNET).eth + co65 --code-label _$(ETHERNET) -o $@ $< +endif diff --git a/cpu/6502/net/ethernet.c b/cpu/6502/net/ethernet.c index bbf06a2c5..1681436e0 100644 --- a/cpu/6502/net/ethernet.c +++ b/cpu/6502/net/ethernet.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * @(#)$Id: ethernet.c,v 1.6 2007/12/23 15:37:28 oliverschmidt Exp $ + * @(#)$Id: ethernet.c,v 1.7 2010/09/28 23:02:16 oliverschmidt Exp $ */ #include @@ -59,6 +59,9 @@ void CC_FASTCALL ethernet_init(struct ethernet_config *config) { static const char signature[4] = {0x65, 0x74, 0x68, 0x01}; + +#ifndef ETHERNET + struct mod_ctrl module_control = {cfs_read}; u8_t byte; @@ -85,6 +88,14 @@ ethernet_init(struct ethernet_config *config) } } +#else /* !ETHERNET */ + + extern void ETHERNET; + + module = ÐERNET; + +#endif /* !ETHERNET */ + module->buffer = uip_buf; module->buffer_size = UIP_BUFSIZE; module->init(config->addr); @@ -109,6 +120,8 @@ ethernet_exit(void) { module->exit(); +#ifndef ETHERNET mod_free(module); +#endif /* !ETHERNET */ } /*---------------------------------------------------------------------------*/