diff --git a/Makefile b/Makefile index 5dee20b..6096ac7 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ bios/int10.o: bios/int10.S bios/int10-real.S check: $(PROGRAM) $(MAKE) -C tests - ./$(PROGRAM) --dbgtest tests/pit/tick.bin + ./$(PROGRAM) tests/pit/tick.bin .PHONY: check clean: diff --git a/ioport.c b/ioport.c index 42454d2..4bcc2b7 100644 --- a/ioport.c +++ b/ioport.c @@ -4,6 +4,7 @@ #include #include +#include #include static uint8_t ioport_to_uint8(void *data) @@ -28,6 +29,15 @@ static struct ioport_operations cmos_ram_rtc_ops = { .io_out = cmos_ram_rtc_io_out, }; +static bool debug_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) +{ + exit(EXIT_SUCCESS); +} + +static struct ioport_operations debug_ops = { + .io_out = debug_io_out, +}; + static bool dummy_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) { return true; @@ -70,6 +80,10 @@ static struct ioport_operations *ioport_ops[USHRT_MAX] = { [0x00A0] = &dummy_read_write_ioport_ops, [0x00A1] = &dummy_read_write_ioport_ops, + /* PORT 00E0-00EF are 'motherboard specific' so we use them for our + internal debugging purposes. */ + [0x00E0] = &debug_ops, + /* PORT 00ED - DUMMY PORT FOR DELAY??? */ [0x00ED] = &dummy_write_only_ioport_ops, diff --git a/main.c b/main.c index 9002c0f..91be735 100644 --- a/main.c +++ b/main.c @@ -10,11 +10,9 @@ #include #include -unsigned int dbgtest_mode; - static void usage(char *argv[]) { - fprintf(stderr, " usage: %s [--dbgtest] [--single-step] [--kernel=]\n", + fprintf(stderr, " usage: %s [--single-step] [--kernel=]\n", argv[0]); exit(1); } @@ -55,9 +53,6 @@ int main(int argc, char *argv[]) } else if (option_matches(argv[i], "--params=")) { kernel_cmdline = &argv[i][9]; continue; - } else if (option_matches(argv[i], "--dbgtest")) { - dbgtest_mode = 1; - continue; } else if (option_matches(argv[i], "--single-step")) { single_step = true; continue; @@ -137,13 +132,6 @@ int main(int argc, char *argv[]) exit_kvm: - if (dbgtest_mode) { - if (kvm->kvm_run->exit_reason == KVM_EXIT_IO && - kvm->kvm_run->io.port == 0xe0) - fprintf(stderr, "KVM: this is an expected IO error\n"); - goto out; - } - fprintf(stderr, "KVM exit reason: %" PRIu32 " (\"%s\")\n", kvm->kvm_run->exit_reason, kvm_exit_reasons[kvm->kvm_run->exit_reason]); if (kvm->kvm_run->exit_reason == KVM_EXIT_UNKNOWN)