コード例 #1
0
ファイル: xbd.c プロジェクト: MarginC/kame
static void
init_interface(void)
{
	block_io_op_t op; 

	reset_interface();

	if (blk_ring == NULL) {
		op.cmd = BLOCK_IO_OP_RING_ADDRESS;
		(void)HYPERVISOR_block_io_op(&op);

		blk_ring = (blk_ring_t *)uvm_km_valloc_align(kernel_map,
		    PAGE_SIZE, PAGE_SIZE);
		pmap_kenter_ma((vaddr_t)blk_ring, op.u.ring_mfn << PAGE_SHIFT,
		    VM_PROT_READ|VM_PROT_WRITE);
		DPRINTF(XBDB_SETUP, ("init_interface: "
		    "ring va %p and wired to %p\n",
		    blk_ring, (void *)(op.u.ring_mfn << PAGE_SHIFT)));

		blk_ring->req_prod = blk_ring->resp_prod =
			resp_cons = req_prod = last_req_prod = 0;

		event_set_handler(_EVENT_BLKDEV, &xbd_response_handler,
		    NULL, IPL_BIO);
		hypervisor_enable_event(_EVENT_BLKDEV);
	}

	__insn_barrier();
	state = STATE_ACTIVE;
}
static void reset(JNIEnv *env, jobject thiz, jstring jName)
{
    const char *name = jName ? env->GetStringUTFChars(jName, NULL) : NULL;
    if (!name) {
        jniThrowNullPointerException(env, "name");
        return;
    }
    if (reset_interface(name) < 0) {
        throwException(env, SYSTEM_ERROR, "Cannot reset interface");
    }
    env->ReleaseStringUTFChars(jName, name);
}