void L4::pop(uint8_t *message, int length) { assert(message != NULL); assert(length >= (int)(2*sizeof(uint16_t))); char* tmp = make_hex((char*)message, length); output(LOG_L4, "Received a message %s",tmp); free(tmp); uint16_t nlen = 0, vlen = 0; memcpy(&nlen, message, sizeof(nlen)); memcpy(&vlen, message+sizeof(nlen), sizeof(vlen)); uint8_t *thename = message +sizeof(nlen)+sizeof(vlen); uint8_t *thevalue = thename+nlen; tmp = make_hex((char*)thename, nlen); output(LOG_L4, "NAME: %s",tmp); //output(LOG_L4, "the name: %s, the len: %d",thename, nlen); free(tmp); tmp = make_hex((char*)thevalue, vlen); output(LOG_L4, "VALUE: %s",tmp); free(tmp); output(LOG_L4, "Popping %d,%d",nlen,vlen); output(LOG_L4, "Popping %.*s,%.*s",nlen,thename,vlen,thevalue); output(LOG_L4,"valuess: %d %d", nlen, vlen); m_upper->pop(thename, nlen, thevalue, vlen); }
int main(){ int decimal[3],i; char n,hex[7]; scanf("%c", &n); if(n == 'h'){ scanf("%s" , hex); make_decimal(hex, decimal); printf("rgb(%d, %d, %d)\n",decimal[0], decimal[1], decimal[2]); }else if(n == 'd'){ scanf("%d,%d,%d" ,&decimal[0], &decimal[1], &decimal[3]); make_hex(decimal, hex); printf("%c%c%c%c%c%c%c \n", hex[0], hex[1], hex[2], hex[3], hex[4], hex[5], hex[6]); }else { return 0; } }
static void handle_out_ep(int ep) { struct usb_ctrlrequest *req = (void*)AS3525_UNCACHED_ADDR(&setup_desc->data1); int ep_sts = USB_OEP_STS(ep) & ~USB_OEP_STS_MASK(ep); if (ep > 3) panicf("out_ep > 3!?"); USB_OEP_STS(ep) = ep_sts; /* ACK */ if (ep_sts & USB_EP_STAT_BNA) { /* Buffer was not set up */ int ctrl = USB_OEP_CTRL(ep); logf("ep%d OUT, status %x ctrl %x (BNA)\n", ep, ep_sts, ctrl); panicf("ep%d OUT 0x%x 0x%x (BNA)", ep, ep_sts, ctrl); ep_sts &= ~USB_EP_STAT_BNA; } if (ep_sts & USB_EP_STAT_OUT_RCVD) { struct usb_dev_dma_desc *uc_desc = endpoints[ep][1].uc_desc; int dma_sts = uc_desc->status; int dma_len = dma_sts & 0xffff; if (!(dma_sts & USB_DMA_DESC_ZERO_LEN)) { logf("EP%d OUT token, st:%08x len:%d frm:%x data=%s epstate=%d\n", ep, dma_sts & 0xf8000000, dma_len, (dma_sts >> 16) & 0x7ff, make_hex(uc_desc->data_ptr, dma_len), endpoints[ep][1].state); /* * If parts of the just dmaed range are in cache, dump them now. */ discard_dcache_range(uc_desc->data_ptr, dma_len); } else{
int main(int argc, char* argv[]) { char *infile = argv[1]; char *outfile = filename_ext(infile); fprintf(stderr, "MIFER Shadow BIOS ROM Utility:\n"); fprintf(stderr, "input file = %s\n", infile); fprintf(stderr, "output file = %s\n", outfile); make_hex(infile, outfile); fprintf(stderr, "Conversion to DAT complete\n"); return(EXIT_SUCCESS); }
static void ep_send(int ep, void *ptr, int len) { struct usb_dev_dma_desc *uc_desc = endpoints[ep][0].uc_desc; endpoints[ep][0].state |= EP_STATE_BUSY; endpoints[ep][0].len = len; endpoints[ep][0].rc = -1; /* * I'm seeing a problem where Linux sends two SETUP requests, * but fails to read the response from the first one. * We then have the response we wanted to send still in our fifo, * so flush the fifo before sending on the control endpoint. */ if (ep == 0) USB_IEP_CTRL(ep) |= USB_EP_CTRL_FLUSH; /* Make sure data is committed to memory */ commit_dcache_range(ptr, len); logf("xx%s\n", make_hex(ptr, len)); uc_desc->status = USB_DMA_DESC_BS_HST_RDY | USB_DMA_DESC_LAST | len; if (len == 0) uc_desc->status |= USB_DMA_DESC_ZERO_LEN; uc_desc->data_ptr = AS3525_PHYSICAL_ADDR(ptr); USB_IEP_DESC_PTR(ep) = AS3525_PHYSICAL_ADDR((int)&dmadescs[ep][0]); USB_IEP_STS(ep) = 0xffffffff; /* clear status */ /* start transfer */ USB_IEP_CTRL(ep) |= USB_EP_CTRL_CNAK | USB_EP_CTRL_PD; /* HW automatically sets NAK bit later */ }