Skip to content
This repository
tree: e35644b668
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 453 lines (424 sloc) 14.066 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
From 03d48388deafe23774fbd3bc5c6947c3671f802a Mon Sep 17 00:00:00 2001
From: Alexander Bernauer <alex@copton.net>
Date: Mon, 4 Jun 2012 15:52:22 +0200
Subject: [PATCH 4/4] detailed CPU cycle tracking for processes

Conflicts:

cpu/msp430/f2xxx/uart0.c
---
 core/sys/process.c | 3 +++
 cpu/msp430/Makefile.msp430 | 3 ++-
 cpu/msp430/cc2420-arch-sfd.c | 3 +++
 cpu/msp430/cc2420-arch.c | 3 +++
 cpu/msp430/cc2520-arch-sfd.c | 3 +++
 cpu/msp430/cc2520-arch.c | 3 +++
 cpu/msp430/f1xxx/clock.c | 3 +++
 cpu/msp430/f1xxx/rtimer-arch.c | 3 +++
 cpu/msp430/f1xxx/uart1.c | 5 +++++
 cpu/msp430/f2xxx/uart0.c | 5 +++++
 cpu/msp430/f5xxx/clock.c | 3 +++
 cpu/msp430/f5xxx/rtimer-arch.c | 3 +++
 cpu/msp430/f5xxx/uart0.c | 3 +++
 cpu/msp430/f5xxx/uart1.c | 3 +++
 cpu/msp430/ocram_cooja.c | 5 +++++
 cpu/msp430/ocram_cooja.h | 17 +++++++++++++++++
 cpu/msp430/watchdog.c | 3 +++
 17 files changed, 70 insertions(+), 1 deletions(-)
 create mode 100644 cpu/msp430/ocram_cooja.c
 create mode 100644 cpu/msp430/ocram_cooja.h

diff --git a/core/sys/process.c b/core/sys/process.c
index 70adf67..24317c6 100644
--- a/core/sys/process.c
+++ b/core/sys/process.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2005, Swedish Institute of Computer Science
  * All rights reserved.
@@ -188,7 +189,9 @@ call_process(struct process *p, process_event_t ev, process_data_t data)
     PRINTF("process: calling process '%s' with event %d\n", PROCESS_NAME_STRING(p), ev);
     process_current = p;
     p->state = PROCESS_STATE_CALLED;
+ ENTER_PROCESS(p);
     ret = p->thread(&p->pt, ev, data);
+ LEAVE_PROCESS();
     if(ret == PT_EXITED ||
        ret == PT_ENDED ||
        ev == PROCESS_EVENT_EXIT) {
diff --git a/cpu/msp430/Makefile.msp430 b/cpu/msp430/Makefile.msp430
index 8e9ffd2..ed14694 100644
--- a/cpu/msp430/Makefile.msp430
+++ b/cpu/msp430/Makefile.msp430
@@ -33,7 +33,8 @@ endif
 CONTIKI_CPU_DIRS = $(CONTIKI_CPU_FAM_DIR) . dev
 
 MSP430 = msp430.c flash.c clock.c leds.c leds-arch.c \
- watchdog.c lpm.c mtarch.c rtimer-arch.c
+ watchdog.c lpm.c mtarch.c rtimer-arch.c \
+ ocram_cooja.c
 UIPDRIVERS = me.c me_tabs.c slip.c crc16.c
 ELFLOADER = elfloader.c elfloader-msp430.c symtab.c
 
diff --git a/cpu/msp430/cc2420-arch-sfd.c b/cpu/msp430/cc2420-arch-sfd.c
index 856a5d2..9bb6c65 100644
--- a/cpu/msp430/cc2420-arch-sfd.c
+++ b/cpu/msp430/cc2420-arch-sfd.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2009, Swedish Institute of Computer Science
  * All rights reserved.
@@ -42,6 +43,7 @@ extern volatile uint16_t cc2420_sfd_end_time;
 /* SFD interrupt for timestamping radio packets */
 ISR(TIMERB1, cc2420_timerb1_interrupt)
 {
+ ENTER_INTERRUPT();
   int tbiv;
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
   /* always read TBIV to clear IFG */
@@ -54,6 +56,7 @@ ISR(TIMERB1, cc2420_timerb1_interrupt)
     cc2420_sfd_end_time = TBCCR1;
   }
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 void
diff --git a/cpu/msp430/cc2420-arch.c b/cpu/msp430/cc2420-arch.c
index e6ad965..6015960 100644
--- a/cpu/msp430/cc2420-arch.c
+++ b/cpu/msp430/cc2420-arch.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2006, Swedish Institute of Computer Science
  * All rights reserved.
@@ -51,6 +52,7 @@
 /*---------------------------------------------------------------------------*/
 ISR(CC2420_IRQ, cc2420_port1_interrupt)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
   if(cc2420_interrupt()) {
@@ -58,6 +60,7 @@ ISR(CC2420_IRQ, cc2420_port1_interrupt)
   }
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 void
diff --git a/cpu/msp430/cc2520-arch-sfd.c b/cpu/msp430/cc2520-arch-sfd.c
index ff47a48..9dee13b 100644
--- a/cpu/msp430/cc2520-arch-sfd.c
+++ b/cpu/msp430/cc2520-arch-sfd.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2011, Swedish Institute of Computer Science
  * All rights reserved.
@@ -40,6 +41,7 @@ extern volatile uint16_t cc2520_sfd_end_time;
 /* SFD interrupt for timestamping radio packets */
 ISR(TIMERB1, cc2520_timerb1_interrupt)
 {
+ ENTER_INTERRUPT();
   int tbiv;
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
   /* always read TBIV to clear IFG */
@@ -52,6 +54,7 @@ ISR(TIMERB1, cc2520_timerb1_interrupt)
     cc2520_sfd_end_time = TBCCR1;
   }
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 void
diff --git a/cpu/msp430/cc2520-arch.c b/cpu/msp430/cc2520-arch.c
index e8792b8..2b113fd 100644
--- a/cpu/msp430/cc2520-arch.c
+++ b/cpu/msp430/cc2520-arch.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2011, Swedish Institute of Computer Science
  * All rights reserved.
@@ -49,6 +50,7 @@
 /*---------------------------------------------------------------------------*/
 ISR(CC2520_IRQ, cc2520_port1_interrupt)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
   if(cc2520_interrupt()) {
@@ -56,6 +58,7 @@ ISR(CC2520_IRQ, cc2520_port1_interrupt)
   }
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 void
diff --git a/cpu/msp430/f1xxx/clock.c b/cpu/msp430/f1xxx/clock.c
index b17694f..f80e625 100644
--- a/cpu/msp430/f1xxx/clock.c
+++ b/cpu/msp430/f1xxx/clock.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2005, Swedish Institute of Computer Science
  * All rights reserved.
@@ -49,6 +50,7 @@ static volatile uint16_t last_tar = 0;
 /*---------------------------------------------------------------------------*/
 ISR(TIMERA1, timera1)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
   watchdog_start();
@@ -94,6 +96,7 @@ ISR(TIMERA1, timera1)
   watchdog_stop();
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 clock_time_t
diff --git a/cpu/msp430/f1xxx/rtimer-arch.c b/cpu/msp430/f1xxx/rtimer-arch.c
index a1ef89a..0907c08 100644
--- a/cpu/msp430/f1xxx/rtimer-arch.c
+++ b/cpu/msp430/f1xxx/rtimer-arch.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2007, Swedish Institute of Computer Science.
  * All rights reserved.
@@ -57,6 +58,7 @@
 /*---------------------------------------------------------------------------*/
 ISR(TIMERA0, timera0)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
   watchdog_start();
@@ -70,6 +72,7 @@ ISR(TIMERA0, timera0)
   watchdog_stop();
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 void
diff --git a/cpu/msp430/f1xxx/uart1.c b/cpu/msp430/f1xxx/uart1.c
index 123b542..055847d 100644
--- a/cpu/msp430/f1xxx/uart1.c
+++ b/cpu/msp430/f1xxx/uart1.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2006, Swedish Institute of Computer Science
  * All rights reserved.
@@ -239,6 +240,7 @@ uart1_init(unsigned long ubr)
 #if !RX_WITH_DMA
 ISR(UART1RX, uart1_rx_interrupt)
 {
+ ENTER_INTERRUPT();
   uint8_t c;
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
@@ -264,12 +266,14 @@ ISR(UART1RX, uart1_rx_interrupt)
   }
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 #endif /* !RX_WITH_DMA */
 /*---------------------------------------------------------------------------*/
 #if TX_WITH_INTERRUPT
 ISR(UART1TX, uart1_tx_interrupt)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
   if(ringbuf_elements(&txbuf) == 0) {
@@ -279,6 +283,7 @@ ISR(UART1TX, uart1_tx_interrupt)
   }
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 #endif /* TX_WITH_INTERRUPT */
 /*---------------------------------------------------------------------------*/
diff --git a/cpu/msp430/f2xxx/uart0.c b/cpu/msp430/f2xxx/uart0.c
index d0ad497..9ab0f47 100644
--- a/cpu/msp430/f2xxx/uart0.c
+++ b/cpu/msp430/f2xxx/uart0.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2010, Swedish Institute of Computer Science
  * All rights reserved.
@@ -141,6 +142,7 @@ uart0_init(unsigned long ubr)
 /*---------------------------------------------------------------------------*/
 ISR(USCIAB0RX, uart0_rx_interrupt)
 {
+ ENTER_INTERRUPT();
   uint8_t c;
 
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
@@ -156,11 +158,13 @@ ISR(USCIAB0RX, uart0_rx_interrupt)
     }
   }
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 #if TX_WITH_INTERRUPT
 ISR(USCIAB0TX, uart0_tx_interrupt)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
   if((IFG2 & UCA0TXIFG)){
 
@@ -175,6 +179,7 @@ ISR(USCIAB0TX, uart0_tx_interrupt)
   IFG2 &= ~UCA0TXIFG;
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 #endif /* TX_WITH_INTERRUPT */
 /*---------------------------------------------------------------------------*/
diff --git a/cpu/msp430/f5xxx/clock.c b/cpu/msp430/f5xxx/clock.c
index 3cda892..b21fd14 100644
--- a/cpu/msp430/f5xxx/clock.c
+++ b/cpu/msp430/f5xxx/clock.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2011, Swedish Institute of Computer Science
  * All rights reserved.
@@ -49,6 +50,7 @@ static volatile uint16_t last_tar = 0;
 /*---------------------------------------------------------------------------*/
 ISR(TIMER1_A1, timera1)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
   /* watchdog_start(); */
@@ -94,6 +96,7 @@ ISR(TIMER1_A1, timera1)
   /* watchdog_stop(); */
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 clock_time_t
diff --git a/cpu/msp430/f5xxx/rtimer-arch.c b/cpu/msp430/f5xxx/rtimer-arch.c
index 80f50ae..a004f5b 100644
--- a/cpu/msp430/f5xxx/rtimer-arch.c
+++ b/cpu/msp430/f5xxx/rtimer-arch.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2011, Swedish Institute of Computer Science.
  * All rights reserved.
@@ -54,6 +55,7 @@
 /*---------------------------------------------------------------------------*/
 ISR(TIMER1_A0, timera0)
 {
+ ENTER_INTERRUPT();
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
 
   watchdog_start();
@@ -67,6 +69,7 @@ ISR(TIMER1_A0, timera0)
   watchdog_stop();
 
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 void
diff --git a/cpu/msp430/f5xxx/uart0.c b/cpu/msp430/f5xxx/uart0.c
index 563da89..32db9ba 100644
--- a/cpu/msp430/f5xxx/uart0.c
+++ b/cpu/msp430/f5xxx/uart0.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2011, Swedish Institute of Computer Science
  * All rights reserved.
@@ -101,6 +102,7 @@ uart0_init(unsigned long ubr)
 /*---------------------------------------------------------------------------*/
 ISR(USCI_A0, uart0_rx_interrupt)
 {
+ ENTER_INTERRUPT();
   uint8_t c;
 
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
@@ -117,5 +119,6 @@ ISR(USCI_A0, uart0_rx_interrupt)
     }
   }
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
diff --git a/cpu/msp430/f5xxx/uart1.c b/cpu/msp430/f5xxx/uart1.c
index 8680b18..3821696 100644
--- a/cpu/msp430/f5xxx/uart1.c
+++ b/cpu/msp430/f5xxx/uart1.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2011, Swedish Institute of Computer Science
  * All rights reserved.
@@ -106,6 +107,7 @@ uart1_init(unsigned long ubr)
 /*---------------------------------------------------------------------------*/
 ISR(USCI_A1, uart1_rx_interrupt)
 {
+ ENTER_INTERRUPT();
   uint8_t c;
 
   ENERGEST_ON(ENERGEST_TYPE_IRQ);
@@ -122,5 +124,6 @@ ISR(USCI_A1, uart1_rx_interrupt)
     }
   }
   ENERGEST_OFF(ENERGEST_TYPE_IRQ);
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
diff --git a/cpu/msp430/ocram_cooja.c b/cpu/msp430/ocram_cooja.c
new file mode 100644
index 0000000..2b34fc4
--- /dev/null
+++ b/cpu/msp430/ocram_cooja.c
@@ -0,0 +1,5 @@
+#include "ocram_cooja.h"
+
+char interrupt_pseudo_process = 0;
+char printf_pseudo_process = 0;
+volatile void* process_hook = 0;
diff --git a/cpu/msp430/ocram_cooja.h b/cpu/msp430/ocram_cooja.h
new file mode 100644
index 0000000..d3c85a5
--- /dev/null
+++ b/cpu/msp430/ocram_cooja.h
@@ -0,0 +1,17 @@
+#ifndef AEXEIVATHEUHOHTIMUZI
+#define AEXEIVATHEUHOHTIMUZI
+
+extern char interrupt_pseudo_process;
+extern char printf_pseudo_process;
+extern volatile void* process_hook;
+
+#define ENTER_INTERRUPT() do { process_hook = &interrupt_pseudo_process; } while(0)
+#define LEAVE_INTERRUPT() do { process_hook = 0; } while(0)
+
+#define ENTER_PROCESS(p) do { process_hook = p; } while(0)
+#define LEAVE_PROCESS() do { process_hook = 0; } while(0)
+
+#define ENTER_PRINTF() do { process_hook = &printf_pseudo_process; } while (0)
+#define LEAVE_PRINTF() do { process_hook = 0; } while(0)
+
+#endif
diff --git a/cpu/msp430/watchdog.c b/cpu/msp430/watchdog.c
index b38db16..c28d747 100644
--- a/cpu/msp430/watchdog.c
+++ b/cpu/msp430/watchdog.c
@@ -1,3 +1,4 @@
+#include "ocram_cooja.h"
 /*
  * Copyright (c) 2005, Swedish Institute of Computer Science
  * All rights reserved.
@@ -73,6 +74,7 @@ printstring(char *s)
 /*---------------------------------------------------------------------------*/
 ISR(WDT, watchdog_interrupt)
 {
+ ENTER_INTERRUPT();
 #ifdef CONTIKI_TARGET_SKY
 #if PRINT_STACK_ON_REBOOT
   uint8_t dummy;
@@ -98,6 +100,7 @@ ISR(WDT, watchdog_interrupt)
 #endif /* CONTIKI_TARGET_SKY */
 
   watchdog_reboot();
+ LEAVE_INTERRUPT();
 }
 /*---------------------------------------------------------------------------*/
 void
--
1.7.1

Something went wrong with that request. Please try again.