/* * Specify endianness constraints. The driver tells us what the device * does and how it would like to see things in memory. We reply with * how things will actually appear in memory. */ pciio_endian_t pciio_endian_set(devfs_handle_t dev, pciio_endian_t device_end, pciio_endian_t desired_end) { ASSERT((device_end == PCIDMA_ENDIAN_BIG) || (device_end == PCIDMA_ENDIAN_LITTLE)); ASSERT((desired_end == PCIDMA_ENDIAN_BIG) || (desired_end == PCIDMA_ENDIAN_LITTLE)); #if DEBUG #if defined(SUPPORT_PRINTING_V_FORMAT) PRINT_ALERT("%v: pciio_endian_set is going away.\n" "\tplease use PCIIO_BYTE_STREAM or PCIIO_WORD_VALUES in your\n" "\tpciio_dmamap_alloc and pciio_dmatrans calls instead.\n", dev); #else PRINT_ALERT("0x%x: pciio_endian_set is going away.\n" "\tplease use PCIIO_BYTE_STREAM or PCIIO_WORD_VALUES in your\n" "\tpciio_dmamap_alloc and pciio_dmatrans calls instead.\n", dev); #endif #endif return DEV_FUNC(dev, endian_set) (dev, device_end, desired_end); }
int pciio_error_devenable(devfs_handle_t pconn_vhdl, int error_code) { return DEV_FUNC(pconn_vhdl, error_devenable) (pconn_vhdl, error_code); /* no cleanup specific to this layer. */ }
static int rkusb_get_symbol( struct rkusb_dev *dev ) { switch ( DEV_FUNC(dev) ) { case FUNC_GSYM_KERNEL: return rkusb_get_kernel_symbols( dev ); case FUNC_GSYM_GETTASKS: return rksub_get_sym_tasks( dev ); case FUNC_GSYM_GETTASKVM: return rkusb_get_task_mm( dev ); case FUNC_GSYM_PROFILE: { char * buf = __rkusb_rwbuffer_start(dev); PROFILE_INFO pe; pe.size = sizeof( pe ); pe.npc = profile_check( buf ); pe.buf = (unsigned long)buf; pe.now = ktime_to_ns( ktime_get() ); rk28printk("%s::profile n=%ld\n" , __func__ , pe.npc ); rkusb_normal_data_xfer_onetime( dev , &pe ); return 0; } default: break; } return RKUSB_CB_FAILD; }
static int vflash_block_isbad(int partition, int offset) { ItcRpcMsg req; int ret; // Construct a request message memset((void *)&req, 0, sizeof(req)); req.dev_func = DEV_FUNC(REMOTE_FLASH_DEVICE_ID, REMOTE_BLOCK_ISBAD, partition, 0); req.xid = read_c0_count(); req.u0 = 0; req.u1 = offset; #if DEBUG_DQM_IO printk("%s partition %d offset %08x\n", __func__, partition, offset); #endif ret = do_rpc_io(&req); #if 0 if(ret == 1) { printk("Bad Block at %08x\n", (unsigned int)offset); } #endif return ret; }
/* * Read value of configuration register */ uint64_t pciio_config_get(devfs_handle_t dev, unsigned reg, unsigned size) { uint64_t value = 0; unsigned shift = 0; /* handle accesses that cross words here, * since that's common code between all * possible providers. */ while (size > 0) { unsigned biw = 4 - (reg&3); if (biw > size) biw = size; value |= DEV_FUNC(dev, config_get) (dev, reg, biw) << shift; shift += 8*biw; reg += biw; size -= biw; } return value; }
/* * Allocate resources required for an interrupt as specified in dev_desc. * Unconditionally setup resources to be non-threaded. * Return resource handle in intr_hdl. */ xtalk_intr_t xtalk_intr_alloc_nothd(vertex_hdl_t dev, /* which Crosstalk device */ device_desc_t dev_desc, /* device descriptor */ vertex_hdl_t owner_dev) /* owner of this interrupt */ { return (xtalk_intr_t) DEV_FUNC(dev, intr_alloc_nothd) (dev, dev_desc, owner_dev); }
/* ===================================================================== * GENERIC PCI SUPPORT FUNCTIONS */ pciio_slot_t pciio_error_extract(devfs_handle_t dev, pciio_space_t *space, iopaddr_t *offset) { ASSERT(dev != NODEV); return DEV_FUNC(dev,error_extract)(dev,space,offset); }
static int rkusb_read_log( struct rkusb_dev *dev ) { switch ( DEV_FUNC(dev) ) { case FUNC_LOG_GETLUNS: /* first int:luns , next int:sizeof log_buffer */ { int num_size[2]; check_xtranfs_len( 8 ); num_size[0] = dev->luns; num_size[1] = sizeof(struct log_buffer ); rkusb_normal_data_xfer_onetime( dev , num_size ); } return 0; case FUNC_LOG_GETSTRUCT: /* report all log info */ { // check_xtranfs_len( sizeof dev->log ); sizeof dev->log may change. if( !check_log_valid( dev ) ) break; rkusb_normal_data_xfer_onetime( dev , dev->log ); } return 0; case FUNC_LOG_INIT: { int i = DEV_LUN( dev ); #if (LOG_NUM>2) static int rkusb_shell_initlog( struct log_buffer *p ); if( i == LUN_SHELL ) { if( rkusb_shell_initlog( &dev->log[i] ) ) { return RKUSB_CB_FAILD_CSW; } } #endif dev->log[i].getlog(&dev->log[i].va_start , &dev->log[i].offset , &dev->log[i].total_len); } return RKUSB_CB_OK_CSW; case FUNC_LOG_UNINIT: { if( DEV_LUN(dev) == LUN_SHELL ){ dev->log[DEV_LUN(dev)].property &= ~LOG_PROT_MAYWRITE; } } return RKUSB_CB_OK_CSW; case FUNC_LOG_OFFLEN: /* read new log info , first int=start offset , next int=len */ { int offset_len[2]; if( !check_log_valid( dev ) ) break; check_xtranfs_len( 8 ); dev->log[DEV_LUN(dev)].getlog_start_length( &dev->log[DEV_LUN(dev)].offset , &dev->log[DEV_LUN(dev)].len ); offset_len[0] = dev->log[DEV_LUN(dev)].offset; offset_len[1] = dev->log[DEV_LUN(dev)].len; rkusb_normal_data_xfer_onetime( dev , offset_len ); } return 0; default: break; } return -1; }
void pciio_piospace_free(devfs_handle_t dev, /* Device freeing space */ pciio_space_t space, /* Type of space */ iopaddr_t pciaddr, /* starting address */ size_t byte_count) { /* Range of address */ DEV_FUNC(dev, piospace_free) (dev, space, pciaddr, byte_count); }
/* * Specify PCI arbitration priority. */ pciio_priority_t pciio_priority_set(devfs_handle_t dev, pciio_priority_t device_prio) { ASSERT((device_prio == PCI_PRIO_HIGH) || (device_prio == PCI_PRIO_LOW)); return DEV_FUNC(dev, priority_set) (dev, device_prio); }
/* * Allocate resources required for an interrupt as specified in intr_desc. * Return resource handle in intr_hdl. */ pciio_intr_t pciio_intr_alloc(devfs_handle_t dev, /* which Crosstalk device */ device_desc_t dev_desc, /* device descriptor */ pciio_intr_line_t lines, /* INTR line(s) to attach */ devfs_handle_t owner_dev) { /* owner of this interrupt */ return (pciio_intr_t) DEV_FUNC(dev, intr_alloc) (dev, dev_desc, lines, owner_dev); }
/* * Specify PCI arbitration priority. */ pciio_priority_t pciio_priority_set(vertex_hdl_t dev, pciio_priority_t device_prio) { ASSERT((device_prio == PCI_PRIO_HIGH) || (device_prio == PCI_PRIO_LOW)); return DEV_FUNC(dev, priority_set) (dev, device_prio); }
/******************************************************************* * vflash_read_buf: * create a request message and send it via do_rpc_io * do_rpc_io waits for response or timeout ******************************************************************/ static int vflash_read_buf(int partition, int offset, u_char *buffer, int numbytes) { ItcRpcMsg req; u_char *vmallocated_buf = NULL; int ret, is_buf_vmallocated; #if defined(CONFIG_MTD_BRCMNAND) uint8 * ecc_buf; uint8 * data_buf; #endif /* VMallocated (mmu translated) memory can't be used by the eCos CPU */ is_buf_vmallocated = KSEGX(buffer) == KSEG2; if (is_buf_vmallocated) { vmallocated_buf = buffer; buffer = kmalloc(numbytes, GFP_KERNEL); if (!buffer) return -EINVAL; } // Construct a request message memset((void *)&req, 0, sizeof(req)); req.dev_func = DEV_FUNC(REMOTE_FLASH_DEVICE_ID, REMOTE_READ, partition, numbytes); req.xid = read_c0_count(); req.u0 = (uint32)buffer; req.u1 = offset; #if !defined(CONFIG_MTD_BRCMNAND) bcm_cache_inv((uint32)buffer, (uint32)numbytes); #else data_buf = (uint8 *)(((BufArray *)buffer)->data_buf); if(data_buf) { bcm_cache_inv((uint32)data_buf, (uint32)numbytes); } ecc_buf = (uint8 *)(((BufArray *)buffer)->ecc_stat_buf); if(ecc_buf) { bcm_cache_inv((uint32)ecc_buf, (uint32)ecc_stat_buf_len); } bcm_cache_wback_inv((uint32)buffer, (uint32)sizeof(BufArray)); #endif #if DEBUG_DQM_IO printk("%s partition %d offset %08x buffer %p size %d\n", __func__, partition, offset, buffer, numbytes); #endif ret = do_rpc_io(&req); if (is_buf_vmallocated) { memcpy(vmallocated_buf, buffer, numbytes); kfree(buffer); } return ret; }
pciio_dmamap_t pciio_dmamap_alloc(devfs_handle_t dev, /* set up mappings for this device */ device_desc_t dev_desc, /* device descriptor */ size_t byte_count_max, /* max size of a mapping */ unsigned flags) { /* defined in dma.h */ return (pciio_dmamap_t) DEV_FUNC(dev, dmamap_alloc) (dev, dev_desc, byte_count_max, flags); }
alenlist_t pciio_dmatrans_list(devfs_handle_t dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ alenlist_t palenlist, /* system address/length list */ unsigned flags) { /* defined in dma.h */ return DEV_FUNC(dev, dmatrans_list) (dev, dev_desc, palenlist, flags); }
xtalk_dmamap_t xtalk_dmamap_alloc(vertex_hdl_t dev, /* set up mappings for this device */ device_desc_t dev_desc, /* device descriptor */ size_t byte_count_max, /* max size of a mapping */ unsigned flags) { /* defined in dma.h */ return (xtalk_dmamap_t) DEV_FUNC(dev, dmamap_alloc) (dev, dev_desc, byte_count_max, flags); }
caddr_t xtalk_piotrans_addr(vertex_hdl_t dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ iopaddr_t xtalk_addr, /* Crosstalk address */ size_t byte_count, /* map this many bytes */ unsigned flags) { /* (currently unused) */ return DEV_FUNC(dev, piotrans_addr) (dev, dev_desc, xtalk_addr, byte_count, flags); }
iopaddr_t pciio_dmatrans_addr(devfs_handle_t dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ paddr_t paddr, /* system physical address */ size_t byte_count, /* length */ unsigned flags) { /* defined in dma.h */ return DEV_FUNC(dev, dmatrans_addr) (dev, dev_desc, paddr, byte_count, flags); }
pciio_endian_t snia_pciio_endian_set(struct pci_dev *pci_dev, pciio_endian_t device_end, pciio_endian_t desired_end) { vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev); return DEV_FUNC(dev, endian_set) (dev, device_end, desired_end); }
static int rkusb_do_task_cmd( struct rkusb_dev *dev ) { switch( DEV_FUNC(dev )) { case FUNC_TASKF_PING: rkusb_send_csw( dev , RKUSB_STATUS_PASS ); break; default: return RKUSB_CB_FAILD; } return RKUSB_CB_OK_NONE; }
xtalk_piomap_t xtalk_piomap_alloc(vertex_hdl_t dev, /* set up mapping for this device */ device_desc_t dev_desc, /* device descriptor */ iopaddr_t xtalk_addr, /* map for this xtalk_addr range */ size_t byte_count, size_t byte_count_max, /* maximum size of a mapping */ unsigned flags) { /* defined in sys/pio.h */ return (xtalk_piomap_t) DEV_FUNC(dev, piomap_alloc) (dev, dev_desc, xtalk_addr, byte_count, byte_count_max, flags); }
caddr_t pciio_piotrans_addr(devfs_handle_t dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ pciio_space_t space, /* CFG, MEM, IO, or a device-decoded window */ iopaddr_t addr, /* starting address (or offset in window) */ size_t byte_count, /* map this many bytes */ unsigned flags) { /* (currently unused) */ return DEV_FUNC(dev, piotrans_addr) (dev, dev_desc, space, addr, byte_count, flags); }
iopaddr_t pciio_piospace_alloc(vertex_hdl_t dev, /* Device requiring space */ device_desc_t dev_desc, /* Device descriptor */ pciio_space_t space, /* MEM32/MEM64/IO */ size_t byte_count, /* Size of mapping */ size_t align) { /* Alignment needed */ if (align < PAGE_SIZE) align = PAGE_SIZE; return DEV_FUNC(dev, piospace_alloc) (dev, dev_desc, space, byte_count, align); }
pciio_piomap_t pciio_piomap_alloc(devfs_handle_t dev, /* set up mapping for this device */ device_desc_t dev_desc, /* device descriptor */ pciio_space_t space, /* CFG, MEM, IO, or a device-decoded window */ iopaddr_t addr, /* lowest address (or offset in window) */ size_t byte_count, /* size of region containing our mappings */ size_t byte_count_max, /* maximum size of a mapping */ unsigned flags) { /* defined in sys/pio.h */ return (pciio_piomap_t) DEV_FUNC(dev, piomap_alloc) (dev, dev_desc, space, addr, byte_count, byte_count_max, flags); }
iopaddr_t pciio_piospace_alloc(devfs_handle_t dev, /* Device requiring space */ device_desc_t dev_desc, /* Device descriptor */ pciio_space_t space, /* MEM32/MEM64/IO */ size_t byte_count, /* Size of mapping */ size_t align) { /* Alignment needed */ if (align < NBPP) align = NBPP; return DEV_FUNC(dev, piospace_alloc) (dev, dev_desc, space, byte_count, align); }
static int vflash_block_markbad(int partition, int offset) { ItcRpcMsg req; // Construct a request message memset((void *)&req, 0, sizeof(req)); req.dev_func = DEV_FUNC(REMOTE_FLASH_DEVICE_ID, REMOTE_BLOCK_MARKBAD, partition, 0); req.xid = read_c0_count(); req.u0 = 0; req.u1 = offset; #if DEBUG_DQM_IO printk("%s partition %d offset %08x\n", __func__, partition, offset); #endif return do_rpc_io(&req); }
/* * for cmd must run at task env.not irq env. */ static int rkusb_task_cmd( struct rkusb_dev *dev ) { int r = RKUSB_CB_FAILD; switch( DEV_FUNC(dev )) { case FUNC_TASKF_PING: /*20100108,HSL@RK, for get cb at complete out.*/ DEV_LENGTH(dev) = RKUSB_BULK_CB_WRAP_LEN; r= RKUSB_CB_OK_NONE; break; default: break; } if( r != RKUSB_CB_FAILD ) rkusb_wakeup_thread( dev ); return r; }
pciio_dmamap_t snia_pciio_dmamap_alloc(struct pci_dev *pci_dev, /* set up mappings for this device */ device_desc_t dev_desc, /* device descriptor */ size_t byte_count_max, /* max size of a mapping */ unsigned flags) { /* defined in dma.h */ vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev); /* * If the device is not a PIC, we always want the PCIIO_BYTE_STREAM to be * set. Otherwise, it must not be set. This applies to SN1 and SN2. */ return (pciio_dmamap_t) DEV_FUNC(dev, dmamap_alloc) (dev, dev_desc, byte_count_max, flags & ~PCIIO_BYTE_STREAM); }
iopaddr_t snia_pciio_dmatrans_addr(struct pci_dev *pci_dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ paddr_t paddr, /* system physical address */ size_t byte_count, /* length */ unsigned flags) { /* defined in dma.h */ vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev); /* * If the device is not a PIC, we always want the PCIIO_BYTE_STREAM to be * set. Otherwise, it must not be set. This applies to SN1 and SN2. */ return DEV_FUNC(dev, dmatrans_addr) (dev, dev_desc, paddr, byte_count, flags & ~PCIIO_BYTE_STREAM); }
static int vflash_get_device_info(vflash_info_t *info) { ItcRpcMsg req; #if DEBUG_DQM_IO printk("-->%s info=%p\n", __func__, (void*)info); #endif // Construct a request message memset((void *)&req, 0, sizeof(req)); req.dev_func = DEV_FUNC(REMOTE_FLASH_DEVICE_ID, REMOTE_GET_DEV_INFO, LINUX_KERNEL_ROOTFS_PARTITION, sizeof(struct vflash_info_t)); req.xid = read_c0_count(); req.u0 = (uint32)info; req.u1 = sizeof(struct vflash_info_t); bcm_cache_inv((uint32)info, sizeof(struct vflash_info_t)); return do_rpc_io(&req); }