X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Frio%2Friotable.c;fp=drivers%2Fchar%2Frio%2Friotable.c;h=a86b216ab6539f674f8d31e0b8a3f00800b33517;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=7e988357326e3a907e892c8ea554ce573cb6d2bb;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c index 7e9883573..a86b216ab 100644 --- a/drivers/char/rio/riotable.c +++ b/drivers/char/rio/riotable.c @@ -53,12 +53,15 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2"; #include "linux_compat.h" #include "rio_linux.h" +#include "typdef.h" #include "pkt.h" #include "daemon.h" #include "rio.h" #include "riospace.h" +#include "top.h" #include "cmdpkt.h" #include "map.h" +#include "riotypes.h" #include "rup.h" #include "port.h" #include "riodrvr.h" @@ -71,20 +74,25 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2"; #include "unixrup.h" #include "board.h" #include "host.h" +#include "error.h" #include "phb.h" #include "link.h" #include "cmdblk.h" #include "route.h" +#include "control.h" #include "cirrus.h" #include "rioioctl.h" #include "param.h" +#include "list.h" +#include "sam.h" #include "protsts.h" /* ** 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 RIONewTable(p) +struct rio_info *p; { int Host, Host1, Host2, NameIsUnique, Entry, SubEnt; struct Map *MapP; @@ -129,7 +137,7 @@ int RIONewTable(struct rio_info *p) cptr = MapP->Name; /* (2) */ cptr[MAX_NAME_LEN - 1] = '\0'; if (cptr[0] == '\0') { - memcpy(MapP->Name, MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", 8); + bcopy(MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", MapP->Name, 8); MapP->Name[5] = '0' + Entry / 10; MapP->Name[6] = '0' + Entry % 10; } @@ -290,9 +298,9 @@ int RIONewTable(struct rio_info *p) */ for (Host = 0; Host < RIO_HOSTS; Host++) { for (Entry = 0; Entry < MAX_RUP; Entry++) { - memset(&p->RIOHosts[Host].Mapping[Entry], 0, sizeof(struct Map)); + bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map)); } - memset(&p->RIOHosts[Host].Name[0], 0, sizeof(p->RIOHosts[Host].Name)); + bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name)); } /* @@ -318,7 +326,7 @@ int RIONewTable(struct rio_info *p) */ if (MapP->ID == 0) { rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name); - memcpy(HostP->Name, MapP->Name, MAX_NAME_LEN); + bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN); continue; } @@ -362,7 +370,7 @@ int RIONewTable(struct rio_info *p) } } if (!p->RIOHosts[Host].Name[0]) { - memcpy(p->RIOHosts[Host].Name, "HOST 1", 7); + bcopy("HOST 1", p->RIOHosts[Host].Name, 7); p->RIOHosts[Host].Name[5] += Host; } /* @@ -390,7 +398,7 @@ int RIONewTable(struct rio_info *p) */ if (Host1 != Host) { rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name); - memcpy(p->RIOHosts[Host].Name, "HOST 1", 7); + bcopy("HOST 1", p->RIOHosts[Host].Name, 7); p->RIOHosts[Host].Name[5] += Host1; } rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name); @@ -401,10 +409,9 @@ int RIONewTable(struct rio_info *p) /* ** User process needs the config table - build it from first ** principles. -** -* FIXME: SMP locking */ -int RIOApel(struct rio_info *p) +int RIOApel(p) +struct rio_info *p; { int Host; int link; @@ -412,17 +419,17 @@ int RIOApel(struct rio_info *p) int Next = 0; struct Map *MapP; struct Host *HostP; - unsigned long flags; + long oldspl; + + disable(oldspl); /* strange but true! */ rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n"); - memset(&p->RIOConnectTable[0], 0, sizeof(struct Map) * TOTAL_MAP_ENTRIES); + bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES); for (Host = 0; Host < RIO_HOSTS; Host++) { rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host); HostP = &p->RIOHosts[Host]; - rio_spin_lock_irqsave(&HostP->HostLock, flags); - MapP = &p->RIOConnectTable[Next++]; MapP->HostUniqueNum = HostP->UniqueNum; if ((HostP->Flags & RUN_STATE) != RC_RUNNING) @@ -433,7 +440,7 @@ int RIOApel(struct rio_info *p) MapP->SysPort = NO_PORT; for (link = 0; link < LINKS_PER_UNIT; link++) MapP->Topology[link] = HostP->Topology[link]; - memcpy(MapP->Name, HostP->Name, MAX_NAME_LEN); + bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN); for (Rup = 0; Rup < MAX_RUP; Rup++) { if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) { p->RIOConnectTable[Next] = HostP->Mapping[Rup]; @@ -446,8 +453,8 @@ int RIOApel(struct rio_info *p) Next++; } } - rio_spin_unlock_irqrestore(&HostP->HostLock, flags); } + restore(oldspl); return 0; } @@ -456,7 +463,9 @@ int RIOApel(struct rio_info *p) ** if the entry is suitably inactive, then we can gob on it and remove ** it from the table. */ -int RIODeleteRta(struct rio_info *p, struct Map *MapP) +int RIODeleteRta(p, MapP) +struct rio_info *p; +struct Map *MapP; { int host, entry, port, link; int SysPort; @@ -532,10 +541,10 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP) ** the phb to port mappings in RIORouteRup. */ if (PortP->SecondBlock) { - u16 dest_unit = HostMapP->ID; - u16 dest_port = port - SysPort; - u16 __iomem *TxPktP; - struct PKT __iomem *Pkt; + ushort dest_unit = HostMapP->ID; + ushort dest_port = port - SysPort; + WORD *TxPktP; + PKT *Pkt; for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { /* @@ -545,19 +554,19 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP) ** a 32 bit pointer so it can be ** accessed from the driver. */ - Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&*TxPktP)); - rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", readw(TxPktP), readb(&Pkt->dest_unit), readb(&Pkt->dest_port), dest_unit, dest_port); - writew(dest_unit, &Pkt->dest_unit); - writew(dest_port, &Pkt->dest_port); + Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP)); + rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port); + WWORD(Pkt->dest_unit, dest_unit); + WWORD(Pkt->dest_port, dest_port); } - rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, readb(&PortP->PhbP->destination) & 0xff, (readb(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port); - writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination); + rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port); + WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); } rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); } } rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n"); - memset(HostMapP, 0, sizeof(struct Map)); + bzero((char *) HostMapP, sizeof(struct Map)); work_done++; } } @@ -567,11 +576,11 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP) /* XXXXX lock me up */ for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { - memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map)); + bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map)); work_done++; } if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { - memset(&p->RIOConnectTable[entry], 0, sizeof(struct Map)); + bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map)); work_done++; } } @@ -593,7 +602,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP) rio_dprintk(RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort); - if ((MapP->ID != (u16) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) { + if ((MapP->ID != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) { rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n"); p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE; return -EINVAL; @@ -639,7 +648,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP) ** Now we have a host we need to allocate an ID ** if the entry does not already have one. */ - if (MapP->ID == (u16) - 1) { + if (MapP->ID == (ushort) - 1) { int nNewID; rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name); @@ -658,7 +667,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP) p->RIOError.Error = COULDNT_FIND_ENTRY; return -EBUSY; } - MapP->ID = (u16) nNewID + 1; + MapP->ID = (ushort) nNewID + 1; rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID); HostMapP = &p->RIOHosts[host].Mapping[nNewID]; HostMapP->RtaUniqueNum = MapP->RtaUniqueNum; @@ -699,7 +708,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP) */ HostMapP->SysPort = MapP->SysPort; if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) - memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN); + CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED; #ifdef NEED_TO_FIX RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]); @@ -733,13 +742,16 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP) } -int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) +int RIOReMapPorts(p, HostP, HostMapP) +struct rio_info *p; +struct Host *HostP; +struct Map *HostMapP; { - struct Port *PortP; - unsigned int SubEnt; - unsigned int HostPort; - unsigned int SysPort; - u16 RtaType; + register struct Port *PortP; + uint SubEnt; + uint HostPort; + uint SysPort; + ushort RtaType; unsigned long flags; rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID); @@ -781,13 +793,13 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) ** unless the host has been booted */ if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { - struct PHB __iomem *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; - PortP->TxAdd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add)); - PortP->TxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start)); - PortP->TxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end)); - PortP->RxRemove = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove)); - PortP->RxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start)); - PortP->RxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end)); + struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; + PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add)); + PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start)); + PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end)); + PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove)); + PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start)); + PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end)); } else PortP->PhbP = NULL; @@ -801,10 +813,10 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) PortP->RupNum = HostMapP->ID - 1; if (HostMapP->Flags & RTA16_SECOND_SLOT) { PortP->ID2 = HostMapP->ID2 - 1; - PortP->SecondBlock = 1; + PortP->SecondBlock = TRUE; } else { PortP->ID2 = 0; - PortP->SecondBlock = 0; + PortP->SecondBlock = FALSE; } PortP->RtaUniqueNum = HostMapP->RtaUniqueNum; @@ -854,6 +866,9 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) PortP->RxDataStart = 0; PortP->Cor2Copy = 0; PortP->Name = &HostMapP->Name[0]; +#ifdef STATS + bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats)); +#endif PortP->statsGather = 0; PortP->txchars = 0; PortP->rxchars = 0; @@ -861,10 +876,10 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) PortP->closes = 0; PortP->ioctls = 0; if (PortP->TxRingBuffer) - memset(PortP->TxRingBuffer, 0, p->RIOBufferSize); + bzero(PortP->TxRingBuffer, p->RIOBufferSize); else if (p->RIOBufferSize) { - PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL); - memset(PortP->TxRingBuffer, 0, p->RIOBufferSize); + PortP->TxRingBuffer = sysbrk(p->RIOBufferSize); + bzero(PortP->TxRingBuffer, p->RIOBufferSize); } PortP->TxBufferOut = 0; PortP->TxBufferIn = 0; @@ -875,7 +890,7 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) ** If the same, we have received the same rx pkt from the RTA ** twice. Initialise to a value not equal to PHB_RX_TGL or 0. */ - PortP->LastRxTgl = ~(u8) PHB_RX_TGL; + PortP->LastRxTgl = ~(uchar) PHB_RX_TGL; /* ** and mark the port as usable @@ -891,7 +906,9 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP) return 0; } -int RIOChangeName(struct rio_info *p, struct Map *MapP) +int RIOChangeName(p, MapP) +struct rio_info *p; +struct Map *MapP; { int host; struct Map *HostMapP; @@ -924,7 +941,7 @@ int RIOChangeName(struct rio_info *p, struct Map *MapP) return -ENXIO; } if (MapP->ID == 0) { - memcpy(p->RIOHosts[host].Name, MapP->Name, MAX_NAME_LEN); + CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN); return 0; } @@ -934,7 +951,7 @@ int RIOChangeName(struct rio_info *p, struct Map *MapP) p->RIOError.Error = RTA_NUMBER_WRONG; return -ENXIO; } - memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN); + CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); return 0; } }