⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 riotable.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 3 页
字号:
/*** -----------------------------------------------------------------------------****  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_LABELSstatic 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.*/intRIONewTable(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.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);			MapP->HostUniqueNum = 0;			/* MapP->RtaUniqueNum	= 0; */			/* MapP->ID			= 0; */			/* MapP->Flags		 = 0; */			/* MapP->SysPort		 = 0; */			/* MapP->Name[0]		 = 0; */			continue;		}		rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(5)\n"); 		if ( MapP->RtaUniqueNum ) { /* (5) */			if ( !MapP->ID ) {				rio_dprintk (RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an ID of zero!\n",							MapP->Name);				p->RIOError.Error		 = ZERO_RTA_ID;				p->RIOError.Entry = Entry;				return -ENXIO;			}			if ( MapP->ID > MAX_RUP ) {				rio_dprintk (RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an invalid ID %d\n",							MapP->Name, MapP->ID);				p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;				p->RIOError.Entry = Entry;				return -ENXIO;			}			for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) {				if ( MapP->HostUniqueNum == 						p->RIOConnectTable[SubEnt].HostUniqueNum && 						MapP->ID == p->RIOConnectTable[SubEnt].ID ) {					rio_dprintk (RIO_DEBUG_TABLE, "Dupl. ID number allocated to RTA %s and RTA %s\n",							MapP->Name, p->RIOConnectTable[SubEnt].Name);					p->RIOError.Error = DUPLICATED_RTA_ID;					p->RIOError.Entry = Entry;					p->RIOError.Other = SubEnt;					return -ENXIO;				}				/*				** If the RtaUniqueNum is the same, it may be looking at both				** entries for a 16 port RTA, so check the ids				*/				if ((MapP->RtaUniqueNum == 						p->RIOConnectTable[SubEnt].RtaUniqueNum)				 		&& (MapP->ID2 != p->RIOConnectTable[SubEnt].ID)) {					rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n",MapP->Name);					rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n",										p->RIOConnectTable[SubEnt].Name);					p->RIOError.Error = DUPLICATE_UNIQUE_NUMBER;					p->RIOError.Entry = Entry;					p->RIOError.Other = SubEnt;					return -ENXIO;				}			}			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7a)\n"); 			/* (7a) */			if ((MapP->SysPort != NO_PORT)&&(MapP->SysPort % PORTS_PER_RTA)) {				rio_dprintk (RIO_DEBUG_TABLE, "TTY Port number %d-RTA %s is not a multiple of %d!\n",					(int)MapP->SysPort,MapP->Name, PORTS_PER_RTA);				p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;				p->RIOError.Entry = Entry;				return -ENXIO;			}			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7b)\n"); 			/* (7b) */			if ((MapP->SysPort != NO_PORT)&&(MapP->SysPort >= RIO_PORTS)) {				rio_dprintk (RIO_DEBUG_TABLE, "TTY Port number %d for RTA %s is too big\n",							(int)MapP->SysPort, MapP->Name);				p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;				p->RIOError.Entry = Entry;				return -ENXIO;			}			for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) {				if ( p->RIOConnectTable[SubEnt].Flags & RTA16_SECOND_SLOT )						continue;				if ( p->RIOConnectTable[SubEnt].RtaUniqueNum ) {					rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(8)\n"); 					/* (8) */					if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort == 									p->RIOConnectTable[SubEnt].SysPort) ) {						rio_dprintk (RIO_DEBUG_TABLE, "RTA %s:same TTY port # as RTA %s (%d)\n",							MapP->Name, p->RIOConnectTable[SubEnt].Name,							(int)MapP->SysPort);						p->RIOError.Error = TTY_NUMBER_IN_USE;						p->RIOError.Entry = Entry;						p->RIOError.Other = SubEnt;						return -ENXIO;					}					rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(9)\n"); 					if (strcmp(MapP->Name,							p->RIOConnectTable[SubEnt].Name)==0 && !(MapP->Flags & RTA16_SECOND_SLOT)) { /* (9) */						rio_dprintk (RIO_DEBUG_TABLE, "RTA name %s used twice\n", MapP->Name);						p->RIOError.Error = NAME_USED_TWICE;						p->RIOError.Entry = Entry;						p->RIOError.Other = SubEnt;						return -ENXIO;					}				}			}		}		else { /* (6) */			rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(6)\n"); 			if ( MapP->ID ) {				rio_dprintk (RIO_DEBUG_TABLE, "RIO:HOST %s has been allocated ID that isn't zero!\n",					MapP->Name);				p->RIOError.Error = HOST_ID_NOT_ZERO;				p->RIOError.Entry = Entry;				return -ENXIO;			}			if ( MapP->SysPort != NO_PORT ) {				rio_dprintk (RIO_DEBUG_TABLE, "RIO: HOST %s has been allocated port numbers!\n",					MapP->Name);				p->RIOError.Error = HOST_SYSPORT_BAD;				p->RIOError.Entry = Entry;				return -ENXIO;			}		}	}	/*	** wow! if we get here then it's a goody!	*/	/*	** Zero the (old) entries for each host...	*/	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));		}		bzero((caddr_t)&p->RIOHosts[Host].Name[0],								sizeof(p->RIOHosts[Host].Name) );	}	/*	** Copy in the new table entries	*/	for ( Entry=0; Entry< TOTAL_MAP_ENTRIES; Entry++ ) {		rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: Copy table for Host entry %d\n", Entry);		MapP = &p->RIOConnectTable[Entry];		/*		** Now, if it is an empty slot ignore it!		*/		if ( MapP->HostUniqueNum==0 )			continue;		/*		** we saved the host number earlier, so grab it back		*/		HostP = &p->RIOHosts[MapP->Topology[0].Unit];		/*		** If it is a host, then we only need to fill in the name field.		*/		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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -