/* Computes the modular exponentiation (num^exp % mod). num, exp, and mod are * big endian numbers of size len, in bytes. Each len value must be a multiple * of 4. */ int dwc_dh_modpow(void *mem_ctx, void *num, uint32_t num_len, void *exp, uint32_t exp_len, void *mod, uint32_t mod_len, void *out) { /* modpow() takes little endian numbers. AM uses big-endian. This * function swaps bytes of numbers before passing onto modpow. */ int retval = 0; uint32_t *result; uint32_t *bignum_num = dwc_alloc(mem_ctx, num_len + 4); uint32_t *bignum_exp = dwc_alloc(mem_ctx, exp_len + 4); uint32_t *bignum_mod = dwc_alloc(mem_ctx, mod_len + 4); dh_swap_bytes(num, &bignum_num[1], num_len); bignum_num[0] = num_len / 4; dh_swap_bytes(exp, &bignum_exp[1], exp_len); bignum_exp[0] = exp_len / 4; dh_swap_bytes(mod, &bignum_mod[1], mod_len); bignum_mod[0] = mod_len / 4; result = dwc_modpow(mem_ctx, bignum_num, bignum_exp, bignum_mod); if (!result) { retval = -1; goto dh_modpow_nomem; } dh_swap_bytes(&result[1], out, result[0] * 4); dwc_free(mem_ctx, result); dh_modpow_nomem: dwc_free(mem_ctx, bignum_num); dwc_free(mem_ctx, bignum_exp); dwc_free(mem_ctx, bignum_mod); return retval; }
static struct gadget_wrapper *alloc_wrapper( struct dwc_otg_device *_dev ) { static char pcd_name[] = "dwc_otg"; //dwc_otg_device_t *otg_dev = platform_get_drvdata(_dev); dwc_otg_device_t *otg_dev = _dev; struct gadget_wrapper *d; int retval; d = dwc_alloc(sizeof(*d)); if (d == NULL) { return NULL; } memset(d, 0, sizeof(*d)); d->gadget.name = pcd_name; d->pcd = otg_dev->pcd; //sword /* strcpy(d->gadget.dev.bus_id, "gadget"); */ #if 0 dev_set_name(&d->gadget.dev, "gadget"); d->gadget.dev.parent = &_dev->dev; d->gadget.dev.release = dwc_otg_pcd_gadget_release; #endif d->gadget.ops = &dwc_otg_pcd_ops; d->gadget.is_dualspeed = dwc_otg_pcd_is_dualspeed(otg_dev->pcd); d->gadget.is_otg = dwc_otg_pcd_is_otg(otg_dev->pcd); d->driver = 0; /* Register the gadget device */ #if 0 retval = device_register(&d->gadget.dev); if (retval != 0) { DWC_ERROR("device_register failed\n"); dwc_free(d); return NULL; } #endif return d; }
static struct gadget_wrapper *alloc_wrapper( struct platform_device *_dev ) { static char pcd_name[] = "dwc_otg"; dwc_otg_device_t *otg_dev = platform_get_drvdata(_dev); struct gadget_wrapper *d; int retval; d = dwc_alloc(sizeof(*d)); if (d == NULL) { return NULL; } memset(d, 0, sizeof(*d)); d->gadget.name = pcd_name; d->pcd = otg_dev->pcd; //sword /* strcpy(d->gadget.dev.bus_id, "gadget"); */ dev_set_name(&d->gadget.dev, "gadget"); d->gadget.dev.parent = &_dev->dev; d->gadget.dev.release = dwc_otg_pcd_gadget_release; d->gadget.ops = &dwc_otg_pcd_ops; d->gadget.max_speed = USB_SPEED_HIGH; d->gadget.is_otg = dwc_otg_pcd_is_otg(otg_dev->pcd); if (d->pcd->core_if->dma_enable && d->pcd->core_if->dma_desc_enable) d->gadget.sg_supported = 1; d->driver = 0; /* Register the gadget device */ #if 0 retval = device_register(&d->gadget.dev); if (retval != 0) { DWC_ERROR("device_register failed\n"); dwc_free(d); return NULL; } #endif return d; }
/** * This function allocates a request object to use with the specified * endpoint. * * @param ep The endpoint to be used with with the request * @param gfp_flags the GFP_* flags to use. */ static struct usb_request *dwc_otg_pcd_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) { struct usb_request *usb_req; DWC_DEBUGPL(DBG_PCDV, "%s(%p,%d)\n", __func__, ep, gfp_flags); if (0 == ep) { DWC_WARN("%s() %s\n", __func__, "Invalid EP!\n"); return 0; } usb_req = dwc_alloc(sizeof(*usb_req)); if (0 == usb_req) { DWC_WARN("%s() %s\n", __func__, "request allocation failed!\n"); return 0; } memset(usb_req, 0, sizeof(*usb_req)); usb_req->dma = DWC_INVALID_DMA_ADDR; return usb_req; }
static struct usb_iso_request *alloc_iso_request(struct usb_ep *ep, int packets, gfp_t gfp_flags) { struct usb_iso_request *pReq = NULL; uint32_t req_size; req_size = sizeof(struct usb_iso_request); req_size += (2 * packets * (sizeof(struct usb_gadget_iso_packet_descriptor))); pReq = dwc_alloc(req_size); if (!pReq) { DWC_WARN("Can't allocate Iso Request\n"); return 0; } pReq->iso_packet_desc0 = (void *)(pReq + 1); pReq->iso_packet_desc1 = pReq->iso_packet_desc0 + packets; return pReq; }
#endif ) { #ifdef LM_INTERFACE dwc_otg_device_t *otg_dev = lm_get_drvdata(_dev); #elif defined(PCI_INTERFACE) dwc_otg_device_t *otg_dev = pci_get_drvdata(_dev); #elif defined(PLATFORM_INTERFACE) dwc_otg_device_t *otg_dev = platform_get_drvdata(_dev); #endif static char pcd_name[] = "dwc_otg_pcd"; struct gadget_wrapper *d; int retval; d = dwc_alloc(sizeof(*d)); if (d == NULL) { return NULL; } memset(d, 0, sizeof(*d)); d->gadget.name = pcd_name; d->pcd = otg_dev->pcd; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) strcpy(d->gadget.dev.bus_id, "gadget"); #else /*d->gadget.dev.bus = NULL;*/ d->gadget.dev.init_name = "gadget"; #endif d->gadget.dev.parent = &_dev->dev;