/*
** -----------------------------------------------------------------------------
**
** Perle Specialix driver for Linux
** Ported from existing RIO Driver for SCO sources.
*
* (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** Module : riotable.c
** SID : 1.2
** Last Modified : 11/6/98 10:33:47
** Retrieved : 11/6/98 10:33:50
**
** ident @(#)riotable.c 1.2
**
** -----------------------------------------------------------------------------
*/
#ifdef SCCS_LABELS
static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
#endif
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/string.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/string.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>
#include <linux/termios.h>
#include <linux/serial.h>
#include <linux/generic_serial.h>
#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"
#include "rioinfo.h"
#include "func.h"
#include "errors.h"
#include "pci.h"
#include "parmmap.h"
#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 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' ) {
bcopy(MapP->RtaUniqueNum?"RTA NN":"HOST NN",MapP->Name,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