📄 kn230.c
字号:
#ifndef lintstatic char *sccsid = "@(#)kn230.c 4.6 (ULTRIX) 4/11/91";#endif lint/************************************************************************ * * * Copyright (c) 1990 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//* * Modification History: kn230.c * * 11-Apr-91 -- Paul Grist * Modified trap and get-SIMM-sizes routines to account for * NVRAM when handling errors. * * 09 Oct 90 -- Paul Grist * Merge for MM to TI sync-ing of pools. * * 22 Aug 90 -- Paul Grist * Added support to print out name string of option card * at boot time. * * 19 Aug 90 -- chet * Changes for presto interface. * * 05-Aug-90 Paul Grist * Addded support for NVRAM/Prestoserve. Removed most of the debug * code, except for option card debug support, this may prove useful * later. * * 04-Aug-90 Randall Brown * Added call to spl_init() to intialize spl function pointers and * the intr() function pointer. * * 16-July-90 Paul Grist * minor FT2 cleanup/fixes and added include for presto.h for * future NVRAM/presto support. * * 06-Jun-90 Paul Grist * Complete option card support, add various fixes and cleanup * before FT build. Added reporting of console state. * * 06-May-90 Paul Grist * Continue clean up, remove debug stuff, add routine to get the * SIMM memory bank sizes for kn230_isolatepar, and add support to * configure the option card. * * 24-Apr-90 Paul Grist * Make initial modifications for pass 2 * * 23-Apr-90 Paul Grist * Name change everything from ds5100 to kn230. * * 13-Apr-90 Paul Grist * Cleanup after first boot, added debug support. * * 09-Mar-90 Paul Grist * Completed first pass code for MIPSMATE. */#include "../machine/pte.h"#include "../machine/cpu.h"#include "../h/param.h"#include "../h/systm.h"#include "../h/map.h"#include "../h/user.h" /* gets time.h and debug.h too */#include "../h/proc.h"#include "../h/vm.h"#include "../h/buf.h"#include "../h/dk.h"#include "../h/conf.h"#include "../h/errlog.h"#include "../h/cmap.h"#include "../h/cpudata.h"#include "../h/presto.h"#include "../machine/fpu.h"#include "../machine/hwconf.h"#include "../machine/reg.h"#include "../machine/mc146818clock.h"#include "../machine/entrypt.h"#include "../../machine/common/cpuconf.h"#define KN230_LANCE 0x18000000 /* physical addr of lance registers */#define KN230_SII 0x1a000000 /* physical addr of sii registers */#define KN230_CLOCK 0x1d000000 /* phys addr of clock chip */#define KN230_ICSR 0x1e000000 /* Interrupt control & status reg */#define KN230_HALT 0x00004000 /* Set if halt switch is pushed */#define KN230_WMERR 0x00002000 /* Set on memory write NXM */#define KN230_NIIRQ 0x00001000 /* "1" is lance posting interrupt*/#define KN230_SCSIRQ 0x00000800 /* "1" is SII posting interrupt*/#define KN230_EXPIRQ1 0x00000400 /* "1" is expan opt posting interrupt*/#define KN230_EXPIRQ0 0x00000200 /* "1" is expan opt posting interrupt*/#define KN230_DZIRQ 0x00000100 /* "1" is console posting interrupt */#define KN230_LED 0x14000000 /* LED register */#define KN230_LED7 0x00008000 /* "1" turns off led 7 */#define KN230_LED6 0x00004000 /* "1" turns off led 6 */#define KN230_LED5 0x00002000 /* "1" turns off led 5 */#define KN230_LED4 0x00001000 /* "1" turns off led 4 */#define KN230_LED3 0x00000800 /* "1" Turns off led 3 and disables main memory, enables wr to EEPROM */#define KN230_LED2 0x00000400 /* "1" Turns off led 2 and selects 38.4 baud, "0" selects default 19.2k */#define KN230_LED1 0x00000200 /* "1" (read only) means 32M in bank1 "0" means 8M in memory bank 1 */#define KN230_LED0 0x00000100 /* "1" enables halts-disables reset */#define KN230_WEAR 0x17000000 /* Write error address register */#define WEAR_IOPRESENT 0x00000001 /* "1" means no option card present */#define WEAR_SECURE 0x00000002 /* "1" means system is insecure */#define KN230_PASSWD 0x1f000244 /* password location */#define PASSWD_FIELD 0xffffffc0 /* mask out passwd field */#define PASSWD_FAILS 0x0000000f /* mask out #of failures */#define KN230_OID 0x1f00020c /* option slot ID register */#define OID_NUMBER_MSK 0x000000ff /* mask out the ID number */#define OID_ERR_COUNT 0x0000ff00 /* mask out diag failure count */#define KN230_DZ0_CSR 0x1c000000 /* DZ0 - Control and status register */#define KN230_DZ1_CSR 0x15000000 /* DZ1 Control and status */#define KN230_DZ2_CSR 0x15200000 /* DZ2 Control and status */#define ESRPKT 1#define MEMPKT 2#define ICSR_ADDR PHYS_TO_K1(KN230_ICSR) /* virt address of ICSR */#define LANCE_ADDR PHYS_TO_K1(KN230_LANCE) /* virt address of LANCE */#define LED_ADDR PHYS_TO_K1(KN230_LED) /* virt address of LED */#define WEAR_ADDR PHYS_TO_K1(KN230_WEAR) /* virt address of WEAR */#define OID_ADDR PHYS_TO_K1(KN230_OID) /* virt address of OID */#define PASSWD_ADDR PHYS_TO_K1(KN230_PASSWD) /* virt address of PASSWD *//* used to save state of registers for logging */u_long kn230_esr_icsr;u_long kn230_esr_leds;u_long kn230_esr_wear;u_long kn230_esr_oid;/* * Since there is no vector register and we want non-configured * devices and controllers to point to stray(), we will use the * general purpose scb to dispatch are interrupts. * * assign indexes into the scb for the five hardware * interrrupts. Use scb locations 100-104. * */#define DZ_UART_INDEX 400 /* DZ UART - DZIRQ */#define EXP0_INDEX 404 /* EXPANSION OPTION - EXPIRQ0 */#define EXP1_INDEX 408 /* EXPANSION OPTION - EXPIRQ1 */#define SII_INDEX 412 /* SII (scsi controller) - SCSI IRQ */#define LANCE_INDEX 416 /* NI (lance) - NIIRQ *//* * These defines, macros, and variables are for memory parity errors. * Format of "memreg" for logging memory parity errors. * */#define SIMMOFF 28#define TYPEOFF 26#define BYTEOFF 25#define DPOFF 24#define TCOUNTOFF 16#define SCOUNTOFF 8#define HCOUNTOFF 0#define MEMREGFMT(simm, type, byte, dp, tcount, scount, hcount) \(simm << SIMMOFF | type << TYPEOFF | byte << BYTEOFF | dp << DPOFF | \tcount << TCOUNTOFF | scount << SCOUNTOFF | hcount << HCOUNTOFF)/* * MEMREG is a hand crafted info register (sw) used for error logging * and handling memory parity errors. * * 31 28 26 25 24 16 8 0 * +------+------+------+----+-------------+------------+------------+ * | SIMM | TYPE | BYTE | TP | TRANS COUNT | SOFT COUNT | HARD COUNT | * +------+------+------+----+-------------+------------+------------+ * */#define TRANSINTVL (60*15) /* time delta to enable parity logging is 15 minutes */int kn230transintvl = TRANSINTVL; /* global var so we can change it */int kn230translog = 1; /* is trans logging currently enabled */struct kn230_trans_errcnt { /* trans parity errors */ long trans_last; /* time of most recent trans err */ long trans_prev; /* time of previous trans err */} kn230_trans_errcnt = { 0, 0 };#define TRANSPAR 0x1 /* transient parity error */#define SOFTPAR 0x2 /* soft parity error */#define HARDPAR 0x3 /* hard parity error */#define TEXTPG(pt) ((pt) & CTEXT)#define SMEMPG(pt) ((pt) & CSMEM)#define MAXSIMM 8int tcount[MAXSIMM]; /* # of trans parity errs per simm*/int scount[MAXSIMM]; /* # of soft errs on each simm */int hcount[MAXSIMM]; /* # of hard errs on each simm */int kn230_parityerr = 0; /* flag for parity err isolation */caddr_t vatophys(); /* typedef of functions */unsigned kn230_isolatepar();int kn230transenable();int kn230_memsize; /* integer size of system memory */int kn230_bank1; /* integer value size of memory bank */int kn230_bank2; /* integer value size of memory bank */int kn230_bank3; /* integer value size of memory bank */int kn230_bank4; /* integer value size of memory bank */extern int nMDC; /* number of mdc chips in config file*//* * console and clock external variables */extern u_int printstate; /* how to print to the console */extern char *rt_clock_addr; /* addr of the mc146818clock chip */extern struct timeval time; /* the system time */extern int hz;extern int tick;extern int tickadj;extern int fixtick; /* set to the number of microsec's that the clock looses per second *//* * option card info structure */struct kn230_option { u_int option_id; /* id# as read from OID register */ char driver_name[32]; /* driver name as read in configuration file */ char type; /* 'D' or 'C',device or controller uba struct*/ u_int exp0_csr; /* add of expansion device 0's csr reg*/ u_int exp1_csr; /* add of expansion device 1's csr reg*/ char option_name[64]; /* name string printed at boot time */};/* * NVRAM/Prestoserve support definitions * */#define KN230_NVRAM_DIAG 0x1f000300 /* NVRAM diagnostic register */#define NVRAM_SIZE 0x000000f0 /* MASK out nvram size bits */#define KN230_NVRAM_FAILED 0x00000008 /* MASK out fail bit */#define KN230_NVRAM_PRESENT 0x00000001 /* MASK out present bit */#define KN230_NVRAM_RO 0x00000002 /* read only test failed */#define KN230_NVRAM_RW 0x00000004 /* read/write test failed */#define KN230_NVRAM_LOCATION 0x1f000304 /* NVRAM location register */#define KN230_NVRAM_BKILL 0x00000002 /* status reg mask for bkill */#define KN230_NVRAM_BFAIL 0x00000001 /* status reg mask for bfail */#define NVRAM_DIAG PHYS_TO_K1(KN230_NVRAM_DIAG)#define NVRAM_LOCATION PHYS_TO_K1(KN230_NVRAM_LOCATION)volatile unsigned int kn230_nvram_estatus; /* even status reg addr*/volatile unsigned int kn230_nvram_ostatus; /* odd status reg addr*/volatile unsigned int kn230_nvram_econtrol; /* even control reg addr*/volatile unsigned int kn230_nvram_ocontrol; /* even control reg addr*/volatile unsigned int kn230_nvram_location; /* nvram start addr value*/unsigned kn230_nvram_start_addr; /* adjusted start value*/unsigned kn230_nvram_size; /* adjusted size value*//***************************************************************************** * * Interrupt handlers for the 6 hardware interrupts and 2 software * interrupts for MIPSMATE. * *****************************************************************************/extern softclock(),softnet(),kn230_hardintr1(),kn230_hardintr0(), hardclock(), fpuintr(),kn230_memintr(),kn230_haltintr();/* The routines that correspond to each of the 8 interrupt lines */int (*kn230intr_vec[IPLSIZE])() = { softclock, /* softint 0 SOFTCLOCK */ softnet, /* softint 1 NET */ kn230_hardintr0, /* hardint 0 DZ UART, IO EXPANSION */ kn230_hardintr1, /* hardint 1 LANCE, SII */ hardclock, /* hardint 2 TOY */ kn230_memintr, /* hardint 3 Write Mem NXM */ kn230_haltintr, /* hardint 4 HALT */ fpuintr /* hardint 5 FPU */};/* * The masks to use to look at each of the 8 interrupt lines. * */int kn230iplmask[IPLSIZE] = { SR_IMASK1|SR_IEC, /* softintr0 - SOFTCLOCK */ SR_IMASK2|SR_IEC, /* softintr1 - NET */ SR_IMASK3|SR_IEC, /* hardintr0 - DZ UART, IO EXPANSION */ SR_IMASK4|SR_IEC, /* hardintr1 - LANCE, SII */ SR_IMASK5|SR_IEC, /* hardintr2 - TOY */ SR_IMASK6|SR_IEC, /* hardintr3 - WRITE MEM NXM */ SR_IMASK7|SR_IEC, /* hardintr4 - HALT */ SR_IMASK8|SR_IEC /* hardintr5 - FPU */};/* * The SR reg masks for splxxx usage. See the defines in cpu.h. */#define SR_HALT 0x4000 /* halt is hardint 4 */int kn230splm[SPLMSIZE] = { SR_IEC | SR_IMASK0 | SR_HALT, /* 0 SPLNONE */ SR_IEC | SR_IMASK1 | SR_HALT, /* 1 SPLSOFTC */ SR_IEC | SR_IMASK2 | SR_HALT, /* 2 SPLNET */ 0, /* 3 NOT_USED */ 0, /* 4 NOT_USED */ SR_IEC | SR_IMASK4 | SR_HALT, /* 5 SPLBIO,SPLIMP,SPLTTY */ SR_IEC | SR_IMASK5 | SR_HALT, /* 6 SPLCLOCK */ SR_IEC | SR_IMASK6 | SR_HALT, /* 7 SPLMEM */ SR_IEC | SR_IMASK8 | SR_HALT, /* 8 SPLFPU */};/***************************************************************************** * * kn230_init(): Initialization routine for kn230 processor (MIPSMATE) * * - initialize interrupt dispatch table: c0vec_tbl * - initialize spl table: splm * - initialize interrupt mask table: splm * - direct lance interrupts to kn230_lance() * - change from console trap handling to kernel trap handling * - set up clock values * *****************************************************************************/kn230_init(){ extern int c0vec_tblsize; extern int (*c0vec_tbl[])(); extern int iplmask[]; extern int splm[]; extern struct cpusw *cpup; extern int (*(scb[])) (); /* * Initialize the interrupt dispatch table c0vec_tbl. * Initialize the spl table for the system we are running on. * Initialize the interrupt masks for the system we are running on. * This must be done very early on at boot time and must * be done before any interrupt (or spl) is allowed. */ bcopy((int *)kn230intr_vec, c0vec_tbl, c0vec_tblsize); bcopy(kn230iplmask, iplmask, IPLSIZE * sizeof(int)); bcopy(kn230splm, splm, (SPLMSIZE) * sizeof(int)); /* Initialize the spl dispatch table and the intr dispatch routine */ spl_init(); /* * change over from console to kernel trap handling; this is * done by changing the BEV bit in the status register. */ clear_bev(); /* * Set up the system specific value for "hz", the number of clock * interrupts per second; and corresponding tick and tickadj values. * These values will be used by hardclock. HZ=256 for mc146818 */ hz = cpup->HZ; tick = 1000000 / hz; tickadj = 240000 / (60 * hz); fixtick = 1000000 - (tick * hz); /* * Assign the rt_clock_addr for this processor */ rt_clock_addr = (char *)PHYS_TO_K1(KN230_CLOCK); return (0);}/************************************************************************ * * kn230_conf: Configuration routine for MIPSMATE * * - set up PROM environment entries * - set up FPU ; turn on interrupts * - configure system devices and controllers * - enable logging of transient parity errors * - report the state of the halt/reset button * ************************************************************************/kn230_conf(){ extern int cold; extern unsigned cpu_systype; extern int cpu; /* ULTRIX internal System type */ extern int kn230_turn_nvram_on; cold = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -