static int curl_cb_debug(CURL *curl, curl_infotype info, char *buf, size_t len, void *userdata) { struct http_ctx *ctx = userdata; switch (info) { case CURLINFO_TEXT: debug_dump(ctx, "CURLINFO_TEXT", buf, len); break; case CURLINFO_HEADER_IN: debug_dump(ctx, "CURLINFO_HEADER_IN", buf, len); break; case CURLINFO_HEADER_OUT: debug_dump(ctx, "CURLINFO_HEADER_OUT", buf, len); break; case CURLINFO_DATA_IN: debug_dump(ctx, "CURLINFO_DATA_IN", buf, len); break; case CURLINFO_DATA_OUT: debug_dump(ctx, "CURLINFO_DATA_OUT", buf, len); break; case CURLINFO_SSL_DATA_IN: wpa_printf(MSG_DEBUG, "debug - CURLINFO_SSL_DATA_IN - %d", (int) len); break; case CURLINFO_SSL_DATA_OUT: wpa_printf(MSG_DEBUG, "debug - CURLINFO_SSL_DATA_OUT - %d", (int) len); break; case CURLINFO_END: wpa_printf(MSG_DEBUG, "debug - CURLINFO_END - %d", (int) len); break; } return 0; }
/* * analyze_object * Look at a library loaded into the current process, and determine as much as * possible about it. The disassembling, allocations are initiated here. * * This is a callback function, passed to dl_iterate_phdr(3). * data and size are just unused callback arguments. * * * From dl_iterate_phdr(3) man page: * * struct dl_phdr_info * { * ElfW(Addr) dlpi_addr; Base address of object * const char *dlpi_name; (Null-terminated) name of object * const ElfW(Phdr) *dlpi_phdr; Pointer to array of ELF program headers * ElfW(Half) dlpi_phnum; # of items in dlpi_phdr * ... * } * */ static int analyze_object(struct dl_phdr_info *info, size_t size, void *data) { (void) data; (void) size; const char *path; debug_dump("analyze_object called on \"%s\" at 0x%016" PRIxPTR "\n", info->dlpi_name, info->dlpi_addr); if ((path = get_object_path(info)) == NULL) return 0; debug_dump("analyze %s\n", path); if (!should_patch_object(info->dlpi_addr, path)) return 0; struct intercept_desc *patches = allocate_next_obj_desc(); patches->base_addr = (unsigned char *)info->dlpi_addr; patches->path = path; find_syscalls(patches); allocate_trampoline_table(patches); create_patch_wrappers(patches); return 0; }
int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec) { int ret = 0; #else #define deb_info(args...) d; #endif u8 *buf = d->priv; buf[0] = cmd; if (outlen > 19) outlen = 19; if (inlen > 11) inlen = 11; ret = mutex_lock_interruptible(&d->usb_mutex); if (ret) return ret; if (out != NULL && outlen > 0) memcpy(&buf[1], out, outlen); deb_xfer("out buffer: "); debug_dump(buf, outlen+1, deb_xfer); if (usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0), TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, buf, 20, 2000) != 20) { err("USB control message 'out' went wrong."); ret = -EIO; goto unlock; } msleep(msec); if (usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev,0), TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, buf, 12, 2000) != 12) { err("USB control message 'in' went wrong."); ret = -EIO; goto unlock; } deb_xfer("in buffer: "); debug_dump(buf, 12, deb_xfer); if (in != NULL && inlen > 0) memcpy(in, &buf[1], inlen); unlock: mutex_unlock(&d->usb_mutex); return ret; }
int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec) { int ret = 0; u8 inbuf[12] = { 0 }, outbuf[20] = { 0 }; outbuf[0] = cmd; if (outlen > 19) outlen = 19; if (inlen > 11) inlen = 11; if (out != NULL && outlen > 0) memcpy(&outbuf[1], out, outlen); deb_xfer("out buffer: "); debug_dump(outbuf,outlen+1,deb_xfer); if ((ret = down_interruptible(&d->usb_sem))) return ret; if (usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0), TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, outbuf, 20, 2000) != 20) { err("USB control message 'out' went wrong."); ret = -EIO; goto unlock; } msleep(msec); if (usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev,0), TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, inbuf, 12, 2000) != 12) { err("USB control message 'in' went wrong."); ret = -EIO; goto unlock; } deb_xfer("in buffer: "); debug_dump(inbuf,12,deb_xfer); if (in != NULL && inlen > 0) memcpy(in,&inbuf[1],inlen); unlock: up(&d->usb_sem); return ret; }
dbuf_t *dtry_reasm_timed(void *pile, uint32_t xid, char *data, uint16_t len, uint16_t offs, int more, time_t now) { reasm_pile_struct_t *rp = (void *)(((dbuf_t *)pile)->buf); reasm_chunk_t *chk; if (now > 0) { check_timeouts(rp, now); } if(offs + len > rp->mtu) { debug(DBG_REASM, 10, "Offset + length (%d + %d) of fragment > MTU (%d), discard", offs, len, rp->mtu); return NULL; } if ((offs > 0) && (offs < HOLE_MIN_LENGTH)) { debug(DBG_REASM, 10, "Offset %d less than min hole length %d\n", offs, HOLE_MIN_LENGTH); return NULL; } chk = hfind(rp->chs, &xid, sizeof(xid)); if (!chk) { debug(DBG_REASM, 10, "Reasm chunk %lu not found, creating", xid); chk = malloc(sizeof(reasm_chunk_t)); chk->xid = xid; chk->maxfrags = rp->maxfrags; chk->hole = 0; chk->esize = rp->ftu; chk->d = dalloc(chk->esize); chk->deadline = now + rp->reasm_timeout; memset(chk->d->buf, 0xaa, chk->d->size); hole_set(chk, 0, chk->esize, 0); hinsert(rp->chs, &xid, sizeof(xid), chk, chk_destructor, NULL, NULL, NULL); TAILQ_INSERT_TAIL(&rp->lru, chk, entries); } else { debug(DBG_REASM, 10, "Reasm chunk %lu found", xid); } debug(DBG_REASM, 100, "Chunk data (hole: %d, esize: %d):", chk->hole, chk->esize); debug_dump(DBG_REASM, 100, chk->d->buf, chk->d->size); if(offs + len > chk->d->size) { debug(DBG_REASM, 10, "Reasm chunk %lu overflow - %d + %d > %d", xid, offs, len, chk->d->size); /* We already checked the MTU overflow above, so we can safely reallocate here */ int oldsize = chk->d->size; dgrow(chk->d, rp->mtu - chk->d->size); hole_grow(chk, oldsize-1, chk->d->size); chk->esize = chk->d->size; debug(DBG_REASM, 100, "Fresh chunk data after growth to MTU:"); debug_dump(DBG_REASM, 100, chk->d->buf, chk->d->size); } chk->atime = now; return dperform_reasm(rp, chk, xid, data, len, offs, more); }
int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen, int delay_ms) { int actlen,ret = -ENOMEM; if (!d || wbuf == NULL || wlen == 0) return -EINVAL; if (d->props.generic_bulk_ctrl_endpoint == 0) { err("endpoint for generic control not specified."); return -EINVAL; } if ((ret = mutex_lock_interruptible(&d->usb_mutex))) return ret; deb_xfer(">>> "); debug_dump(wbuf,wlen,deb_xfer); ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint), wbuf,wlen,&actlen, 2000); if (ret) err("bulk message failed: %d (%d/%d)",ret,wlen,actlen); else ret = actlen != wlen ? -1 : 0; if (!ret && rbuf && rlen) { if (delay_ms) msleep(delay_ms); ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint_response ? d->props.generic_bulk_ctrl_endpoint_response : d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen, 2000); if (ret) err("recv bulk message failed: %d",ret); else { deb_xfer("<<< "); debug_dump(rbuf,actlen,deb_xfer); } } mutex_unlock(&d->usb_mutex); return ret; }
static int __az6007_write(struct usb_device *udev, u8 req, u16 value, u16 index, u8 *b, int blen) { int ret; deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ", req, value, index); debug_dump(b, blen, deb_xfer); if (blen > 64) { err("az6007: tried to write %d bytes, but I2C max size is 64 bytes\n", blen); return -EOPNOTSUPP; } ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), req, USB_TYPE_VENDOR | USB_DIR_OUT, value, index, b, blen, 5000); if (ret != blen) { err("usb write operation failed. (%d)", ret); return -EIO; } return 0; }
/* * Kernel debug service. */ int sys_debug(int cmd, u_long arg) { #ifdef DEBUG int rc; switch (cmd) { case DCMD_DUMP: rc = debug_dump(arg); break; case DCMD_LOGSIZE: rc = LOGBUF_SIZE; break; case DCMD_GETLOG: rc = debug_getlog((void *)arg); break; default: rc = DERR(-EINVAL); break; } return rc; #else return -ENOSYS; #endif }
void debug_sigsegv () { debug_dump (1); unhook_all (); gui_main_end (0); string_iconv_fprintf ( stderr, "\n" "*** Very bad! WeeChat is crashing (SIGSEGV received)\n"); if (!log_crash_rename ()) { string_iconv_fprintf ( stderr, "*** Full crash dump was saved to %s/weechat.log file.\n", weechat_home); } string_iconv_fprintf ( stderr, "***\n" "*** Please help WeeChat developers to fix this bug:\n" "*** 1. If you have a core file, please run: gdb /path/to/weechat core\n" "*** then issue command: \"bt full\" and send result to developers\n" "*** (see user's guide for more info about report of crashes).\n" "*** 2. Otherwise send backtrace (below), only if it is a complete trace.\n" "*** Keep the crash log file, just in case developers ask you some info\n" "*** (be careful, private info like passwords may be in this file).\n\n"); weechat_backtrace (); /* shutdown with error code */ weechat_shutdown (EXIT_FAILURE, 1); }
dbuf_t *check_reasm_done(reasm_pile_struct_t *rp, reasm_chunk_t *chk, uint16_t hoffs1, uint16_t hoffs0, char *data, uint16_t len, uint16_t offs, int more) { dbuf_t *d = chk->d; if (!more) { debug(DBG_REASM, 20, "Set desired length %d <= %d + %d\n", chk->esize, offs, len); chk->esize = offs+len; } memcpy(&chk->d->buf[offs], data, len); reset_timeout(rp, chk); if (d->dsize < offs+len) { d->dsize = offs+len; } debug(DBG_REASM, 20, "Offs: %d, len: %d, chk->esize: %d, chk->hole: %d, d->dsize: %d", offs, len, chk->esize, chk->hole, d->dsize); debug_dump(DBG_REASM, 100, d->buf, d->size); if (chk->esize == chk->hole) { /* * reassembly complete. Delete chunk, and return the dbuf. * do not unlock since we should have locked it anyway */ d->dsize = chk->esize; dispose_chk(rp, chk); return d; } return NULL; }
void debug_sigsegv () { debug_dump (1); unhook_all (); gui_main_end (0); string_iconv_fprintf (stderr, "\n"); string_iconv_fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n"); if (!log_crash_rename ()) string_iconv_fprintf (stderr, "*** Full crash dump was saved to %s/weechat.log file.\n", weechat_home); string_iconv_fprintf (stderr, "***\n"); string_iconv_fprintf (stderr, "*** Please help WeeChat developers to fix this bug:\n"); string_iconv_fprintf (stderr, "*** 1. If you have a core file, please run: gdb weechat-curses core\n"); string_iconv_fprintf (stderr, "*** then issue \"bt\" command and send result to developers\n"); string_iconv_fprintf (stderr, "*** To enable core files with bash shell: ulimit -c 10000\n"); string_iconv_fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n"); string_iconv_fprintf (stderr, "*** (be careful, private info may be in this file since\n"); string_iconv_fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n"); weechat_backtrace (); /* shutdown with error code */ weechat_shutdown (EXIT_FAILURE, 1); }
void debug_input(void) { // screenshot always works if (input_action_get_state_single(nc_debug_screenshot)) { debug_screenshot(); return; } // others require debug mode to be on if (!hud.debug) return; if (input_action_get_state_single(nc_debug_status)) { debug_dump(); return; } if (input_action_get_state_single(nc_debug_game)) { debug_game(); return; } if (input_action_get_state_single(nc_debug_map)) { map_pick_trigger_set(); return; } }
int dibusb_readwrite_usb(struct usb_dibusb *dib, u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) { int actlen,ret = -ENOMEM; if (wbuf == NULL || wlen == 0) return -EINVAL; if ((ret = down_interruptible(&dib->usb_sem))) return ret; debug_dump(wbuf,wlen); ret = usb_bulk_msg( dib->udev, usb_sndbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_cmd), wbuf, wlen, &actlen, DIBUSB_I2C_TIMEOUT); if (ret) err("bulk message failed: %d (%d/%d)",ret,wlen,actlen); else ret = (actlen != wlen) ? -1 : 0; /* an answer is expected, and no error before */ if (!ret && rbuf && rlen) { ret = usb_bulk_msg(dib->udev,usb_rcvbulkpipe(dib->udev, dib->dibdev->dev_cl->pipe_cmd),rbuf,rlen,&actlen, DIBUSB_I2C_TIMEOUT); if (ret) err("recv bulk message failed: %d",ret); else { deb_alot("rlen: %d\n",rlen); debug_dump(rbuf,actlen); } } up(&dib->usb_sem); return ret; }
void dsend(int idx, dbuf_t * d) { debug(DBG_GLOBAL, 5, "pushing %d bytes for index %d", d->dsize, idx); debug_dump(DBG_GLOBAL, 100, d->buf, d->dsize); lpush(&cdata[idx].xmit_list, d); ufds[idx].events |= POLLOUT; // Will be unlocked by the send mechanism dlock(d); }
/* URB stuff for streaming */ static void dvb_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs) { struct dvb_usb_device *d = urb->context; int ptype = usb_pipetype(urb->pipe); int i; u8 *b; deb_ts("'%s' urb completed. feedcount: %d, status: %d, length: %d/%d, pack_num: %d, errors: %d\n", ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", d->feedcount, urb->status,urb->actual_length,urb->transfer_buffer_length, urb->number_of_packets,urb->error_count); switch (urb->status) { case 0: /* success */ case -ETIMEDOUT: /* NAK */ break; case -ECONNRESET: /* kill */ case -ENOENT: case -ESHUTDOWN: return; default: /* error */ deb_ts("urb completition error %d.", urb->status); break; } if (d->feedcount > 0) { if (d->state & DVB_USB_STATE_DVB) { switch (ptype) { case PIPE_ISOCHRONOUS: b = (u8 *) urb->transfer_buffer; for (i = 0; i < urb->number_of_packets; i++) { if (urb->iso_frame_desc[i].status != 0) deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status); else if (urb->iso_frame_desc[i].actual_length > 0) { dvb_dmx_swfilter(&d->demux,b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length); } urb->iso_frame_desc[i].status = 0; urb->iso_frame_desc[i].actual_length = 0; } debug_dump(b,20,deb_ts); break; case PIPE_BULK: if (urb->actual_length > 0) dvb_dmx_swfilter(&d->demux, (u8 *) urb->transfer_buffer,urb->actual_length); break; default: err("unkown endpoint type in completition handler."); return; } } } usb_submit_urb(urb,GFP_ATOMIC); }
static void acpi_init_global (void) { u64 rsdp; struct rsdp *p; struct facp *q; struct acpi_ent_dmar *r; struct domain *create_dom() ; rsdp_found = false; pm1a_cnt_found = false; rsdp = find_rsdp (); if (rsdp == FIND_RSDP_NOT_FOUND) { printf ("ACPI RSDP not found.\n"); return; } p = acpi_mapmem (rsdp, sizeof *p); memcpy (&rsdp_copy, p, sizeof *p); rsdp_found = true; r=find_entry(DMAR_SIGNATURE); if (!r) { printf ("ACPI DMAR not found.\n"); iommu_detected=0; } else { int i ; printf ("ACPI DMAR found.\n"); iommu_detected=1; parse_dmar_bios_report(r) ; num_dom=0 ; for (i=0 ; i<MAX_IO_DOM ; i++) dom_io[i]=create_dom(i) ; } q = find_facp (); if (!q) { printf ("ACPI FACP not found.\n"); return; } #ifdef ACPI_DSDT acpi_dsdt_parse (q->dsdt); #endif get_pm1a_cnt_ioaddr (q); get_facs_addr (q); if (0) debug_dump (q, q->header.length); if (0) printf ("PM1a control port is 0x%X\n", pm1a_cnt_ioaddr); pm1a_cnt_found = true; clear_mcfg (); }
static int vp7045_read_eeprom(struct dvb_usb_device *d,u8 *buf, int len, int offset) { int i = 0; u8 v,br[2]; for (i=0; i < len; i++) { v = offset + i; vp7045_usb_op(d,GET_EE_VALUE,&v,1,br,2,5); buf[i] = br[1]; } deb_info("VP7045 EEPROM read (offs: %d, len: %d) : ",offset, i); debug_dump(buf,i,deb_info); return 0; }
int debug_dump_cb (void *data, const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ (void) data; (void) signal; (void) type_data; if (!signal_data || (string_strcasecmp ((char *)signal_data, "core") == 0)) debug_dump (0); return WEECHAT_RC_OK; }
/* URB stuff for streaming */ static void usb_urb_complete(struct urb *urb) { struct usb_data_stream *stream = urb->context; int ptype = usb_pipetype(urb->pipe); int i; u8 *b; deb_uxfer("'%s' urb completed. status: %d, length: %d/%d, pack_num: %d, errors: %d\n", ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", urb->status,urb->actual_length,urb->transfer_buffer_length, urb->number_of_packets,urb->error_count); switch (urb->status) { case 0: /* success */ case -ETIMEDOUT: /* NAK */ break; case -ECONNRESET: /* kill */ case -ENOENT: case -ESHUTDOWN: return; default: /* error */ deb_ts("urb completition error %d.\n", urb->status); break; } b = (u8 *) urb->transfer_buffer; switch (ptype) { case PIPE_ISOCHRONOUS: for (i = 0; i < urb->number_of_packets; i++) { if (urb->iso_frame_desc[i].status != 0) deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status); else if (urb->iso_frame_desc[i].actual_length > 0) stream->complete(stream, b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length); urb->iso_frame_desc[i].status = 0; urb->iso_frame_desc[i].actual_length = 0; } debug_dump(b,20,deb_uxfer); break; case PIPE_BULK: if (urb->actual_length > 0) stream->complete(stream, b, urb->actual_length); break; default: err("unkown endpoint type in completition handler."); return; } usb_submit_urb(urb,GFP_ATOMIC); }
/* expecting tx buffer: request data[0] ... data[n] (n <= 4) */ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen) { u16 index, value; int status; if (txlen < 2) { err("tx buffer length is smaller than 2. Makes no sense."); return -EINVAL; } if (txlen > 4) { err("tx buffer length is larger than 4. Not supported."); return -EINVAL; } deb_data(">>> "); debug_dump(tx,txlen,deb_data); value = ((txlen - 2) << 8) | tx[1]; index = 0; if (txlen > 2) index |= (tx[2] << 8); if (txlen > 3) index |= tx[3]; status = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev,0), tx[0], USB_TYPE_VENDOR | USB_DIR_IN, value, index, rx, rxlen, USB_CTRL_GET_TIMEOUT); if (status < 0) deb_info("ep 0 read error (status = %d)\n",status); deb_data("<<< "); debug_dump(rx, rxlen, deb_data); return status; /* length in case of success */ }
/* expecting rx buffer: request data[0] data[1] ... data[2] */ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen) { int status; deb_data(">>> "); debug_dump(tx, txlen, deb_data); status = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0), tx[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, tx, txlen, USB_CTRL_GET_TIMEOUT); if (status != txlen) deb_data("ep 0 write error (status = %d, len: %d)\n",status,txlen); return status < 0 ? status : 0; }
/* * should_patch_object * Decides whether a particular loaded object should should be targeted for * hotpatching. * Always skipped: [vdso], and the syscall_intercept library itself. * Besides these two, if patch_all_objs is true, everything object is * a target. When patch_all_objs is false, only libraries that are parts of * the glibc implementation are targeted, i.e.: libc and libpthread. */ static bool should_patch_object(uintptr_t addr, const char *path) { static uintptr_t self_addr; if (self_addr == 0) { extern unsigned char intercept_asm_wrapper_tmpl[]; Dl_info self; if (!dladdr((void *)&intercept_asm_wrapper_tmpl, &self)) xabort("self dladdr failure"); self_addr = (uintptr_t)self.dli_fbase; } static const char libc[] = "libc"; static const char pthr[] = "libpthread"; static const char caps[] = "libcapstone"; if (is_vdso(addr, path)) { debug_dump(" - skipping: is_vdso\n"); return false; } const char *name = get_lib_short_name(path); size_t len = strcspn(name, "-."); if (len == 0) return false; if (addr == self_addr) { debug_dump(" - skipping: matches self\n"); return false; } if (str_match(name, len, caps)) { debug_dump(" - skipping: matches capstone\n"); return false; } if (str_match(name, len, libc)) { debug_dump(" - libc found\n"); libc_found = true; return true; } if (patch_all_objs) return true; if (str_match(name, len, pthr)) { debug_dump(" - libpthread found\n"); return true; } debug_dump(" - skipping, patch_all_objs == false\n"); return false; }
void dunlock(void *ptr) { dbuf_t *d = ptr; check_dbuf_list(); if(d != NULL) { dchecksig(d); d->lock--; debug(DBG_MEMORY, 10, "dunlock of %x, new lock count is %d", d, d->lock); assert(d->lock >= 0); if (d->dsize > d->size) { debug(0,0, "dsize > size, impossible. Memory corruption has/will occur. dumping the block and quitting"); debug_dump(0,0, d->buf, d->size); assert(0 == "Buffer corruption"); } if(d->lock == 0) { if(d->destructor != NULL) { debug(DBG_MEMORY, 10, "dunlock calling destructor %x", d->destructor); d->destructor(d); } get_backtrace(&d->releaser); /* LISTXXX if(lbelongs(&dbuf_list, d->list_entry)) { ldelete(&dbuf_list, d->list_entry); } else { assert("Corrupt dbuf list!" == NULL); } print_dbuf(1013, 11, d); */ memset(d->buf, 0xCA, d->size); free(d->buf); //memset(d, 0xCA, sizeof(*d)); d->signature = 0xCACACACA; d->uptype_sig = NULL; if (d->user_struct) { free(d->user_struct); d->user_struct = (void *)0xCACACACA; } free(d); } } check_dbuf_list(); }
/* * DKT 010817 - add support for V8 memory read/write and flash update */ static int flexcop_usb_v8_memory_req(struct flexcop_usb *fc_usb, flexcop_usb_request_t req, u8 page, u16 wAddress, u8 *pbBuffer, u32 buflen) { u8 request_type = USB_TYPE_VENDOR; u16 wIndex; int nWaitTime, pipe, len; wIndex = page << 8; switch (req) { case B2C2_USB_READ_V8_MEM: nWaitTime = B2C2_WAIT_FOR_OPERATION_V8READ; request_type |= USB_DIR_IN; pipe = B2C2_USB_CTRL_PIPE_IN; break; case B2C2_USB_WRITE_V8_MEM: wIndex |= pbBuffer[0]; request_type |= USB_DIR_OUT; nWaitTime = B2C2_WAIT_FOR_OPERATION_V8WRITE; pipe = B2C2_USB_CTRL_PIPE_OUT; break; case B2C2_USB_FLASH_BLOCK: request_type |= USB_DIR_OUT; nWaitTime = B2C2_WAIT_FOR_OPERATION_V8FLASH; pipe = B2C2_USB_CTRL_PIPE_OUT; break; default: deb_info("unsupported request for v8_mem_req %x.\n", req); return -EINVAL; } deb_v8("v8mem: %02x %02x %04x %04x, len: %d\n", request_type, req, wAddress, wIndex, buflen); len = usb_control_msg(fc_usb->udev, pipe, req, request_type, wAddress, wIndex, pbBuffer, buflen, nWaitTime * HZ); debug_dump(pbBuffer, len, deb_v8); return len == buflen ? 0 : -EIO; }
int vp702x_usb_out_op_unlocked(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) { int ret; deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index); debug_dump(b,blen,deb_xfer); if ((ret = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0), req, USB_TYPE_VENDOR | USB_DIR_OUT, value,index,b,blen, 2000)) != blen) { warn("usb out operation failed. (%d)",ret); return -EIO; } else return 0; }
/** * Event function which fires when * the data in the dbuf has been read from the socket with index idx */ int ev_read(int idx, dbuf_t * d, void *u_ptr) { int out = 0; debug(DBG_GLOBAL, 1, "ev_read for index %d idx, apptype: %d\n", idx, cdata[idx].apptype); debug_dump(DBG_GLOBAL, 100, d->buf, d->dsize); if (cdata[idx].handlers.ev_read) { out = cdata[idx].handlers.ev_read(idx, d, u_ptr); } else { /* * make the absent event handler act like a sink, * rather than forcing the local close by returning zero */ out = d->dsize; } return out; }
static int __az6007_read(struct usb_device *udev, u8 req, u16 value, u16 index, u8 *b, int blen) { int ret; ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), req, USB_TYPE_VENDOR | USB_DIR_IN, value, index, b, blen, 5000); if (ret < 0) { warn("usb read operation failed. (%d)", ret); return -EIO; } deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ", req, value, index); debug_dump(b, blen, deb_xfer); return ret; }
static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, u8 *rbuf, u8 rlen) { struct anysee_state *state = d->priv; int act_len, ret; u8 buf[64]; if (slen > sizeof(buf)) slen = sizeof(buf); memcpy(&buf[0], sbuf, slen); buf[60] = state->seq++; if (mutex_lock_interruptible(&anysee_usb_mutex) < 0) return -EAGAIN; /* We need receive one message more after dvb_usb_generic_rw due to weird transaction flow, which is 1 x send + 2 x receive. */ ret = dvb_usb_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf), 0); if (!ret) { /* receive 2nd answer */ ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint), buf, sizeof(buf), &act_len, 2000); if (ret) err("%s: recv bulk message failed: %d", __func__, ret); else { deb_xfer("<<< "); debug_dump(buf, act_len, deb_xfer); } } /* read request, copy returned data to return buf */ if (!ret && rbuf && rlen) memcpy(rbuf, buf, rlen); mutex_unlock(&anysee_usb_mutex); return ret; }
/// \brief Add an operation to the ordered op queue. /// /// Any time adjustment required is made to the operation, and it /// is added to the apropriate place in the chronologically ordered /// queue. The From attribute of the operation is set to the id of /// the entity that is responsible for adding the operation to the /// queue. void OperationsDispatcher::addOperationToQueue(const Operation & op, LocatedEntity & ent) { assert(op.isValid()); assert(op->getFrom() != "cheat"); m_operation_queues_dirty = true; op->setFrom(ent.getId()); if (!op->hasAttrFlag(Atlas::Objects::Operation::FUTURE_SECONDS_FLAG)) { op->setSeconds(getTime()); m_immediateQueue.push(OpQueEntry(op, ent)); return; } double t = getTime() + (op->getFutureSeconds() * consts::time_multiplier); op->setSeconds(t); op->setFutureSeconds(0.); m_operationQueue.push(OpQueEntry(op, ent)); if (debug_flag) { std::cout << "WorldRouter::addOperationToQueue {" << std::endl; debug_dump(op, std::cout); std::cout << "}" << std::endl << std::flush; } }
static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, u8 *rbuf, u8 rlen) { struct anysee_state *state = d->priv; int act_len, ret; u8 buf[64]; if (slen > sizeof(buf)) slen = sizeof(buf); memcpy(&buf[0], sbuf, slen); buf[60] = state->seq++; if (mutex_lock_interruptible(&anysee_usb_mutex) < 0) return -EAGAIN; ret = dvb_usb_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf), 0); if (!ret) { ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint), buf, sizeof(buf), &act_len, 2000); if (ret) err("%s: recv bulk message failed: %d", __func__, ret); else { deb_xfer("<<< "); debug_dump(buf, act_len, deb_xfer); } } if (!ret && rbuf && rlen) memcpy(rbuf, buf, rlen); mutex_unlock(&anysee_usb_mutex); return ret; }