static int
cmd_reboot(int argc, char **argv)
{
	arch_cpu_shutdown(true);
	return 0;
		// I'll be really suprised if this line ever runs! ;-)
}
static int32
debug_keyboard_interrupt(void *data)
{
    static bool controlPressed = false;
    static bool altPressed = false;
    static bool sysReqPressed = false;
    uint8 key;

    key = in8(PS2_PORT_DATA);
    //dprintf("debug_keyboard_interrupt: key = 0x%x\n", key);

    if (key & 0x80) {
        if (key == LEFT_CONTROL)
            controlPressed = false;
        else if (key == LEFT_ALT)
            altPressed = false;
        else if (key == SYS_REQ)
            sysReqPressed = false;

        return B_HANDLED_INTERRUPT;
    }

    switch (key) {
    case LEFT_CONTROL:
        controlPressed = true;
        break;

    case LEFT_ALT:
    case RIGHT_ALT:
        altPressed = true;
        break;

    case SYS_REQ:
        sysReqPressed = true;
        break;

    case DELETE:
        if (controlPressed && altPressed)
            arch_cpu_shutdown(true);
        break;

    default:
        if (altPressed && sysReqPressed) {
            if (debug_emergency_key_pressed(kUnshiftedKeymap[key])) {
                // we probably have lost some keys, so reset our key states
                controlPressed = false;
                sysReqPressed = false;
                altPressed = false;
            }
        }
        break;
    }

    return B_HANDLED_INTERRUPT;
}
Beispiel #3
0
status_t
system_shutdown(bool reboot)
{
	int32 cookie = 0;
	team_info info;
	
	// Now shutdown all system services!
	// TODO: Once we are sure we can shutdown the system on all hardware
	// checking reboot may not be necessary anymore.
	if (reboot) {
		while (get_next_team_info(&cookie, &info) == B_OK) {
			if (info.team == B_SYSTEM_TEAM)
				continue;
			kill_team(info.team);
		}
	}
	
	sync();

	return arch_cpu_shutdown(reboot);
}
static int
cmd_shutdown(int argc, char **argv)
{
	arch_cpu_shutdown(false);
	return 0;
}
int
arch_debug_blue_screen_try_getchar(void)
{
    /* polling the keyboard, similar to code in keyboard
     * driver, but without using an interrupt
     */
    static bool shiftPressed = false;
    static bool controlPressed = false;
    static bool altPressed = false;
    static uint8 special = 0;
    static uint8 special2 = 0;
    uint8 key = 0;

    if (special & 0x80) {
        special &= ~0x80;
        return '[';
    }
    if (special != 0) {
        key = special;
        special = 0;
        return key;
    }
    if (special2 != 0) {
        key = special2;
        special2 = 0;
        return key;
    }

    uint8 status = in8(PS2_PORT_CTRL);

    if ((status & PS2_STATUS_OUTPUT_BUFFER_FULL) == 0) {
        // no data in keyboard buffer
        return -1;
    }

    key = in8(PS2_PORT_DATA);

    if (status & PS2_STATUS_AUX_DATA) {
        // we read mouse data, ignore it
        return -1;
    }

    if (key & 0x80) {
        // key up
        switch (key & ~0x80) {
        case LEFT_SHIFT:
        case RIGHT_SHIFT:
            shiftPressed = false;
            return -1;
        case LEFT_CONTROL:
            controlPressed = false;
            return -1;
        case LEFT_ALT:
            altPressed = false;
            return -1;
        }
    } else {
        // key down
        switch (key) {
        case LEFT_SHIFT:
        case RIGHT_SHIFT:
            shiftPressed = true;
            return -1;

        case LEFT_CONTROL:
            controlPressed = true;
            return -1;

        case LEFT_ALT:
            altPressed = true;
            return -1;

        // start escape sequence for cursor movement
        case CURSOR_UP:
            special = 0x80 | 'A';
            return '\x1b';
        case CURSOR_DOWN:
            special = 0x80 | 'B';
            return '\x1b';
        case CURSOR_RIGHT:
            special = 0x80 | 'C';
            return '\x1b';
        case CURSOR_LEFT:
            special = 0x80 | 'D';
            return '\x1b';
        case CURSOR_HOME:
            special = 0x80 | 'H';
            return '\x1b';
        case CURSOR_END:
            special = 0x80 | 'F';
            return '\x1b';
        case PAGE_UP:
            special = 0x80 | '5';
            special2 = '~';
            return '\x1b';
        case PAGE_DOWN:
            special = 0x80 | '6';
            special2 = '~';
            return '\x1b';


        case DELETE:
            if (controlPressed && altPressed)
                arch_cpu_shutdown(true);

            special = 0x80 | '3';
            special2 = '~';
            return '\x1b';

        default:
            if (controlPressed) {
                char c = kShiftedKeymap[key];
                if (c >= 'A' && c <= 'Z')
                    return 0x1f & c;
            }

            if (altPressed)
                return kAltedKeymap[key];

            return shiftPressed
                   ? kShiftedKeymap[key] : kUnshiftedKeymap[key];
        }
    }

    return -1;
}