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 <penberg@cs.helsinki.fi>
This commit is contained in:
Pekka Enberg
2015-06-01 16:39:38 +01:00
committed by Will Deacon
parent 1f9cff2305
commit b6e5a081c5
4 changed files with 21 additions and 12 deletions
+4 -1
View File
@@ -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
+14
View File
@@ -0,0 +1,14 @@
#include "kvm/cpu.h"
#include <stdlib.h>
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;
}
+3
View File
@@ -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 */
-11
View File
@@ -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;