本文整理汇总了C++中rio_dprintk函数的典型用法代码示例。如果您正苦于以下问题:C++ rio_dprintk函数的具体用法?C++ rio_dprintk怎么用?C++ rio_dprintk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rio_dprintk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RIOFoadRta
int RIOFoadRta(struct Host *HostP, struct Map *MapP)
{
struct CmdBlk *CmdBlkP;
rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA\n");
CmdBlkP = RIOGetCmdBlk();
if (!CmdBlkP) {
rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: GetCmdBlk failed\n");
return -ENXIO;
}
CmdBlkP->Packet.dest_unit = MapP->ID;
CmdBlkP->Packet.dest_port = BOOT_RUP;
CmdBlkP->Packet.src_unit = 0;
CmdBlkP->Packet.src_port = BOOT_RUP;
CmdBlkP->Packet.len = 0x84;
CmdBlkP->Packet.data[0] = IFOAD;
CmdBlkP->Packet.data[1] = 0;
CmdBlkP->Packet.data[2] = IFOAD_MAGIC & 0xFF;
CmdBlkP->Packet.data[3] = (IFOAD_MAGIC >> 8) & 0xFF;
if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_CMD, "FOAD RTA: Failed to queue foad command\n");
return -EIO;
}
return 0;
}
示例2: RIOSuspendBootRta
int RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
{
struct CmdBlk *CmdBlkP;
rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA ID %d, link %c\n", ID, 'A' + Link);
CmdBlkP = RIOGetCmdBlk();
if (!CmdBlkP) {
rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: GetCmdBlk failed\n");
return -ENXIO;
}
CmdBlkP->Packet.dest_unit = ID;
CmdBlkP->Packet.dest_port = BOOT_RUP;
CmdBlkP->Packet.src_unit = 0;
CmdBlkP->Packet.src_port = BOOT_RUP;
CmdBlkP->Packet.len = 0x84;
CmdBlkP->Packet.data[0] = IWAIT;
CmdBlkP->Packet.data[1] = Link;
CmdBlkP->Packet.data[2] = IWAIT_MAGIC & 0xFF;
CmdBlkP->Packet.data[3] = (IWAIT_MAGIC >> 8) & 0xFF;
if (RIOQueueCmdBlk(HostP, ID - 1, CmdBlkP) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_CMD, "SUSPEND BOOT ON RTA: Failed to queue iwait command\n");
return -EIO;
}
return 0;
}
示例3: put_free_end
/****************************************
* Put a packet onto the end of the
* free list
****************************************/
void put_free_end(struct Host *HostP, struct PKT __iomem *PktP)
{
struct rio_free_list __iomem *tmp_pointer;
unsigned short old_end, new_end;
unsigned long flags;
rio_spin_lock_irqsave(&HostP->HostLock, flags);
/*************************************************
* Put a packet back onto the back of the free list
*
************************************************/
rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP);
if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {
new_end = RIO_OFF(HostP->Caddr, PktP);
tmp_pointer = (struct rio_free_list __iomem *) RIO_PTR(HostP->Caddr, old_end);
writew(new_end, &tmp_pointer->next);
writew(old_end, &((struct rio_free_list __iomem *) PktP)->prev);
writew(TPNULL, &((struct rio_free_list __iomem *) PktP)->next);
writew(new_end, &HostP->ParmMapP->free_list_end);
} else { /* First packet on the free list this should never happen! */
rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);
tmp_pointer = (struct rio_free_list __iomem *) PktP;
writew(TPNULL, &tmp_pointer->prev);
writew(TPNULL, &tmp_pointer->next);
}
rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
}
示例4: add_transmit
/*
** To add a packet to the queue, you set the PKT_IN_USE bit in the address,
** and then move the TxAdd pointer along one position to point to the next
** packet pointer. You must wrap the pointer from the end back to the start.
*/
void add_transmit(struct Port *PortP)
{
if (readw(PortP->TxAdd) & PKT_IN_USE) {
rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
}
writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd);
PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;
writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add);
}
示例5: RIOCommandRta
int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
{
unsigned int Host;
rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func);
if (!RtaUnique)
return (0);
for (Host = 0; Host < p->RIONumHosts; Host++) {
unsigned int Rta;
struct Host *HostP = &p->RIOHosts[Host];
for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
struct Map *MapP = &HostP->Mapping[Rta];
if (MapP->RtaUniqueNum == RtaUnique) {
uint Link;
/*
** now, lets just check we have a route to it...
** IF the routing stuff is working, then one of the
** topology entries for this unit will have a legit
** route *somewhere*. We care not where - if its got
** any connections, we can get to it.
*/
for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
/*
** Its worth trying the operation...
*/
return (*func) (HostP, MapP);
}
}
}
}
}
return -ENXIO;
}
示例6: RIOUnUse
int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
{
struct Port *PortP = (struct Port *) iPortP;
unsigned long flags;
rio_spin_lock_irqsave(&PortP->portSem, flags);
rio_dprintk(RIO_DEBUG_CMD, "Decrement in use count for port\n");
if (PortP->InUse) {
if (--PortP->InUse != NOT_INUSE) {
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
return 0;
}
}
/*
** While PortP->InUse is set (i.e. a preemptive command has been sent to
** the RTA and is awaiting completion), any transmit data is prevented from
** being transferred from the write queue into the transmit packets
** (add_transmit) and no furthur transmit interrupt will be sent for that
** data. The next interrupt will occur up to 500ms later (RIOIntr is called
** twice a second as a saftey measure). This was the case when kermit was
** used to send data into a RIO port. After each packet was sent, TCFLSH
** was called to flush the read queue preemptively. PortP->InUse was
** incremented, thereby blocking the 6 byte acknowledgement packet
** transmitted back. This acknowledgment hung around for 500ms before
** being sent, thus reducing input performance substantially!.
** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
** hanging around in the transmit buffer is sent immediately.
*/
writew(1, &PortP->HostP->ParmMapP->tx_intr);
/* What to do here ..
wakeup( (caddr_t)&(PortP->InUse) );
*/
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
return 0;
}
示例7: RIORFlushEnable
int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP)
{
struct Port *PortP = (struct Port *) iPortP;
struct PKT __iomem *PacketP;
unsigned long flags;
rio_spin_lock_irqsave(&PortP->portSem, flags);
while (can_remove_receive(&PacketP, PortP)) {
remove_receive(PortP);
put_free_end(PortP->HostP, PacketP);
}
if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
/*
** MAGIC! (Basically, handshake the RX buffer, so that
** the RTAs upstream can be re-enabled.)
*/
rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
}
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
return RIOUnUse(iPortP, CmdBlkP);
}
示例8: RIOIdentifyRta
int RIOIdentifyRta(struct rio_info *p, void __user * arg)
{
unsigned int Host;
if (copy_from_user(&IdRta, arg, sizeof(IdRta))) {
rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
for (Host = 0; Host < p->RIONumHosts; Host++) {
unsigned int Rta;
struct Host *HostP = &p->RIOHosts[Host];
for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
struct Map *MapP = &HostP->Mapping[Rta];
if (MapP->RtaUniqueNum == IdRta.RtaUnique) {
uint Link;
/*
** now, lets just check we have a route to it...
** IF the routing stuff is working, then one of the
** topology entries for this unit will have a legit
** route *somewhere*. We care not where - if its got
** any connections, we can get to it.
*/
for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
/*
** Its worth trying the operation...
*/
struct CmdBlk *CmdBlkP;
rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA\n");
CmdBlkP = RIOGetCmdBlk();
if (!CmdBlkP) {
rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: GetCmdBlk failed\n");
return -ENXIO;
}
CmdBlkP->Packet.dest_unit = MapP->ID;
CmdBlkP->Packet.dest_port = BOOT_RUP;
CmdBlkP->Packet.src_unit = 0;
CmdBlkP->Packet.src_port = BOOT_RUP;
CmdBlkP->Packet.len = 0x84;
CmdBlkP->Packet.data[0] = IDENTIFY;
CmdBlkP->Packet.data[1] = 0;
CmdBlkP->Packet.data[2] = IdRta.ID;
if (RIOQueueCmdBlk(HostP, MapP->ID - 1, CmdBlkP) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_CMD, "IDENTIFY RTA: Failed to queue command\n");
return -EIO;
}
return 0;
}
}
}
}
}
return -ENOENT;
}
示例9: RIOQueueCmdBlk
/*
** attach a command block to the list of commands to be performed for
** a given rup.
*/
int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
{
struct CmdBlk **Base;
struct UnixRup *UnixRupP;
unsigned long flags;
if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) {
rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup);
RIOFreeCmdBlk(CmdBlkP);
return RIO_FAIL;
}
UnixRupP = &HostP->UnixRups[Rup];
rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
/*
** If the RUP is currently inactive, then put the request
** straight on the RUP....
*/
if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
: 1)) {
rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]);
/*
** Whammy! blat that pack!
*/
HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT));
/*
** place command packet on the pending position.
*/
UnixRupP->CmdPendingP = CmdBlkP;
/*
** set the command register
*/
writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
return 0;
}
rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n");
if (UnixRupP->CmdsWaitingP != NULL)
rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n");
if (UnixRupP->CmdPendingP != NULL)
rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n");
if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
Base = &UnixRupP->CmdsWaitingP;
rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base);
while (*Base) {
rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base);
Base = &((*Base)->NextP);
rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base);
}
rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base);
*Base = CmdBlkP;
CmdBlkP->NextP = NULL;
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
return 0;
}
示例10: RIOServiceHost
void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
{
rio_spin_lock(&HostP->HostLock);
if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
static int t = 0;
rio_spin_unlock(&HostP->HostLock);
if ((t++ % 200) == 0)
rio_dprintk(RIO_DEBUG_INTR, "Interrupt but host not running. flags=%x.\n", (int) HostP->Flags);
return;
}
rio_spin_unlock(&HostP->HostLock);
if (readw(&HostP->ParmMapP->rup_intr)) {
writew(0, &HostP->ParmMapP->rup_intr);
p->RIORupCount++;
RupIntr++;
rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts);
RIOPollHostCommands(p, HostP);
}
if (readw(&HostP->ParmMapP->rx_intr)) {
int port;
writew(0, &HostP->ParmMapP->rx_intr);
p->RIORxCount++;
RxIntr++;
rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts);
/*
** Loop through every port. If the port is mapped into
** the system ( i.e. has /dev/ttyXXXX associated ) then it is
** worth checking. If the port isn't open, grab any packets
** hanging on its receive queue and stuff them on the free
** list; check for commands on the way.
*/
for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) {
struct Port *PortP = p->RIOPortp[port];
struct tty_struct *ttyP;
struct PKT __iomem *PacketP;
/*
** not mapped in - most of the RIOPortp[] information
** has not been set up!
** Optimise: ports come in bundles of eight.
*/
if (!PortP->Mapped) {
port += 7;
continue; /* with the next port */
}
/*
** If the host board isn't THIS host board, check the next one.
** optimise: ports come in bundles of eight.
*/
if (PortP->HostP != HostP) {
port += 7;
continue;
}
/*
** Let us see - is the port open? If not, then don't service it.
*/
if (!(PortP->PortState & PORT_ISOPEN)) {
continue;
}
/*
** find corresponding tty structure. The process of mapping
** the ports puts these here.
*/
ttyP = PortP->gs.tty;
/*
** Lock the port before we begin working on it.
*/
rio_spin_lock(&PortP->portSem);
/*
** Process received data if there is any.
*/
if (can_remove_receive(&PacketP, PortP))
RIOReceive(p, PortP);
/*
** If there is no data left to be read from the port, and
** it's handshake bit is set, then we must clear the handshake,
** so that that downstream RTA is re-enabled.
*/
if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
/*
** MAGIC! ( Basically, handshake the RX buffer, so that
** the RTAs upstream can be re-enabled. )
*/
rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n");
writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
}
rio_spin_unlock(&PortP->portSem);
}
}
//.........这里部分代码省略.........
示例11: RIOKillNeighbour
int RIOKillNeighbour(struct rio_info *p, void __user * arg)
{
uint Host;
uint ID;
struct Host *HostP;
struct CmdBlk *CmdBlkP;
rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) {
rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
if (KillUnit.Link > 3)
return -ENXIO;
CmdBlkP = RIOGetCmdBlk();
if (!CmdBlkP) {
rio_dprintk(RIO_DEBUG_CMD, "UFOAD: GetCmdBlk failed\n");
return -ENXIO;
}
CmdBlkP->Packet.dest_unit = 0;
CmdBlkP->Packet.src_unit = 0;
CmdBlkP->Packet.dest_port = BOOT_RUP;
CmdBlkP->Packet.src_port = BOOT_RUP;
CmdBlkP->Packet.len = 0x84;
CmdBlkP->Packet.data[0] = UFOAD;
CmdBlkP->Packet.data[1] = KillUnit.Link;
CmdBlkP->Packet.data[2] = UFOAD_MAGIC & 0xFF;
CmdBlkP->Packet.data[3] = (UFOAD_MAGIC >> 8) & 0xFF;
for (Host = 0; Host < p->RIONumHosts; Host++) {
ID = 0;
HostP = &p->RIOHosts[Host];
if (HostP->UniqueNum == KillUnit.UniqueNum) {
if (RIOQueueCmdBlk(HostP, RTAS_PER_HOST + KillUnit.Link, CmdBlkP) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
return -EIO;
}
return 0;
}
for (ID = 0; ID < RTAS_PER_HOST; ID++) {
if (HostP->Mapping[ID].RtaUniqueNum == KillUnit.UniqueNum) {
CmdBlkP->Packet.dest_unit = ID + 1;
if (RIOQueueCmdBlk(HostP, ID, CmdBlkP) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_CMD, "UFOAD: Failed queue command\n");
return -EIO;
}
return 0;
}
}
}
RIOFreeCmdBlk(CmdBlkP);
return -ENXIO;
}
示例12: RIOPollHostCommands
/*
** Here we go - if there is an empty rup, fill it!
** must be called at splrio() or higher.
*/
void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
{
struct CmdBlk *CmdBlkP;
struct UnixRup *UnixRupP;
struct PKT __iomem *PacketP;
unsigned short Rup;
unsigned long flags;
Rup = MAX_RUP + LINKS_PER_UNIT;
do { /* do this loop for each RUP */
/*
** locate the rup we are processing & lock it
*/
UnixRupP = &HostP->UnixRups[--Rup];
spin_lock_irqsave(&UnixRupP->RupLock, flags);
/*
** First check for incoming commands:
*/
if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
int FreeMe;
PacketP = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt));
switch (readb(&PacketP->dest_port)) {
case BOOT_RUP:
rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0]));
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
FreeMe = RIOBootRup(p, Rup, HostP, PacketP);
rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
break;
case COMMAND_RUP:
/*
** Free the RUP lock as loss of carrier causes a
** ttyflush which will (eventually) call another
** routine that uses the RUP lock.
*/
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
if (readb(&PacketP->data[5]) == MEMDUMP) {
rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", readw(&(PacketP->data[6])));
rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32);
}
rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
break;
case ROUTE_RUP:
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
FreeMe = RIORouteRup(p, Rup, HostP, PacketP);
rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
break;
default:
rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port));
FreeMe = 1;
break;
}
if (FreeMe) {
rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n");
put_free_end(HostP, PacketP);
writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol);
if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup);
writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake);
}
}
}
/*
** IF a command was running on the port,
** and it has completed, then tidy it up.
*/
if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */
(readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
/*
** we are idle.
** there is a command in pending.
** Therefore, this command has finished.
** So, wakeup whoever is waiting for it (and tell them
** what happened).
*/
if (CmdBlkP->Packet.dest_port == BOOT_RUP)
rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]);
rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP);
/*
** Clear the Rup lock to prevent mutual exclusion.
*/
//.........这里部分代码省略.........
示例13: riotopen
int riotopen(struct tty_struct *tty, struct file *filp)
{
unsigned int SysPort;
int repeat_this = 250;
struct Port *PortP; /* pointer to the port structure */
unsigned long flags;
int retval = 0;
func_enter();
/* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close
is going to oops.
*/
tty->driver_data = NULL;
SysPort = rio_minor(tty);
if (p->RIOFailed) {
rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
func_exit();
return -ENXIO;
}
rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped);
/*
** Validate that we have received a legitimate request.
** Currently, just check that we are opening a port on
** a host card that actually exists, and that the port
** has been mapped onto a host.
*/
if (SysPort >= RIO_PORTS) { /* out of range ? */
rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
func_exit();
return -ENXIO;
}
/*
** Grab pointer to the port stucture
*/
PortP = p->RIOPortp[SysPort]; /* Get control struc */
rio_dprintk(RIO_DEBUG_TTY, "PortP: %p\n", PortP);
if (!PortP->Mapped) { /* we aren't mapped yet! */
/*
** The system doesn't know which RTA this port
** corresponds to.
*/
rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
func_exit();
return -ENXIO;
}
tty->driver_data = PortP;
PortP->gs.tty = tty;
PortP->gs.count++;
rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt);
retval = gs_init_port(&PortP->gs);
if (retval) {
PortP->gs.count--;
return -ENXIO;
}
/*
** If the host hasn't been booted yet, then
** fail
*/
if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
func_exit();
return -ENXIO;
}
/*
** If the RTA has not booted yet and the user has choosen to block
** until the RTA is present then we must spin here waiting for
** the RTA to boot.
*/
/* I find the above code a bit hairy. I find the below code
easier to read and shorter. Now, if it works too that would
be great... -- REW
*/
rio_dprintk(RIO_DEBUG_TTY, "Checking if RTA has booted... \n");
while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) {
if (!PortP->WaitUntilBooted) {
rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n");
func_exit();
return -ENXIO;
}
/* Under Linux you'd normally use a wait instead of this
busy-waiting. I'll stick with the old implementation for
now. --REW
*/
if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n");
func_exit();
return -EINTR;
}
//.........这里部分代码省略.........
示例14: RIONewTable
/*
** A configuration table has been loaded. It is now up to us
** to sort it out and use the information contained therein.
*/
int RIONewTable(struct rio_info *p)
{
int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
struct Map *MapP;
struct Map *HostMapP;
struct Host *HostP;
char *cptr;
/*
** We have been sent a new table to install. We need to break
** it down into little bits and spread it around a bit to see
** what we have got.
*/
/*
** Things to check:
** (things marked 'xx' aren't checked any more!)
** (1) That there are no booted Hosts/RTAs out there.
** (2) That the names are properly formed
** (3) That blank entries really are.
** xx (4) That hosts mentioned in the table actually exist. xx
** (5) That the IDs are unique (per host).
** (6) That host IDs are zero
** (7) That port numbers are valid
** (8) That port numbers aren't duplicated
** (9) That names aren't duplicated
** xx (10) That hosts that actually exist are mentioned in the table. xx
*/
rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(1)\n");
if (p->RIOSystemUp) { /* (1) */
p->RIOError.Error = HOST_HAS_ALREADY_BEEN_BOOTED;
return -EBUSY;
}
p->RIOError.Error = NOTHING_WRONG_AT_ALL;
p->RIOError.Entry = -1;
p->RIOError.Other = -1;
for (Entry = 0; Entry < TOTAL_MAP_ENTRIES; Entry++) {
MapP = &p->RIOConnectTable[Entry];
if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) {
rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(2)\n");
cptr = MapP->Name; /* (2) */
cptr[MAX_NAME_LEN - 1] = '\0';
if (cptr[0] == '\0') {
memcpy(MapP->Name, MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", 8);
MapP->Name[5] = '0' + Entry / 10;
MapP->Name[6] = '0' + Entry % 10;
}
while (*cptr) {
if (*cptr < ' ' || *cptr > '~') {
p->RIOError.Error = BAD_CHARACTER_IN_NAME;
p->RIOError.Entry = Entry;
return -ENXIO;
}
cptr++;
}
}
/*
** If the entry saved was a tentative entry then just forget
** about it.
*/
if (MapP->Flags & SLOT_TENTATIVE) {
MapP->HostUniqueNum = 0;
MapP->RtaUniqueNum = 0;
continue;
}
rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(3)\n");
if (!MapP->RtaUniqueNum && !MapP->HostUniqueNum) { /* (3) */
if (MapP->ID || MapP->SysPort || MapP->Flags) {
rio_dprintk(RIO_DEBUG_TABLE, "%s pretending to be empty but isn't\n", MapP->Name);
p->RIOError.Error = TABLE_ENTRY_ISNT_PROPERLY_NULL;
p->RIOError.Entry = Entry;
return -ENXIO;
}
rio_dprintk(RIO_DEBUG_TABLE, "!RIO: Daemon: test (3) passes\n");
continue;
}
rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(4)\n");
for (Host = 0; Host < p->RIONumHosts; Host++) { /* (4) */
if (p->RIOHosts[Host].UniqueNum == MapP->HostUniqueNum) {
HostP = &p->RIOHosts[Host];
/*
** having done the lookup, we don't really want to do
** it again, so hang the host number in a safe place
*/
MapP->Topology[0].Unit = Host;
break;
}
}
if (Host >= p->RIONumHosts) {
rio_dprintk(RIO_DEBUG_TABLE, "RTA %s has unknown host unique number 0x%x\n", MapP->Name, MapP->HostUniqueNum);
//.........这里部分代码省略.........
示例15: RIOReceive
/*
** Routine for handling received data for tty drivers
*/
static void RIOReceive(struct rio_info *p, struct Port *PortP)
{
struct tty_struct *TtyP;
unsigned short transCount;
struct PKT __iomem *PacketP;
register unsigned int DataCnt;
unsigned char __iomem *ptr;
unsigned char *buf;
int copied = 0;
static int intCount, RxIntCnt;
/*
** The receive data process is to remove packets from the
** PHB until there aren't any more or the current cblock
** is full. When this occurs, there will be some left over
** data in the packet, that we must do something with.
** As we haven't unhooked the packet from the read list
** yet, we can just leave the packet there, having first
** made a note of how far we got. This means that we need
** a pointer per port saying where we start taking the
** data from - this will normally be zero, but when we
** run out of space it will be set to the offset of the
** next byte to copy from the packet data area. The packet
** length field is decremented by the number of bytes that
** we successfully removed from the packet. When this reaches
** zero, we reset the offset pointer to be zero, and free
** the packet from the front of the queue.
*/
intCount++;
TtyP = PortP->gs.tty;
if (!TtyP) {
rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n");
return;
}
if (PortP->State & RIO_THROTTLE_RX) {
rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: Throttled. Can't handle more input.\n");
return;
}
if (PortP->State & RIO_DELETED) {
while (can_remove_receive(&PacketP, PortP)) {
remove_receive(PortP);
put_free_end(PortP->HostP, PacketP);
}
} else {
/*
** loop, just so long as:
** i ) there's some data ( i.e. can_remove_receive )
** ii ) we haven't been blocked
** iii ) there's somewhere to put the data
** iv ) we haven't outstayed our welcome
*/
transCount = 1;
while (can_remove_receive(&PacketP, PortP)
&& transCount) {
RxIntCnt++;
/*
** check that it is not a command!
*/
if (readb(&PacketP->len) & PKT_CMD_BIT) {
rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n");
/* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */
rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", readb(&PacketP->dest_unit));
rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", readb(&PacketP->dest_port));
rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", readb(&PacketP->src_unit));
rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", readb(&PacketP->src_port));
rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", readb(&PacketP->len));
rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", readb(&PacketP->control));
rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", readw(&PacketP->csum));
rio_dprintk(RIO_DEBUG_INTR, " data bytes: ");
for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++)
rio_dprintk(RIO_DEBUG_INTR, "%d\n", readb(&PacketP->data[DataCnt]));
remove_receive(PortP);
put_free_end(PortP->HostP, PacketP);
continue; /* with next packet */
}
/*
** How many characters can we move 'upstream' ?
**
** Determine the minimum of the amount of data
** available and the amount of space in which to
** put it.
**
** 1. Get the packet length by masking 'len'
** for only the length bits.
** 2. Available space is [buffer size] - [space used]
**
** Transfer count is the minimum of packet length
** and available space.
*/
//.........这里部分代码省略.........