Fixes to conf.c

Cleaning of code.
This commit is contained in:
ragge 1995-04-12 15:34:44 +00:00
parent 81f3a84289
commit bf15373974
7 changed files with 231 additions and 208 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.6 1995/03/30 21:25:14 ragge Exp $ */
/* $NetBSD: clock.c,v 1.7 1995/04/12 15:34:44 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -33,14 +33,9 @@
/******************************************************************************
clock.c
******************************************************************************/
#include <sys/param.h>
#include <sys/kernel.h>
#include "machine/mtpr.h"
#include "machine/sid.h"
@ -60,10 +55,12 @@ void
microtime(tvp)
register struct timeval *tvp;
{
int s = splhigh(),i;
u_int int_time=mfpr(PR_TODR),tmp_year;
int s,i;
u_int int_time,tmp_year;
static struct timeval lasttime;
s = splhigh();
int_time=mfpr(PR_TODR);
bcopy(&time,tvp,sizeof(struct timeval));
i=mfpr(PR_ICR)+tick; /* Get current interval count */
tvp->tv_usec += i;
@ -96,81 +93,91 @@ microtime(tvp)
* alert is printed and the time is temporary set to the time in fs_time.
*/
void inittodr(time_t fs_time) {
void
inittodr(fs_time)
time_t fs_time;
{
unsigned long tmp_year,sluttid=fs_time,year_ticks;
int clock_stopped;
unsigned long tmp_year,sluttid,year_ticks;
int clock_stopped;
year=(fs_time/SEC_PER_DAY/365)*365*SEC_PER_DAY;
tmp_year=year/SEC_PER_DAY/365+2;
year_len=100*SEC_PER_DAY*((tmp_year%4&&tmp_year!=32)?365:366);
sluttid=fs_time;
year=(fs_time/SEC_PER_DAY/365)*365*SEC_PER_DAY;
tmp_year=year/SEC_PER_DAY/365+2;
year_len=100*SEC_PER_DAY*((tmp_year%4&&tmp_year!=32)?365:366);
switch (cpunumber) {
switch (cpunumber) {
#if VAX750
case VAX_750:
year_ticks = mfpr(PR_TODR);
clock_stopped = todrstopped;
break;
case VAX_750:
year_ticks = mfpr(PR_TODR);
clock_stopped = todrstopped;
break;
#endif
#if VAX630 || VAX410
case VAX_78032:
year_ticks = uvaxII_gettodr(&clock_stopped);
break;
case VAX_78032:
year_ticks = uvaxII_gettodr(&clock_stopped);
break;
#endif
default:
year_ticks = 0;
clock_stopped = 1;
};
default:
year_ticks = 0;
clock_stopped = 1;
};
if(clock_stopped){
printf("Internal clock not started. Using time from file system.\n");
switch (cpunumber) {
if(clock_stopped){
printf(
"Internal clock not started. Using time from file system.\n");
switch (cpunumber) {
#if VAX750
case VAX_750:
mtpr((fs_time-year)*100+1, PR_TODR); /*+1 so the clock won't be stopped */
break;
case VAX_750:
/*+1 so the clock won't be stopped */
mtpr((fs_time-year)*100+1, PR_TODR);
break;
#endif
#if VAX630 || VAX410
case VAX_78032:
uvaxII_settodr((fs_time-year)*100+1);
break;
case VAX_78032:
uvaxII_settodr((fs_time-year)*100+1);
break;
#endif
};
todrstopped=0;
} else if(year_ticks/100>fs_time-year+SEC_PER_DAY*3) {
printf("WARNING: Clock has gained %d days - CHECK AND RESET THE DATE.\n",
(year_ticks/100-(fs_time-year))/SEC_PER_DAY);
sluttid=year+(year_ticks/100);
} else if(year_ticks/100<fs_time-year) {
printf("WARNING: Clock has lost time - CHECK AND RESET THE DATE.\n");
} else sluttid=year+(year_ticks/100);
time.tv_sec=sluttid;
};
todrstopped=0;
} else if(year_ticks/100>fs_time-year+SEC_PER_DAY*3) {
printf(
"WARNING: Clock has gained %d days - CHECK AND RESET THE DATE.\n",
(year_ticks/100-(fs_time-year))/SEC_PER_DAY);
sluttid=year+(year_ticks/100);
} else if(year_ticks/100<fs_time-year) {
printf(
"WARNING: Clock has lost time - CHECK AND RESET THE DATE.\n");
} else sluttid=year+(year_ticks/100);
time.tv_sec=sluttid;
}
/*
* Resettodr restores the time of day hardware after a time change.
*/
void resettodr(void) {
void
resettodr()
{
unsigned long tmp_year;
unsigned long tmp_year;
year=(time.tv_sec/SEC_PER_DAY/365)*365*SEC_PER_DAY;
tmp_year=year/SEC_PER_DAY/365+2;
year_len=100*SEC_PER_DAY*((tmp_year%4&&tmp_year!=32)?365:366);
switch (cpunumber) {
year=(time.tv_sec/SEC_PER_DAY/365)*365*SEC_PER_DAY;
tmp_year=year/SEC_PER_DAY/365+2;
year_len=100*SEC_PER_DAY*((tmp_year%4&&tmp_year!=32)?365:366);
switch (cpunumber) {
#if VAX750
case VAX_750:
mtpr((time.tv_sec-year)*100+1, PR_TODR);
break;
case VAX_750:
mtpr((time.tv_sec-year)*100+1, PR_TODR);
break;
#endif
#if VAX630 || VAX410
case VAX_78032:
uvaxII_settodr((time.tv_sec-year)*100+1);
break;
case VAX_78032:
uvaxII_settodr((time.tv_sec-year)*100+1);
break;
#endif
};
todrstopped=0;
};
todrstopped=0;
}
/*
@ -181,7 +188,7 @@ void resettodr(void) {
*/
int
todr()
{
{
int delaycnt, x = 4, y = 4;
static int todr_val;

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.8 1995/04/10 03:36:17 mycroft Exp $ */
/* $NetBSD: conf.c,v 1.9 1995/04/12 15:34:52 ragge Exp $ */
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
@ -50,111 +50,97 @@ int rawwrite __P((dev_t, struct uio *, int));
void swstrategy __P((struct buf *));
int ttselect __P((dev_t, int, struct proc *));
#define CHARDEV(open,close,read,write,ioctl,stop,reset,ttys,select,mmap,strat)\
{(int(*)(dev_t, int, int, struct proc *))open, \
(int(*)(dev_t, int, int, struct proc *))close, \
(int(*)(dev_t, struct uio *, int))read, \
(int(*)(dev_t, struct uio *, int))write, \
(int(*)(dev_t, u_long, caddr_t, int, struct proc *))ioctl, \
(int(*)(struct tty *, int))stop, \
(int(*)(int))reset, \
(struct tty **)ttys, \
(int(*)(dev_t, int, struct proc *))select, \
(int(*)())mmap, \
(void(*)(struct buf *))strat }
#ifndef LKM
#define lkmenodev enodev
#else
int lkmenodev();
#endif
#include "hp.h"
#include "hp.h" /* 0 */
bdev_decl(hp);
#include "tu.h"
bdev_decl(ht);
#include "rk.h"
bdev_decl(rk);
#include "te.h"
bdev_decl(tm);
#include "tmscp.h"
bdev_decl(tmscp);
#include "ts.h"
bdev_decl(ts);
#include "mu.h"
bdev_decl(mt);
#if 0 /* defined(VAX750) || defined(VAX730) */
#define NCTU 1
#else
#define NCTU 0
#endif
bdev_decl(tu);
#include "uda.h"
bdev_decl(uda);
/*#include "kra.h" */
#if 0
int kdbopen(),kdbstrategy(),kdbdump(),kdbsize();
#else
#define kdbopen enxio
#define kdbstrategy enxio
#define kdbdump enxio
#define kdbsize 0
#endif
#include "kdb.h"
bdev_decl(kdb);
#include "up.h"
bdev_decl(up);
#include "tj.h"
bdev_decl(ut);
#include "rb.h"
bdev_decl(idc);
#include "rx.h"
#if NFX > 0
int rxopen(),rxstrategy(),rxclose(),rxread(),rxwrite(),rxreset(),rxioctl();
#else
#define rxopen enxio
#define rxstrategy enxio
#define rxclose enxio
#define rxread enxio
#define rxwrite enxio
#define rxreset nullop
#define rxioctl enxio
#endif
bdev_decl(rx);
#include "uu.h"
#if NUU > 0
int uuopen(),uustrategy(),uuclose(),uureset(),uuioctl();
#else
#define uuopen enxio
#define uustrategy enxio
#define uuclose enxio
#define uureset nullop
#define uuioctl enxio
#endif
bdev_decl(uu);
#include "rl.h"
#if NRL > 0
int rlopen(),rlstrategy(),rlreset(),rldump(),rlsize();
#else
#define rlopen enxio
#define rlstrategy enxio
#define rlreset nullop
#define rldump enxio
#define rlsize 0
#endif
#include "np.h"
#if NNP > 0
int npopen(),npclose(),npread(),npwrite();
int npreset(),npioctl();
#else
#define npopen enxio
#define npclose enxio
#define npread enxio
#define npwrite enxio
#define npreset nullop
#define npioctl enxio
#endif
bdev_decl(rl);
struct bdevsw bdevsw[] =
{
bdev_disk_init(NHP,hp), /* 0: ??? */
bdev_notdef(), /* 1 */
bdev_disk_init(NHP,hp), /* 0: RP0?/RM0? */
bdev_tape_init(NTU,ht), /* 1: TU77 w/ TM03 */
bdev_disk_init(NUP,up), /* 2: SC-21/SC-31 */
bdev_disk_init(NRK,rk), /* 3: RK06/07 */
bdev_swap_init(), /* 4: swap pseudo-device */
bdev_tape_init(NTE,tm), /* 5: TM11/TE10 */
bdev_tape_init(NTS,ts), /* 6: TS11 */
bdev_tape_init(NMU,mt), /* 7: TU78 */
bdev_tape_init(NTU,tu), /* 8: TU58 */
bdev_disk_init(NUDA,uda), /* 9: ??? */
bdev_tape_init(NCTU,tu), /* 8: TU58 */
bdev_disk_init(NUDA,uda), /* 9: UDA50/RA?? */
bdev_tape_init(NTJ,ut), /* 10: TU45 */
bdec_disk_init(NRB,idc), /* 11: IDC (RB730) */
BLOCKDEV(rxopen,rxclose,rxstrategy,enodev,enodev,0,0), /* 12 */
BLOCKDEV(uuopen,uuclose,uustrategy,enodev,enodev,0,0), /* 13 */
BLOCKDEV(rlopen,nullop,rlstrategy,enodev,rldump,rlsize,0), /* 14 */
bdev_tape_init(NTMSCP,tmscp),
BLOCKDEV(kdbopen,nullop,kdbstrategy,enodev,kdbdump,kdbsize,0), /* 16 */
bdev_disk_init(NRB,idc), /* 11: IDC (RB730) */
bdev_disk_init(NRX,rx), /* 12: RX01/02 on unibus */
bdev_disk_init(NUU,uu), /* 13: ?? */
bdev_disk_init(NRL,rl), /* 14: RL01/02 */
bdev_tape_init(NTMSCP,tmscp), /* 15: TMSCP tape */
bdev_disk_init(NKDB,kdb), /* 16: KDB50/RA?? */
};
int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
@ -164,8 +150,9 @@ int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
*/
#include <dev/cons.h>
int gencnprobe(), gencninit(), gencngetc(), gencnputc();
void gencnprobe(), gencninit(), gencnputc();
int gencnopen(), gencnclose(), gencnwrite(), gencnread(), gencnioctl();
int gencngetc();
extern struct tty *gencntty[];
@ -212,6 +199,7 @@ cdev_decl(uda);
cdev_decl(up);
cdev_decl(ut);
cdev_decl(idc);
cdev_decl(fd);
#include "acc.h"
#if NACC > 0
@ -234,6 +222,19 @@ cdev_decl(dh);
#include "dmf.h"
cdev_decl(dmf);
#include "np.h"
#if NNP > 0
int npopen(),npclose(),npread(),npwrite();
int npreset(),npioctl();
#else
#define npopen enxio
#define npclose enxio
#define npread enxio
#define npwrite enxio
#define npreset nullop
#define npioctl enxio
#endif
#if VAX8600
int crlopen(),crlclose(),crlrw();
#else
@ -493,12 +494,10 @@ struct cdevsw cdevsw[] =
cdev_lkm_init(NLKM,lkm), /* 28: loadable module driver */
CHARDEV(adopen, adclose,enodev, enodev, /*29*/ adioctl, enodev,
adreset,NULL, seltrue, enodev, NULL),
CHARDEV(rxopen, rxclose,rxread, rxwrite,/*30*/ rxioctl, enodev,
rxreset,NULL, seltrue, enodev, NULL),
cdev_disk_init(NRX,rx), /* 30: RX01/02 on unibus */
CHARDEV(ikopen, ikclose,ikread, ikwrite,/*31*/ ikioctl, enodev,
ikreset,NULL, seltrue, enodev, NULL),
CHARDEV(rlopen, enodev, rawread,rawwrite,/*32*/ enodev, enodev,
rlreset,NULL, seltrue, enodev, rlstrategy),
cdev_disk_init(NRL,rl), /* 32: RL01/02 on unibus */
cdev_log_init(1,log), /* 33: /dev/klog */
cdev_tty_init(NDHU,dhu), /* 34: DHU-11 */
CHARDEV(crlopen,crlclose, crlrw, crlrw, /*35*/
@ -508,10 +507,12 @@ struct cdevsw cdevsw[] =
vsioctl, enodev, vsreset, NULL,
vsselect, enodev, NULL),
cdev_tty_init(NDMZ,dmz), /* 37: DMZ32 */
cdev_tape_init(NTMSCP,tmscp),
CHARDEV(npopen, npclose, npread, npwrite, /*39*/
npioctl, enodev, npreset, NULL,
seltrue, enodev, NULL),
cdev_tape_init(NTMSCP,tmscp), /* 38: TMSCP tape */
CHARDEV(npopen, npclose, npread, npwrite, /*39*/
npioctl, enodev, npreset, NULL,
seltrue, enodev, NULL),
CHARDEV(qvopen, qvclose, qvread, qvwrite, /*40*/
qvioctl, qvstop, qvreset, NULL,
qvselect, enodev, NULL),
@ -538,10 +539,7 @@ struct cdevsw cdevsw[] =
CHARDEV(rx50open,rx50close, rx50rw, rx50rw, /*51*/
enodev, enodev, nullop, 0,
seltrue, enodev, NULL),
/* kdb50 ra */
CHARDEV(kdbopen,nullop/*XXX*/, rawread, rawwrite, /*52*/
enodev, enodev, nullop, 0,
seltrue, enodev, kdbstrategy),
cdev_disk_init(NKDB,kdb), /* 52: KDB50/RA?? */
cdev_fd_init(1,fd), /* 53: file descriptor pseudo-device */
};
int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);

View File

@ -1,4 +1,4 @@
/* $NetBSD: intvec.s,v 1.7 1995/02/23 17:53:52 ragge Exp $ */
/* $NetBSD: intvec.s,v 1.8 1995/04/12 15:34:56 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -61,7 +61,7 @@
_kernbase:
INTVEC(stray00, ISTACK) # Unused., 0
INTVEC(mcheck, ISTACK) # Machine Check., 4
INTVEC(stray08, ISTACK) # Kernel Stack Invalid., 8
INTVEC(invkstk, ISTACK) # Kernel Stack Invalid., 8
INTVEC(stray0C, ISTACK) # Power Failed., C
INTVEC(privinflt, KSTACK) # Privileged/Reserved Instruction.
INTVEC(stray14, ISTACK) # Customer Reserved Instruction, 14
@ -162,7 +162,9 @@ mcheck: .globl mcheck
movl _memtest,(sp) # REI to new adress
rei
STRAY(0, 08)
.align 2
invkstk: chmk $8 # skould always halt.
/* STRAY(0, 08) */
STRAY(0, 0C)
TRAPCALL(privinflt, T_PRIVINFLT)

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.9 1995/04/10 16:49:22 mycroft Exp $ */
/* $NetBSD: machdep.c,v 1.10 1995/04/12 15:35:00 ragge Exp $ */
/* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* Copyright (c) 1993 Adam Glass
@ -71,6 +71,7 @@
#include "vax/include/macros.h"
#include "vax/include/nexus.h"
#include "vax/include/trap.h"
#include "machine/reg.h"
#include "net/netisr.h"
#ifdef SYSVMSG
#include "sys/msg.h"
@ -132,7 +133,7 @@ cpu_startup() {
*/
#if 0
for (i = 0; i < btoc(sizeof (struct msgbuf)); i++)
pmap_enter(pmap_kernel(), (vm_offset_t)msgbufp,
pmap_enter(kernel_pmap, (vm_offset_t)msgbufp,
avail_end + i * NBPG, VM_PROT_ALL, TRUE);
msgbufmapped = 1;
#endif
@ -507,12 +508,9 @@ boot(howto)
}
splhigh(); /* extreme priority */
if (howto&RB_HALT) {
int *i;
printf("halting (due to bad scbvector)\n");
/* This should halt almost every known VAX cpu */
i=(int *)0x80000008;
*i+=2;
asm("movl $0xf0000000,sp;pushl $0;chmk $3");
printf("halting (in tight loop); hit\n\t^P\n\tHALT\n\n");
for(;;)
;
} else {
if (howto & RB_DUMP)
dumpsys();
@ -614,6 +612,64 @@ suswintr(){
panic("suswintr: need to be implemented");
}
int
process_read_regs(p, regs)
struct proc *p;
struct reg *regs;
{
struct trapframe *tf=p->p_addr->u_pcb.framep;
regs->r0=tf->r0;
regs->r1=tf->r1;
regs->r2=tf->r2;
regs->r3=tf->r3;
regs->r4=tf->r4;
regs->r5=tf->r5;
#ifdef notyet
regs->r6=tf->r6;
regs->r7=tf->r7;
regs->r8=tf->r8;
regs->r9=tf->r9;
regs->r10=tf->r10;
regs->r11=tf->r11;
#endif
regs->ap=tf->ap;
regs->fp=tf->fp;
regs->sp=mfpr(PR_USP);
regs->pc=tf->pc;
regs->psl=tf->psl;
return 0;
}
int
process_write_regs(p, regs)
struct proc *p;
struct reg *regs;
{
struct trapframe *tf=p->p_addr->u_pcb.framep;
tf->r0=regs->r0;
tf->r1=regs->r1;
tf->r2=regs->r2;
tf->r3=regs->r3;
tf->r4=regs->r4;
tf->r5=regs->r5;
#ifdef notyet
tf->r6=regs->r6;
tf->r7=regs->r7;
tf->r8=regs->r8;
tf->r9=regs->r9;
tf->r10=regs->r10;
tf->r11=regs->r11;
#endif
tf->ap=regs->ap;
tf->fp=regs->fp;
mtpr(regs->sp,PR_USP);
tf->pc=regs->pc;
tf->psl=regs->psl;
return 0;
}
int
process_set_pc(p, addr)
struct proc *p;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rootfil.c,v 1.5 1995/03/30 21:25:32 ragge Exp $ */
/* $NetBSD: rootfil.c,v 1.6 1995/04/12 15:35:04 ragge Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -49,8 +49,8 @@
#include "buf.h"
#include "mbuf.h"
#include "vax/include/pte.h"
#include "uba.h"
#include "uda.h"
#include "uba.h"
#include "reboot.h"
#include "conf.h"
#include "vax/include/macros.h"
@ -154,17 +154,19 @@ setroot()
} else {
register struct uba_device *ubap;
for (ubap = ubdinit; ubap->ui_driver; ubap++)
for (ubap = ubdinit; ubap->ui_driver; ubap++){
printf("ubap %x\n",ubap);
if (ubap->ui_alive && ubap->ui_slave == unit &&
ubap->ui_ctlr == controller &&
ubap->ui_ubanum == adaptor &&
ubap->ui_driver->ud_dname[0] == devname[majdev][0] &&
ubap->ui_driver->ud_dname[1] == devname[majdev][1])
break;
}
if (ubap->ui_driver == 0)
return;
mindev = ubap->ui_unit;
printf("mindev %x, majdev %x\n",mindev,majdev);
#endif
}
mindev = (mindev << PARTITIONSHIFT) + part;

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr.s,v 1.7 1995/04/10 03:54:46 mycroft Exp $ */
/* $NetBSD: subr.s,v 1.8 1995/04/12 15:35:09 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -137,28 +137,7 @@ _badaddr: .word 0x0
5: mtpr (sp)+,$0x12
movl r3,r0
ret
#if 0
.align 2
_mba_0: .globl _mba_0
movl $0,mbanum
brb _mba
.align 2
_mba_1: .globl _mba_1
movl $1,mbanum
brb _mba
.align 2
_mba_2: .globl _mba_2
movl $2,mbanum
brb _mba
.align 2
_mba_3: .globl _mba_3
movl $3,mbanum
_mba: pushr $0xffff
pushl mbanum
calls $1,_mbainterrupt
popr $0xffff
rei
#endif
#
# copyin(from, to, len) copies from userspace to kernelspace.
#
@ -261,27 +240,6 @@ _loswtch: .globl _loswtch
ldpctx
rei
#if 0
.globl _savectx
_savectx:
clrl r0
svpctx
ldpctx
mtpr _p0lr,$PR_P0LR
mtpr _p0br,$PR_P0BR
mtpr _p1lr,$PR_P1LR
mtpr _p1br,$PR_P1BR
mfpr $PR_ESP,r0 # PR_ESP == start chld pcb
mtpr $0,$PR_ESP # Clear ESP, used in fault routine
clrl 4(r0) # Clear ESP in child
movl _ustat,(r0) # New kernel sp in chld
addl2 _uofset,68(r0) # set fp to new stack
movl _ustat,r0
movl (sp),(r0)
movl 4(sp),4(r0)
rei
#endif
.data
mbanum: .long 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.10 1995/03/30 21:25:51 ragge Exp $ */
/* $NetBSD: vm_machdep.c,v 1.11 1995/04/12 15:35:14 ragge Exp $ */
#undef SWDEBUG
/*
@ -52,24 +52,24 @@
volatile int whichqs;
extern u_int proc0paddr;
/*
* pagemove - moves pages at virtual address from to virtual address to,
* block moved of size size. Using fast insn bcopy for pte move.
*/
void
pagemove(from, to, size)
caddr_t from, to;
int size;
{
u_int *fpte, *tpte;
u_int *fpte, *tpte,stor;
fpte = kvtopte(from);
tpte = kvtopte(to);
while (size > 0) {
*tpte++ = *fpte;
*(int *)fpte++ = PG_NV;
mtpr(from,PR_TBIS);
mtpr(to,PR_TBIS);
from += NBPG;
to += NBPG;
size -= NBPG;
}
stor = (size/NBPG) * sizeof(struct pte);
bcopy(fpte,tpte,stor);
bzero(fpte,stor);
mtpr(0,PR_TBIA);
}
#define VIRT2PHYS(x) \