aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rio/riotable.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/rio/riotable.c')
-rw-r--r--drivers/char/rio/riotable.c123
1 files changed, 53 insertions, 70 deletions
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index a86b216ab653..d3abe0d37d64 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -53,15 +53,12 @@ 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"
@@ -74,25 +71,20 @@ 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(p)
-struct rio_info *p;
+int RIONewTable(struct rio_info *p)
{
int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
struct Map *MapP;
@@ -137,7 +129,7 @@ struct rio_info *p;
cptr = MapP->Name; /* (2) */
cptr[MAX_NAME_LEN - 1] = '\0';
if (cptr[0] == '\0') {
- bcopy(MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", MapP->Name, 8);
+ memcpy(MapP->Name, MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", 8);
MapP->Name[5] = '0' + Entry / 10;
MapP->Name[6] = '0' + Entry % 10;
}
@@ -298,9 +290,9 @@ struct rio_info *p;
*/
for (Host = 0; Host < RIO_HOSTS; Host++) {
for (Entry = 0; Entry < MAX_RUP; Entry++) {
- bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map));
+ memset(&p->RIOHosts[Host].Mapping[Entry], 0, sizeof(struct Map));
}
- bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name));
+ memset(&p->RIOHosts[Host].Name[0], 0, sizeof(p->RIOHosts[Host].Name));
}
/*
@@ -326,7 +318,7 @@ struct rio_info *p;
*/
if (MapP->ID == 0) {
rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
- bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN);
+ memcpy(HostP->Name, MapP->Name, MAX_NAME_LEN);
continue;
}
@@ -370,7 +362,7 @@ struct rio_info *p;
}
}
if (!p->RIOHosts[Host].Name[0]) {
- bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
+ memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
p->RIOHosts[Host].Name[5] += Host;
}
/*
@@ -398,7 +390,7 @@ struct rio_info *p;
*/
if (Host1 != Host) {
rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
- bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
+ memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
p->RIOHosts[Host].Name[5] += Host1;
}
rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
@@ -409,9 +401,10 @@ struct rio_info *p;
/*
** User process needs the config table - build it from first
** principles.
+**
+* FIXME: SMP locking
*/
-int RIOApel(p)
-struct rio_info *p;
+int RIOApel(struct rio_info *p)
{
int Host;
int link;
@@ -419,17 +412,17 @@ struct rio_info *p;
int Next = 0;
struct Map *MapP;
struct Host *HostP;
- long oldspl;
-
- disable(oldspl); /* strange but true! */
+ unsigned long flags;
rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
- bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES);
+ memset(&p->RIOConnectTable[0], 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)
@@ -440,7 +433,7 @@ struct rio_info *p;
MapP->SysPort = NO_PORT;
for (link = 0; link < LINKS_PER_UNIT; link++)
MapP->Topology[link] = HostP->Topology[link];
- bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN);
+ memcpy(MapP->Name, HostP->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];
@@ -453,8 +446,8 @@ struct rio_info *p;
Next++;
}
}
+ rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
}
- restore(oldspl);
return 0;
}
@@ -463,9 +456,7 @@ struct rio_info *p;
** if the entry is suitably inactive, then we can gob on it and remove
** it from the table.
*/
-int RIODeleteRta(p, MapP)
-struct rio_info *p;
-struct Map *MapP;
+int RIODeleteRta(struct rio_info *p, struct Map *MapP)
{
int host, entry, port, link;
int SysPort;
@@ -541,10 +532,10 @@ struct Map *MapP;
** the phb to port mappings in RIORouteRup.
*/
if (PortP->SecondBlock) {
- ushort dest_unit = HostMapP->ID;
- ushort dest_port = port - SysPort;
- WORD *TxPktP;
- PKT *Pkt;
+ u16 dest_unit = HostMapP->ID;
+ u16 dest_port = port - SysPort;
+ u16 *TxPktP;
+ struct PKT *Pkt;
for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
/*
@@ -554,19 +545,19 @@ struct Map *MapP;
** a 32 bit pointer so it can be
** accessed from the driver.
*/
- Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP));
+ Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&*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);
+ writew(dest_unit, &Pkt->dest_unit);
+ writew(dest_port, &Pkt->dest_port);
}
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));
+ writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
}
rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
}
}
rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n");
- bzero((char *) HostMapP, sizeof(struct Map));
+ memset(HostMapP, 0, sizeof(struct Map));
work_done++;
}
}
@@ -576,11 +567,11 @@ struct Map *MapP;
/* XXXXX lock me up */
for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
- bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map));
+ memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
work_done++;
}
if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
- bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map));
+ memset(&p->RIOConnectTable[entry], 0, sizeof(struct Map));
work_done++;
}
}
@@ -602,7 +593,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 != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
+ if ((MapP->ID != (u16) - 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;
@@ -648,7 +639,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 == (ushort) - 1) {
+ if (MapP->ID == (u16) - 1) {
int nNewID;
rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name);
@@ -667,7 +658,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
p->RIOError.Error = COULDNT_FIND_ENTRY;
return -EBUSY;
}
- MapP->ID = (ushort) nNewID + 1;
+ MapP->ID = (u16) 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;
@@ -708,7 +699,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
*/
HostMapP->SysPort = MapP->SysPort;
if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
- CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
+ memcpy(HostMapP->Name, MapP->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]);
@@ -742,16 +733,13 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
}
-int RIOReMapPorts(p, HostP, HostMapP)
-struct rio_info *p;
-struct Host *HostP;
-struct Map *HostMapP;
+int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
{
- register struct Port *PortP;
- uint SubEnt;
- uint HostPort;
- uint SysPort;
- ushort RtaType;
+ struct Port *PortP;
+ unsigned int SubEnt;
+ unsigned int HostPort;
+ unsigned int SysPort;
+ u16 RtaType;
unsigned long flags;
rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID);
@@ -794,12 +782,12 @@ struct Map *HostMapP;
*/
if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
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));
+ PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add));
+ PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start));
+ PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end));
+ PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove));
+ PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start));
+ PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end));
} else
PortP->PhbP = NULL;
@@ -813,10 +801,10 @@ struct Map *HostMapP;
PortP->RupNum = HostMapP->ID - 1;
if (HostMapP->Flags & RTA16_SECOND_SLOT) {
PortP->ID2 = HostMapP->ID2 - 1;
- PortP->SecondBlock = TRUE;
+ PortP->SecondBlock = 1;
} else {
PortP->ID2 = 0;
- PortP->SecondBlock = FALSE;
+ PortP->SecondBlock = 0;
}
PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;
@@ -866,9 +854,6 @@ 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;
@@ -876,10 +861,10 @@ struct Map *HostMapP;
PortP->closes = 0;
PortP->ioctls = 0;
if (PortP->TxRingBuffer)
- bzero(PortP->TxRingBuffer, p->RIOBufferSize);
+ memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
else if (p->RIOBufferSize) {
- PortP->TxRingBuffer = sysbrk(p->RIOBufferSize);
- bzero(PortP->TxRingBuffer, p->RIOBufferSize);
+ PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL);
+ memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
}
PortP->TxBufferOut = 0;
PortP->TxBufferIn = 0;
@@ -890,7 +875,7 @@ 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 = ~(uchar) PHB_RX_TGL;
+ PortP->LastRxTgl = ~(u8) PHB_RX_TGL;
/*
** and mark the port as usable
@@ -906,9 +891,7 @@ struct Map *HostMapP;
return 0;
}
-int RIOChangeName(p, MapP)
-struct rio_info *p;
-struct Map *MapP;
+int RIOChangeName(struct rio_info *p, struct Map *MapP)
{
int host;
struct Map *HostMapP;
@@ -941,7 +924,7 @@ struct Map *MapP;
return -ENXIO;
}
if (MapP->ID == 0) {
- CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN);
+ memcpy(p->RIOHosts[host].Name, MapP->Name, MAX_NAME_LEN);
return 0;
}
@@ -951,7 +934,7 @@ struct Map *MapP;
p->RIOError.Error = RTA_NUMBER_WRONG;
return -ENXIO;
}
- CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
+ memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
return 0;
}
}