Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 631 → Rev 630

/kernel/trunk/arch/ia32/include/atomic.h
31,14 → 31,14
 
#include <arch/types.h>
 
typedef struct { volatile __u64 count; } atomic_t;
typedef struct { volatile __u32 count; } atomic_t;
 
static inline void atomic_set(atomic_t *val, __u64 i)
static inline void atomic_set(atomic_t *val, __u32 i)
{
val->count = i;
}
 
static inline __u64 atomic_get(atomic_t *val)
static inline __u32 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->count)
: "=r" (r), "=m" (*val)
);
return r;
/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 */
atomic_set(&haltstate,1);
haltstate = 1;
kconsole("debug");
atomic_set(&haltstate,0);
haltstate = 0;
}
/kernel/trunk/generic/include/func.h
31,9 → 31,8
 
#include <arch/types.h>
#include <typedefs.h>
#include <arch/atomic.h>
 
extern atomic_t haltstate;
extern volatile __u32 haltstate;
 
extern void halt(void);
 
/kernel/trunk/generic/src/console/console.c
36,7 → 36,6
#include <arch.h>
#include <func.h>
#include <print.h>
#include <arch/atomic.h>
 
/** Standard input character device. */
chardev_t *stdin = NULL;
53,7 → 52,7
__u8 ch;
ipl_t ipl;
 
if (atomic_get(&haltstate)) {
if (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
61,11 → 60,7
if (chardev->op->read)
return chardev->op->read(chardev);
/* no other way of interacting with user, halt */
if (CPU)
printf("cpu%d: ", CPU->id);
else
printf("cpu: ");
printf("halted - no kconsole\n");
printf("cpu: halted - no kconsole\n");
cpu_halt();
}
 
/kernel/trunk/generic/src/proc/scheduler.c
406,7 → 406,7
 
ipl = interrupts_disable();
 
if (atomic_get(&haltstate))
if (haltstate)
halt();
 
if (THREAD) {
/kernel/trunk/generic/src/lib/func.c
34,7 → 34,7
#include <typedefs.h>
#include <console/kconsole.h>
 
atomic_t haltstate = {0}; /**< Halt flag */
__u32 volatile haltstate = 0; /**< Halt flag */
 
 
/** Halt wrapper
42,28 → 42,15
* Set halt flag and halt the cpu.
*
*/
void halt()
void halt(void)
{
#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
 
haltstate = 1;
interrupts_disable();
#ifdef CONFIG_DEBUG
if (rundebugger) {
printf("\n");
kconsole("panic"); /* Run kconsole as a last resort to user */
}
printf("\n");
kconsole("panic"); /* Run kconsole as a last resort to user */
#endif
 
if (CPU)
printf("cpu%d: halted\n", CPU->id);
else