📄 rioctrl.c
字号:
sizeof(struct portStats)) == COPYFAIL ) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } if ( portStats.port >= RIO_PORTS ) { p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; return -ENXIO; } PortP = (p->RIOPortp[portStats.port]); rio_spin_lock_irqsave(&PortP->portSem, flags); PortP->statsGather = portStats.gather; rio_spin_unlock_irqrestore( &PortP->portSem , flags); return retval;#ifdef DEBUG_SUPPORTED case RIO_READ_LEVELS: { int num; rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_LEVELS\n"); for ( num=0; RIODbInf[num].Flag; num++ ) ; rio_dprintk (RIO_DEBUG_CTRL, "%d levels to copy\n",num); if (copyout((caddr_t)RIODbInf,(int)arg, sizeof(struct DbInf)*(num+1))==COPYFAIL) { rio_dprintk (RIO_DEBUG_CTRL, "ReadLevels Copy failed\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } rio_dprintk (RIO_DEBUG_CTRL, "%d levels to copied\n",num); return retval; }#endif case RIO_READ_CONFIG: rio_dprintk (RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n"); if (copyout((caddr_t)&p->RIOConf, (int)arg, sizeof(struct Conf)) ==COPYFAIL ) { p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return retval; case RIO_SET_CONFIG: rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_CONFIG\n"); if ( !su ) { p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } if ( copyin((int)arg, (caddr_t)&p->RIOConf, sizeof(struct Conf) ) ==COPYFAIL ) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } /* ** move a few value around */ for (Host=0; Host < p->RIONumHosts; Host++) if ( (p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING ) WWORD(p->RIOHosts[Host].ParmMapP->timer , p->RIOConf.Timer); return retval; case RIO_START_POLLER: rio_dprintk (RIO_DEBUG_CTRL, "RIO_START_POLLER\n"); return -EINVAL; case RIO_STOP_POLLER: rio_dprintk (RIO_DEBUG_CTRL, "RIO_STOP_POLLER\n"); if ( !su ) { p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } p->RIOPolling = NOT_POLLING; return retval; case RIO_SETDEBUG: case RIO_GETDEBUG: rio_dprintk (RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n"); if ( copyin( (int)arg, (caddr_t)&DebugCtrl, sizeof(DebugCtrl) ) ==COPYFAIL ) { p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } if ( DebugCtrl.SysPort == NO_PORT ) { if ( cmd == RIO_SETDEBUG ) { if ( !su ) { p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } p->rio_debug = DebugCtrl.Debug; p->RIODebugWait = DebugCtrl.Wait; rio_dprintk (RIO_DEBUG_CTRL, "Set global debug to 0x%x set wait to 0x%x\n", p->rio_debug,p->RIODebugWait); } else { rio_dprintk (RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug,p->RIODebugWait); DebugCtrl.Debug = p->rio_debug; DebugCtrl.Wait = p->RIODebugWait; if ( copyout((caddr_t)&DebugCtrl,(int)arg, sizeof(DebugCtrl)) == COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } } } else if ( DebugCtrl.SysPort >= RIO_PORTS && DebugCtrl.SysPort != NO_PORT ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort); p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; return -ENXIO; } else if ( cmd == RIO_SETDEBUG ) { if ( !su ) { p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } rio_spin_lock_irqsave(&PortP->portSem, flags); p->RIOPortp[DebugCtrl.SysPort]->Debug = DebugCtrl.Debug; rio_spin_unlock_irqrestore( &PortP->portSem , flags); rio_dprintk (RIO_DEBUG_CTRL, "RIO_SETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug); } else { rio_dprintk (RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug); DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug; if ( copyout((caddr_t)&DebugCtrl,(int)arg, sizeof(DebugCtrl))==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } } return retval; case RIO_VERSID: /* ** Enquire about the release and version. ** We return MAX_VERSION_LEN bytes, being a ** textual null terminated string. */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_VERSID\n"); if ( copyout( (caddr_t)RIOVersid(), (int)arg, sizeof(struct rioVersion) ) == COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return retval; /* ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ** !! commented out previous 'RIO_VERSID' functionality !! ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ** case RIO_VERSID: ** ** Enquire about the release and version. ** We return MAX_VERSION_LEN bytes, being a textual null ** terminated string. ** rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n")); if (copyout((caddr_t)RIOVersid(), (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) { rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host)); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return retval; ** ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ case RIO_NUM_HOSTS: /* ** Enquire as to the number of hosts located ** at init time. */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n"); if (copyout((caddr_t)&p->RIONumHosts, (int)arg, sizeof(p->RIONumHosts) )==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n"); p->RIOError.Error = COPYOUT_FAILED; return -EFAULT; } return retval; case RIO_HOST_FOAD: /* ** Kill host. This may not be in the final version... */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_FOAD %d\n", (int)arg); if ( !su ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n"); p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } p->RIOHalted = 1; p->RIOSystemUp = 0; for ( Host=0; Host<p->RIONumHosts; Host++ ) { (void)RIOBoardTest( p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot ); bzero( (caddr_t)&p->RIOHosts[Host].Flags, ((int)&p->RIOHosts[Host].____end_marker____) - ((int)&p->RIOHosts[Host].Flags) ); p->RIOHosts[Host].Flags = RC_WAITING;#if 0 RIOSetupDataStructs(p);#endif } RIOFoadWakeup(p); p->RIONumBootPkts = 0; p->RIOBooting = 0;#ifdef RINGBUFFER_SUPPORT for( loop=0; loop<RIO_PORTS; loop++ ) if ( p->RIOPortp[loop]->TxRingBuffer ) sysfree((void *)p->RIOPortp[loop]->TxRingBuffer, RIOBufferSize );#endif#if 0 bzero((caddr_t)&p->RIOPortp[0],RIO_PORTS*sizeof(struct Port));#else printk ("HEEEEELP!\n");#endif for( loop=0; loop<RIO_PORTS; loop++ ) {#if 0 p->RIOPortp[loop]->TtyP = &p->channel[loop];#endif spin_lock_init(&p->RIOPortp[loop]->portSem); p->RIOPortp[loop]->InUse = NOT_INUSE; } p->RIOSystemUp = 0; return retval; case RIO_DOWNLOAD: rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD\n"); if ( !su ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Not super user\n"); p->RIOError.Error = NOT_SUPER_USER; return -EPERM; } if ( copyin((int)arg, (caddr_t)&DownLoad, sizeof(DownLoad) )==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } rio_dprintk (RIO_DEBUG_CTRL, "Copied in download code for product code 0x%x\n", DownLoad.ProductCode); /* ** It is important that the product code is an unsigned object! */ if ( DownLoad.ProductCode > MAX_PRODUCT ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Bad product code %d passed\n", DownLoad.ProductCode); p->RIOError.Error = NO_SUCH_PRODUCT; return -ENXIO; } /* ** do something! */ retval = (*(RIOBootTable[DownLoad.ProductCode]))(p, &DownLoad); /* <-- Panic */ p->RIOHalted = 0; /* ** and go back, content with a job well completed. */ return retval; case RIO_PARMS: { uint host; if (copyin((int)arg, (caddr_t)&host, sizeof(host) ) == COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } /* ** Fetch the parmmap */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_PARMS\n"); if ( copyout( (caddr_t)p->RIOHosts[host].ParmMapP, (int)arg, sizeof(PARM_MAP) )==COPYFAIL ) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk (RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n"); return -EFAULT; } } return retval; case RIO_HOST_REQ: rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ\n"); if (copyin((int)arg, (caddr_t)&HostReq, sizeof(HostReq) )==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } if ( HostReq.HostNum >= p->RIONumHosts ) { p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE; rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Illegal host number %d\n", HostReq.HostNum); return -ENXIO; } rio_dprintk (RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum); if (copyout((caddr_t)&p->RIOHosts[HostReq.HostNum], (int)HostReq.HostP,sizeof(struct Host) ) == COPYFAIL) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n"); return -EFAULT; } return retval; case RIO_HOST_DPRAM: rio_dprintk (RIO_DEBUG_CTRL, "Request for DPRAM\n"); if ( copyin( (int)arg, (caddr_t)&HostDpRam, sizeof(HostDpRam) )==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } if ( HostDpRam.HostNum >= p->RIONumHosts ) { p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE; rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Illegal host number %d\n", HostDpRam.HostNum); return -ENXIO; } rio_dprintk (RIO_DEBUG_CTRL, "Request for host %d\n", HostDpRam.HostNum); if (p->RIOHosts[HostDpRam.HostNum].Type == RIO_PCI) { int off; /* It's hardware like this that really gets on my tits. */ static unsigned char copy[sizeof(struct DpRam)]; for ( off=0; off<sizeof(struct DpRam); off++ ) copy[off] = p->RIOHosts[HostDpRam.HostNum].Caddr[off]; if ( copyout( (caddr_t)copy, (int)HostDpRam.DpRamP, sizeof(struct DpRam) ) == COPYFAIL ) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); return -EFAULT; } } else if (copyout((caddr_t)p->RIOHosts[HostDpRam.HostNum].Caddr, (int)HostDpRam.DpRamP, sizeof(struct DpRam) ) == COPYFAIL ) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); return -EFAULT; } return retval; case RIO_SET_BUSY: rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_BUSY\n"); if ( (int)arg < 0 || (int)arg > 511 ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n",(int)arg); p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; return -EINVAL; } rio_spin_lock_irqsave(&PortP->portSem, flags); p->RIOPortp[(int)arg]->State |= RIO_BUSY; rio_spin_unlock_irqrestore( &PortP->portSem , flags); return retval; case RIO_HOST_PORT: /* ** The daemon want port information ** (probably for debug reasons) */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT\n"); if ( copyin((int)arg, (caddr_t)&PortReq, sizeof(PortReq) )==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } if (PortReq.SysPort >= RIO_PORTS) { /* SysPort is unsigned */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Illegal port number %d\n", PortReq.SysPort); p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; return -ENXIO; } rio_dprintk (RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort); if (copyout((caddr_t)p->RIOPortp[PortReq.SysPort], (int)PortReq.PortP, sizeof(struct Port) ) == COPYFAIL) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n"); return -EFAULT; } return retval; case RIO_HOST_RUP: /* ** The daemon want rup information ** (probably for debug reasons) */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP\n"); if (copyin((int)arg, (caddr_t)&RupReq, sizeof(RupReq) )==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } if (RupReq.HostNum >= p->RIONumHosts) { /* host is unsigned */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal host number %d\n", RupReq.HostNum); p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE; return -ENXIO; } if ( RupReq.RupNum >= MAX_RUP+LINKS_PER_UNIT ) { /* eek! */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Illegal rup number %d\n", RupReq.RupNum); p->RIOError.Error = RUP_NUMBER_OUT_OF_RANGE; return -EINVAL; } HostP = &p->RIOHosts[RupReq.HostNum]; if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Host %d not running\n", RupReq.HostNum); p->RIOError.Error = HOST_NOT_RUNNING; return -EIO; } rio_dprintk (RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum,RupReq.HostNum); if (copyout((caddr_t)HostP->UnixRups[RupReq.RupNum].RupP, (int)RupReq.RupP,sizeof(struct RUP) ) == COPYFAIL) { p->RIOError.Error = COPYOUT_FAILED; rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n"); return -EFAULT; } return retval; case RIO_HOST_LPB: /* ** The daemon want lpb information ** (probably for debug reasons) */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB\n"); if (copyin((int)arg, (caddr_t)&LpbReq, sizeof(LpbReq) )==COPYFAIL ) { rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n"); p->RIOError.Error = COPYIN_FAILED; return -EFAULT; } if (LpbReq.Host >= p->RIONumHosts) { /* host is unsigned */ rio_dprintk (RIO_DEBUG_CTRL, "RIO_HOST_LPB: Illegal host number %d\n", LpbReq.Host); p->RIOError.Error = HOST_NUMBER_OUT_OF_RANGE; return -ENXIO;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -