#include "kvm/term.h"
#include "kvm/kvm.h"
#include "kvm/i8042.h"
+#include "kvm/kvm-cpu.h"
#include <stdint.h>
#define I8042_CMD_AUX_TEST 0xA9
#define I8042_CMD_AUX_DISABLE 0xA7
#define I8042_CMD_AUX_ENABLE 0xA8
+#define I8042_CMD_SYSTEM_RESET 0xFE
#define RESPONSE_ACK 0xFA
kbd_update_irq();
}
-static void kbd_write_command(u8 val)
+static void kbd_write_command(struct kvm *kvm, u8 val)
{
switch (val) {
case I8042_CMD_CTL_RCTR:
case I8042_CMD_AUX_ENABLE:
state.mode &= ~MODE_DISABLE_AUX;
break;
+ case I8042_CMD_SYSTEM_RESET:
+ kvm_cpu__reboot();
+ break;
default:
break;
}
switch (port) {
case I8042_COMMAND_REG: {
u8 value = ioport__read8(data);
- kbd_write_command(value);
+ kbd_write_command(kvm, value);
break;
}
case I8042_DATA_REG: {
void kvm_cpu__setup_cpuid(struct kvm_cpu *vcpu);
void kvm_cpu__enable_singlestep(struct kvm_cpu *vcpu);
void kvm_cpu__run(struct kvm_cpu *vcpu);
+void kvm_cpu__reboot(void);
int kvm_cpu__start(struct kvm_cpu *cpu);
void kvm_cpu__show_code(struct kvm_cpu *vcpu);
#define PAGE_SIZE (sysconf(_SC_PAGE_SIZE))
+extern struct kvm_cpu *kvm_cpus[KVM_NR_CPUS];
extern __thread struct kvm_cpu *current_kvm_cpu;
static inline bool is_in_protected_mode(struct kvm_cpu *vcpu)
static void kvm_cpu_signal_handler(int signum)
{
if (signum == SIGKVMEXIT) {
- if (current_kvm_cpu->is_running) {
+ if (current_kvm_cpu && current_kvm_cpu->is_running) {
current_kvm_cpu->is_running = false;
pthread_kill(pthread_self(), SIGKVMEXIT);
}
}
}
+void kvm_cpu__reboot(void)
+{
+ pthread_kill(kvm_cpus[0]->thread, SIGKVMEXIT);
+}
+
int kvm_cpu__start(struct kvm_cpu *cpu)
{
sigset_t sigset;
vidmode = 0;
memset(real_cmdline, 0, sizeof(real_cmdline));
- strcpy(real_cmdline, "notsc noapic noacpi pci=conf1");
+ strcpy(real_cmdline, "notsc noapic noacpi pci=conf1 reboot=k");
if (vnc || sdl) {
strcat(real_cmdline, " video=vesafb console=tty0");
} else
kvm__init_ram(kvm);
+ kbd__init(kvm);
+
if (vnc || sdl)
fb = vesa__init(kvm);
if (vnc) {
- kbd__init(kvm);
if (fb)
vnc__init(fb);
}
if (sdl) {
- kbd__init(kvm);
if (fb)
sdl__init(fb);
}