static void print_profile(int status, void *p) { Parrot_Interp interpreter = (Parrot_Interp) p; if (interpreter->profile != NULL) { UINTVAL j; int k; UINTVAL op_count = 0; UINTVAL call_count = 0; FLOATVAL sum_time = 0.0; RunProfile *profile = interpreter->profile; FLOATVAL empty = calibrate(interpreter); PIO_printf(interpreter, "\n"); PIO_printf(interpreter, " OPERATION PROFILE \n\n"); PIO_printf(interpreter, " CODE OP FULL NAME CALLS TOTAL TIME AVG T. ms\n"); PIO_printf(interpreter, " ---- ----------------- ------- ---------- ----------\n"); for (j = 0; j < interpreter->op_count + PARROT_PROF_EXTRA; j++) { UINTVAL n = profile->data[j].numcalls; profile->data[j].op = j; if (j >= PARROT_PROF_EXTRA) profile->data[j].time -= (empty * n / 1000000); } qsort(profile->data, interpreter->op_count + PARROT_PROF_EXTRA, sizeof(ProfData), prof_sort_f); for (j = 0; j < interpreter->op_count + PARROT_PROF_EXTRA; j++) { UINTVAL n = profile->data[j].numcalls; FLOATVAL t = profile->data[j].time; if (n > 0) { op_count++; call_count += n; sum_time += t; k = profile->data[j].op; PIO_printf(interpreter, " %4d %-20s %7vu %10vf %10.4vf\n", k - PARROT_PROF_EXTRA, op_name(interpreter, k), n, t, (FLOATVAL)(t * 1000.0 / n) ); } } PIO_printf(interpreter, " ---- ----------------- ------- ---------- ----------\n"); PIO_printf(interpreter, " %4vu %-20s %7vu %10vf %10.4vf\n", op_count, "", call_count, sum_time, (FLOATVAL)(sum_time * 1000.0 / (FLOATVAL)call_count) ); } }
Term * func_op_names(TermList terms) { Term *ops_t; ops_t = (Term *)get_list_pos(terms, 1); if (! ops_t ) { report_fatal_external_error((char *)"Cannot retrieve OP instance term"); } if (ops_t->type != LISP_LIST) { report_fatal_external_error((char *)"Term is not of type LISP_LIST"); } TermList name_list = sl_make_slist(); for (L_List p_l = ops_t->u.l_list; p_l; p_l = l_cdr(p_l)) { Term *t = l_car(p_l); if (t->type == TT_INTENTION) { Op_Instance *opi = (Op_Instance *)(t->u.in->top_op); Op_Structure *op_s = op_instance_op(opi); name_list = build_term_list(name_list, build_id(op_name(op_s))); } else if (t->type == TT_OP_INSTANCE) { Op_Instance *opi = (Op_Instance *)(t->u.opi); Op_Structure *op_s = op_instance_op(opi); if (! op_s) { name_list = build_term_list(name_list, build_id(declare_atom("NOT-AN-OP"))); } else { name_list = build_term_list(name_list, build_id(op_name(op_s))); } } else { name_list = build_term_list(name_list, build_id(declare_atom("NOT-AN-OP-INSTANCE"))); } } return build_term_l_list_from_c_list(name_list); }
/* * Pass on a notification message from the cluster driver. * * Must run in the main thread as it accesses unlocked state like * sys->pending_list. */ void sd_notify_handler(struct sd_node *sender, void *data, size_t data_len) { struct vdi_op_message *msg = data; struct sd_op_template *op = get_sd_op(msg->req.opcode); int ret = msg->rsp.result; struct request *req = NULL; dprintf("op %s, size: %zd, from: %s\n", op_name(op), data_len, node_to_str(sender)); if (is_myself(sender->nid.addr, sender->nid.port)) { req = list_first_entry(&sys->pending_list, struct request, pending_list); list_del(&req->pending_list); }
static void cluster_op_done(struct work *work) { struct request *req = container_of(work, struct request, work); struct vdi_op_message *msg; size_t size; cluster_op_running = false; dprintf("%s (%p)\n", op_name(req->op), req); msg = prepare_cluster_msg(req, &size); if (!msg) panic(); sys->cdrv->unblock(msg, size); free(msg); }
/* * Pass on a notification message from the cluster driver. * * Must run in the main thread as it accesses unlocked state like * sys->pending_list. */ void sd_notify_handler(const struct sd_node *sender, void *data, size_t data_len) { struct vdi_op_message *msg = data; const struct sd_op_template *op = get_sd_op(msg->req.opcode); int ret = msg->rsp.result; struct request *req = NULL; sd_dprintf("op %s, size: %zd, from: %s\n", op_name(op), data_len, node_to_str(sender)); if (node_is_local(sender)) { if (has_process_work(op)) req = list_first_entry(&sys->pending_block_list, struct request, pending_list); else req = list_first_entry(&sys->pending_notify_list, struct request, pending_list); list_del(&req->pending_list); }
int dump_subexp (struct expression *exp, struct ui_file *stream, int elt) { static int indent = 0; int i; fprintf_filtered (stream, "\n"); fprintf_filtered (stream, "\t%5d ", elt); for (i = 1; i <= indent; i++) fprintf_filtered (stream, " "); indent += 2; fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode)); elt = dump_subexp_body (exp, stream, elt); indent -= 2; return elt; }
void do_ex_stage() { alu_t alufun = gen_alufun(); bool_t setcc = gen_set_cc(); word_t alua, alub; alua = gen_aluA(); alub = gen_aluB(); e_bcond = cond_holds(cc, id_ex_curr->ifun); ex_mem_next->takebranch = e_bcond; if (id_ex_curr->icode == I_JMP) sim_log("\tExecute: instr = %s, cc = %s, branch %staken\n", iname(HPACK(id_ex_curr->icode, id_ex_curr->ifun)), cc_name(cc), ex_mem_next->takebranch ? "" : "not "); /* Perform the ALU operation */ word_t aluout = compute_alu(alufun, alua, alub); ex_mem_next->vale = aluout; sim_log("\tExecute: ALU: %c 0x%x 0x%x --> 0x%x\n", op_name(alufun), alua, alub, aluout); if (setcc) { cc_in = compute_cc(alufun, alua, alub); sim_log("\tExecute: New cc = %s\n", cc_name(cc_in)); } ex_mem_next->icode = id_ex_curr->icode; ex_mem_next->ifun = id_ex_curr->ifun; ex_mem_next->vala = gen_e_valA(); ex_mem_next->deste = gen_e_dstE(); ex_mem_next->destm = id_ex_curr->destm; ex_mem_next->srca = id_ex_curr->srca; ex_mem_next->status = id_ex_curr->status; ex_mem_next->stage_pc = id_ex_curr->stage_pc; }
Term * func_op_name(TermList terms) { Term *op_t; Op_Instance *opi; op_t = (Term *)get_list_pos(terms, 1); if (! op_t ) { report_fatal_external_error((char *)"Cannot retrieve OP instance term"); } if (op_t->type != TT_OP_INSTANCE) { report_fatal_external_error((char *)"Term is not of type OP_INSTANCE"); } opi = (Op_Instance *)(op_t->u.opi); Op_Structure *op_s = op_instance_op(opi); if (! op_s) { report_fatal_external_error((char *)"Failed to get OP structure from OP instance"); } return build_id(op_name(op_s)); }
void dump_raw_expression (struct expression *exp, struct ui_file *stream, char *note) { int elt; char *opcode_name; char *eltscan; int eltsize; fprintf_filtered (stream, "Dump of expression @ "); gdb_print_host_address (exp, stream); if (note) fprintf_filtered (stream, ", %s:", note); fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n", exp->language_defn->la_name, exp->nelts, (long) sizeof (union exp_element)); fprintf_filtered (stream, "\t%5s %20s %16s %s\n", "Index", "Opcode", "Hex Value", "String Value"); for (elt = 0; elt < exp->nelts; elt++) { fprintf_filtered (stream, "\t%5d ", elt); opcode_name = op_name (exp, exp->elts[elt].opcode); fprintf_filtered (stream, "%20s ", opcode_name); print_longest (stream, 'd', 0, exp->elts[elt].longconst); fprintf_filtered (stream, " "); for (eltscan = (char *) &exp->elts[elt], eltsize = sizeof (union exp_element); eltsize-- > 0; eltscan++) { fprintf_filtered (stream, "%c", isprint (*eltscan) ? (*eltscan & 0xFF) : '.'); } fprintf_filtered (stream, "\n"); } }
/* * Execute a cluster operation by letting the cluster driver send it to all * nodes in the cluster. * * Must run in the main thread as it access unlocked state like * sys->pending_list. */ void queue_cluster_request(struct request *req) { eprintf("%s (%p)\n", op_name(req->op), req); if (has_process_work(req->op)) { list_add_tail(&req->pending_list, &sys->pending_list); sys->cdrv->block(); } else { struct vdi_op_message *msg; size_t size; msg = prepare_cluster_msg(req, &size); if (!msg) return; list_add_tail(&req->pending_list, &sys->pending_list); msg->rsp.result = SD_RES_SUCCESS; sys->cdrv->notify(msg, size); free(msg); } }
static irqreturn_t chrif_int(int irq, void *dev_id) { int err; RING_IDX rc, rp; int more_to_do, notify; chrif_request_t req; chrif_response_t resp; printk(KERN_INFO "\n------------------------------start response-------------------------------------"); printk(KERN_DEBUG "\nxen: Dom0: chrif_int called with dev_id=%x info=%x", (unsigned int)dev_id, (unsigned int) &info); rc = info.ring.req_cons; rp = info.ring.sring->req_prod; printk(KERN_DEBUG "\nxen: Dom0: rc = %d rp = %d", rc, rp); while (rc != rp) { if (RING_REQUEST_CONS_OVERFLOW(&info.ring, rc)) break; memcpy(&req, RING_GET_REQUEST(&info.ring, rc), sizeof(req)); resp.id = req.id; resp.operation = req.operation; resp.status = req.status + 1; printk(KERN_DEBUG "\nxen: Dom0: Recvd at IDX-%d: id = %d, op=%d, status=%d", rc, req.id, req.operation, req.status); info.ring.req_cons = ++rc; barrier(); printk(KERN_DEBUG "\nxen: Dom0: operation: %s", op_name(resp.operation)); switch(resp.operation) { case CHRIF_OP_OPEN: info.chrif_filp = filp_open(DEVICE_PATH, O_RDWR, 0); printk(KERN_DEBUG "\nxen: dom0: response open"); break; case CHRIF_OP_READ: { resp.rdwr.len = req.rdwr.len; //struct pdma_info pdma_info; //memset(op_page->addr, 0, resp.rdwr.len); old_fs = get_fs(); set_fs(get_ds()); //get read size of block //err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_INFO, (unsigned long)&pdma_info); //read data from device to page //err =info.chrif_filp->f_op->read(info.chrif_filp, op_page->addr, resp.rdwr.len, &info.chrif_filp->f_pos); set_fs(old_fs); if(err < 0) printk(KERN_DEBUG "\nxen: Dom0: read %u bytes error", resp.rdwr.len); printk(KERN_DEBUG "\nxen: dom0: response read"); break; } case CHRIF_OP_WRITE: { int i = 0, count, ret; struct vm_struct *op_page; struct gnttab_map_grant_ref op_page_ops; struct gnttab_unmap_grant_ref op_page_unmap_ops; resp.rdwr.len = req.rdwr.len; count = resp.rdwr.len/4096; printk(KERN_DEBUG "\nxen: Dom0: write %u bytes %d times", resp.rdwr.len, count); block_buf = (char *)kmalloc(resp.rdwr.len, GFP_KERNEL); memset(block_buf, 0, resp.rdwr.len); while(i < count) { resp.op_gref[i] = req.op_gref[i]; printk(KERN_DEBUG "\nxen: dom0: req.op_gref[0]: %d", resp.op_gref[i]); op_page = alloc_vm_area(PAGE_SIZE, NULL); if(op_page == 0) { free_vm_area(op_page); printk("\nxen: dom0: could not allocate shared_page"); return -EFAULT; } /*gnttab_set_map_op(&op_page_ops, (unsigned long)op_page->addr, GNTMAP_host_map, resp.op_gref[i], info.remoteDomain); op_page_unmap_ops.host_addr = (unsigned long)(op_page->addr); unmap_ops.handle = op_page_ops.handle; if(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op_page_ops, 1)){ printk(KERN_DEBUG "\nxen: dom0: HYPERVISOR map grant ref failed"); return -EFAULT; } if (op_page_ops.status) { printk(KERN_DEBUG "\nxen: dom0: HYPERVISOR map grant ref failed status = %d", op_page_ops.status); return -EFAULT; } printk(KERN_DEBUG "\nxen: dom0: map shared page success, shared_page=%x, handle = %x, status = %x", (unsigned int)op_page->addr, op_page_ops.handle, op_page_ops.status); memcpy(block_buf+i*4096, op_page->addr, 4096); ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op_page_unmap_ops, 1); if (ret == 0) { printk(KERN_DEBUG "\nxen: dom0: dom0_exit: unmapped shared frame"); } else { printk(KERN_DEBUG "\nxen: dom0: dom0_exit: unmapped shared frame failed"); } free_vm_area(op_page);*/ i++; } /* old_fs = get_fs(); set_fs(get_ds()); //write data from page to device //err = info.chrif_filp->f_op->write(info.chrif_filp, block_buf, resp.rdwr.len, &info.chrif_filp->f_pos); set_fs(old_fs); if(err < 0) printk(KERN_DEBUG "\nxen: Dom0: write %u bytes error", resp.rdwr.len); */ //kfree(block_buf); printk(KERN_DEBUG "\nxen: dom0: response write"); break; } case CHRIF_OP_IOCTL: { resp.ioc_parm.cmd = req.ioc_parm.cmd; switch(resp.ioc_parm.cmd) { case PDMA_IOC_START_DMA: { old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_START_DMA, NULL); set_fs(old_fs); if(err) { printk(KERN_DEBUG "\nxen: Dom0: start-dma ioctl failed"); resp.status = 0; } else printk(KERN_DEBUG "\nxen: Dom0: start-dma ioctl success"); //err = call_ioctl(info.chrif_filp, PDMA_IOC_START_DMA, NULL); break; } case PDMA_IOC_STOP_DMA: { //err = call_ioctl(info.chrif_filp, PDMA_IOC_STOP_DMA, NULL); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_STOP_DMA, NULL); set_fs(old_fs); if(err) { printk(KERN_DEBUG "\nxen: Dom0: stop-dma ioctl failed"); resp.status = 0; } else printk(KERN_DEBUG "\nxen: Dom0: stop-dma ioctl success"); break; } case PDMA_IOC_INFO: { struct pdma_info pdma_info; //err = call_ioctl(info.chrif_filp, PDMA_IOC_INFO, (unsigned long)&pdma_info); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_INFO, (unsigned long)&pdma_info); set_fs(old_fs); if(err) { printk(KERN_DEBUG "\nxen: Dom0: info ioctl failed"); resp.status = 0; } else printk(KERN_DEBUG "\nxen: Dom0: info ioctl success"); resp.ioc_parm.info = pdma_info; break; } case PDMA_IOC_STAT: { struct pdma_stat pdma_stat; //err = call_ioctl(info.chrif_filp, PDMA_IOC_STAT, (unsigned long)&pdma_stat); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_STAT, (unsigned long)&pdma_stat); set_fs(old_fs); if(err) { printk(KERN_DEBUG "\nxen: Dom0: stat ioctl failed"); resp.status = 0; } else printk(KERN_DEBUG "\nxen: Dom0: stat ioctl success"); resp.ioc_parm.stat = pdma_stat; break; } case PDMA_IOC_RW_REG: { struct pdma_rw_reg ctrl = req.ioc_parm.ctrl; //err = call_ioctl(info.chrif_filp, PDMA_IOC_RW_REG, (unsigned long)&ctrl); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_RW_REG, (unsigned long)&ctrl); set_fs(old_fs); if(err) { printk(KERN_DEBUG "\nxen: Dom0: rw-reg ioctl failed"); resp.status = 0; } else printk(KERN_DEBUG "\nxen: Dom0: rw-reg ioctl success"); resp.ioc_parm.ctrl = ctrl; break; } default: printk(KERN_DEBUG "\nxen: Dom0: unknow the operation"); break; } printk(KERN_INFO "\nxen: Dom0: response ioctl"); break; } case CHRIF_OP_CLOSE: filp_close(info.chrif_filp, NULL); printk(KERN_INFO "\nxen: Dom0: response close"); break; default: printk(KERN_DEBUG "\nxen: Dom0: unknow the operation"); break; } memcpy(RING_GET_RESPONSE(&info.ring, info.ring.rsp_prod_pvt), &resp, sizeof(resp)); info.ring.rsp_prod_pvt++; //put response and check whether or not notify domU RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&info.ring, notify); if (info.ring.rsp_prod_pvt == info.ring.req_cons) { RING_FINAL_CHECK_FOR_REQUESTS(&info.ring, more_to_do); } else if (RING_HAS_UNCONSUMED_REQUESTS(&info.ring)) { more_to_do = 1; } if (notify) { printk(KERN_DEBUG "\nxen:dom0:send notify to domu"); notify_remote_via_irq(info.irq); } } return IRQ_HANDLED; }
void InstructionPrinter::print_op2(Op2* instr) { print_value(instr->x()); tty->print(" %s ", op_name(instr->op())); print_value(instr->y()); }
print_e(expr e, int lev) { struct expression *ep = e; register int i, slev=lev; if(!ep) { printf("() "); return; } switch(ep->func) { /* Literals */ case 257: printf("$%d ", ep->values[0].num); return; case OP_NUMBER: printf("%d ", ep->values[0].num); return; case OP_STRING: printf("%s ", ep->values[0].data); return; case OP_NULL: printf("NULL "); return; /* Names */ case OP_COLNAME: printf("COLUMN:%s ", ep->values[0].name); return; case OP_TABLENAME: printf("TABLE:%s ", ep->values[0].name); return; case OP_FNAME: printf("FUNC:%s ", ep->values[0].name); return; /* Relational operators */ case OP_PROJECTROW: printf("(PROJECT1 \n"); break; case OP_PROJECTION: printf("(PROJECT \n"); break; case OP_SELECTROW: printf("(SELECT1 \n"); break; case OP_SELECTION: printf("(SELECT \n"); break; case OP_PRODUCT: printf("(PRODUCT \n"); break; case OP_SORT: printf("(SORT \n"); break; case OP_GROUP: printf("(GROUP \n"); break; case OP_DELTA: printf("(DELTA \n"); break; case OP_CREATETABLE: printf("(CREATETABLE \n"); break; case OP_INSERTROW: printf("(INSERTROW \n"); break; case OP_GETNEXT: printf("(GETNEXT \n"); break; case OP_ITERATE: printf("(ITERATE \n"); break; case OP_PLUS: printf("(+ \n"); break; case OP_BMINUS: printf("(- \n"); break; case OP_TIMES: printf("(* \n"); break; case OP_DIVIDE: printf("(/ \n"); break; case OP_AND: printf("(AND \n"); break; case OP_OR: printf("(OR \n"); break; case OP_NOT: printf("(! \n"); break; case OP_GT: printf("(> \n"); break; case OP_LT: printf("(< \n"); break; case OP_EQUAL: printf("(== \n"); break; case OP_NOTEQ: printf("(<> \n"); break; case OP_GEQ: printf("(>= \n"); break; case OP_LEQ: printf("(<= \n"); break; case OP_SORTSPEC: printf("(SORTSPEC \n"); break; case OP_COLUMNDEF: printf("(COLSPEC \n"); break; case OP_OUTCOLNAME: printf("(AS \n"); break; case OP_RLIST: printf("(RLIST "); print_e(ep->values[0].ep, lev+7); putchar('\n'); for(i=0;i<lev;i++) putchar(' '); print_e(ep->values[1].ep, lev); putchar(')'); return; default: printf("(%s \n", op_name(ep->func)); break; } lev += 2; for(i=0; i<lev; i++) putchar(' '); for(i=0; i<ep->count; i++) { print_e(ep->values[i].ep, lev+2); putchar(' '); } putchar('\n'); for(i=0; i<slev; i++) putchar(' '); putchar(')'); }
static const char *verify_csi32( const unsigned char *patch_start, const unsigned char *patch_end, const char *expected) { const unsigned char *p = patch_start; if (p >= patch_end) return "Patch type byte missing"; if (*p++ != PT_CSI32) return "Patch type byte is not PT_CSI32"; for (;;) { int patch_op; uint32_t patch_size; int expected_op; uint32_t expected_size; while (*expected == ' ') expected++; if (*expected == '\0') break; if (!csi32_parse_op(&p, patch_end, &patch_op, &patch_size)) { if (p == patch_end) return "Patch shorter than expected."; else return "Patch contains invalid CSI-32"; } switch (*expected) { case 'c': expected_op = OP_COPY; break; case 's': expected_op = OP_SKIP; break; case 'i': expected_op = OP_INSERT; break; default: diag("verify_csi32: Unexpected character %c", *expected); return "Syntax error in expected difference"; } expected++; while (*expected == ' ') expected++; if (patch_op != expected_op) { diag("verify_csi32: Expected %s, but next op is %s %lu", op_name(expected_op), op_name(patch_op), (unsigned long)patch_size); return "Operation mismatch"; } if (expected_op == OP_COPY || expected_op == OP_SKIP) { if (!is_digit(*expected)) { diag("verify_csi32: Expected size after %s instruction", op_name(expected_op)); return "Syntax error in expected difference"; } expected_size = parse_int(&expected); if (patch_size != expected_size) { diag("verify_csi32: Expected %s %lu, but patch says %s %lu", op_name(expected_op), (unsigned long)expected_size, op_name(expected_op), (unsigned long)patch_size); return "Operation size mismatch"; } } else { if (*expected++ != '\'') { diag("verify_csi32: Expected single-quoted string after insert instruction"); return "Syntax error in expected difference"; } for (expected_size = 0; ; expected_size++) { unsigned char c; if (*expected == '\'' && *(expected + 1) == '\'') { c = '\''; expected += 2; } else if (*expected == '\'') { expected++; break; } else if (*expected == '\0') { diag("verify_csi32: Missing end quote"); return "Syntax error in expected difference"; } else { c = *expected++; } if (!(p < patch_end && *p++ == c)) return "Insertion string mismatch"; } if (patch_size != expected_size) return "Insertion string mismatch"; } } if (p != patch_end) return "Patch longer than expected."; return NULL; }
static irqreturn_t chrif_int(int irq, void *dev_id) { int err; RING_IDX rc, rp; int more_to_do, notify; chrif_request_t req; chrif_response_t resp; printk(KERN_INFO "\n------------------------------start response-------------------------------------"); printk(KERN_DEBUG "\nxen: Dom0: chrif_int called with dev_id=%x info=%x", (unsigned int)dev_id, (unsigned int) &info); rc = info.ring.req_cons; rp = info.ring.sring->req_prod; printk(KERN_DEBUG "\nxen: Dom0: rc = %d rp = %d", rc, rp); while (rc != rp) { if (RING_REQUEST_CONS_OVERFLOW(&info.ring, rc)) break; memcpy(&req, RING_GET_REQUEST(&info.ring, rc), sizeof(req)); resp.id = req.id; resp.operation = req.operation; resp.status = req.status + 1; printk(KERN_DEBUG "\nxen: Dom0: Recvd at IDX-%d: id = %d, op=%d, status=%d", rc, req.id, req.operation, req.status); info.ring.req_cons = ++rc; barrier(); printk(KERN_DEBUG "\nxen: Dom0: operation: %s", op_name(resp.operation)); switch(resp.operation) { case CHRIF_OP_OPEN: info.chrif_filp = filp_open(DEVICE_PATH, O_RDWR, 0); printk(KERN_DEBUG "\nxen: dom0: response open"); break; case CHRIF_OP_READ:{ int cnt; resp.rdwr.len = req.rdwr.len; cnt = resp.rdwr.len/4096; printk(KERN_DEBUG "\nxen: dom0: read %d times", cnt); memset(op_page->addr, 0, 4096); if(rd_time == 0){ old_fs = get_fs(); set_fs(get_ds()); //read data from device to page err =info.chrif_filp->f_op->read(info.chrif_filp, block_buf, resp.rdwr.len, &info.chrif_filp->f_pos); set_fs(old_fs); if(err < 0) printk(KERN_DEBUG "\nxen: Dom0: read %u bytes error", resp.rdwr.len); } memcpy(op_page->addr, block_buf+rd_time*4096, 4096); rd_time++; if(rd_time == cnt){ rd_time = 0; memset(block_buf, 0, resp.rdwr.len); } printk(KERN_DEBUG "\nxen: dom0: response read"); break; } case CHRIF_OP_WRITE:{ int count; resp.rdwr.len = req.rdwr.len; count = resp.rdwr.len/4096; printk(KERN_DEBUG "\nxen: dom0: write %d times", count); //if(count == 0){ block_buf = (char *)kmalloc(resp.rdwr.len, GFP_KERNEL);} memcpy(block_buf+wr_time*4096, op_page->addr, 4096); wr_time++; if(wr_time == count){ old_fs = get_fs(); set_fs(get_ds()); //write data from page to device err = info.chrif_filp->f_op->write(info.chrif_filp, block_buf, resp.rdwr.len, &info.chrif_filp->f_pos); set_fs(old_fs); wr_time = 0; if(err < 0) printk(KERN_DEBUG "\nxen: Dom0: write %u bytes error", resp.rdwr.len); memset(block_buf, 0, resp.rdwr.len); } //kfree(block_buf); printk(KERN_DEBUG "\nxen: dom0: response write"); break; } case CHRIF_OP_IOCTL:{ resp.ioc_parm.cmd = req.ioc_parm.cmd; switch(resp.ioc_parm.cmd){ case PDMA_IOC_START_DMA:{ old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_START_DMA, NULL); set_fs(old_fs); if(err){ printk(KERN_DEBUG "\nxen: Dom0: start-dma ioctl failed"); resp.status = 0; }else printk(KERN_DEBUG "\nxen: Dom0: start-dma ioctl success"); //err = call_ioctl(info.chrif_filp, PDMA_IOC_START_DMA, NULL); get_block_info(); break; } case PDMA_IOC_STOP_DMA:{ //err = call_ioctl(info.chrif_filp, PDMA_IOC_STOP_DMA, NULL); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_STOP_DMA, NULL); set_fs(old_fs); if(err){ printk(KERN_DEBUG "\nxen: Dom0: stop-dma ioctl failed"); resp.status = 0; }else printk(KERN_DEBUG "\nxen: Dom0: stop-dma ioctl success"); break; } case PDMA_IOC_INFO:{ struct pdma_info pdma_info; //err = call_ioctl(info.chrif_filp, PDMA_IOC_INFO, (unsigned long)&pdma_info); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_INFO, (unsigned long)&pdma_info); set_fs(old_fs); if(err){ printk(KERN_DEBUG "\nxen: Dom0: info ioctl failed"); resp.status = 0; }else printk(KERN_DEBUG "\nxen: Dom0: info ioctl success"); resp.ioc_parm.info = pdma_info; break; } case PDMA_IOC_STAT:{ struct pdma_stat pdma_stat; //err = call_ioctl(info.chrif_filp, PDMA_IOC_STAT, (unsigned long)&pdma_stat); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_STAT, (unsigned long)&pdma_stat); set_fs(old_fs); if(err){ printk(KERN_DEBUG "\nxen: Dom0: stat ioctl failed"); resp.status = 0; }else printk(KERN_DEBUG "\nxen: Dom0: stat ioctl success"); resp.ioc_parm.stat = pdma_stat; break; } case PDMA_IOC_RW_REG:{ struct pdma_rw_reg ctrl = req.ioc_parm.ctrl; //err = call_ioctl(info.chrif_filp, PDMA_IOC_RW_REG, (unsigned long)&ctrl); old_fs = get_fs(); set_fs(get_ds()); err = info.chrif_filp->f_op->unlocked_ioctl(info.chrif_filp, PDMA_IOC_RW_REG, (unsigned long)&ctrl); set_fs(old_fs); if(err){ printk(KERN_DEBUG "\nxen: Dom0: rw-reg ioctl failed"); resp.status = 0; }else printk(KERN_DEBUG "\nxen: Dom0: rw-reg ioctl success"); resp.ioc_parm.ctrl = ctrl; break; } default: printk(KERN_DEBUG "\nxen: Dom0: unknow the operation"); break; } printk(KERN_INFO "\nxen: Dom0: response ioctl"); break; } case CHRIF_OP_CLOSE: filp_close(info.chrif_filp, NULL); printk(KERN_INFO "\nxen: Dom0: response close"); break; default: printk(KERN_DEBUG "\nxen: Dom0: unknow the operation"); break; } memcpy(RING_GET_RESPONSE(&info.ring, info.ring.rsp_prod_pvt), &resp, sizeof(resp)); info.ring.rsp_prod_pvt++; //put response and check whether or not notify domU RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&info.ring, notify); if (info.ring.rsp_prod_pvt == info.ring.req_cons) { RING_FINAL_CHECK_FOR_REQUESTS(&info.ring, more_to_do); } else if (RING_HAS_UNCONSUMED_REQUESTS(&info.ring)) { more_to_do = 1; } if (notify) { printk(KERN_DEBUG "\nxen:dom0:send notify to domu"); notify_remote_via_irq(info.irq); } } return IRQ_HANDLED; }
int be_visitor_attribute::visit_attribute (be_attribute *node) { this->ctx_->node (node); this->ctx_->attribute (node); UTL_Scope *s = node->defined_in (); AST_Decl *d = ScopeAsDecl (s); ACE_CString op_name (this->ctx_->port_prefix ()); op_name += node->local_name ()->get_string (); Identifier *op_id = 0; ACE_NEW_RETURN (op_id, Identifier (op_name.c_str ()), -1); UTL_ScopedName *op_ln = 0; ACE_NEW_RETURN (op_ln, UTL_ScopedName (op_id, 0), -1); UTL_ScopedName *op_sn = static_cast<UTL_ScopedName *> (d->name ()->copy ()); op_sn->nconc (op_ln); // first the "get" operation be_operation get_op (node->field_type (), AST_Operation::OP_noflags, 0, node->is_local (), node->is_abstract ()); get_op.set_defined_in (s); get_op.set_name (op_sn); UTL_ExceptList *get_exceptions = node->get_get_exceptions (); if (0 != get_exceptions) { get_op.be_add_exceptions (get_exceptions->copy ()); } be_visitor_context ctx (*this->ctx_); int status = 1; switch (this->ctx_->state ()) { // These two cases are the only ones that could involve a strategy. case TAO_CodeGen::TAO_ROOT_CH: case TAO_CodeGen::TAO_INTERFACE_CH: { ctx.state (TAO_CodeGen::TAO_OPERATION_CH); be_visitor_operation_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CS: { ctx.state (TAO_CodeGen::TAO_OPERATION_CS); be_visitor_operation_cs visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SH: { be_visitor_operation_sh visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IH: { be_visitor_operation_ih visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SS: { be_visitor_operation_ss visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IS: { be_visitor_operation_is visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: { be_visitor_operation_proxy_impl_xh visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: { be_visitor_operation_direct_proxy_impl_ss visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: { be_visitor_operation_smart_proxy_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: { be_visitor_operation_smart_proxy_cs visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SH: { be_visitor_operation_tie_sh visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SS: { be_visitor_operation_tie_ss visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTH: case TAO_CodeGen::TAO_ROOT_SVH: { be_visitor_operation_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTS: case TAO_CodeGen::TAO_ROOT_SVS: { be_visitor_operation_svs visitor (&ctx); visitor.scope (this->op_scope_); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXH: { be_visitor_operation_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXS: { be_visitor_operation_exs visitor (&ctx); visitor.scope (this->op_scope_); visitor.class_extension (this->exec_class_extension_.c_str ()); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CNH: case TAO_CodeGen::TAO_ROOT_CNS: break; default: get_op.destroy (); return 0; } if (status == -1) { get_op.destroy (); ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for get_attribute failed\n"), -1); } // Do nothing for readonly attributes. if (node->readonly ()) { get_op.destroy (); return 0; } status = 1; // Create the set method. Identifier id ("void"); UTL_ScopedName sn (&id, 0); // The return type is "void". be_predefined_type rt (AST_PredefinedType::PT_void, &sn); // Argument type is the same as the attribute type. AST_Argument *arg = idl_global->gen ()->create_argument (AST_Argument::dir_IN, node->field_type (), node->name ()); arg->set_name ((UTL_IdList *) node->name ()->copy ()); // Create the operation. be_operation set_op (&rt, AST_Operation::OP_noflags, 0, node->is_local (), node->is_abstract ()); set_op.set_defined_in (node->defined_in ()); set_op.set_name (static_cast<UTL_ScopedName *> (op_sn->copy ())); set_op.be_add_argument (arg); UTL_ExceptList *set_exceptions = node->get_set_exceptions (); if (0 != set_exceptions) { set_op.be_add_exceptions (set_exceptions->copy ()); } ctx = *this->ctx_; status = 1; switch (this->ctx_->state ()) { // These two cases are the only ones that could involved a strategy. case TAO_CodeGen::TAO_ROOT_CH: case TAO_CodeGen::TAO_INTERFACE_CH: { ctx.state (TAO_CodeGen::TAO_OPERATION_CH); be_visitor_operation_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CS: { ctx.state (TAO_CodeGen::TAO_OPERATION_CS); be_visitor_operation_cs visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SH: { be_visitor_operation_sh visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IH: { be_visitor_operation_ih visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SS: { be_visitor_operation_ss visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IS: { be_visitor_operation_is visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: { be_visitor_operation_proxy_impl_xh visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: { be_visitor_operation_direct_proxy_impl_ss visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: { be_visitor_operation_smart_proxy_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: { be_visitor_operation_smart_proxy_cs visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SH: { be_visitor_operation_tie_sh visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SS: { be_visitor_operation_tie_ss visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTH: case TAO_CodeGen::TAO_ROOT_SVH: { be_visitor_operation_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTS: case TAO_CodeGen::TAO_ROOT_SVS: { be_visitor_operation_svs visitor (&ctx); visitor.scope (this->op_scope_); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXH: { be_visitor_operation_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXS: { be_visitor_operation_exs visitor (&ctx); visitor.scope (this->op_scope_); visitor.class_extension (this->exec_class_extension_.c_str ()); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CNH: case TAO_CodeGen::TAO_ROOT_CNS: break; default: // Error. set_op.destroy (); rt.destroy (); ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "bad codegen state\n"), -1); } if (status == 0) { get_op.destroy (); set_op.destroy (); rt.destroy (); return 0; } else if (status == -1) { get_op.destroy (); set_op.destroy (); rt.destroy (); ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for get_attribute failed\n"), -1); } get_op.destroy (); set_op.destroy (); rt.destroy (); return 0; }