1 #include <geekos/svm_io.h>
2 #include <geekos/vmm_io.h>
6 // This should package up an IO request and call vmm_handle_io
7 int handle_svm_io_in(struct guest_info * info) {
8 vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(info->vmm_data));
9 // vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
10 struct svm_io_info * io_info = (struct svm_io_info *)&(ctrl_area->exit_info1);
12 vmm_io_hook_t * hook = get_io_hook(&(info->io_map), io_info->port);
16 // error, we should not have exited on this port
20 PrintDebug("IN on port %d (0x%x)\n", io_info->port, io_info->port);
24 } else if (io_info->sz16) {
26 } else if (io_info->sz32) {
31 if (hook->read(io_info->port, &(info->vm_regs.rax), read_size, read_size) != read_size) {
32 // not sure how we handle errors.....
36 info->rip = ctrl_area->exit_info2;
42 int handle_svm_io_ins(struct guest_info * info) {
44 // PrintDebug("INS on port %d (0x%x)\n", io_info->port, io_info->port);
50 int handle_svm_io_out(struct guest_info * info) {
51 vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(info->vmm_data));
52 // vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
53 struct svm_io_info * io_info = (struct svm_io_info *)&(ctrl_area->exit_info1);
55 vmm_io_hook_t * hook = get_io_hook(&(info->io_map), io_info->port);
56 uint_t write_size = 0;
59 // error, we should not have exited on this port
63 PrintDebug("OUT on port %d (0x%x)\n", io_info->port, io_info->port);
67 } else if (io_info->sz16) {
69 } else if (io_info->sz32) {
74 if (hook->write(io_info->port, &(info->vm_regs.rax), write_size, write_size) != write_size) {
75 // not sure how we handle errors.....
79 info->rip = ctrl_area->exit_info2;
85 int handle_svm_io_outs(struct guest_info * info) {