Contiki 3.x
8051def.h
1 /*
2  * \file
3  * This file contains a set of configuration for using SDCC as a compiler.
4  * Modified from z80 port for cc2430 port.
5  *
6  * \author
7  * Takahide Matsutsuka <markn@markn.org> (Original)
8  * George Oikonomou - <oikonomou@users.sourceforge.net>
9  * (recent updates for the sensinode/cc2430 port)
10  */
11 
12 #ifndef E051_DEF_H_
13 #define E051_DEF_H_
14 
15 #include <stdint.h>
16 
17 /* This port no longer implements the legacy clock_delay. Hack its usages
18  * outta the way till it gets phased out completely
19  * NB: This also overwrites the prototype so delay_usec() is declared twice */
20 #define clock_delay(t) clock_delay_usec(t)
21 
22 /*
23  * lint - style defines to help syntax parsers with sdcc-specific 8051 code
24  * They don't interfere with actual compilation
25  */
26 #if !defined(__SDCC_mcs51) && !defined(SDCC_mcs51)
27 #define __data
28 #define __xdata
29 #define __code
30 #define __bit bool
31 #define __sfr volatile unsigned char
32 #define __sbit volatile bool
33 #define __critical
34 #define __at(x)
35 #define __using(x)
36 #define __interrupt(x)
37 #define __naked
38 #endif
39 
40 #define CC_CONF_FUNCTION_POINTER_ARGS 1
41 #define CC_CONF_FASTCALL
42 #define CC_CONF_VA_ARGS 1
43 #define CC_CONF_UNSIGNED_CHAR_BUGS 0
44 #define CC_CONF_REGISTER_ARGS 0
45 #define CC_CONF_FUNCTION_POINTER_KEYWORD __reentrant
46 #define CC_CONF_NON_BANKED_OPTIMIZATION 1
47 
48 #if (defined(__SDCC_mcs51) || defined(SDCC_mcs51)) && CC_CONF_NON_BANKED_OPTIMIZATION
49 #define CC_NON_BANKED __nonbanked
50 #else
51 #define CC_NON_BANKED
52 #endif
53 
54 /*
55  * Max Stack Depth manipulation. It is possible to get up to 247 bytes
56  * allocated for the stack if:
57  * - You set this to 1 and
58  * - You have a patched toolchain and
59  * - You don't use __bit variables
60  * - You do not link libraries using BIT registers (e.g. printf_large)
61  * Enabling this will mean ISRs will NOT push bits (#pragma exclude bits) so
62  * make sure you know what you're doing
63  *
64  * More information on the wiki
65  */
66 #define CC_CONF_OPTIMIZE_STACK_SIZE 0
67 
68 #if CC_CONF_OPTIMIZE_STACK_SIZE
69 #define CC_AT_DATA
70 #else
71 #define CC_AT_DATA __data
72 #endif
73 
74 /* Generic types. */
75 typedef unsigned short uip_stats_t;
76 
77 /* Time type. */
78 typedef unsigned short clock_time_t;
79 #define MAX_TICKS (~((clock_time_t)0) / 2)
80 /* Defines tick counts for a second. */
81 #define CLOCK_CONF_SECOND 128
82 
83 /* Compiler configurations */
84 #define CCIF
85 #define CLIF
86 
87 /* Single asm instruction without messing up syntax highlighting */
88 #if defined(__SDCC_mcs51) || defined(SDCC_mcs51)
89 #define ASM(x) __asm \
90  x \
91  __endasm
92 #else
93 #define ASM(x)
94 #endif
95 
96 /* Critical section management */
97 #define DISABLE_INTERRUPTS() do {EA = 0;} while(0)
98 #define ENABLE_INTERRUPTS() do {EA = 1;} while(0)
99 
100 /* Macro for a soft reset. */
101 #define SOFT_RESET() do {((void (__code *) (void)) 0x0000) ();} while(0)
102 
103 /* We don't provide architecture-specific checksum calculations */
104 #define UIP_ARCH_ADD32 0
105 #define UIP_ARCH_CHKSUM 0
106 
107 #define CC_CONF_ASSIGN_AGGREGATE(dest, src) \
108  memcpy(dest, src, sizeof(*dest))
109 
110 #define uip_ipaddr_copy(dest, src) \
111  memcpy(dest, src, sizeof(*dest))
112 
113 #endif /* E051_DEF_H_ */