/kernel/trunk/generic/include/func.h |
---|
31,8 → 31,9 |
#include <arch/types.h> |
#include <typedefs.h> |
#include <arch/atomic.h> |
extern volatile __u32 haltstate; |
extern atomic_t haltstate; |
extern void halt(void); |
/kernel/trunk/generic/src/console/console.c |
---|
36,6 → 36,7 |
#include <arch.h> |
#include <func.h> |
#include <print.h> |
#include <arch/atomic.h> |
/** Standard input character device. */ |
chardev_t *stdin = NULL; |
52,7 → 53,7 |
__u8 ch; |
ipl_t ipl; |
if (haltstate) { |
if (atomic_get(&haltstate)) { |
/* If we are here, we are hopefully on the processor, that |
* issued the 'halt' command, so proceed to read the character |
* directly from input |
60,7 → 61,11 |
if (chardev->op->read) |
return chardev->op->read(chardev); |
/* no other way of interacting with user, halt */ |
printf("cpu: halted - no kconsole\n"); |
if (CPU) |
printf("cpu%d: ", CPU->id); |
else |
printf("cpu: "); |
printf("halted - no kconsole\n"); |
cpu_halt(); |
} |
/kernel/trunk/generic/src/proc/scheduler.c |
---|
406,7 → 406,7 |
ipl = interrupts_disable(); |
if (haltstate) |
if (atomic_get(&haltstate)) |
halt(); |
if (THREAD) { |
/kernel/trunk/generic/src/lib/func.c |
---|
34,7 → 34,7 |
#include <typedefs.h> |
#include <console/kconsole.h> |
__u32 volatile haltstate = 0; /**< Halt flag */ |
atomic_t haltstate = {0}; /**< Halt flag */ |
/** Halt wrapper |
42,15 → 42,28 |
* Set halt flag and halt the cpu. |
* |
*/ |
void halt(void) |
void halt() |
{ |
haltstate = 1; |
#ifdef CONFIG_DEBUG |
bool rundebugger; |
// TODO test_and_set not defined on all arches |
// if (!test_and_set(&haltstate)) |
if (!atomic_get(&haltstate)) { |
atomic_set(&haltstate, 1); |
rundebugger = true; |
} |
#else |
atomic_set(haltstate, 1); |
#endif |
interrupts_disable(); |
#ifdef CONFIG_DEBUG |
if (rundebugger) { |
printf("\n"); |
kconsole("panic"); /* Run kconsole as a last resort to user */ |
} |
#endif |
if (CPU) |
printf("cpu%d: halted\n", CPU->id); |
else |
/kernel/trunk/arch/mips32/src/debugger.c |
---|
256,7 → 256,7 |
printf("***Type 'exit' to exit kconsole.\n"); |
/* Umm..we should rather set some 'debugstate' here */ |
haltstate = 1; |
atomic_set(&haltstate,1); |
kconsole("debug"); |
haltstate = 0; |
atomic_set(&haltstate,0); |
} |
/kernel/trunk/arch/ia32/include/atomic.h |
---|
31,14 → 31,14 |
#include <arch/types.h> |
typedef struct { volatile __u32 count; } atomic_t; |
typedef struct { volatile __u64 count; } atomic_t; |
static inline void atomic_set(atomic_t *val, __u32 i) |
static inline void atomic_set(atomic_t *val, __u64 i) |
{ |
val->count = i; |
} |
static inline __u32 atomic_get(atomic_t *val) |
static inline __u64 atomic_get(atomic_t *val) |
{ |
return val->count; |
} |
79,7 → 79,7 |
__asm__ volatile ( |
"movl $-1, %0\n" |
"lock xaddl %0, %1\n" |
: "=r" (r), "=m" (*val) |
: "=r" (r), "=m" (val->count) |
); |
return r; |