Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 630 → Rev 631

/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
printf("\n");
kconsole("panic"); /* Run kconsole as a last resort to user */
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