]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
safe tinyos annotations
authorregehr <regehr>
Tue, 3 Jun 2008 03:00:59 +0000 (03:00 +0000)
committerregehr <regehr>
Tue, 3 Jun 2008 03:00:59 +0000 (03:00 +0000)
tos/chips/atm128/Atm128UartP.nc
tos/chips/atm128/adc/AdcStreamP.nc
tos/chips/atm128/spi/Atm128SpiP.nc
tos/chips/atm128/timer/HplAtm128Timer1P.nc

index 2b904b41422bd371b1efd2dce1788b0343888387..527e264e48e01eb465d14bec459e4ed801da0aaa 100644 (file)
@@ -59,8 +59,8 @@ generic module Atm128UartP(){
 
 implementation{
   
-  norace uint8_t *m_tx_buf, *m_rx_buf;
   norace uint16_t m_tx_len, m_rx_len;
+  norace uint8_t *COUNT_NOK(m_tx_len) m_tx_buf, * COUNT_NOK(m_rx_len) m_rx_buf;
   norace uint16_t m_tx_pos, m_rx_pos;
   norace uint16_t m_byte_time;
   norace uint8_t m_rx_intr;
@@ -159,8 +159,8 @@ implementation{
     else if ( m_tx_buf )
       return EBUSY;
     
-    m_tx_buf = buf;
     m_tx_len = len;
+    m_tx_buf = buf;
     m_tx_pos = 0;
     m_tx_intr = 1;
     call HplUart.enableTxIntr();
index 6bc47bc1272199dd6447220bb50bea15c322f5e8..7d3701cc59e4517b7f727582f002fdeece214924 100644 (file)
@@ -68,13 +68,15 @@ implementation {
   /* Stream data */
   struct list_entry_t {
     uint16_t count;
-    struct list_entry_t *next;
+    struct list_entry_t * ONE_NOK next;
   };
   struct list_entry_t *bufferQueue[NSTREAM];
-  struct list_entry_t **bufferQueueEnd[NSTREAM];
-  uint16_t *lastBuffer, lastCount;
+  struct list_entry_t * ONE_NOK * bufferQueueEnd[NSTREAM];
+  uint16_t * ONE_NOK lastBuffer, lastCount;
 
-  norace uint16_t *buffer, *pos, count;
+  norace uint16_t count;
+  norace uint16_t * COUNT_NOK(count) buffer; 
+  norace uint16_t * FAT_NOK(buffer, buffer+count) pos;
   norace uint32_t now, period;
 
 
@@ -108,7 +110,7 @@ implementation {
       return ESIZE;
     atomic
       {
-       struct list_entry_t *newEntry = (struct list_entry_t *)buf;
+       struct list_entry_t * ONE newEntry = TCAST(struct list_entry_t * ONE, buf);
 
        if (!bufferQueueEnd[c]) // Can't post right now.
          return FAIL;
@@ -141,8 +143,10 @@ implementation {
     uint8_t c = client;
 
     atomic entry = bufferQueue[c];
-    for (; entry; entry = entry->next)
-      signal ReadStream.bufferDone[c](FAIL, (uint16_t *)entry, entry->count);
+    for (; entry; entry = entry->next){
+      uint16_t tmp_count = entry->count;
+      signal ReadStream.bufferDone[c](FAIL, TCAST(uint16_t * COUNT_NOK(tmp_count),entry), entry->count);
+    }
 
     atomic
       {
@@ -200,11 +204,13 @@ implementation {
          }
        else
          {
+            uint16_t tmp_count;
            bufferQueue[client] = entry->next;
            if (!bufferQueue[client])
              bufferQueueEnd[client] = &bufferQueue[client];
-           pos = buffer = (uint16_t *)entry;
            count = entry->count;
+            tmp_count = count;
+           pos = buffer = TCAST(uint16_t * COUNT_NOK(tmp_count), entry);
            nextAlarm();
          }
       }
index da7f06298d3b02dede343f8bf047c908969a9d66..ffa653cc904b40eeb721c232163e1e9afdafd9e3 100644 (file)
@@ -87,9 +87,9 @@ module Atm128SpiP {
   }
 }
 implementation {
-  uint8_t* txBuffer;
-  uint8_t* rxBuffer;
   uint16_t len;
+  uint8_t* COUNT_NOK(len) txBuffer;
+  uint8_t* COUNT_NOK(len) rxBuffer;
   uint16_t pos;
   
   enum {
@@ -162,10 +162,12 @@ implementation {
   error_t sendNextPart() {
     uint16_t end;
     uint16_t tmpPos;
-    uint8_t* tx;
-    uint8_t* rx;
+    uint16_t myLen;
+    uint8_t* COUNT_NOK(myLen) tx;
+    uint8_t* COUNT_NOK(myLen) rx;
     
     atomic {
+      myLen = len;
       tx = txBuffer;
       rx = rxBuffer;
       tmpPos = pos;
@@ -203,13 +205,14 @@ implementation {
 
 
   task void zeroTask() {
-     uint8_t* rx;
-     uint8_t* tx;
      uint16_t  myLen;
+     uint8_t* COUNT_NOK(myLen) rx;
+     uint8_t* COUNT_NOK(myLen) tx;
+
      atomic {
+       myLen = len;
        rx = rxBuffer;
        tx = txBuffer;
-       myLen = len;
        rxBuffer = NULL;
        txBuffer = NULL;
        len = 0;
@@ -240,9 +243,9 @@ implementation {
                                       uint16_t  bufLen) {
     uint8_t discard;
     atomic {
+      len = bufLen;
       txBuffer = writeBuf;
       rxBuffer = readBuf;
-      len = bufLen;
       pos = 0;
     }
     if (bufLen > 0) {
@@ -279,15 +282,15 @@ implementation {
      sendNextPart();
    }
    else {
-     uint8_t* rx;
-     uint8_t* tx;
-     uint16_t  myLen;
      uint8_t discard;
+     uint16_t  myLen;
+     uint8_t* COUNT_NOK(myLen) rx;
+     uint8_t* COUNT_NOK(myLen) tx;
      
      atomic {
+       myLen = len;
        rx = rxBuffer;
        tx = txBuffer;
-       myLen = len;
        rxBuffer = NULL;
        txBuffer = NULL;
        len = 0;
index adaa66dea1e7eb2bebc55e6782ce0af2b87ab7fa..91f6ebf6f03224038ccca4ec56261d4b8d51625f 100644 (file)
@@ -66,13 +66,13 @@ implementation
 
   //=== Read the control registers. =====================================
   async command Atm128TimerCtrlCompare_t TimerCtrl.getCtrlCompare() { 
-    return *(Atm128TimerCtrlCompare_t*)&TCCR1A; 
+    return *(Atm128TimerCtrlCompare_t*ONE)&TCCR1A; 
   }
   async command Atm128TimerCtrlCapture_t TimerCtrl.getCtrlCapture() { 
-    return *(Atm128TimerCtrlCapture_t*)&TCCR1B; 
+    return *(Atm128TimerCtrlCapture_t*ONE)&TCCR1B; 
   }
   async command Atm128TimerCtrlClock_t TimerCtrl.getCtrlClock() { 
-    return *(Atm128TimerCtrlClock_t*)&TCCR1C; 
+    return *(Atm128TimerCtrlClock_t*ONE)&TCCR1C; 
   }
 
 
@@ -107,7 +107,7 @@ implementation
 
   //=== Read the interrupt flags. =====================================
   async command Atm128_ETIFR_t TimerCtrl.getInterruptFlag() { 
-    return *(Atm128_ETIFR_t*)&ETIFR; 
+    return *(Atm128_ETIFR_t*ONE)&ETIFR; 
   }
 
   //=== Write the interrupt flags. ====================================