Rev 615 | Rev 635 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 615 | Rev 631 | ||
|---|---|---|---|
| Line 32... | Line 32... | ||
| 32 | #include <arch/asm.h> |
32 | #include <arch/asm.h> |
| 33 | #include <arch.h> |
33 | #include <arch.h> |
| 34 | #include <typedefs.h> |
34 | #include <typedefs.h> |
| 35 | #include <console/kconsole.h> |
35 | #include <console/kconsole.h> |
| 36 | 36 | ||
| 37 | __u32 volatile haltstate = 0; /**< Halt flag */ |
37 | atomic_t haltstate = {0}; /**< Halt flag */ |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | /** Halt wrapper |
40 | /** Halt wrapper |
| 41 | * |
41 | * |
| 42 | * Set halt flag and halt the cpu. |
42 | * Set halt flag and halt the cpu. |
| 43 | * |
43 | * |
| 44 | */ |
44 | */ |
| 45 | void halt(void) |
45 | void halt() |
| 46 | { |
46 | { |
| - | 47 | #ifdef CONFIG_DEBUG |
|
| - | 48 | bool rundebugger; |
|
| - | 49 | ||
| - | 50 | // TODO test_and_set not defined on all arches |
|
| - | 51 | // if (!test_and_set(&haltstate)) |
|
| - | 52 | if (!atomic_get(&haltstate)) { |
|
| - | 53 | atomic_set(&haltstate, 1); |
|
| - | 54 | rundebugger = true; |
|
| - | 55 | } |
|
| - | 56 | #else |
|
| 47 | haltstate = 1; |
57 | atomic_set(haltstate, 1); |
| - | 58 | #endif |
|
| - | 59 | ||
| 48 | interrupts_disable(); |
60 | interrupts_disable(); |
| 49 | #ifdef CONFIG_DEBUG |
61 | #ifdef CONFIG_DEBUG |
| - | 62 | if (rundebugger) { |
|
| 50 | printf("\n"); |
63 | printf("\n"); |
| 51 | kconsole("panic"); /* Run kconsole as a last resort to user */ |
64 | kconsole("panic"); /* Run kconsole as a last resort to user */ |
| - | 65 | } |
|
| 52 | #endif |
66 | #endif |
| 53 | - | ||
| 54 | if (CPU) |
67 | if (CPU) |
| 55 | printf("cpu%d: halted\n", CPU->id); |
68 | printf("cpu%d: halted\n", CPU->id); |
| 56 | else |
69 | else |
| 57 | printf("cpu: halted\n"); |
70 | printf("cpu: halted\n"); |
| 58 | cpu_halt(); |
71 | cpu_halt(); |