资源简介
QEMU 加速器 如果主机操作系统和来宾操作系统运行于相同的处理器架构之上,那么您可以使用 QEMU 加速器(KQEMU)实现近似本地的性能。KQEMU 是一个驱动程序(Linux 的内核模块),允许用户模式的代码和内核代码直接在主机 CPU 上执行。构建 QEMU 加速器与构建 QEMU 本身相同
代码片段和文件信息
/* $Id: kqemu-freebsd.cv 1.6 2006/04/25 22:16:42 bellard Exp $ */
#include
#include
#include
#include
#include
#include
#include
#include
#if __FreeBSD_version >= 500000
#include
#endif
#include
#include
#if __FreeBSD_version >= 500000
#include
#endif
#include
#include
#include
#include
#if __FreeBSD_version < 500000
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “kqemu-kernel.h“
#ifndef KQEMU_MAJOR
#define KQEMU_MAJOR 250
#endif
MALLOC_DECLARE(M_KQEMU);
MALLOC_DEFINE(M_KQEMU “kqemu“ “kqemu buffers“);
int kqemu_debug;
SYSCTL_INT(_debug OID_AUTO kqemu_debug CTLFLAG_RW &kqemu_debug 0
“kqemu debug flag“);
#define USER_base 0x1000
/* lock the page at virtual address ‘user_addr‘ and return its
physical page index. Return NULL if error */
struct kqemu_user_page *CDECL kqemu_lock_user_page(unsigned long *ppage_index
unsigned long user_addr)
{
struct vmspace *vm = curproc->p_vmspace;
vm_offset_t va = user_addr;
vm_paddr_t pa = 0;
int ret;
pmap_t pmap;
#if __FreeBSD_version >= 500000
ret = vm_map_wire(&vm->vm_map va va+PAGE_SIZE VM_MAP_WIRE_USER);
#else
ret = vm_map_user_pageable(&vm->vm_map va va+PAGE_SIZE FALSE);
#endif
if (ret != KERN_SUCCESS) {
kqemu_log(“kqemu_lock_user_page(%08lx) failed ret=%d\n“ user_addr ret);
return NULL;
}
pmap = vm_map_pmap(&vm->vm_map);
pa = pmap_extract(pmap va);
/* kqemu_log(“kqemu_lock_user_page(%08lx) va=%08x pa=%08x\n“ user_addr va pa); */
*ppage_index = pa >> PAGE_SHIFT;
return (struct kqemu_user_page *)va;
}
void CDECL kqemu_unlock_user_page(struct kqemu_user_page *page)
{
struct vmspace *vm = curproc->p_vmspace;
vm_offset_t va;
int ret;
/* kqemu_log(“kqemu_unlock_user_page(%08lx)\n“ page_index); */
va = (vm_offset_t)page;
#if __FreeBSD_version >= 500000
ret = vm_map_unwire(&vm->vm_map va va+PAGE_SIZE VM_MAP_WIRE_USER);
#else
ret = vm_map_user_pageable(&vm->vm_map va va+PAGE_SIZE TRUE);
#endif
#if 0
if (ret != KERN_SUCCESS) {
kqemu_log(“kqemu_unlock_user_page(%08lx) failed ret=%d\n“ page_index ret);
}
#endif
}
/*
* Allocate a new page. The page must be mapped in the kernel space.
* Return the page_index or -1 if error.
*/
struct kqemu_page *CDECL kqemu_alloc_zeroed_page(unsigned long *ppage_index)
{
pmap_t pmap;
vm_offset_t va;
vm_paddr_t pa;
va = kmem_alloc(kernel_map PAGE_SIZE);
if (va == 0) {
kqemu_log(“kqemu_alloc_zeroed_page: NULL\n“);
return NULL;
}
- 上一篇:qtsoap-2.7_1
- 下一篇:非常好看后台登陆界面
评论
共有 条评论