X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2F8254.c;h=f330a8bd7eda9f854a8cca3f0869bb42f5e60a58;hb=3e5e5a12e64630d7a37ed32b8d7e2d993c79f7e0;hp=4b2f4c079ba7a5a5c98f6c4675d285f539198d12;hpb=dabe645642889502900e7783420052b1c5241354;p=palacios.git diff --git a/palacios/src/devices/8254.c b/palacios/src/devices/8254.c index 4b2f4c0..f330a8b 100644 --- a/palacios/src/devices/8254.c +++ b/palacios/src/devices/8254.c @@ -231,8 +231,9 @@ static int handle_crystal_tics(struct vm_device * dev, struct channel * ch, uint } +#include -static void pit_update_time(ullong_t cpu_cycles, ullong_t cpu_freq, void * private_data) { +static void pit_update_time(struct guest_info * info, ullong_t cpu_cycles, ullong_t cpu_freq, void * private_data) { struct vm_device * dev = (struct vm_device *)private_data; struct pit * state = (struct pit *)dev->private_data; // ullong_t tmp_ctr = state->pit_counter; @@ -296,7 +297,7 @@ static void pit_update_time(ullong_t cpu_cycles, ullong_t cpu_freq, void * priva if (handle_crystal_tics(dev, &(state->ch_0), oscillations) == 1) { // raise interrupt PrintDebug("8254 PIT: Injecting Timer interrupt to guest\n"); - v3_raise_irq(dev->vm, 0); + v3_raise_irq(info->vm_info, 0); } //handle_crystal_tics(dev, &(state->ch_1), oscillations); @@ -462,7 +463,7 @@ static int handle_channel_cmd(struct channel * ch, struct pit_cmd_word cmd) { -static int pit_read_channel(ushort_t port, void * dst, uint_t length, struct vm_device * dev) { +static int pit_read_channel(struct guest_info * core, ushort_t port, void * dst, uint_t length, struct vm_device * dev) { struct pit * state = (struct pit *)dev->private_data; char * val = (char *)dst; @@ -502,7 +503,7 @@ static int pit_read_channel(ushort_t port, void * dst, uint_t length, struct vm_ -static int pit_write_channel(ushort_t port, void * src, uint_t length, struct vm_device * dev) { +static int pit_write_channel(struct guest_info * core, ushort_t port, void * src, uint_t length, struct vm_device * dev) { struct pit * state = (struct pit *)dev->private_data; char val = *(char *)src; @@ -544,7 +545,7 @@ static int pit_write_channel(ushort_t port, void * src, uint_t length, struct vm -static int pit_write_command(ushort_t port, void * src, uint_t length, struct vm_device * dev) { +static int pit_write_command(struct guest_info * core, ushort_t port, void * src, uint_t length, struct vm_device * dev) { struct pit * state = (struct pit *)dev->private_data; struct pit_cmd_word * cmd = (struct pit_cmd_word *)src; @@ -630,11 +631,16 @@ static struct v3_device_ops dev_ops = { }; +#include -static int pit_init(struct guest_info * info, v3_cfg_tree_t * cfg) { +static int pit_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct pit * pit_state = NULL; struct vm_device * dev = NULL; char * name = v3_cfg_val(cfg, "name"); + + // PIT is only usable in non-multicore environments + // just hardcode the core context + struct guest_info * info = &(vm->cores[0]); uint_t cpu_khz = V3_CPU_KHZ(); ullong_t reload_val = (ullong_t)cpu_khz * 1000; @@ -644,7 +650,7 @@ static int pit_init(struct guest_info * info, v3_cfg_tree_t * cfg) { dev = v3_allocate_device(name, &dev_ops, pit_state); - if (v3_attach_device(info, dev) == -1) { + if (v3_attach_device(vm, dev) == -1) { PrintError("Could not attach device %s\n", name); return -1; } @@ -660,6 +666,7 @@ static int pit_init(struct guest_info * info, v3_cfg_tree_t * cfg) { PrintDebug("\n"); #endif + v3_add_timer(info, &timer_ops, dev); // Get cpu frequency and calculate the global pit oscilattor counter/cycle