Be somewhat better at machine dependence, clean up a hair, and get rid

of addupc.
This commit is contained in:
briggs 1994-07-10 16:58:05 +00:00
parent f8d560f187
commit 5ec3485979
6 changed files with 416 additions and 428 deletions

View File

@ -73,7 +73,7 @@
* from: Utah $Hdr: clock.c 1.18 91/01/21$
*
* from: @(#)clock.c 7.6 (Berkeley) 5/7/91
* $Id: clock.c,v 1.5 1994/05/06 17:39:39 briggs Exp $
* $Id: clock.c,v 1.6 1994/07/10 16:58:05 briggs Exp $
*/
#if !defined(STANDALONE)
@ -249,7 +249,7 @@ void profclock(clockframe *pclk)
*/
if (USERMODE(pclk->ps)) {
if (p->p_stats.p_prof.pr_scale)
addupc(pclk->pc, &curproc->p_stats.p_prof, 1);
addupc_task(&curproc, pclk->pc, 1);
}
/*
* Came from kernel (supervisor) mode.

View File

@ -86,7 +86,7 @@
* from: Utah $Hdr: locore.s 1.58 91/04/22$
*
* from: @(#)locore.s 7.11 (Berkeley) 5/9/91
* $Id: locore.s,v 1.20 1994/07/09 06:33:46 briggs Exp $
* $Id: locore.s,v 1.21 1994/07/10 16:58:08 briggs Exp $
*/
#include "assym.s"
@ -546,6 +546,17 @@ Lsigr1:
* Level 5:
* Level 6:
* Level 7: Non-maskable: parity errors, RESET button, FOO key
*
* On the Q700, at least, in "A/UX mode," this should become:
*
* Level 0: Spurious: ignored
* Level 1: Software
* Level 2: VIA2 (except ethernet, sound)
* Level 3: Ethernet
* Level 4: Serial (SCC)
* Level 5: Sound
* Level 6: VIA1
* Level 7: NMIs: parity errors, RESET button, YANCC error
*/
/* BARF We must re-configure this. */
.globl _hardclock, _nmihand
@ -563,7 +574,7 @@ _lev1intr:
clrl sp@-
moveml #0xFFFF,sp@-
movl sp, sp@-
jbsr _via1_intr | ALICE: Used to be _hilint
jbsr _via1_intr
addql #4,sp
moveml sp@+,#0xFFFF
addql #4,sp
@ -600,42 +611,6 @@ _lev4intr:
/* MAJORBARF: Fix this routine to be like Mac clocks */
_rtclock_intr:
#ifdef PROFTIMER
.globl _profon
tstb _profon | profile clock on?
jeq Ltimer1 | no, then must be timer1 interrupt
btst #2,d0 | timer3 interrupt?
jeq Ltimer1 | no, must be timer1
movb a0@(CLKMSB3),d1 | clear timer3 interrupt
lea sp@(16),a1 | get pointer to PS
#ifdef GPROF
.globl _profclock
movl d0,sp@- | save status so jsr will not clobber
movl a1@,sp@- | push padded PS
movl a1@(4),sp@- | push PC
jbsr _profclock | profclock(pc, ps)
addql #8,sp | pop params
#else /* notdef GPROF */
btst #5,a1@(2) | saved PS in user mode?
jne Lttimer1 | no, go check timer1
movl _curpcb,a0 | current pcb
tstl a0@(U_PROFSCALE) | process being profiled?
jeq Lttimer1 | no, go check timer1
movl d0,sp@- | save status so jsr will not clobber
movl #1,sp@-
pea a0@(U_PROF)
movl a1@(4),sp@-
jbsr _addupc | addupc(pc, &u.u_prof, 1)
lea sp@(12),sp | pop params
#endif /* GPROF */
addql #1,_intrcnt+32 | add another profile clock interrupt
movl sp@+,d0 | get saved clock status
CLKADDR(a0)
Lttimer1:
btst #0,d0 | timer1 interrupt?
jeq Ltimend | no, check state of kernel profiling
Ltimer1:
#endif /* PROFTIMER */
movl a6@(8),a1 | get pointer to frame in via1_intr
movl a1@(64), sp@- | push ps
movl a1@(68), sp@- | push pc
@ -643,22 +618,9 @@ Ltimer1:
jbsr _hardclock | call generic clock int routine
lea sp@(12), sp | pop params
addql #1,_intrcnt+28 | add another system clock interrupt
#ifdef PROFTIMER
Ltimend:
#ifdef GPROF
.globl _profiling, _startprofclock
tstl _profiling | kernel profiling desired?
jne Ltimdone | no, all done
bset #7,_profon | mark continuous timing
jne Ltimdone | was already enabled, all done
jbsr _startprofclock | else turn it on
Ltimdone:
#endif /* GPROF */
#endif /* PROFTIMER */
addql #1,_cnt+V_INTR | chalk up another interrupt
/* BARF -- We should look at this "rei" crap. in any case, via1_intr */
/* goes back to it. */
movl #1, d0 | clock taken care of
rts | go back to lev1intr...
|jra rei | all done
@ -869,7 +831,6 @@ abouttouser:
.globl start
.globl _gray_bar
| .globl _macinit
.globl _root_scsi_id | CPC - for scsi id passed in on d7 from booter
.globl _serial_boot_echo
.globl _videoaddr, _videorowbytes
.globl _videobitdepth
@ -1189,7 +1150,7 @@ List2:
movl sp@,a1 | Get start of PM
movl sp@(4),a0 | and ST
movl #INTIOBASE,d1 | Find offset to IO space
movl _IOBase,d1 | Find offset to IO space
movl #SG_ISHIFT,d0
lsrl d0,d1 | Find which segment it is (/4M)
lsll #2,d1 | 4 bytes per PTE
@ -1311,8 +1272,6 @@ Lipt4:
cmpl a2,a0 | done yet?
jcs Lipt4 | no, keep going
/* record base KVA of IO spaces (they are mapped PA == VA) */
movl #INTIOBASE,d0
movl d0,_IOBase
movl #NBBASE,d0 | base of NuBus
movl d0,_NuBusBase | and record
| BARF: intiolimit is wrong:
@ -1678,44 +1637,6 @@ _esigcode:
#include "m68k/asm.h"
/*
* update profiling information for the user
* addupc(pc, &u.u_prof, ticks)
*/
ENTRY(addupc)
movl a2,sp@- | scratch register
movl sp@(12),a2 | get &u.u_prof
movl sp@(8),d0 | get user pc
subl a2@(8),d0 | pc -= pr->pr_off
jlt Lauexit | less than 0, skip it
movl a2@(12),d1 | get pr->pr_scale
lsrl #1,d0 | pc /= 2
lsrl #1,d1 | scale /= 2
mulul d1,d0 | pc /= scale
moveq #14,d1
lsrl d1,d0 | pc >>= 14
bclr #0,d0 | pc &= ~1
cmpl a2@(4),d0 | too big for buffer?
jge Lauexit | yes, screw it
addl a2@,d0 | no, add base
movl d0,sp@- | push address
jbsr _fusword | grab old value
movl sp@+,a0 | grab address back
cmpl #-1,d0 | access ok
jeq Lauerror | no, skip out
addw sp@(18),d0 | add tick to current value
movl d0,sp@- | push value
movl a0,sp@- | push address
jbsr _susword | write back new value
addql #8,sp | pop params
tstl d0 | fault?
jeq Lauexit | no, all done
Lauerror:
clrl a2@(12) | clear scale (turn off prof)
Lauexit:
movl sp@+,a2 | restore scratch reg
rts
/*
* non-local gotos
*/
@ -2737,7 +2658,7 @@ _doboot:
movw #PSL_HIGHIPL,sr | no interrupts
movl #CACHE_OFF,d0
movc d0,cacr | disable on-chip cache(s)
/* LAK: Store boothowto and bootdev somewhere */
lea longscratch,a0 | make sure we have real memory
movl #0,a0@ | value for pmove to TC (turn off MMU)
pmove a0@,tc | disable MMU

View File

@ -29,7 +29,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: mac68k_init.c,v 1.4 1994/07/04 22:44:24 briggs Exp $
* $Id: mac68k_init.c,v 1.5 1994/07/10 16:58:11 briggs Exp $
*
*/
@ -54,15 +54,10 @@ extern u_int Sysseg1;
extern u_long esym; /* Set in machdep.c:getenvvars() */
volatile unsigned char *Via1Base = (volatile unsigned char *) INTIOBASE;
unsigned long NuBusBase = NBBASE;
unsigned long IOBase = INTIOBASE;
int has5380scsi = 0; /* Set in setmachdep() */
int has53c96scsi = 0; /* Set in setmachdep() */
static u_int Sysseg1_pa;
extern volatile unsigned char *sccA;
extern volatile unsigned char *Via1Base;
extern unsigned char *ASCBase;
extern unsigned long videoaddr;
@ -118,7 +113,10 @@ extern void etext(); /* Okaaaaay... */
u_int p0_ptpa, p0_u_area_pa, i;
u_int sg_proto, pg_proto;
u_int *sg, *pg, *pg2;
u_int oldIOBase, oldNBBase;
oldIOBase = IOBase;
oldNBBase = NuBusBase;
/* init "tracking" values */
vend = get_top_of_ram();
avail = vend;
@ -286,7 +284,7 @@ extern void etext(); /* Okaaaaay... */
*/
pg -= ptextra;
pg2 = pg;
pg_proto = (INTIOBASE & PG_FRAME) | PG_RW | PG_CI | PG_V;
pg_proto = (IOBase & PG_FRAME) | PG_RW | PG_CI | PG_V;
while (pg_proto < INTIOTOP) {
*pg++ = pg_proto;
pg_proto += NBPG;
@ -379,7 +377,7 @@ extern void etext(); /* Okaaaaay... */
* Init mem sizes.
*/
maxmem = pend >> PGSHIFT;
physmem = (mach_memsize*1024*1024) >> PGSHIFT;
physmem = (mac68k_machine.mach_memsize*1024*1024) >> PGSHIFT;
/*
* Get the pmap module in sync with reality.
@ -416,10 +414,8 @@ extern void etext(); /* Okaaaaay... */
* Reset pointers that will be wrong, now.
* They are set this way to avoid blowing up the working MacII, et al.
*/
sccA = (volatile unsigned char *) ((u_int) sccA - INTIOBASE + IOBase);
Via1Base = (volatile unsigned char *)
((u_int) Via1Base - INTIOBASE + IOBase);
ASCBase = (unsigned char *) ((u_int) ASCBase - INTIOBASE + IOBase);
videoaddr = videoaddr - NBBASE + NuBusBase;
NewScreenAddress();
((u_int) Via1Base - oldIOBase + IOBase);
ASCBase = (unsigned char *) ((u_int) ASCBase - oldIOBase + IOBase);
videoaddr = videoaddr - oldNBBase + NuBusBase;
}

View File

@ -72,7 +72,7 @@
* from: Utah $Hdr: machdep.c 1.63 91/04/24$
*
* from: @(#)machdep.c 7.16 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.20 1994/07/09 06:36:11 briggs Exp $
* $Id: machdep.c,v 1.21 1994/07/10 16:58:13 briggs Exp $
*/
#include <param.h>
@ -129,10 +129,12 @@ vm_map_t buffer_map;
extern vm_offset_t avail_end;
int dbg_flg = 0;
int mach_processor;
int do_graybars;
int mach_memsize;
int booter_version;
struct mac68k_machine_S mac68k_machine;
volatile unsigned char *Via1Base;
unsigned long NuBusBase = NBBASE;
unsigned long IOBase;
extern unsigned long videoaddr;
extern unsigned long videorowbytes;
u_int cache_copyback = PG_CCB;
@ -165,6 +167,8 @@ extern int freebufspace;
void sun_sendsig();
#endif
static void identifycpu(void);
/*
* Console initialization: called early on from main,
* before vm init or startup. Do enough configuration
@ -403,83 +407,6 @@ setregs(p, entry, sp, retval)
#endif
}
char cpu_model[120];
identifycpu()
{
extern unsigned long bootdev, root_scsi_id,
videobitdepth, videosize;
char *mod, *proc;
switch (machineid) {
case MACH_MACII: mod = ("II "); break;
case MACH_MACIIX: mod = ("IIx "); break;
case MACH_MACIISI: mod = ("IIsi "); break;
case MACH_MACIICI: mod = ("IIci "); break;
case MACH_MACIICX: mod = ("IIcx "); break;
case MACH_MACIIFX: mod = ("IIfx "); break;
case MACH_MACSE30: mod = ("SE/30 "); break;
case MACH_MACQ700: mod = ("Quadra 700 "); break;
case MACH_MACQ900: mod = ("Quadra 900 "); break;
case MACH_MACPB140: mod = ("PowerBook 140 "); break;
case MACH_MACPB100: mod = ("PowerBook 100 "); break;
case MACH_MACPB170: mod = ("PowerBook 170 "); break;
case MACH_MACCLASSICII: mod = ("Classic II "); break;
case MACH_MACQ950: mod = ("Quadra 950 "); break;
case MACH_MACLCIII: mod = ("LC III "); break;
case MACH_MACPB210: mod = ("PowerBook 950 "); break;
case MACH_MACC650: mod = ("Centris 650 "); break;
case MACH_MACPB230: mod = ("PowerBook 230 "); break;
case MACH_MACPB180: mod = ("PowerBook 180 "); break;
case MACH_MACPB160: mod = ("PowerBook 160 "); break;
case MACH_MACQ800: mod = ("Quadra 800 "); break;
case MACH_MACQ650: mod = ("Quadra 650 "); break;
case MACH_MACLCII: mod = ("LC II "); break;
case MACH_MACPB250: mod = ("PowerBook 250 "); break;
case MACH_MACIIVI: mod = ("IIvi "); break;
case MACH_MACP600: mod = ("Performa 600 "); break;
case MACH_MACIIVX: mod = ("IIvx "); break;
case MACH_MACCCLASSIC: mod = ("Classic "); break;
case MACH_MACPB165C: mod = ("PowerBook 165c "); break;
case MACH_MACC610: mod = ("Centris 610 "); break;
case MACH_MACQ610: mod = ("Quadra 610 "); break;
case MACH_MACPB145: mod = ("PowerBook 950 "); break;
case MACH_MACLC520: mod = ("LC 520 "); break;
case MACH_MACC660AV: mod = ("Centris 660AV "); break;
case MACH_MACP460: mod = ("Performa 460 "); break;
case MACH_MACPB180C: mod = ("PowerBook 180c "); break;
case MACH_MACPB270: mod = ("PowerBook 270 "); break;
case MACH_MACQ840AV: mod = ("Quadra 840AV "); break;
case MACH_MACP550: mod = ("Performa 550 "); break;
case MACH_MACPB165: mod = ("PowerBook 165 "); break;
case MACH_MACTV: mod = ("TV "); break;
case MACH_MACLC475: mod = ("LC 475 "); break;
case MACH_MACLC575: mod = ("LC 575 "); break;
case MACH_MACQ605: mod = ("Quadra 605 "); break;
default:
printf("Pentium (gestalt %d) ", machineid);
break;
}
switch(mach_processor) {
case MACH_68020:
proc = ("(68020)");
break;
case MACH_68030:
proc = ("(68030)");
break;
case MACH_68040:
proc = ("(68040)");
break;
case MACH_PENTIUM:
default:
proc = ("");
break;
}
sprintf(cpu_model, "Apple Macintosh %s %s", mod, proc);
printf ("%s\n", cpu_model);
}
#define SS_RTEFRAME 1
#define SS_FPSTATE 2
#define SS_USERREGS 4
@ -1540,70 +1467,6 @@ hexstr(val, len)
return(nbuf);
}
static unsigned long gray_nextaddr = 0;
void gray_bar2()
{
static int i=0;
static int flag=0;
/* Same premise as gray_bar, but bigger. Gives a quicker check of
where we are while debugging. */
asm("movl a0, sp@-");
asm("movl a1, sp@-");
asm("movl d0, sp@-");
asm("movl d1, sp@-");
/* check to see if gray bars are turned off */
if (do_graybars) {
/* MF the 10*rowbytes is done lots, but we want this to be slow */
for(i = 0; i < 10*videorowbytes; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0xaaaaaaaa;
for(i = 0; i < 2*videorowbytes; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0x00000000;
}
asm("movl sp@+, d1");
asm("movl sp@+, d0");
asm("movl sp@+, a1");
asm("movl sp@+, a0");
}
void gray_bar()
{
static int i=0;
static int flag=0;
/* MF basic premise as I see it:
1) Save the scratch regs as they are not saved by the compilier.
2) Check to see if we want gray bars, if so,
display some lines of gray,
a couple of lines of white(about 8),
and loop to slow this down.
3) restore regs
*/
asm("movl a0, sp@-");
asm("movl a1, sp@-");
asm("movl d0, sp@-");
asm("movl d1, sp@-");
/* check to see if gray bars are turned off */
if (do_graybars) {
/* MF the 10*rowbytes/4 is done lots, but we want this to be slow */
for(i = 0; i < 10*videorowbytes/4; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0xaaaaaaaa;
for(i = 0; i < 2*videorowbytes/4; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0x00000000;
}
asm("movl sp@+, d1");
asm("movl sp@+, d0");
asm("movl sp@+, a1");
asm("movl sp@+, a0");
}
#if 0
extern void macserputchar(unsigned char c);
#endif
@ -1840,7 +1703,7 @@ int get_top_of_ram(void)
unsigned long i, found, store;
char *p, *zero;
return((mach_memsize * MEGABYTE) - 4096);
return((mac68k_machine.mach_memsize * MEGABYTE) - 4096);
#if TESTING /* Why doesn't any of this code work? */
found = 0;
@ -1959,6 +1822,38 @@ int alice_debug(p, uap, retval)
return(0);
}
/*
* machine dependent system variables.
*/
cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
int *name;
u_int namelen;
void *oldp;
size_t *oldlenp;
void *newp;
size_t newlen;
struct proc *p;
{
dev_t consdev;
/* all sysctl names at this level are terminal */
if (namelen != 1)
return (ENOTDIR); /* overloaded */
switch (name[0]) {
case CPU_CONSDEV:
if (cn_tab != NULL)
consdev = cn_tab->cn_dev;
else
consdev = NODEV;
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
sizeof consdev));
default:
return (EOPNOTSUPP);
}
/* NOTREACHED */
}
cpu_exec_aout_makecmds(p, epp)
struct proc *p;
struct exec_package *epp;
@ -2080,7 +1975,7 @@ void ddprintf (char *fmt, int val)
#if 0
char buf[128], *s;
if (!serial_boot_echo) return;
if (!mac68k_machine.serial_boot_echo) return;
sprintf (buf, fmt, val);
for (s = buf; *s; s++) {
macserputchar (*s);
@ -2096,7 +1991,7 @@ void dddprintf (char *fmt, int val1, int val2)
#if 0
char buf[128], *s;
if (!serial_boot_echo) return;
if (!mac68k_machine.serial_boot_echo) return;
sprintf (buf, fmt, val1, val2);
for (s = buf; *s; s++) {
macserputchar (*s);
@ -2189,161 +2084,311 @@ static long getenv (char *str)
}
}
void getenvvars (void)
struct cpu_model_info {
int machineid; /* MacOS Gestalt value. */
char *model_major; /* Make this distinction to save a few */
char *model_minor; /* bytes--might be useful, too. */
int class; /* Rough class of machine. */
} cpu_models[] = {
/* The first four. */
{ MACH_MACII, "II ", "", MACH_CLASSII },
{ MACH_MACIIX, "IIx ", "", MACH_CLASSII },
{ MACH_MACIICX, "IIcx ", "", MACH_CLASSII },
{ MACH_MACSE30, "SE/30 ", "", MACH_CLASSII },
/* The rest of the II series... */
{ MACH_MACIICI, "IIci ", "", MACH_CLASSIIci },
{ MACH_MACIISI, "IIsi ", "", MACH_CLASSIIci },
{ MACH_MACIIVI, "IIvi ", "", MACH_CLASSIIci },
{ MACH_MACIIVX, "IIvx ", "", MACH_CLASSIIci },
{ MACH_MACIIFX, "IIfx ", "", MACH_CLASSIIfx },
/* The Centris/Quadra series. */
{ MACH_MACQ700, "Quadra", " 700 ", MACH_CLASSQ },
{ MACH_MACQ900, "Quadra", " 900 ", MACH_CLASSQ },
{ MACH_MACQ950, "Quadra", " 950 ", MACH_CLASSQ },
{ MACH_MACQ800, "Quadra", " 800 ", MACH_CLASSQ },
{ MACH_MACQ650, "Quadra", " 650 ", MACH_CLASSQ },
{ MACH_MACC650, "Centris", " 650 ", MACH_CLASSQ },
{ MACH_MACQ605, "Quadra", " 605", MACH_CLASSQ },
{ MACH_MACC610, "Centris", " 610 ", MACH_CLASSQ },
{ MACH_MACQ610, "Quadra", " 610 ", MACH_CLASSQ },
{ MACH_MACC660AV, "Centris", " 660AV ", MACH_CLASSQ },
{ MACH_MACQ840AV, "Quadra", " 840AV ", MACH_CLASSQ },
/* The Powerbooks/Duos... */
{ MACH_MACPB100, "PowerBook", " 100 ", MACH_CLASSPB },
{ MACH_MACPB140, "PowerBook", " 140 ", MACH_CLASSPB },
{ MACH_MACPB145, "PowerBook", " 145 ", MACH_CLASSPB },
{ MACH_MACPB160, "PowerBook", " 160 ", MACH_CLASSPB },
{ MACH_MACPB165, "PowerBook", " 165 ", MACH_CLASSPB },
{ MACH_MACPB165C, "PowerBook", " 165c ", MACH_CLASSPB },
{ MACH_MACPB170, "PowerBook", " 170 ", MACH_CLASSPB },
{ MACH_MACPB180, "PowerBook", " 180 ", MACH_CLASSPB },
{ MACH_MACPB180C, "PowerBook", " 180c ", MACH_CLASSPB },
{ MACH_MACPB210, "PowerBook", " 210 ", MACH_CLASSPB },
{ MACH_MACPB230, "PowerBook", " 230 ", MACH_CLASSPB },
{ MACH_MACPB250, "PowerBook", " 250 ", MACH_CLASSPB },
{ MACH_MACPB270, "PowerBook", " 270 ", MACH_CLASSPB },
/* The Performas... */
{ MACH_MACP600, "Performa", " 600 ", MACH_CLASSLC },
{ MACH_MACP460, "Performa", " 460 ", MACH_CLASSLC },
{ MACH_MACP550, "Performa", " 550 ", MACH_CLASSLC },
/* The LCs... */
{ MACH_MACLCII, "LC", " II ", MACH_CLASSLC },
{ MACH_MACLCIII, "LC", " III ", MACH_CLASSLC },
{ MACH_MACLC475, "LC", " 475 ", MACH_CLASSLC },
{ MACH_MACLC520, "LC", " 520 ", MACH_CLASSLC },
{ MACH_MACLC575, "LC", " 575 ", MACH_CLASSLC },
/* Does this belong here? */
{ MACH_MACCLASSICII, "Classic", " II ", MACH_CLASSLC },
/* The hopeless ones... */
{ MACH_MACCCLASSIC, "Classic ", "", MACH_CLASSH },
{ MACH_MACTV, "TV ", "", MACH_CLASSH },
/* The unknown one and the end... */
{ 0, "Unknown", "", MACH_CLASSII},
{ 0, NULL, NULL, 0 },
}; /* End of cpu_models[] initialization. */
char cpu_model[120]; /* for sysctl */
static void
identifycpu(void)
{
/* LAK: Grab a few useful variables */
char *proc;
extern unsigned long bootdev, root_scsi_id, videobitdepth, videosize;
extern unsigned long end, esym;
switch(mac68k_machine.mach_processor) {
case MACH_68020:
proc = ("(68020)");
break;
case MACH_68030:
proc = ("(68030)");
break;
case MACH_68040:
proc = ("(68040)");
break;
case MACH_PENTIUM:
default:
proc = ("(unknown processor)");
break;
}
sprintf(cpu_model, "Apple Macintosh %s%s %s",
cpu_models[mac68k_machine.cpu_model_index].model_major,
cpu_models[mac68k_machine.cpu_model_index].model_minor,
proc);
printf("%s\n", cpu_model);
}
static void
get_machine_info(void)
{
char *proc;
int i;
for (i=0 ; cpu_models[i].model_major ; i++) {
if (mac68k_machine.machineid == cpu_models[i].machineid)
break;
}
if (cpu_models[i].model_major == NULL)
i--;
switch(mac68k_machine.mach_processor) {
case MACH_68040:
cpu040 = 1;
break;
case MACH_68020:
case MACH_68030:
case MACH_PENTIUM:
default:
cpu040 = 0;
break;
}
mac68k_machine.cpu_model_index = i;
}
/*
* getenvvars: Grab a few useful variables
*/
extern void
getenvvars (void)
{
extern unsigned long bootdev, videobitdepth, videosize;
extern unsigned long end, esym;
int root_scsi_id;
root_scsi_id = getenv ("ROOT_SCSI_ID");
/*
* For now, we assume that the boot device is off the first controller.
*/
bootdev = (root_scsi_id << 16) | 4;
bootdev = root_scsi_id = getenv ("ROOT_SCSI_ID");
bootdev = (bootdev << 16) | 4; /* This is wrong for non-scsi-id */
/* bootdev... */
boothowto = getenv ("SINGLE_USER");
videoaddr = getenv ("VIDEO_ADDR");
/* These next two should give us mapped video & serial */
/* We need these for pre-mapping graybars & echo, but probably */
/* only on MacII or LC. */
/* These next two should give us mapped video & serial */
/* We need these for pre-mapping graybars & echo, but probably */
/* only on MacII or LC. -- XXX */
/* videoaddr = getenv("MACOS_VIDEO"); */
/* sccaddr = getenv("MACOS_SCC"); */
/*
* The following are not in a structure so that they can be
* accessed more quickly.
*/
videoaddr = getenv ("VIDEO_ADDR");
videorowbytes = getenv ("ROW_BYTES");
videobitdepth = getenv ("SCREEN_DEPTH");
videosize = getenv ("DIMENSIONS");
/* New info stuff */
machineid = getenv("MACHINEID");
mach_processor = getenv("PROCESSOR");
mach_memsize = getenv("MEMSIZE");
do_graybars = getenv("GRAYBARS");
serial_boot_echo = getenv("SERIALECHO");
/*
* More misc stuff from booter.
*/
mac68k_machine.machineid = getenv("MACHINEID");
mac68k_machine.mach_processor = getenv("PROCESSOR");
mac68k_machine.mach_memsize = getenv("MEMSIZE");
mac68k_machine.do_graybars = getenv("GRAYBARS");
mac68k_machine.serial_boot_echo = getenv("SERIALECHO");
/* Should probably check this and fail if old */
booter_version = getenv("BOOTERVER");
mac68k_machine.booter_version = getenv("BOOTERVER");
/*
* Get end of symbols for kernel debugging
*/
esym = getenv("END_SYM");
if (esym == 0) esym = (long) &end;
}
void printenvvars (void)
{
extern unsigned long bootdev, root_scsi_id, videobitdepth, videosize;
extern unsigned long bootdev, videobitdepth, videosize;
ddprintf ("bootdev = %u\n\r", (int)bootdev);
ddprintf ("root_scsi_id = %u\n\r", (int)root_scsi_id);
ddprintf ("boothowto = %u\n\r", (int)boothowto);
ddprintf ("videoaddr = %u\n\r", (int)videoaddr);
ddprintf ("videorowbytes = %u\n\r", (int)videorowbytes);
ddprintf ("videobitdepth = %u\n\r", (int)videobitdepth);
ddprintf ("videosize = %u\n\r", (int)videosize);
ddprintf ("machineid = %u\n\r", (int)machineid);
ddprintf ("processor = %u\n\r", (int)mach_processor);
ddprintf ("memsize = %u\n\r", (int)mach_memsize);
ddprintf ("graybars = %u\n\r", (int)do_graybars);
ddprintf ("serial echo = %u\n\r", (int)serial_boot_echo);
ddprintf ("machineid = %u\n\r", (int)mac68k_machine.machineid);
ddprintf ("processor = %u\n\r", (int)mac68k_machine.mach_processor);
ddprintf ("memsize = %u\n\r", (int)mac68k_machine.mach_memsize);
ddprintf ("graybars = %u\n\r", (int)mac68k_machine.do_graybars);
ddprintf ("serial echo = %u\n\r", (int)mac68k_machine.serial_boot_echo);
}
extern long (*via1itab[7])();
extern long adb_intr_II(void);
extern long adb_intr_SI(void);
extern long adb_intr_PB(void);
extern volatile unsigned char *sccA;
extern int sccClkConst;
extern int has5380scsi;
extern int has53c96scsi;
/* BG 1/2/94 */
/*
* Sets a bunch of machine-specific variables
*/
void
setmachdep(void)
{
static int firstpass = 1;
struct cpu_model_info *cpui;
/* Sets a bunch of machine-specific variables */
/* First, set things that need to be set on the first pass only */
/* Ideally, we'd only call this once, but for some reason, the */
/* VIAs need interrupts turned off twice !? */
/*
* First, set things that need to be set on the first pass only
* Ideally, we'd only call this once, but for some reason, the
* VIAs need interrupts turned off twice !?
*/
if (firstpass) {
load_addr = 0;
get_machine_info();
has5380scsi = 1;
has53c96scsi = 0;
load_addr = 0;
}
/* Set up any machine specific stuff that we have to before */
/* ANYTHING else happens */
switch(machineid){ /* remove bit overlap */
case MACH_MACII:
case MACH_MACSE30:
case MACH_MACIIX:
case MACH_MACIICX:
case MACH_MACLCII:
VIA2 = 1;
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */
via1itab[2] = adb_intr_II;
break;
case MACH_MACPB140:
case MACH_MACPB170:
VIA2 = 1;
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */
via1itab[2] = adb_intr_PB;
break;
case MACH_MACIICI:
VIA2 = 0x13;
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */
/*
* LAK: Find out if internal video is on. If yes, then
* we loaded in bank B. We need a better way to determine
* this, like use the TT0 register.
*/
if (rbv_vidstatus ()) {
load_addr = 0x04000000;
}
via1itab[2] = adb_intr_II;
sccClkConst = 122400;
break;
case MACH_MACIISI: /* I'm really not sure about IIsi. */
VIA2 = 0x13;
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */
/*
* LAK: Find out if internal video is on. If yes, then
* we loaded in bank B. We need a better way to determine
* this, like use the TT0 register.
*/
if (rbv_vidstatus ()) {
load_addr = 0x04000000;
}
via1itab[2] = adb_intr_SI;
sccClkConst = 122400;
break;
case MACH_MACQ700:
case MACH_MACQ900: /* Maybe? */
case MACH_MACC610: /* Maybe? */
case MACH_MACQ610: /* Maybe? */
cpu040 = 1;
VIA2 = 0x1;
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */
cpui = &(cpu_models[mac68k_machine.cpu_model_index]);
/*
* Set up any machine specific stuff that we have to before
* ANYTHING else happens
*/
switch(cpui->class){ /* Base this on class of machine... */
case MACH_CLASSII:
if (firstpass) {
via1itab[2] = adb_intr_II;
sccA = IOBase + 0xc000;
sccClkConst = 249600;
has5380scsi = 0;
has53c96scsi = 1;
VIA2 = 1;
IOBase = 0x50000000;
Via1Base = (volatile u_char *) IOBase;
sccA = (volatile u_char *) 0x4000;
mac68k_machine.scsi80 = 1;
mac68k_machine.sccClkConst = 115200;
}
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */
break;
case MACH_MACCLASSICII:
VIA2 = 0x13;
case MACH_CLASSPB:
if (firstpass) {
VIA2 = 1;
IOBase = 0x50000000;
Via1Base = (volatile u_char *) IOBase;
sccA = (volatile u_char *) 0x4000;
mac68k_machine.scsi80 = 1;
mac68k_machine.sccClkConst = 115200;
}
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */
break;
case MACH_CLASSQ:
if (firstpass) {
VIA2 = 1;
IOBase = 0x50f00000;
Via1Base = (volatile u_char *) IOBase;
sccA = (volatile u_char *) 0xc000;
mac68k_machine.scsi96 = 1;
mac68k_machine.sccClkConst = 249600;
}
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */
break;
case MACH_CLASSIIci:
if (firstpass) {
VIA2 = 0x13;
IOBase = 0x50000000;
Via1Base = (volatile u_char *) IOBase;
sccA = (volatile u_char *) 0x4000;
mac68k_machine.scsi80 = 1;
mac68k_machine.sccClkConst = 122400;
/*
* LAK: Find out if internal video is on. If yes, then
* we loaded in bank B. We need a better way to
* determine this, like use the TT0 register.
*/
if (rbv_vidstatus ()) {
load_addr = 0x04000000;
}
}
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */
break;
case MACH_CLASSLC:
if (firstpass) {
VIA2 = 0x13;
IOBase = 0x50000000;
Via1Base = (volatile u_char *) IOBase;
sccA = (volatile u_char *) 0x4000;
mac68k_machine.scsi80 = 1;
mac68k_machine.sccClkConst = 122400;
/*
* LAK: Find out if internal video is on. If yes, then
* we loaded in bank B. We need a better way to
* determine this, like use the TT0 register.
*/
if (rbv_vidstatus ()) {
load_addr = 0x04000000;
}
}
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */
via1itab[2] = adb_intr_SI;
break;
default:
/* For any other machine, I have no idea how to handle it! */
VIA2 = 0x13; /* Is it the same as RBV?? */
via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */
via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */
via1itab[2] = adb_intr_SI;
case MACH_CLASSH:
case MACH_CLASSIIfx:
break;
}
firstpass = 0;
@ -2433,34 +2478,68 @@ unsigned long getphysical (unsigned long tc, unsigned long pte,
return pte;
}
/*
* machine dependent system variables.
*/
cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
int *name;
u_int namelen;
void *oldp;
size_t *oldlenp;
void *newp;
size_t newlen;
struct proc *p;
static unsigned long gray_nextaddr = 0;
void
gray_bar2(void)
{
dev_t consdev;
static int i=0;
static int flag=0;
/* all sysctl names at this level are terminal */
if (namelen != 1)
return (ENOTDIR); /* overloaded */
/* Same premise as gray_bar, but bigger. Gives a quicker check of
where we are while debugging. */
switch (name[0]) {
case CPU_CONSDEV:
if (cn_tab != NULL)
consdev = cn_tab->cn_dev;
else
consdev = NODEV;
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
sizeof consdev));
default:
return (EOPNOTSUPP);
}
/* NOTREACHED */
asm("movl a0, sp@-");
asm("movl a1, sp@-");
asm("movl d0, sp@-");
asm("movl d1, sp@-");
/* check to see if gray bars are turned off */
if (mac68k_machine.do_graybars) {
/* MF the 10*rowbytes is done lots, but we want this to be slow */
for(i = 0; i < 10*videorowbytes; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0xaaaaaaaa;
for(i = 0; i < 2*videorowbytes; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0x00000000;
}
asm("movl sp@+, d1");
asm("movl sp@+, d0");
asm("movl sp@+, a1");
asm("movl sp@+, a0");
}
void
gray_bar(void)
{
static int i=0;
static int flag=0;
/* MF basic premise as I see it:
1) Save the scratch regs as they are not saved by the compilier.
2) Check to see if we want gray bars, if so,
display some lines of gray,
a couple of lines of white(about 8),
and loop to slow this down.
3) restore regs
*/
asm("movl a0, sp@-");
asm("movl a1, sp@-");
asm("movl d0, sp@-");
asm("movl d1, sp@-");
/* check to see if gray bars are turned off */
if (mac68k_machine.do_graybars) {
/* MF the 10*rowbytes/4 is done lots, but we want this to be slow */
for(i = 0; i < 10*videorowbytes/4; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0xaaaaaaaa;
for(i = 0; i < 2*videorowbytes/4; i++)
((unsigned long *)videoaddr)[gray_nextaddr++] = 0x00000000;
}
asm("movl sp@+, d1");
asm("movl sp@+, d0");
asm("movl sp@+, a1");
asm("movl sp@+, a0");
}

View File

@ -38,7 +38,7 @@
* from: Utah $Hdr: trap.c 1.32 91/04/06$
*
* @(#)trap.c 7.15 (Berkeley) 8/2/91
* $Id: trap.c,v 1.13 1994/06/26 13:05:33 briggs Exp $
* $Id: trap.c,v 1.14 1994/07/10 16:58:15 briggs Exp $
*/
#include <sys/param.h>
@ -593,8 +593,8 @@ trap(type, code, v, frame)
spl0();
#ifndef PROFTIMER
if ((p->p_flag & P_OWEUPC) && p->p_stats->p_prof.pr_scale) {
addupc(frame.f_pc, &p->p_stats->p_prof, 1);
p->p_flag &= ~P_OWEUPC;
ADDUPROF(p);
}
#endif
userret(p, frame.f_pc, sticks);

View File

@ -36,20 +36,19 @@
* This code handles both the VIA and RBV functionality.
*/
#include "sys/param.h"
#include "machine/frame.h"
#include <sys/param.h>
#include <machine/cpu.h>
#include <machine/frame.h>
#include "via.h"
#include "kernel.h"
/* #include "stand.h" */
#include <sys/kernel.h>
static int scsi_drq_intr(void), scsi_irq_intr(void);
long via1_noint(), via2_noint();
long adb_intr_II(), rtclock_intr(), profclock();
long nubus_intr();
int slot_noint();
int VIA2 = 1; /* default for II, IIx, IIcx, SE/30. */
long adb_intr_PB();
long via1_noint(), via2_noint();
long adb_intr(), rtclock_intr(), profclock();
long nubus_intr();
int slot_noint();
int VIA2 = 1; /* default for II, IIx, IIcx, SE/30. */
long via1_spent[2][7]={
{0,0,0,0,0,0,0},
@ -59,27 +58,22 @@ long via1_spent[2][7]={
long (*via1itab[7])()={
via1_noint,
via1_noint,
adb_intr_II,
adb_intr,
via1_noint,
via1_noint,
via1_noint,
rtclock_intr,
}; /* VIA1 interrupt handler table */
}; /* VIA1 interrupt handler table */
long (*via2itab[7])()={
scsi_drq_intr,
(long (*)()) scsi_drq_intr,
nubus_intr,
adb_intr_PB, /* BARF BARF BARF - BG on hunch */
scsi_irq_intr,
via2_noint,
(long (*)()) scsi_irq_intr,
via2_noint, /* snd_intr */
via2_noint, /* via2t2_intr */
#if defined(GPROF) && defined(PROFTIMER)
/* profclock, we don't have the right parameters for this. */
via2_noint,
#else
via2_noint,
#endif
}; /* VIA2 interrupt handler table */
}; /* VIA2 interrupt handler table */
static int via_inited=0;
@ -345,15 +339,13 @@ int rbv_vidstatus(void)
return(montype);
}
extern int has53c96scsi,has5380scsi;
static int
scsi_irq_intr(void)
{
if (has53c96scsi) {
if (mac68k_machine.scsi96) {
if (ncr53c96_irq_intr()) return 1;
}
if (has5380scsi) {
if (mac68k_machine.scsi80) {
if (ncr5380_irq_intr()) return 1;
}
return 0;
@ -362,10 +354,10 @@ scsi_irq_intr(void)
static int
scsi_drq_intr(void)
{
if (has53c96scsi) {
if (mac68k_machine.scsi96) {
if (ncr53c96_drq_intr()) return 1;
}
if (has5380scsi) {
if (mac68k_machine.scsi80) {
if (ncr5380_drq_intr()) return 1;
}
return 0;