예제 #1
0
void
do_panic_reboot (void)
{
	int d;

	printf ("Reboot in 5 seconds...\n");
	sleep_set_timer_counter ();
	usleep (5 * 1000000);
	printf ("Rebooting...");
	usleep (1 * 1000000);
	d = msgopen ("reboot");
	if (d >= 0) {
		msgsendint (d, 0);
		msgclose (d);
		printf ("Reboot failed.\n");
	} else
		printf ("reboot not found.\n");
}
예제 #2
0
static void
do_boot_guest (void)
{
	enable = false;
	/* clear screen */
	vramwrite_clearscreen ();
	/* printf ("init pic\n"); */
	asm_outb (0x20, 0x11);
	asm_outb (0x21, 0x8);
	asm_outb (0x21, 0x4);
	asm_outb (0x21, 0x1);
	asm_outb (0xA0, 0x11);
	asm_outb (0xA1, 0x70);
	asm_outb (0xA1, 0x2);
	asm_outb (0xA1, 0x1);
	asm_outb (0x21, 0xFC);
	asm_outb (0xA1, 0xFF);
	/* printf ("init pit\n"); */
	sleep_set_timer_counter ();
	/* printf ("sleep 1 sec\n"); */
	usleep (1000000);
	/* printf ("Starting\n"); */
	reinitialize_vm (true, boot_drive);
}
예제 #3
0
panic (char *format, ...)
{
	u64 time;
	int count;
	va_list ap;
	ulong curstk;
	bool w = false;
	char *p, *pend;
	int cpunum = -1;
	static int panic_count = 0;
	static ulong panic_shell = 0;
	struct panic_pcpu_data_state *state, local_state;

	va_start (ap, format);
	if (currentcpu_available ())
		cpunum = get_cpu_id ();
	if (cpunum >= 0) {
		spinlock_lock (&panic_lock);
		count = panic_count++;
		spinlock_unlock (&panic_lock);
		wait_for_other_cpu (cpunum);
		p = panicmsg_tmp;
		pend = panicmsg_tmp + sizeof panicmsg_tmp;
		if (panic_reboot)
			*p = '\0';
		else
			snprintf (p, pend - p, "panic(CPU%d): ", cpunum);
		p += strlen (p);
		vsnprintf (p, pend - p, format, ap);
		if (*p != '\0') {
			printf ("%s\n", panicmsg_tmp);
			if (panicmsg[0] == '\0')
				snprintf (panicmsg, sizeof panicmsg, "%s",
					  panicmsg_tmp);
		}
		asm_rdrsp (&curstk);
		if (count > 5 ||
		    curstk - (ulong)currentcpu->stackaddr < VMM_MINSTACKSIZE) {
			spinlock_lock (&panic_lock);
			paniccpu = -1;
			spinlock_unlock (&panic_lock);
			freeze ();
		}
		state = &currentcpu->panic.state;
	} else {
		spinlock_lock (&panic_lock);
		count = panic_count++;
		printf ("panic: ");
		vprintf (format, ap);
		printf ("\n");
		spinlock_unlock (&panic_lock);
		if (count)
			freeze ();
		state = &local_state;
		state->dump_vmm = false;
		state->backtrace = false;
		state->flag_dump_vm = false;
	}
	va_end (ap);
	if (!state->dump_vmm) {
		state->dump_vmm = true;
		catch_exception (cpunum, dump_vmm_control_regs);
		catch_exception (cpunum, dump_vmm_other_regs);
		state->dump_vmm = false;
	}
	if (!state->backtrace) {
		state->backtrace = true;
		catch_exception (cpunum, backtrace);
		state->backtrace = false;
	}
	if (cpunum >= 0 && current && !state->flag_dump_vm) {
		/* Guest state is printed only once.  Because the
		 * state will not change if panic will have been
		 * called twice or more. */
		state->flag_dump_vm = true;
		printf ("Guest state and registers of cpu %d ------------\n",
			cpunum);
		catch_exception (cpunum, dump_vm_general_regs);
		catch_exception (cpunum, dump_vm_control_regs);
		catch_exception (cpunum, dump_vm_sregs);
		catch_exception (cpunum, dump_vm_other_regs);
		printf ("------------------------------------------------\n");
	}
	if (cpunum < 0)
		freeze ();
	if (do_wakeup) {
		do_wakeup = false;
		w = true;
	}
	spinlock_lock (&panic_lock);
	paniccpu = -1;
	spinlock_unlock (&panic_lock);
	if (w) {
		sleep_set_timer_counter ();
		panic_wakeup_all ();
	}
	call_initfunc ("panic");
	if (cpunum == 0) {
		usleep (1000000);	/* wait for dump of other processors */
#ifndef TTY_SERIAL
		setkbdled (LED_NUMLOCK_BIT | LED_SCROLLLOCK_BIT |
			   LED_CAPSLOCK_BIT);
		if (!uefi_booted) {
			disable_apic ();
			if (bios_area_saved)
				copy_bios_area (bios_area_panic,
						bios_area_orig);
			callrealmode_setvideomode
				(VIDEOMODE_80x25TEXT_16COLORS);
			if (bios_area_saved)
				copy_bios_area (NULL, bios_area_panic);
			if (panic_reboot)
				printf ("%s\n", panicmsg);
		}
		keyboard_reset ();
		usleep (250000);
		setkbdled (LED_SCROLLLOCK_BIT | LED_CAPSLOCK_BIT);
#endif
	} else {
		/* setvideomode is expected to be done in 3 seconds */
		time = get_time ();
		while (get_time () - time < 3000000);
	}
	if (asm_lock_ulong_swap (&panic_shell, 1)) {
		for (;;)
			reboot_test ();
		clihlt ();
	}
	if (panic_reboot)
		do_panic_reboot ();
	printf ("%s\n", panicmsg);
	call_panic_shell ();
}