From b6e5a081c5b71b3efedf47cccf60034223a967bb Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Tue, 23 Mar 2010 21:57:32 +0200 Subject: [PATCH] Move CPU emulation code to cpu.c The kvm.c file is getting bigger so move CPU emulation code to a separate file. Signed-off-by: Pekka Enberg --- Makefile | 5 ++++- cpu.c | 14 ++++++++++++++ include/kvm/cpu.h | 3 +++ kvm.c | 11 ----------- 4 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 cpu.c diff --git a/Makefile b/Makefile index a0cde18..d537775 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,17 @@ PROGRAM = kvm OBJS += kvm.o +OBJS += cpu.o CFLAGS += -Iinclude all: $(PROGRAM) -$(PRORAM): $(OBJS) +$(PROGRAM): $(OBJS) $(CC) $(OBJS) -o $@ +$(OBJS): + clean: rm -f $(OBJS) $(PROGRAM) .PHONY: clean diff --git a/cpu.c b/cpu.c new file mode 100644 index 0000000..631b2b1 --- /dev/null +++ b/cpu.c @@ -0,0 +1,14 @@ +#include "kvm/cpu.h" + +#include + +struct cpu *cpu__new(void) +{ + return calloc(1, sizeof(struct cpu)); +} + +void cpu__reset(struct cpu *self) +{ + self->regs.eip = 0x000fff0UL; + self->regs.eflags = 0x0000002UL; +} diff --git a/include/kvm/cpu.h b/include/kvm/cpu.h index ced2e5e..9029f20 100644 --- a/include/kvm/cpu.h +++ b/include/kvm/cpu.h @@ -39,4 +39,7 @@ struct cpu { struct cpu_registers regs; }; +struct cpu *cpu__new(void); +void cpu__reset(struct cpu *self); + #endif /* KVM__CPU_H */ diff --git a/kvm.c b/kvm.c index 4a2a04a..9fd377d 100644 --- a/kvm.c +++ b/kvm.c @@ -28,17 +28,6 @@ static void die(const char *s) exit(1); } -static void cpu__reset(struct cpu *self) -{ - self->regs.eip = 0x000fff0UL; - self->regs.eflags = 0x0000002UL; -} - -static struct cpu *cpu__new(void) -{ - return calloc(1, sizeof(struct cpu)); -} - static inline bool kvm__supports_extension(struct kvm *self, unsigned int extension) { int ret;