Ejemplo n.º 1
0
static int shutdown_thread_fn(void *data)
{
	int ret;
	struct mcu *mcu = glob_mcu;

	while (!kthread_should_stop()) {
		ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL);
		if (ret < 0)
			pr_err("MCU status reg read failed.\n");
		mcu->reg_ctrl = ret;


		if (mcu->reg_ctrl & MCU_CTRL_BTN) {
			i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL,
						  mcu->reg_ctrl & ~MCU_CTRL_BTN);

			ctrl_alt_del();
		}

		set_current_state(TASK_INTERRUPTIBLE);
		schedule_timeout(HZ);
	}

	return 0;
}
Ejemplo n.º 2
0
static irqreturn_t beat_reset_event(int virq, void *arg)
{
	printk(KERN_DEBUG "Beat: reset button pressed\n");
	beat_pm_poweroff_flag = 0;
	ctrl_alt_del();
	return IRQ_HANDLED;
}
Ejemplo n.º 3
0
static void dsmg600_power_handler(unsigned long data)
{
	/* This routine is called twice per second to check the
	 * state of the power button.
	 */

	if (gpio_get_value(DSMG600_PB_GPIO)) {

		/* IO Pin is 1 (button pushed) */
		if (power_button_countdown > 0)
			power_button_countdown--;

	} else {

		/* Done on button release, to allow for auto-power-on mods. */
		if (power_button_countdown == 0) {
			/* Signal init to do the ctrlaltdel action,
			 * this will bypass init if it hasn't started
			 * and do a kernel_restart.
			 */
			ctrl_alt_del();

			/* Change the state of the power LED to "blink" */
			gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
		} else {
			power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
		}
	}

	mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
}
Ejemplo n.º 4
0
/* Handler for quiesce event. Start shutdown procedure. */
static void
sclp_quiesce_handler(struct evbuf_header *evbuf)
{
	_machine_restart = (void *) do_machine_quiesce;
	_machine_halt = do_machine_quiesce;
	_machine_power_off = do_machine_quiesce;
	ctrl_alt_del();
}
static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
{
	/*                                                                  
                                              
  */
	ctrl_alt_del();

	return IRQ_HANDLED;
}
Ejemplo n.º 6
0
static irqreturn_t nas100d_reset_handler(int irq, void *dev_id, struct pt_regs *regs)
{
	/* Signal init to do the ctrlaltdel action, this will bypass init if
	 * it hasn't started and do a kernel_restart.
	 */
	ctrl_alt_del();

	return IRQ_HANDLED;
}
Ejemplo n.º 7
0
static irqreturn_t fsg_power_handler(int irq, void *dev_id)
{
	/* Signal init to do the ctrlaltdel action, this will bypass init if
	 * it hasn't started and do a kernel_restart.
	 */
	ctrl_alt_del();

	return IRQ_HANDLED;
}
Ejemplo n.º 8
0
static void boot_it(void)
{
	extern int obp_system_intr(void);

	if (!obp_system_intr())
		ctrl_alt_del();
	/* sigh.. attempt to prevent multiple entry */
	last_keycode=1;
	rep = 0;
}
Ejemplo n.º 9
0
static void power_button_poll(unsigned long dummy)
{
	if (gpio_line_get(N2100_POWER_BUTTON) == 0) {
		ctrl_alt_del();
		return;
	}

	power_button_poll_timer.expires = jiffies + (HZ / 10);
	add_timer(&power_button_poll_timer);
}
Ejemplo n.º 10
0
/* Handler for quiesce event. Start shutdown procedure. */
static void sclp_quiesce_handler(struct evbuf_header *evbuf)
{
	if (_machine_restart != (void *) do_machine_quiesce) {
		old_machine_restart = _machine_restart;
		old_machine_halt = _machine_halt;
		old_machine_power_off = _machine_power_off;
		_machine_restart = (void *) do_machine_quiesce;
		_machine_halt = do_machine_quiesce;
		_machine_power_off = do_machine_quiesce;
	}
	ctrl_alt_del();
}
Ejemplo n.º 11
0
static void shutdown_handler(struct xenbus_watch *watch,
			     const char **vec, unsigned int len)
{
	extern void ctrl_alt_del(void);
	char *str;
	struct xenbus_transaction xbt;
	int err, new_state = SHUTDOWN_INVALID;

	if ((shutting_down != SHUTDOWN_INVALID) &&
	    (shutting_down != SHUTDOWN_RESUMING))
		return;

 again:
	err = xenbus_transaction_start(&xbt);
	if (err)
		return;

	str = (char *)xenbus_read(xbt, "control", "shutdown", NULL);
	/* Ignore read errors and empty reads. */
	if (XENBUS_IS_ERR_READ(str)) {
		xenbus_transaction_end(xbt, 1);
		return;
	}

  /*将其清空后,如果热迁移时suspend失败则会导致迁移挂死,去掉后suspend失败后则会迁移超时*/
	//xenbus_write(xbt, "control", "shutdown", "");

	err = xenbus_transaction_end(xbt, 0);
	if (err == -EAGAIN) {
		kfree(str);
		goto again;
	}
    
    printk(KERN_WARNING "%s(%d): receive shutdown request %s\n", __FUNCTION__, __LINE__, str);
    
	if (strcmp(str, "poweroff") == 0)
		new_state = SHUTDOWN_POWEROFF;
	else if (strcmp(str, "reboot") == 0)
		ctrl_alt_del();
	else if (strcmp(str, "suspend") == 0)
		new_state = SHUTDOWN_SUSPEND;
	else if (strcmp(str, "halt") == 0)
		new_state = SHUTDOWN_HALT;
	else
		printk("Ignoring shutdown request: %s\n", str);

	switch_shutdown_state(new_state);

	kfree(str);
}
Ejemplo n.º 12
0
static void shutdown_handler(struct xenbus_watch *watch,
			     const char **vec, unsigned int len)
{
	extern void ctrl_alt_del(void);
	char *str;
	struct xenbus_transaction xbt;
	int err;

	if (shutting_down != SHUTDOWN_INVALID)
		return;

 again:
	err = xenbus_transaction_start(&xbt);
	if (err)
		return;
	str = (char *)xenbus_read(xbt, "control", "shutdown", NULL);
	/* Ignore read errors and empty reads. */
	if (XENBUS_IS_ERR_READ(str)) {
		xenbus_transaction_end(xbt, 1);
		return;
	}

	xenbus_write(xbt, "control", "shutdown", "");

	err = xenbus_transaction_end(xbt, 0);
	if (err == -EAGAIN) {
		kfree(str);
		goto again;
	}

	if (strcmp(str, "poweroff") == 0)
		shutting_down = SHUTDOWN_POWEROFF;
	else if (strcmp(str, "reboot") == 0)
		ctrl_alt_del();
	else if (strcmp(str, "suspend") == 0)
		shutting_down = SHUTDOWN_SUSPEND;
	else if (strcmp(str, "halt") == 0)
		shutting_down = SHUTDOWN_HALT;
	else {
		printk("Ignoring shutdown request: %s\n", str);
		shutting_down = SHUTDOWN_INVALID;
	}

	if (shutting_down != SHUTDOWN_INVALID)
		schedule_work(&shutdown_work);

	kfree(str);
}
Ejemplo n.º 13
0
static void shutdown_handler(struct xenbus_watch *watch,
                             const char **vec, unsigned int len)
{
    char *str;
    struct xenbus_transaction xbt;
    int err;

    if (shutting_down != SHUTDOWN_INVALID)
        return;

again:
    err = xenbus_transaction_start(&xbt);
    if (err)
        return;

    str = (char *)xenbus_read(xbt, "control", "shutdown", NULL);
    /* Ignore read errors and empty reads. */
    if (XENBUS_IS_ERR_READ(str)) {
        xenbus_transaction_end(xbt, 1);
        return;
    }

    xenbus_write(xbt, "control", "shutdown", "");

    err = xenbus_transaction_end(xbt, 0);
    if (err == -EAGAIN) {
        kfree(str);
        goto again;
    }

    if (strcmp(str, "poweroff") == 0 ||
            strcmp(str, "halt") == 0) {
        shutting_down = SHUTDOWN_POWEROFF;
        orderly_poweroff(false);
    } else if (strcmp(str, "reboot") == 0) {
        shutting_down = SHUTDOWN_POWEROFF; /* ? */
        ctrl_alt_del();
#ifdef CONFIG_PM_SLEEP
    } else if (strcmp(str, "suspend") == 0) {
        do_suspend();
#endif
    } else {
        printk(KERN_INFO "Ignoring shutdown request: %s\n", str);
        shutting_down = SHUTDOWN_INVALID;
    }

    kfree(str);
}
Ejemplo n.º 14
0
static irqreturn_t gpio_interrupt(int irq, void *ignored)
{
	int state;

	if (!ssb_chipco_irq_status(&bcm47xx_bus.ssb.chipco,
				   SSB_CHIPCO_IRQ_GPIO))
		return IRQ_NONE;

	state = gpio_get_value(WGT634U_GPIO_RESET);

	gpio_polarity(WGT634U_GPIO_RESET, state);

	if (!state) {
		printk(KERN_INFO "Reset button pressed");
		ctrl_alt_del();
	}

	return IRQ_HANDLED;
}
Ejemplo n.º 15
0
static irqreturn_t gpio_interrupt(int irq, void *ignored)
{
	int state;

	/* Interrupts are shared, check if the current one is
	   a GPIO interrupt. */
	if (!ssb_chipco_irq_status(&bcm47xx_bus.ssb.chipco,
				   SSB_CHIPCO_IRQ_GPIO))
		return IRQ_NONE;

	state = gpio_get_value(WGT634U_GPIO_RESET);

	/* Interrupt are level triggered, revert the interrupt polarity
	   to clear the interrupt. */
	gpio_polarity(WGT634U_GPIO_RESET, state);

	if (!state) {
		printk(KERN_INFO "Reset button pressed");
		ctrl_alt_del();
	}

	return IRQ_HANDLED;
}
Ejemplo n.º 16
0
/*
 * s390_machine_check_handler
 *
 * machine check handler, dequeueing machine check entries
 *  and processing them
 */
static int s390_machine_check_handler( void *parm)
{
	struct semaphore *sem = parm;
	unsigned long     flags;
	mache_t          *pmache;

	int               found = 0;

        /* set name to something sensible */
        strcpy (current->comm, "kmcheck");


        /* block all signals */
        sigfillset(&current->blocked);

#ifdef S390_MACHCHK_DEBUG
	printk( KERN_NOTICE "mach_handler : ready\n");
#endif	

	do {

#ifdef S390_MACHCHK_DEBUG
		printk( KERN_NOTICE "mach_handler : waiting for wakeup\n");
#endif	

		down_interruptible( sem );

#ifdef S390_MACHCHK_DEBUG
		printk( KERN_NOTICE "\nmach_handler : wakeup ... \n");
#endif	
		found = 0; /* init ... */

		__save_flags( flags );
		__cli();

		do {

		pmache = s390_dequeue_mchchk();

		if ( pmache )
		{
			found = 1;
		
			if ( pmache->mcic.mcc.mcd.cp )
			{
				crwe_t *pcrwe_n;
				crwe_t *pcrwe_h;

				s390_do_crw_pending( pmache->mc.crwe );

				pcrwe_h = pmache->mc.crwe;
				pcrwe_n = pmache->mc.crwe->crwe_next;

				pmache->mcic.mcc.mcd.cp = 0;
				pmache->mc.crwe         = NULL;

				spin_lock( &crw_queue_lock);

				while ( pcrwe_h )
				{
					pcrwe_h->crwe_next = crw_buffer_anchor;
					crw_buffer_anchor  = pcrwe_h;
					pcrwe_h            = pcrwe_n;

					if ( pcrwe_h != NULL )
						pcrwe_n = pcrwe_h->crwe_next;

				} /* endwhile */

				spin_unlock( &crw_queue_lock);

			} /* endif */

#ifdef CONFIG_MACHCHK_WARNING
			if ( pmache->mcic.mcc.mcd.w )
			{
				ctrl_alt_del();		// shutdown NOW!
#ifdef S390_MACHCHK_DEBUG
			printk( KERN_DEBUG "mach_handler : kill -SIGPWR init\n");
#endif
			} /* endif */
#endif

#ifdef CONFIG_MACHCHK_WARNING
			if ( pmache->mcic.mcc.mcd.w )
			{
				ctrl_alt_del();		// shutdown NOW!
#ifdef S390_MACHCHK_DEBUG
			printk( KERN_DEBUG "mach_handler : kill -SIGPWR init\n");
#endif
			} /* endif */
#endif

			s390_enqueue_free_mchchk( pmache );
		}
		else
		{

			// unconditional surrender ...
#ifdef S390_MACHCHK_DEBUG
			printk( KERN_DEBUG "mach_handler : nothing to do, sleeping\n");
#endif	

		} /* endif */	

		} while ( pmache );

		__restore_flags( flags );

	} while ( 1 );

	return( 0);
}
Ejemplo n.º 17
0
void keyboard_irq(int irq, struct pt_regs *regs, void *dev_id)
{
    static unsigned int ModeState = 0;
    static int E0Prefix = 0;
    int code, mode, E0 = 0;
    register char *keyp;
    register char *IsReleasep;

    code = inb_p((void *) KBD_IO);
    mode = inb_p((void *) KBD_CTL);

    /* Necessary for the XT. */
    outb_p((unsigned char) (mode | 0x80), (void *) KBD_CTL);
    outb_p((unsigned char) mode, (void *) KBD_CTL);

    if (kraw) {
	AddQueue((unsigned char) code);
	return;
    }
    if (code == 0xE0) {		/* Remember this has been received */
	E0Prefix = 1;
	return;
    }
    if (E0Prefix) {
	E0 = 1;
	E0Prefix = 0;
    }
    IsReleasep = (char *)(code & 0x80);
    switch (code & 0x7F) {
    case 29:
	IsReleasep ? (ModeState &= ~CTRL) : (ModeState |= CTRL);
	return;
    case 42:
	IsReleasep ? (ModeState &= ~LSHIFT) : (ModeState |= LSHIFT);
	return;
    case 54:
	IsReleasep ? (ModeState &= ~RSHIFT) : (ModeState |= RSHIFT);
	return;
    case 56:

#if defined(CONFIG_KEYMAP_DE) || defined(CONFIG_KEYMAP_SE)

	if (E0 == 0) {
	    IsReleasep ? (ModeState &= ~ALT) : (ModeState |= ALT);
	} else {
	    IsReleasep ? (ModeState &= ~ALT_GR) : (ModeState |= ALT_GR);
	}

#else

	IsReleasep ? (ModeState &= ~ALT) : (ModeState |= ALT);

#endif

	return;
    case 58:
	ModeState ^= IsReleasep ? 0 : CAPS;
	return;
    case 69:
	ModeState ^= IsReleasep ? 0 : NUM;
	return;
    default:
	if (IsReleasep)
	    return;
	break;
    }

    /*      Handle CTRL-ALT-DEL     */

    if ((code == 0x53) && (ModeState & CTRL) && (ModeState & ALT))
	ctrl_alt_del();

    /*
     *      Pick the right keymap
     */
    if (ModeState & CAPS && !(ModeState & ANYSHIFT))
	keyp = (char *) xtkb_scan_caps[code];
    else if (ModeState & ANYSHIFT && !(ModeState & CAPS))
	keyp = (char *) xtkb_scan_shifted[code];

    /* added for belgian keyboard (Stefke) */

    else if ((ModeState & CTRL) && (ModeState & ALT))
	keyp = (char *) xtkb_scan_ctrl_alt[code];

    /* end belgian                                  */

    /* added for German keyboard (Klaus Syttkus) */

    else if (ModeState & ALT_GR)
	keyp = (char *) xtkb_scan_ctrl_alt[code];
    /* end German */
    else
	keyp = (char *) xtkb_scan[code];

    if (ModeState & CTRL && code < 14 && !(ModeState & ALT))
	keyp = (char *) xtkb_scan_shifted[code];
    if (code < 70 && ModeState & NUM)
	keyp = (char *) xtkb_scan_shifted[code];
    /*
     *      Apply special modifiers
     */
    if (ModeState & ALT && !(ModeState & CTRL))	/* Changed to support CTRL-ALT */
	keyp = (char *)(((int) keyp) | 0x80); /* META-.. */
    if (!keyp)			/* non meta-@ is 64 */
	keyp = (char *) '@';
    if (ModeState & CTRL && !(ModeState & ALT))	/* Changed to support CTRL-ALT */
	keyp = (char *)(((int) keyp) & 0x1F); /* CTRL-.. */
    if (code < 0x45 && code > 0x3A) {	/* F1 .. F10 */

#ifdef CONFIG_CONSOLE_DIRECT

	if (ModeState & ALT) {
	    Console_set_vc((unsigned) (code - 0x3B));
	    return;
	}
#endif

	AddQueue(ESC);
	AddQueue((unsigned char) (code - 0x3B + 'a'));
	return;
    }
    if (E0)			/* Is extended scancode */
	switch (code) {
	case 0x48:		/* Arrow up */
	    AddQueue(ESC);
	    AddQueue('A');
	    return;
	case 0x50:		/* Arrow down */
	    AddQueue(ESC);
	    AddQueue('B');
	    return;
	case 0x4D:		/* Arrow right */
	    AddQueue(ESC);
	    AddQueue('C');
	    return;
	case 0x4B:		/* Arrow left */
	    AddQueue(ESC);
	    AddQueue('D');
	    return;
	case 0x1c:		/* keypad enter */
	    AddQueue('\n');
	    return;
	}
    if (((int)keyp) == '\r')
	keyp = (char *) '\n';
    AddQueue((unsigned char) keyp);
}
Ejemplo n.º 18
0
static void do_reboot(void)
{
	shutting_down = SHUTDOWN_POWEROFF; /* ? */
	ctrl_alt_del();
}
Ejemplo n.º 19
0
static void gcn_rsw_normal_reset(unsigned long dummy)
{
	ctrl_alt_del();
}
Ejemplo n.º 20
0
static void boot_it(void)
{
	ctrl_alt_del();
}