15 #include <sys/thread.h>
32 #define HUBDATA __attribute__((section(".hub")))
43 #define HUBTEXT __attribute__((section(".hubtext")))
46 #define CLKFREQ _CLKFREQ
49 #define CLKMODE _CLKMODE
63 #define clkset(mode, frequency) \
65 _CLKFREQ = (frequency); \
67 __builtin_propeller_clkset(mode); \
76 #define cogid() __builtin_propeller_cogid()
94 #define cognew(code, param) coginit(0x8, (code), (param))
100 #define cogstop(a) __builtin_propeller_cogstop((a))
108 #ifndef EXTRA_STACK_BYTES
109 #ifdef __PROPELLER_USE_XMM__
110 #define EXTRA_STACK_BYTES (1024 + 128 + 16 + 16 + sizeof(_thread_state_t))
112 #define EXTRA_STACK_BYTES (16 + sizeof(_thread_state_t))
119 #ifndef EXTRA_STACK_LONGS
120 #define EXTRA_STACK_LONGS (EXTRA_STACK_BYTES / 4)
139 int cogstart(
void (*func)(
void *),
void *par,
void *stack,
size_t stacksize);
147 #define locknew() __builtin_propeller_locknew()
155 #define lockret(lockid) __builtin_propeller_lockret((lockid))
163 #define lockset(lockid) __builtin_propeller_lockset((lockid))
170 #define lockclr(lockid) __builtin_propeller_lockclr((lockid))
176 #define waitcnt(a) __builtin_propeller_waitcnt((a),0)
183 #define waitcnt2(a,b) __builtin_propeller_waitcnt((a),(b))
190 #define waitpeq(state, mask) __builtin_propeller_waitpeq((state), (mask))
197 #define waitpne(state, mask) __builtin_propeller_waitpne((state), (mask))
205 #define waitvid(colors, pixels) __builtin_propeller_waitvid((colors), (pixels))
210 #if defined(__PROPELLER_USE_XMM__)
230 static __inline__
void copy_from_xmm(uint32_t *dst, uint32_t *src,
int count)
232 memcpy(dst, src,
count*4);
240 static __inline__ uint32_t rdlong_xmm(uint32_t *addr)
244 "xmmio rdlong,%[_value],%[_addr]"
246 [_value]
"=r" (value)
259 static __inline__
void wrlong_xmm(uint32_t *addr, uint32_t value)
262 "xmmio wrlong,%[_value],%[_addr]"
275 void kernel_use_lock(uint32_t lockId);
283 #if defined(__PROPELLER_USE_XMM__)
289 #define use_cog_driver(id) extern uint32_t binary_##id##_dat_start[], binary_##id##_dat_end[]
295 #define get_cog_driver(id) \
296 get_cog_driver_xmm( \
297 binary_##id##_dat_start, \
298 binary_##id##_dat_end - binary_##id##_dat_start)
306 #define load_cog_driver(id, param) \
307 load_cog_driver_xmm( \
308 binary_##id##_dat_start, \
309 binary_##id##_dat_end - binary_##id##_dat_start, \
312 uint32_t *get_cog_driver_xmm(uint32_t *code, uint32_t codelen);
313 int load_cog_driver_xmm(uint32_t *code, uint32_t codelen, uint32_t *params);
321 #define use_cog_driver(id) extern uint32_t binary_##id##_dat_start[]
327 #define get_cog_driver(id) (binary_##id##_dat_start) \
335 #define load_cog_driver(id, param) cognew(binary_##id##_dat_start, (uint32_t *)(param))