void MBXSyncSrv_MMapGetFullMapDataHandler(IMG_VOID *pvData) { IMG_PVOID pvKVBase; IMG_UINT32 ui32BaseBytes; IMG_UINT32 ui32Offset; PVR_MMAP_TYPE eMapType; MBXUserDataForMMapGetFullMapData infoFromUser; COPY_FROM_USER((void*)&infoFromUser, pvData, sizeof(MBXUserDataForMMapGetFullMapData)); infoFromUser.err = PVRMMapGetFullMapData( infoFromUser.pvKVAddr, infoFromUser.ui32Bytes, &pvKVBase, &ui32BaseBytes, &ui32Offset, &eMapType); infoFromUser.pvKVBase = pvKVBase; infoFromUser.ui32BaseBytes = ui32BaseBytes; infoFromUser.ui32Offset = ui32Offset; infoFromUser.eMapType = eMapType; COPY_TO_USER(pvData,(void*)&infoFromUser, sizeof(MBXUserDataForMMapGetFullMapData)); }
static int sis1100_read_irqdata(struct sis1100_softc* sc, struct sis1100_fdata* fd, size_t count, size_t* count_read, void __user *data, int nonblocking) { struct sis1100_irq_get2 get; int res, version=1; /* count too small? */ if (count<sizeof(struct sis1100_irq_get)) return EINVAL; /* count large enough for sis1100_irq_get2? */ if (count>=sizeof(struct sis1100_irq_get2)) version=2; if (nonblocking && !irq_pending(sc, fd, fd->owned_irqs)) return EAGAIN; get.irq_mask=fd->owned_irqs; res=sis1100_irq_wait(fd, &get); if (res) { pINFO(sc, "read_irqdata: res=%d", res); return res; } count=version==1? sizeof(struct sis1100_irq_get):sizeof(struct sis1100_irq_get2); if (COPY_TO_USER(data, &get, count)) return EFAULT; *count_read=count; return 0; }
void MBXSyncSrv_HostReadHWRegHandler(IMG_VOID *pvData) { MBXUserDataForHostHWReg infoFromUser; COPY_FROM_USER((void*)&infoFromUser, pvData, sizeof(MBXUserDataForHostHWReg)); infoFromUser.value = readl(infoFromUser.pBaseAddr+infoFromUser.offset); COPY_TO_USER(pvData,(void*)&infoFromUser, sizeof(MBXUserDataForHostHWReg)); }
static int pcicommand(pcidata* x) { struct pci_dev* sh=(struct pci_dev*)x->starthandle; switch(x->command) { case CMD_FIND_SLOT: x->handle=(unsigned long)pci_find_slot(x->busnum, PCI_DEVFN(x->devnum,x->funnum)); return 0; case CMD_FIND_SUBSYS: x->handle=(unsigned long)pci_find_subsys(x->vendor, x->device, x->subsys_vendor, x->subsys_device, sh); return 0; case CMD_FIND_DEVICE: x->handle=(unsigned long)pci_find_device(x->vendor, x->device, sh); return 0; case CMD_FIND_CLASS: x->handle=(unsigned long)pci_find_class(x->class, sh); return 0; case CMD_FIND_CAPAB: x->cappos=pci_find_capability(sh, x->capability); return 0; case CMD_SET_POWER: x->oldpowerstate=pci_set_power_state(sh, x->powerstate); return 0; case CMD_ENABLE: x->result=pci_enable_device(sh); return 0; case CMD_DISABLE: pci_disable_device(sh); return 0; case CMD_RELEASE: release_device(sh,0); return 0; case CMD_REQUEST: { char* name; if (x->res_name) { int len; char c; int i; len=0; while (!COPY_FROM_USER(&c, x->res_name+len,1)) { if (!c) break; len++; } name=kmalloc(len+1,GFP_KERNEL); for (i=0;i<len;i++) { name[i]=0; COPY_FROM_USER(name+i, x->res_name+i,1); } name[i]=0; } else { name=kmalloc(22,GFP_KERNEL); strcpy(name,"amithlon pci system"); } x->result=pci_request_regions(sh,name); if (!x->result) { /* Successful */ pci_list* n=kmalloc(sizeof(pci_list),GFP_KERNEL); n->dev=sh; if (x->releasecode) { int size=find_code_size(x->releasecode); n->releasecode=kmalloc(size,GFP_KERNEL); COPY_FROM_USER(n->releasecode,x->releasecode,size); } else n->releasecode=NULL; n->name=name; n->next=devlist; n->prev_p=&devlist; if (devlist) devlist->prev_p=&(n->next); devlist=n; } else { kfree(name); } } return 0; case CMD_READBYTE: x->confdata=0; x->result=pci_read_config_byte(sh, x->offset, (u8*)&(x->confdata)); return 0; case CMD_READWORD: x->confdata=0; x->result=pci_read_config_word(sh, x->offset, (u16*)&(x->confdata)); return 0; case CMD_READLONG: x->confdata=0; x->result=pci_read_config_dword(sh, x->offset, (u32*)&(x->confdata)); return 0; case CMD_WRITEBYTE: x->result=pci_write_config_byte(sh, x->offset, (u8)(x->confdata)); return 0; case CMD_WRITEWORD: x->result=pci_write_config_word(sh, x->offset, (u16)(x->confdata)); return 0; case CMD_WRITELONG: x->result=pci_write_config_dword(sh, x->offset, (u32)(x->confdata)); return 0; case CMD_GETBASE: x->start=sh->resource[x->basenum].start; x->end=sh->resource[x->basenum].end; x->flags=sh->resource[x->basenum].flags; return 0; case CMD_GETINFO: x->irq=sh->irq; x->devnum=PCI_SLOT(sh->devfn); x->funnum=PCI_FUNC(sh->devfn); x->busnum=sh->bus->number; return 0; case CMD_GETNAME: { int len=0; do { if (COPY_TO_USER((void*)(x->res_name+len),(void*)(sh->name+len),1)) return -EFAULT; } while (sh->name[len++]); } return 0; default: return -EINVAL; } }
/* n_hdlc_tty_read() * * Called to retreive one frame of data (if available) * * Arguments: * * tty pointer to tty instance data * file pointer to open file object * buf pointer to returned data buffer * nr size of returned data buffer * * Return Value: * * Number of bytes returned or error code */ static rw_ret_t n_hdlc_tty_read (struct tty_struct *tty, struct file *file, __u8 * buf, rw_count_t nr) { struct n_hdlc *n_hdlc = tty2n_hdlc(tty); int error; rw_ret_t ret; N_HDLC_BUF *rbuf; if (debuglevel >= DEBUG_LEVEL_INFO) printk("%s(%d)n_hdlc_tty_read() called\n",__FILE__,__LINE__); /* Validate the pointers */ if (!n_hdlc) return -EIO; /* verify user access to buffer */ error = verify_area (VERIFY_WRITE, buf, nr); if (error != 0) { printk(KERN_WARNING"%s(%d) n_hdlc_tty_read() can't verify user " "buffer\n",__FILE__,__LINE__); return (error); } for (;;) { n_hdlc = tty2n_hdlc (tty); if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || tty != n_hdlc->tty) return 0; rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); if (rbuf) break; /* no data */ if (file->f_flags & O_NONBLOCK) return -EAGAIN; interruptible_sleep_on (&n_hdlc->read_wait); if (signal_pending(current)) return -EINTR; } if (rbuf->count > nr) { /* frame too large for caller's buffer (discard frame) */ ret = (rw_ret_t)-EOVERFLOW; } else { /* Copy the data to the caller's buffer */ COPY_TO_USER(error,buf,rbuf->buf,rbuf->count); if (error) ret = (rw_ret_t)error; else ret = (rw_ret_t)rbuf->count; } /* return HDLC buffer to free list unless the free list */ /* count has exceeded the default value, in which case the */ /* buffer is freed back to the OS to conserve memory */ if (n_hdlc->rx_free_buf_list.count > DEFAULT_RX_BUF_COUNT) kfree(rbuf); else n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf); return ret; } /* end of n_hdlc_tty_read() */