Silenced all warnings in kitten build.
Removed dead prototypes in palacios.h.
Fixed race in delivering keyboard interrupt to v3vee before guest was started.
Depends on having IOAPIC configured to generate keyboard interrupts.
#include <lwk/task.h>
#include <lwk/sched.h>
#include <lwk/timer.h>
+#include <lwk/palacios.h>
#include <arch/desc.h>
#include <arch/idt_vectors.h>
#include <arch/show.h>
#include <arch/xcall.h>
#include <arch/i387.h>
+#include <arch/io.h>
idtvec_handler_t idtvec_table[NUM_IDT_ENTRIES];
static DEFINE_SPINLOCK(idtvec_table_lock);
}
void
+do_keyboard_interrupt(struct pt_regs *regs, unsigned int vector)
+{
+ const uint8_t KB_OUTPUT_FULL = 0x01;
+ const uint8_t KB_STATUS_PORT = 0x64;
+ const uint8_t KB_DATA_PORT = 0x60;
+
+ uint8_t status = inb( KB_STATUS_PORT );
+
+ if( (status & KB_OUTPUT_FULL) == 0 )
+ return;
+
+ uint8_t key = inb( KB_DATA_PORT );
+#ifdef CONFIG_V3VEE
+ send_key_to_vmm( status, key );
+#endif
+}
+
+
+void
set_idtvec_handler(unsigned int vector, idtvec_handler_t handler)
{
char namebuf[KSYM_NAME_LEN+1];
*/
for (vector = 0; vector < NUM_IDT_ENTRIES; vector++) {
void *asm_handler = (void *) (
- (unsigned long)(&asm_idtvec_table) + (vector * 16)
+ (uintptr_t)(&asm_idtvec_table) + (vector * 16)
);
set_intr_gate(vector, asm_handler);
set_idtvec_handler(vector, &do_unhandled_idt_vector);
set_idtvec_handler( ALIGNMENT_CHECK_VECTOR, &do_alignment_check );
set_idtvec_handler( MACHINE_CHECK_VECTOR, &do_machine_check );
set_idtvec_handler( SIMD_COPROCESSOR_ERROR_VECTOR, &do_simd_coprocessor_error );
+ set_idtvec_handler( IRQ1_VECTOR, &do_keyboard_interrupt );
/*
* Register handlers for all of the local APIC vectors.
#!/bin/sh
exec /usr/local/qemu/bin/qemu-system-x86_64 \
+ -smp 1 \
-m 1024 \
-serial file:./serial.out \
-cdrom ./arch/x86_64/boot/image.iso \
#include <palacios/vmm.h>
#include <palacios/vmm_host_events.h>
+extern struct guest_info * g_vm_guest;
+
+
+extern void
+v3vee_init_stubs( void );
-extern void v3vee_init_stubs( struct guest_info * info );
extern int
v3vee_run_vmm( void );
+
extern struct v3_os_hooks v3vee_os_hooks;
/****
extern paddr_t initrd_start, initrd_end;
-/*
- * OS Hooks required to interface with the V3VEE library
- */
-extern void
-v3vee_print_config(
- const char * fmt,
- ...
-) __attribute__((format(printf,1,2)));
-
-
-extern void
-v3vee_print_debug(
- const char * fmt,
- ...
-) __attribute__((format(printf,1,2)));
-
-
-extern void
-v3vee_print_trace(
- const char * fmt,
- ...
-) __attribute__((format(printf,1,2)));
-
-
-extern void *
-v3vee_allocate_pages( int num_pages );
-
-
-extern void
-v3vee_free_page( void * page );
-
-
-extern void *
-v3vee_malloc( unsigned int size );
-
-
-extern void
-v3vee_free( void * addr );
-
-
-extern void *
-v3vee_paddr_to_vaddr( void * addr );
-
-
-extern void *
-v3vee_vaddr_to_paddr( void * addr );
-
-
-extern int
-v3vee_hook_interrupt(
- struct guest_info * vm,
- unsigned int irq
-);
-
-
-extern int
-v3vee_ack_irq(
- int irq
-);
-
-
-unsigned int
-v3vee_get_cpu_khz( void );
-
-
-void
-v3vee_start_kernel_thread( void );
-
-
-void
-v3vee_yield_cpu( void );
-
-
#endif // CONFIG_V3VEE
#endif
{
struct v3_ctrl_ops v3_ops = {};
- void * ramdiskImage=initrd_start;
- uintptr_t ramdiskSize=initrd_end-initrd_start;
-
Init_V3( &v3vee_os_hooks, &v3_ops );
struct v3_vm_config vm_config = {
.rombios_size = (&rombios_end)-(&rombios_start),
.vgabios = &vgabios_start,
.vgabios_size = (&vgabios_end)-(&vgabios_start),
- .use_ramdisk = ramdiskImage != NULL,
- .ramdisk = ramdiskImage,
- .ramdisk_size = ramdiskSize,
+ .use_ramdisk = 1,
+ .ramdisk = (void*) initrd_start,
+ .ramdisk_size = initrd_end - initrd_start,
};
- struct guest_info * vm_info = (v3_ops).allocate_guest();
- v3vee_init_stubs(vm_info);
+ struct guest_info * vm_info = v3_ops.allocate_guest();
+ v3vee_init_stubs();
v3_ops.config_guest(vm_info, &vm_config);
v3_ops.init_guest(vm_info);
+ g_vm_guest = vm_info;
+
printk("Starting Guest\n");
v3_ops.start_guest(vm_info);
#include <arch/apic.h>
struct guest_info * g_vm_guest = NULL;
-
-
-// This is the function the interface code should call to deliver
-// the interrupt to the vmm for handling
-//extern int v3_deliver_interrupt(struct guest_info * vm, struct v3_interrupt *intr);
-
-
struct guest_info * irq_to_guest_map[256];
-
-
void
-v3vee_init_stubs(
- struct guest_info * info
-)
+v3vee_init_stubs( void )
{
- memset(irq_to_guest_map, 0, sizeof(struct guest_info *) * 256);
- g_vm_guest = info;
+ memset(irq_to_guest_map, 0, sizeof(irq_to_guest_map) );
}
if( rc )
return 0;
- return result.start;
+ return (void*) result.start;
}
static void
pmem_region_unset_all(&query);
- query.start = page;
- query.end = page+PAGE_SIZE;
+ query.start = (uintptr_t)( page );
+ query.end = (uintptr_t)( page + PAGE_SIZE );
int rc = pmem_query(&query,&result);
};
// PrintBoth("translate_intr_handler: opaque=0x%x\n",mystate.opaque);
+ printk( "%s: irq %d\n", __func__, vector );
v3_deliver_irq( irq_to_guest_map[intr.irq], &intr );
}
}
//PrintBoth("Hooked interrupt 0x%x with opaque 0x%x\n", irq, vm);
+ printk( "%s: hook irq %d to %p\n", __func__, irq, vm );
irq_to_guest_map[irq] = vm;
set_idtvec_handler( irq, translate_intr_handler );
return cpu_info[0].arch.cur_cpu_khz;
}
+static void *
+v3vee_alloc(
+ unsigned int size
+)
+{
+ return kmem_alloc( size );
+}
+
+
+static void
+v3vee_free(
+ void * addr
+)
+{
+ return kmem_free( addr );
+}
+
+
+static void
+v3vee_printk(
+ const char * fmt,
+ ...
+)
+{
+ va_list ap;
+ va_start( ap, fmt );
+ vprintk( fmt, ap );
+ va_end( ap );
+}
+
struct v3_os_hooks v3vee_os_hooks = {
- .print_debug = printk, // serial print ideally
- .print_info = printk, // serial print ideally
- .print_trace = printk, // serial print ideally
+ .print_debug = 0, // printk, // serial print ideally
+ .print_info = v3vee_printk, // serial print ideally
+ .print_trace = v3vee_printk, // serial print ideally
.allocate_pages = Allocate_VMM_Pages, // defined in vmm_stubs
.free_page = Free_VMM_Page, // defined in vmm_stubs
- .malloc = kmem_alloc,
- .free = kmem_free,
+ .malloc = v3vee_alloc,
+ .free = v3vee_free,
.vaddr_to_paddr = kitten_va_to_pa,
.paddr_to_vaddr = kitten_pa_to_va,
.hook_interrupt = kitten_hook_interrupt,