We can now use SDCC's __nonbanked feature

This allows us to reduce CODE footprint of SDCC projects
built with --model-huge. Use carefully!

* Added a facility which allows us to enable/disable the
  feature from the CPU dir (CC_CONF_NON_BANKED_OPTIMIZATION)
* Added the CC_NON_BANKED keyword to some platform files
  (expands to __nonbanked)
* Started using this for some examples
This commit is contained in:
George Oikonomou 2012-04-01 20:07:53 +01:00
parent d3b4efa06f
commit dd26accc07
10 changed files with 46 additions and 27 deletions

View file

@ -38,6 +38,13 @@
#define CC_CONF_UNSIGNED_CHAR_BUGS 0
#define CC_CONF_REGISTER_ARGS 0
#define CC_CONF_FUNCTION_POINTER_KEYWORD __reentrant
#define CC_CONF_NON_BANKED_OPTIMIZATION 1
#if (defined(__SDCC_mcs51) || defined(SDCC_mcs51)) && CC_CONF_NON_BANKED_OPTIMIZATION
#define CC_NON_BANKED __nonbanked
#else
#define CC_NON_BANKED
#endif
/* Generic types. */
typedef unsigned short uip_stats_t;

View file

@ -38,6 +38,13 @@
#define CC_CONF_UNSIGNED_CHAR_BUGS 0
#define CC_CONF_REGISTER_ARGS 0
#define CC_CONF_FUNCTION_POINTER_KEYWORD __reentrant
#define CC_CONF_NON_BANKED_OPTIMIZATION 1
#if (defined(__SDCC_mcs51) || defined(SDCC_mcs51)) && CC_CONF_NON_BANKED_OPTIMIZATION
#define CC_NON_BANKED __nonbanked
#else
#define CC_NON_BANKED
#endif
/* Generic types. */
typedef unsigned short uip_stats_t;

View file

@ -50,7 +50,7 @@ PROCESS(border_router_process, "Border Router process");
AUTOSTART_PROCESSES(&border_router_process);
/*---------------------------------------------------------------------------*/
static void
print_local_addresses(void)
print_local_addresses(void) CC_NON_BANKED
{
int i;
uint8_t state;
@ -70,8 +70,9 @@ print_local_addresses(void)
}
}
/*---------------------------------------------------------------------------*/
void
request_prefix(void) {
static void
request_prefix(void) CC_NON_BANKED
{
/* mess up uip_buf with a dirty request... */
uip_buf[0] = '?';
uip_buf[1] = 'P';
@ -82,7 +83,8 @@ request_prefix(void) {
/*---------------------------------------------------------------------------*/
/* Set our prefix when we receive one over SLIP */
void
set_prefix_64(uip_ipaddr_t *prefix_64) {
set_prefix_64(uip_ipaddr_t *prefix_64)
{
rpl_dag_t *dag;
uip_ipaddr_t ipaddr;
memcpy(&ipaddr, prefix_64, 16);

View file

@ -59,7 +59,7 @@ static unsigned long irq_energest = 0;
#endif
/*---------------------------------------------------------------------------*/
static void
fade(int l)
fade(int l) CC_NON_BANKED
{
volatile int i, a;
int k, j;
@ -78,7 +78,7 @@ fade(int l)
}
/*---------------------------------------------------------------------------*/
static void
set_rime_addr(void)
set_rime_addr(void) CC_NON_BANKED
{
char i;
@ -136,10 +136,11 @@ set_rime_addr(void)
#endif
cc2530_rf_set_addr(IEEE802154_PANID);
return;
}
/*---------------------------------------------------------------------------*/
int
main(void)
main(void) CC_NON_BANKED
{
/* Hardware initialization */
clock_init();

View file

@ -73,7 +73,7 @@ extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB];
extern uip_ds6_defrt_t uip_ds6_defrt_list[UIP_DS6_DEFRT_NB];
/*---------------------------------------------------------------------------*/
static uint8_t
process_request()
process_request() CC_NON_BANKED
{
uint8_t len;
uint8_t count; /* How many did we pack? */
@ -251,7 +251,7 @@ process_request()
PROCESS(viztool_process, "Network Visualization Tool Process");
/*---------------------------------------------------------------------------*/
static void
tcpip_handler(void)
tcpip_handler(void) CC_NON_BANKED
{
if(uip_newdata()) {
memset(buf, 0, VIZTOOL_MAX_PAYLOAD_LEN);

View file

@ -99,7 +99,7 @@ static struct etimer et;
PROCESS(batmon_process, "Logger Process");
/*---------------------------------------------------------------------------*/
static int
find_gap()
find_gap() CC_NON_BANKED
{
uint8_t seq[3];
uint32_t address = FLASH_START_ADDR;
@ -124,7 +124,7 @@ find_gap()
}
/*---------------------------------------------------------------------------*/
static void
abort()
abort() CC_NON_BANKED
{
PRINTF("BatMon: Abort\n");
etimer_stop(&et);

View file

@ -72,7 +72,7 @@ static unsigned long irq_energest = 0;
#endif
/*---------------------------------------------------------------------------*/
static void
fade(int l)
fade(int l) CC_NON_BANKED
{
volatile int i, a;
int k, j;
@ -91,7 +91,7 @@ fade(int l)
}
/*---------------------------------------------------------------------------*/
static void
set_rime_addr(void)
set_rime_addr(void) CC_NON_BANKED
{
uint8_t *addr_long = NULL;
uint16_t addr_short = 0;

View file

@ -63,7 +63,7 @@
/*---------------------------------------------------------------------------*/
/* Bit-Bang write a byte to the chip */
static void
bit_bang_write(uint8_t byte)
bit_bang_write(uint8_t byte) CC_NON_BANKED
{
uint8_t i;
uint8_t bit;
@ -85,7 +85,7 @@ bit_bang_write(uint8_t byte)
/*---------------------------------------------------------------------------*/
/* Bit-Bang read a byte from the chip */
static uint8_t
bit_bang_read()
bit_bang_read() CC_NON_BANKED
{
int8_t i;
uint8_t bits = 0;
@ -102,7 +102,7 @@ bit_bang_read()
}
/*---------------------------------------------------------------------------*/
static void
select()
select() CC_NON_BANKED
{
/* Read current ser/par value */
uint8_t ser_par = n740_ser_par_get();
@ -116,7 +116,7 @@ select()
}
/*---------------------------------------------------------------------------*/
static void
deselect()
deselect() CC_NON_BANKED
{
/* Read current ser/par value */
uint8_t ser_par = n740_ser_par_get();

View file

@ -95,7 +95,7 @@ __xdata __at(BOOTTY_CMD_LOCATION) static uint8_t bd;
static void timer_handler(void * p);
/*---------------------------------------------------------------------------*/
static void
abort()
abort() CC_NON_BANKED
{
PRINTF("Disco: Abort @ %lu\n", clock_seconds());
n740_analog_deactivate();
@ -108,7 +108,7 @@ abort()
}
/*---------------------------------------------------------------------------*/
static void
restart_timer(uint16_t t)
restart_timer(uint16_t t) CC_NON_BANKED
{
interval = t;
ctimer_stop(&disco_timer);
@ -160,7 +160,9 @@ timer_handler(void * p)
}
}
/*---------------------------------------------------------------------------*/
static uint8_t is_protected(uint8_t a) {
static uint8_t
is_protected(uint8_t a) CC_NON_BANKED
{
uint8_t bp = M25P16_BP() >> 2;
if(bp > 5) {
@ -176,7 +178,7 @@ static uint8_t is_protected(uint8_t a) {
}
/*---------------------------------------------------------------------------*/
static uint8_t
cmd_init()
cmd_init() CC_NON_BANKED
{
PRINTF("Disco: Init 0x%02x\n", req->addr[0]);
if(uip_datalen() != DISCO_LEN_INIT) {
@ -209,7 +211,7 @@ cmd_init()
}
/*---------------------------------------------------------------------------*/
static uint8_t
cmd_write()
cmd_write() CC_NON_BANKED
{
PRINTF("Disco: Write 0x%02x%02x%02x\n", req->addr[0], req->addr[1], req->addr[2]);
if(uip_datalen() != DISCO_LEN_WRITE) {
@ -228,7 +230,7 @@ cmd_write()
}
/*---------------------------------------------------------------------------*/
static uint8_t
cmd_switch()
cmd_switch() CC_NON_BANKED
{
PRINTF("Disco: Switch 0x%02x\n", req->addr[0]);
if(uip_datalen() != DISCO_LEN_SWITCH) {
@ -253,7 +255,7 @@ cmd_switch()
}
/*---------------------------------------------------------------------------*/
static uint8_t
cmd_done()
cmd_done() CC_NON_BANKED
{
PRINTF("Disco: Done\n");
if(uip_datalen() != DISCO_LEN_DONE) {
@ -268,7 +270,7 @@ cmd_done()
}
/*---------------------------------------------------------------------------*/
static uint8_t
event_handler(process_event_t ev)
event_handler(process_event_t ev) CC_NON_BANKED
{
uint8_t rv = DISCO_RESPONSE_NONE;

View file

@ -73,7 +73,7 @@ extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB];
extern uip_ds6_defrt_t uip_ds6_defrt_list[UIP_DS6_DEFRT_NB];
/*---------------------------------------------------------------------------*/
static uint8_t
process_request()
process_request() CC_NON_BANKED
{
uint8_t len;
uint8_t count; /* How many did we pack? */
@ -251,7 +251,7 @@ process_request()
PROCESS(viztool_process, "Network Visualization Tool Process");
/*---------------------------------------------------------------------------*/
static void
tcpip_handler(void)
tcpip_handler(void) CC_NON_BANKED
{
if(uip_newdata()) {
memset(buf, 0, VIZTOOL_MAX_PAYLOAD_LEN);