/************************************************************ * WhatOS generated operating system * * * * File : include file * * WhatOS version: 2.0.2 * * Time: Sat, 28 May 2005 20:19:55 EDT * ************************************************************/ #ifndef __WOS_SIGNALS_H #define __WOS_SIGNALS_H 1 /************************************************************ * General defines and compiler-dependent types */ #define WOS_LITTLE_ENDIAN 1234 #define WOS_BIG_ENDIAN 4321 #define WOS_PDP_ENDIAN 3412 typedef char wchar; typedef short wshort; typedef long wlong; typedef int wint; typedef wint wboolean; typedef unsigned char wuchar; typedef unsigned short wushort; typedef unsigned long wulong; typedef unsigned int wuint; typedef float wfloat; typedef double wdouble; /************************************************************ * Target configuration: avr_gcc */ #include <inttypes.h> #define WOS_BYTE_ORDER WOS_LITTLE_ENDIAN typedef int8_t wint8; typedef uint8_t wuint8; typedef int16_t wint16; typedef uint16_t wuint16; typedef int32_t wint32; typedef uint32_t wuint32; /************************************************************ * Non-elementary type definitions */ typedef struct packet { wuint8 len; wuint8 data[16]; } packet; /************************************************************ * External C interface */ #define WOS_ENVIRONMENT (0xff) #define wos_acquire(typeid) wos_alloc_acquire(typeid) #define wos_reference(b) wos_alloc_reference(b) #define wos_release(b) wos_alloc_release(b) #ifdef __cplusplus extern "C" #endif void wos_init(void); #ifdef __cplusplus extern "C" #endif void wos_process(wuint8 forever); #ifdef __cplusplus extern "C" #endif void wos_emit(wuint8 sigid, void * sigval, wuint8 source_taskid); #ifdef __cplusplus extern "C" #endif wuint16 wos_system_signature(void); #ifdef __cplusplus extern "C" #endif void * wos_alloc_acquire(wuint8 typeid_); #ifdef __cplusplus extern "C" #endif void wos_alloc_reference(void *b); #ifdef __cplusplus extern "C" #endif void wos_alloc_release(void *b); /*** signal ids ***/ /* -- non-group signals -- */ #define wos_sig_hello (0) #define wos_sig_reply (1) #define wos_sig_sub_rx_byte (2) #define wos_sig_sub_tx_byte (3) #define wos_sig_sub_tx_rdy (4) /*** allocated type ids ***/ #define wos_type_packet (0) #define wos_type_wos_Signal (1) /************************************************************ * User defined header */ #include <avr/io.h> #include <avr/interrupt.h> #define hook_sub_tx_byte(src, val) {UDR = (wuint8) (unsigned int)(val);} #define wos_periodic() { if (UCSRA & (1<<TXC)) { UCSRA |= (1<<TXC); wos_emit(wos_sig_sub_tx_rdy, 0, WOS_ENVIRONMENT); } if (UCSRA & (1<<RXC)) { wos_emit(wos_sig_sub_rx_byte, (void *) (unsigned int) UDR, WOS_ENVIRONMENT); } } /************************************************************ * Debugging support */ /* define one of (WOS_DBG_SIM, WOS_DBG_SHELL, nothing) */ #ifdef WOS_ASSERT_INTERNALS # define WOS_ASSERT_wos_block_simint 1 # define WOS_ASSERT_wos_block_signalq 1 # define WOS_ASSERT_wos_block_alloc 1 # define WOS_ASSERT_wos_block_process 1 # define WOS_ASSERT_wos_block_types 1 # define WOS_ASSERT_wos_block_glue 1 #endif /* WOS_ASSERT_INTERNALS */ #ifndef WOS_TRACE_wos_block_simint # define WOS_TRACE_wos_block_simint 0 #endif #ifndef WOS_ASSERT_wos_block_simint # define WOS_ASSERT_wos_block_simint 0 #endif #ifndef WOS_TRACEE_wos_block_simint # define WOS_TRACEE_wos_block_simint 0 #endif #ifndef WOS_ASSERTE_wos_block_simint # define WOS_ASSERTE_wos_block_simint 0 #endif #ifndef WOS_TRACE_wos_block_signalq # define WOS_TRACE_wos_block_signalq 0 #endif #ifndef WOS_ASSERT_wos_block_signalq # define WOS_ASSERT_wos_block_signalq 0 #endif #ifndef WOS_TRACEE_wos_block_signalq # define WOS_TRACEE_wos_block_signalq 0 #endif #ifndef WOS_ASSERTE_wos_block_signalq # define WOS_ASSERTE_wos_block_signalq 0 #endif #ifndef WOS_TRACE_wos_block_alloc # define WOS_TRACE_wos_block_alloc 0 #endif #ifndef WOS_ASSERT_wos_block_alloc # define WOS_ASSERT_wos_block_alloc 0 #endif #ifndef WOS_TRACEE_wos_block_alloc # define WOS_TRACEE_wos_block_alloc 0 #endif #ifndef WOS_ASSERTE_wos_block_alloc # define WOS_ASSERTE_wos_block_alloc 0 #endif #ifndef WOS_TRACE_wos_block_process # define WOS_TRACE_wos_block_process 0 #endif #ifndef WOS_ASSERT_wos_block_process # define WOS_ASSERT_wos_block_process 0 #endif #ifndef WOS_TRACEE_wos_block_process # define WOS_TRACEE_wos_block_process 0 #endif #ifndef WOS_ASSERTE_wos_block_process # define WOS_ASSERTE_wos_block_process 0 #endif #ifndef WOS_TRACE_wos_block_types # define WOS_TRACE_wos_block_types 0 #endif #ifndef WOS_ASSERT_wos_block_types # define WOS_ASSERT_wos_block_types 0 #endif #ifndef WOS_TRACEE_wos_block_types # define WOS_TRACEE_wos_block_types 0 #endif #ifndef WOS_ASSERTE_wos_block_types # define WOS_ASSERTE_wos_block_types 0 #endif #ifndef WOS_TRACE_wos_block_glue # define WOS_TRACE_wos_block_glue 0 #endif #ifndef WOS_ASSERT_wos_block_glue # define WOS_ASSERT_wos_block_glue 0 #endif #ifndef WOS_TRACEE_wos_block_glue # define WOS_TRACEE_wos_block_glue 0 #endif #ifndef WOS_ASSERTE_wos_block_glue # define WOS_ASSERTE_wos_block_glue 0 #endif #ifndef WOS_TRACE_csliprx # define WOS_TRACE_csliprx 0 #endif #ifndef WOS_ASSERT_csliprx # define WOS_ASSERT_csliprx 0 #endif #ifndef WOS_TRACEE_csliprx # define WOS_TRACEE_csliprx 0 #endif #ifndef WOS_ASSERTE_csliprx # define WOS_ASSERTE_csliprx 0 #endif #ifndef WOS_TRACE_csliptx # define WOS_TRACE_csliptx 0 #endif #ifndef WOS_ASSERT_csliptx # define WOS_ASSERT_csliptx 0 #endif #ifndef WOS_TRACEE_csliptx # define WOS_TRACEE_csliptx 0 #endif #ifndef WOS_ASSERTE_csliptx # define WOS_ASSERTE_csliptx 0 #endif #ifndef WOS_TRACE_hello_whatos # define WOS_TRACE_hello_whatos 0 #endif #ifndef WOS_ASSERT_hello_whatos # define WOS_ASSERT_hello_whatos 0 #endif #ifndef WOS_TRACEE_hello_whatos # define WOS_TRACEE_hello_whatos 0 #endif #ifndef WOS_ASSERTE_hello_whatos # define WOS_ASSERTE_hello_whatos 0 #endif #define WOS_DBG_NOTHING1(a) {} #define WOS_DBG_NOTHING2(a, b) {} #define WOS_DBG_NOTHING3(a, b, c) {} #define WOS_DBG_NOTHING4(a, b, c, d) {} #define WOS_DBG_NOTHING5(a, b, c, d, e) {} #define WOS_DBG_NOTHING6(a, b, c, d, e, f) {} #define WOS_DBG_NOTHING7(a, b, c, d, e, f, g) {} #define WOS_DBG_NOTHING8(a, b, c, d, e, f, g, h) {} #define WOS_DBG_NOTHING9(a, b, c, d, e, f, g, h, i) {} #if defined WOS_DBG_SHELL /****** shell debugging ******/ #include <stdio.h> /* TRACE */ #define wos_trace_before { \ fprintf(stderr, "TRACE(%s): ", WOS_STRING(WOS_BLOCKNAME)); \ fprintf(stderr, #define wos_trace_after ); fprintf(stderr, "\n");} #define WOS_TRACE1(a) \ wos_trace_before a wos_trace_after #define WOS_TRACE2(a, b) \ wos_trace_before a, b wos_trace_after #define WOS_TRACE3(a, b, c) \ wos_trace_before a, b, c wos_trace_after #define WOS_TRACE4(a, b, c, d) \ wos_trace_before a, b, c, d wos_trace_after #define WOS_TRACE5(a, b, c, d, e) \ wos_trace_before a, b, c, d, e wos_trace_after #define WOS_TRACE6(a, b, c, d, e, f) \ wos_trace_before a, b, c, d, e, f wos_trace_after #define WOS_TRACE7(a, b, c, d, e, f, g) \ wos_trace_before a, b, c, d, e, f, g wos_trace_after #define WOS_TRACE8(a, b, c, d, e, f, g, h) \ wos_trace_before a, b, c, d, e, f, g, h wos_trace_after /* SM_TRACE */ #define WOS_SM_TRACE(transition) { \ fprintf(stderr, "TRACE(%s): %s", WOS_STRING(WOS_BLOCKNAME), \ transition); \ fprintf(stderr, "\n"); \ } /* ASSERT */ #define wos_assert_before(cond) if (!(cond)) { \ fprintf(stderr, "ASSERT(%s): ", WOS_STRING(WOS_BLOCKNAME)); \ fprintf(stderr, #define wos_assert_after ); fprintf(stderr, "\n");} #define WOS_ASSERT1(cond, a) \ wos_assert_before(cond) a wos_assert_after #define WOS_ASSERT2(cond, a, b) \ wos_assert_before(cond) a, b wos_assert_after #define WOS_ASSERT3(cond, a, b, c) \ wos_assert_before(cond) a, b, c wos_assert_after #define WOS_ASSERT4(cond, a, b, c, d) \ wos_assert_before(cond) a, b, c, d wos_assert_after #define WOS_ASSERT5(cond, a, b, c, d, e) \ wos_assert_before(cond) a, b, c, d, e wos_assert_after #define WOS_ASSERT6(cond, a, b, c, d, e, f) \ wos_assert_before(cond) a, b, c, d, e, f wos_assert_after #define WOS_ASSERT7(cond, a, b, c, d, e, f, g) \ wos_assert_before(cond) a, b, c, d, e, f, g wos_assert_after #define WOS_ASSERT8(cond, a, b, c, d, e, f, g, h) \ wos_assert_before(cond) a, b, c, d, e, f, g, h wos_assert_after #elif defined WOS_DBG_SIM /****** python simulation debugging ******/ #include <stdio.h> /* every object file contains a buf */ static char wos_sim_outbuf[1024]; #ifdef __cplusplus extern "C" #else extern #endif void wos_sim_assert(char const *s, char const *message, wint line); #ifdef __cplusplus extern "C" #else extern #endif void wos_sim_trace(char const *s, char const *message, wint line); #ifdef __cplusplus extern "C" #else extern #endif void wos_sim_sm_trace(char const *s, char const *message); /* TRACE */ #define wos_trace_before {sprintf(wos_sim_outbuf, #define wos_trace_after ); \ wos_sim_trace((char const *) WOS_STRING(WOS_BLOCKNAME), \ (char const *) wos_sim_outbuf, 0); \ } #define WOS_TRACE1(a) \ wos_trace_before a wos_trace_after #define WOS_TRACE2(a, b) \ wos_trace_before a, b wos_trace_after #define WOS_TRACE3(a, b, c) \ wos_trace_before a, b, c wos_trace_after #define WOS_TRACE4(a, b, c, d) \ wos_trace_before a, b, c, d wos_trace_after #define WOS_TRACE5(a, b, c, d, e) \ wos_trace_before a, b, c, d, e wos_trace_after #define WOS_TRACE6(a, b, c, d, e, f) \ wos_trace_before a, b, c, d, e, f wos_trace_after #define WOS_TRACE7(a, b, c, d, e, f, g) \ wos_trace_before a, b, c, d, e, f, g wos_trace_after #define WOS_TRACE8(a, b, c, d, e, f, g, h) \ wos_trace_before a, b, c, d, e, f, g, h wos_trace_after /* SM_TRACE */ #define WOS_SM_TRACE(transition) { \ wos_sim_sm_trace((char const *) WOS_STRING(WOS_BLOCKNAME), \ (char const *) transition); \ } /* ASSERT */ #define wos_assert_before(cond) if (!(cond)) {sprintf(wos_sim_outbuf, #define wos_assert_after ); \ wos_sim_assert((char const *) WOS_STRING(WOS_BLOCKNAME), \ (char const *) wos_sim_outbuf, 0); \ } #define WOS_ASSERT1(cond, a) \ wos_assert_before(cond) a wos_assert_after #define WOS_ASSERT2(cond, a, b) \ wos_assert_before(cond) a, b wos_assert_after #define WOS_ASSERT3(cond, a, b, c) \ wos_assert_before(cond) a, b, c wos_assert_after #define WOS_ASSERT4(cond, a, b, c, d) \ wos_assert_before(cond) a, b, c, d wos_assert_after #define WOS_ASSERT5(cond, a, b, c, d, e) \ wos_assert_before(cond) a, b, c, d, e wos_assert_after #define WOS_ASSERT6(cond, a, b, c, d, e, f) \ wos_assert_before(cond) a, b, c, d, e, f wos_assert_after #define WOS_ASSERT7(cond, a, b, c, d, e, f, g) \ wos_assert_before(cond) a, b, c, d, e, f, g wos_assert_after #define WOS_ASSERT8(cond, a, b, c, d, e, f, g, h) \ wos_assert_before(cond) a, b, c, d, e, f, g, h wos_assert_after #else /****** no debugging ******/ /* TRACE */ #define WOS_TRACE1 WOS_DBG_NOTHING1 #define WOS_TRACE2 WOS_DBG_NOTHING2 #define WOS_TRACE3 WOS_DBG_NOTHING3 #define WOS_TRACE4 WOS_DBG_NOTHING4 #define WOS_TRACE5 WOS_DBG_NOTHING5 #define WOS_TRACE6 WOS_DBG_NOTHING6 #define WOS_TRACE7 WOS_DBG_NOTHING7 #define WOS_TRACE8 WOS_DBG_NOTHING8 /* SM_TRACE */ #define WOS_SM_TRACE(transition) {} /* ASSERT */ #define WOS_ASSERT1 WOS_DBG_NOTHING2 #define WOS_ASSERT2 WOS_DBG_NOTHING3 #define WOS_ASSERT3 WOS_DBG_NOTHING4 #define WOS_ASSERT4 WOS_DBG_NOTHING5 #define WOS_ASSERT5 WOS_DBG_NOTHING6 #define WOS_ASSERT6 WOS_DBG_NOTHING7 #define WOS_ASSERT7 WOS_DBG_NOTHING8 #define WOS_ASSERT8 WOS_DBG_NOTHING9 #endif /* type of debugging */ /* tests to see if debugging is enabled for a block */ #define WOS_TRACE_ON_(x) WOS_TRACE_##x #define WOS_TRACE_ON(x) WOS_TRACE_ON_(x) #define WOS_ASSERT_ON_(x) WOS_ASSERT_##x #define WOS_ASSERT_ON(x) WOS_ASSERT_ON_(x) #define WOS_TRACEE_ON_(x) WOS_TRACEE_##x #define WOS_TRACEE_ON(x) WOS_TRACEE_ON_(x) #define WOS_ASSERTE_ON_(x) WOS_ASSERTE_##x #define WOS_ASSERTE_ON(x) WOS_ASSERTE_ON_(x) /* sringify */ #define WOS_STRING_(x) #x #define WOS_STRING(x) WOS_STRING_(x) #endif /* __WOS_SIGNALS_H */ /* included repeatedly to start/end a block */ #if defined WOS_BLOCK_START # if WOS_TRACE_ON(WOS_BLOCKNAME) # define TRACE1 WOS_TRACE1 # define TRACE2 WOS_TRACE2 # define TRACE3 WOS_TRACE3 # define TRACE4 WOS_TRACE4 # define TRACE5 WOS_TRACE5 # define TRACE6 WOS_TRACE6 # define TRACE7 WOS_TRACE7 # define TRACE8 WOS_TRACE8 # else # define TRACE1 WOS_DBG_NOTHING1 # define TRACE2 WOS_DBG_NOTHING2 # define TRACE3 WOS_DBG_NOTHING3 # define TRACE4 WOS_DBG_NOTHING4 # define TRACE5 WOS_DBG_NOTHING5 # define TRACE6 WOS_DBG_NOTHING6 # define TRACE7 WOS_DBG_NOTHING7 # define TRACE8 WOS_DBG_NOTHING8 # endif # if WOS_TRACEE_ON(WOS_BLOCKNAME) # define TRACEE WOS_TRACEE # define MTRACEE WOS_MTRACEE # else # define TRACEE WOS_DBG_NOTHING1 # define MTRACEE WOS_DBG_NOTHING1 # endif # if WOS_ASSERTE_ON(WOS_BLOCKNAME) # define ASSERTE WOS_ASSERTE # define MASSERTE WOS_MASSERTE # else # define ASSERTE WOS_DBG_NOTHING2 # define MASSERTE WOS_DBG_NOTHING2 # endif # if WOS_ASSERT_ON(WOS_BLOCKNAME) # define ASSERT1 WOS_ASSERT1 # define ASSERT2 WOS_ASSERT2 # define ASSERT3 WOS_ASSERT3 # define ASSERT4 WOS_ASSERT4 # define ASSERT5 WOS_ASSERT5 # define ASSERT6 WOS_ASSERT6 # define ASSERT7 WOS_ASSERT7 # define ASSERT8 WOS_ASSERT8 # else # define ASSERT1 WOS_DBG_NOTHING2 # define ASSERT2 WOS_DBG_NOTHING3 # define ASSERT3 WOS_DBG_NOTHING4 # define ASSERT4 WOS_DBG_NOTHING5 # define ASSERT5 WOS_DBG_NOTHING6 # define ASSERT6 WOS_DBG_NOTHING7 # define ASSERT7 WOS_DBG_NOTHING8 # define ASSERT8 WOS_DBG_NOTHING9 # endif # undef WOS_BLOCK_START #endif /* WOS_BLOCK_START */ #if defined WOS_BLOCK_END # undef TRACE1 # undef TRACE2 # undef TRACE3 # undef TRACE4 # undef TRACE5 # undef TRACE6 # undef TRACE7 # undef TRACE8 # undef ASSERT1 # undef ASSERT2 # undef ASSERT3 # undef ASSERT4 # undef ASSERT5 # undef ASSERT6 # undef ASSERT7 # undef ASSERT8 # undef ASSERTE # undef MASSERTE # undef TRACEE # undef MTRACEE # undef WOS_BLOCK_END # undef WOS_BLOCKNAME #endif /* WOS_BLOCK_END */