From: Jack Lange Date: Wed, 4 Feb 2009 20:01:47 +0000 (-0600) Subject: added os_debug device X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f8b30059c9ffdde7196610bcc264793c190b4b3;p=palacios.releases.git added os_debug device --- diff --git a/palacios/include/devices/os_debug.h b/palacios/include/devices/os_debug.h new file mode 100644 index 0000000..5434492 --- /dev/null +++ b/palacios/include/devices/os_debug.h @@ -0,0 +1,32 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2008, Jack Lange + * Copyright (c) 2008, The V3VEE Project + * All rights reserved. + * + * Author: Jack Lange + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + +#ifndef __DEVICES_OS_DEBUG_H__ +#define __DEVICES_OS_DEBUG_H__ + +#ifdef __V3VEE__ + +#include + +struct vm_device * v3_create_os_debug(); + + +#endif // ! __V3VEE__ + +#endif diff --git a/palacios/src/devices/os_debug.c b/palacios/src/devices/os_debug.c new file mode 100644 index 0000000..2ceac6f --- /dev/null +++ b/palacios/src/devices/os_debug.c @@ -0,0 +1,88 @@ +/* + * This file is part of the Palacios Virtual Machine Monitor developed + * by the V3VEE Project with funding from the United States National + * Science Foundation and the Department of Energy. + * + * The V3VEE Project is a joint project between Northwestern University + * and the University of New Mexico. You can find out more at + * http://www.v3vee.org + * + * Copyright (c) 2008, Jack Lange + * Copyright (c) 2008, The V3VEE Project + * All rights reserved. + * + * Author: Jack Lange + * + * This is free software. You are permitted to use, + * redistribute, and modify it as specified in the file "V3VEE_LICENSE". + */ + + +#include +#include + + +#define DEBUG_PORT1 0xcc + + + + +static int handle_gen_write(ushort_t port, void * src, uint_t length, struct vm_device * dev) { + PrintError("OS_DEBUG Write\n"); + + switch (length) { + case 1: + PrintDebug("OS_DEBUG ->0x%.2x\n", *(uchar_t*)src); + break; + case 2: + PrintDebug("OS_DEBUG ->0x%.4x\n", *(ushort_t*)src); + break; + case 4: + PrintDebug("OS_DEBUG ->0x%.8x\n", *(uint_t*)src); + break; + default: + PrintError("OS_DEBUG -> Invalid length in handle_gen_write\n"); + return -1; + break; + } + + return length; +} + + +static int debug_init(struct vm_device * dev) { + + v3_dev_hook_io(dev, DEBUG_PORT1, NULL, &handle_gen_write); + + + return 0; +} + +static int debug_deinit(struct vm_device * dev) { + v3_dev_unhook_io(dev, DEBUG_PORT1); + + + return 0; +}; + + + + +static struct vm_device_ops dev_ops = { + .init = debug_init, + .deinit = debug_deinit, + .reset = NULL, + .start = NULL, + .stop = NULL, +}; + + +struct vm_device * v3_create_os_debug() { + + PrintDebug("Creating OS Debug Device\n"); + struct vm_device * device = v3_create_device("OS Debug", &dev_ops, NULL); + + + + return device; +}