cleanup, one time compile with -Wall, include systm.h
conversion to new asm.h, removal of ALTENTRY(), ENTRY() pairs replaced by TWOENTRY(). moved idprom fetching stuff to sun3_startup bug fixes to pmap added to sun3_startup.c support for initializing the vm layout, and for verifying the hardware vs the -Ds from config(8) still doesn't link. but list is much shorter, and much stupider
This commit is contained in:
parent
58e4b64f4d
commit
2ba88bc252
|
@ -224,8 +224,7 @@ Lcoflt:
|
|||
/*
|
||||
* {fu,su},{byte,sword,word}
|
||||
*/
|
||||
ALTENTRY(fuiword, _fuword)
|
||||
ENTRY(fuword)
|
||||
TWOENTRY(fuword,fuiword)
|
||||
movl sp@(4),a0 | address to read
|
||||
movl _curpcb,a1 | current pcb
|
||||
movl #Lfserr,a1@(PCB_ONFAULT) | where to return to on a fault
|
||||
|
@ -240,8 +239,7 @@ ENTRY(fusword)
|
|||
movsw a0@,d0 | do read from user space
|
||||
jra Lfsdone
|
||||
|
||||
ALTENTRY(fuibyte, _fubyte)
|
||||
ENTRY(fubyte)
|
||||
TWOENTRY(fubyte,fuibyte)
|
||||
movl sp@(4),a0 | address to read
|
||||
movl _curpcb,a1 | current pcb
|
||||
movl #Lfserr,a1@(PCB_ONFAULT) | where to return to on a fault
|
||||
|
@ -255,8 +253,7 @@ Lfsdone:
|
|||
clrl a1@(PCB_ONFAULT) | clear fault address
|
||||
rts
|
||||
|
||||
ALTENTRY(suiword, _suword)
|
||||
ENTRY(suword)
|
||||
TWOENTRY(suword,suiword)
|
||||
movl sp@(4),a0 | address to write
|
||||
movl sp@(8),d0 | value to put there
|
||||
movl _curpcb,a1 | current pcb
|
||||
|
@ -274,8 +271,7 @@ ENTRY(susword)
|
|||
moveq #0,d0 | indicate no fault
|
||||
jra Lfsdone
|
||||
|
||||
ALTENTRY(suibyte, _subyte)
|
||||
ENTRY(subyte)
|
||||
TWOENTRY(subyte,suibyte)
|
||||
movl sp@(4),a0 | address to write
|
||||
movb sp@(11),d0 | value to put there
|
||||
movl _curpcb,a1 | current pcb
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
* machine-dependent clock routines; intersil7170
|
||||
* by Adam Glass
|
||||
*
|
||||
* $Header: /cvsroot/src/sys/arch/sun3/sun3/clock.c,v 1.4 1993/06/27 00:46:09 glass Exp $
|
||||
* $Header: /cvsroot/src/sys/arch/sun3/sun3/clock.c,v 1.5 1993/08/02 02:08:25 glass Exp $
|
||||
*/
|
||||
|
||||
#include "systm.h"
|
||||
#include "param.h"
|
||||
#include "kernel.h"
|
||||
#include "intersil7170.h"
|
||||
|
@ -132,7 +133,6 @@ struct timeval intersil_to_timeval()
|
|||
void inittodr(base)
|
||||
time_t base;
|
||||
{
|
||||
int s;
|
||||
struct timeval clock_time;
|
||||
long diff_time;
|
||||
void resettodr();
|
||||
|
|
|
@ -1 +1 @@
|
|||
revision 1.3 intentionally removed
|
||||
revision 1.4 intentionally removed
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
* cons.c,v 1.2 1993/05/22 07:57:18 cgd Exp
|
||||
*/
|
||||
|
||||
#include "systm.h"
|
||||
#include "sys/param.h"
|
||||
#include "sys/proc.h"
|
||||
#include "sys/systm.h"
|
||||
|
|
|
@ -224,8 +224,7 @@ Lcoflt:
|
|||
/*
|
||||
* {fu,su},{byte,sword,word}
|
||||
*/
|
||||
ALTENTRY(fuiword, _fuword)
|
||||
ENTRY(fuword)
|
||||
TWOENTRY(fuword,fuiword)
|
||||
movl sp@(4),a0 | address to read
|
||||
movl _curpcb,a1 | current pcb
|
||||
movl #Lfserr,a1@(PCB_ONFAULT) | where to return to on a fault
|
||||
|
@ -240,8 +239,7 @@ ENTRY(fusword)
|
|||
movsw a0@,d0 | do read from user space
|
||||
jra Lfsdone
|
||||
|
||||
ALTENTRY(fuibyte, _fubyte)
|
||||
ENTRY(fubyte)
|
||||
TWOENTRY(fubyte,fuibyte)
|
||||
movl sp@(4),a0 | address to read
|
||||
movl _curpcb,a1 | current pcb
|
||||
movl #Lfserr,a1@(PCB_ONFAULT) | where to return to on a fault
|
||||
|
@ -255,8 +253,7 @@ Lfsdone:
|
|||
clrl a1@(PCB_ONFAULT) | clear fault address
|
||||
rts
|
||||
|
||||
ALTENTRY(suiword, _suword)
|
||||
ENTRY(suword)
|
||||
TWOENTRY(suword,suiword)
|
||||
movl sp@(4),a0 | address to write
|
||||
movl sp@(8),d0 | value to put there
|
||||
movl _curpcb,a1 | current pcb
|
||||
|
@ -274,8 +271,7 @@ ENTRY(susword)
|
|||
moveq #0,d0 | indicate no fault
|
||||
jra Lfsdone
|
||||
|
||||
ALTENTRY(suibyte, _subyte)
|
||||
ENTRY(subyte)
|
||||
TWOENTRY(subyte,suibyte)
|
||||
movl sp@(4),a0 | address to write
|
||||
movb sp@(11),d0 | value to put there
|
||||
movl _curpcb,a1 | current pcb
|
||||
|
|
|
@ -72,7 +72,7 @@ cpu_readdisklabel(dev, strat, lp, osdep)
|
|||
* Check new disk label for sensibility
|
||||
* before setting it.
|
||||
*/
|
||||
cpu_setdisklabel(olp, nlp, openmask, osdep)
|
||||
int cpu_setdisklabel(olp, nlp, openmask, osdep)
|
||||
register struct disklabel *olp, *nlp;
|
||||
u_long openmask;
|
||||
struct cpu_disklabel *osdep;
|
||||
|
@ -84,7 +84,7 @@ cpu_setdisklabel(olp, nlp, openmask, osdep)
|
|||
/*
|
||||
* Write disk label back to device after modification.
|
||||
*/
|
||||
cpu_writedisklabel(dev, strat, lp, osdep)
|
||||
int cpu_writedisklabel(dev, strat, lp, osdep)
|
||||
dev_t dev;
|
||||
int (*strat)();
|
||||
register struct disklabel *lp;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
.text
|
||||
ENTRY(insque)
|
||||
ENTRY(_insque)
|
||||
movw sr,d0
|
||||
movw #PSL_HIGHIPL,sr | atomic
|
||||
movl sp@(8),a0 | where to insert (after)
|
||||
|
@ -16,7 +16,7 @@ ENTRY(insque)
|
|||
movw d0,sr
|
||||
rts
|
||||
|
||||
ENTRY(remque)
|
||||
ENTRY(_remque)
|
||||
movw sr,d0
|
||||
movw #PSL_HIGHIPL,sr | atomic
|
||||
movl sp@(4),a0 | element to remove (e)
|
||||
|
@ -30,8 +30,7 @@ ENTRY(remque)
|
|||
/*
|
||||
* bzero(addr, count)
|
||||
*/
|
||||
ALTENTRY(blkclr, _bzero)
|
||||
ENTRY(bzero)
|
||||
TWOENTRY(bzero,blkclr)
|
||||
movl sp@(4),a0 | address
|
||||
movl sp@(8),d0 | count
|
||||
jeq Lbzdone | if zero, nothing to do
|
||||
|
@ -96,8 +95,7 @@ Lcmpdone:
|
|||
*
|
||||
* Works for counts up to 128K.
|
||||
*/
|
||||
ALTENTRY(ovbcopy, _bcopy)
|
||||
ENTRY(bcopy)
|
||||
TWOENTRY(bcopy,ovbcopy)
|
||||
movl sp@(12),d0 | get count
|
||||
jeq Lcpyexit | if zero, return
|
||||
movl sp@(4),a0 | src address
|
||||
|
|
|
@ -1,10 +1,33 @@
|
|||
#include <machine/cpufunc.h>
|
||||
#include <machine/mon.h>
|
||||
#include "systm.h"
|
||||
#include "param.h"
|
||||
|
||||
#include "vm/vm.h"
|
||||
|
||||
#include "machine/cpufunc.h"
|
||||
#include "machine/cpu.h"
|
||||
#include "machine/mon.h"
|
||||
#include "machine/control.h"
|
||||
#include "machine/pte.h"
|
||||
#include "machine/pmap.h"
|
||||
|
||||
#include "vector.h"
|
||||
|
||||
#include "../dev/idprom.h"
|
||||
|
||||
|
||||
|
||||
unsigned int *old_vector_table;
|
||||
|
||||
static struct idprom identity_prom;
|
||||
|
||||
int msgbufmapped = 0;
|
||||
struct msgbuf *msgbufp = NULL;
|
||||
|
||||
extern vm_offset_t tmp_vpages[];
|
||||
|
||||
vm_offset_t high_segment_free_start = 0;
|
||||
vm_offset_t high_segment_free_end = 0;
|
||||
|
||||
static void initialize_vector_table()
|
||||
{
|
||||
int i;
|
||||
|
@ -17,19 +40,193 @@ static void initialize_vector_table()
|
|||
setvbr(vector_table);
|
||||
}
|
||||
|
||||
void sun3_vm_init()
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* initialize vpage[2]
|
||||
* allocate msgbuf physical memory
|
||||
* possibly allocate virtual segment for temp_seg_addr
|
||||
* get/compute information about available physical memory
|
||||
* get/compute information about start/end of kernel virtual addresses
|
||||
* will this actually work or will it have problems because of this supposed
|
||||
* wierd thing with (word or short?) aligned addresses
|
||||
*
|
||||
* needs checksumming support as well
|
||||
*/
|
||||
|
||||
int idprom_fetch(idp, version)
|
||||
struct idprom *idp;
|
||||
int version;
|
||||
{
|
||||
control_copy_byte(OIDPROM_BASE, (caddr_t) idp, sizeof(idp->idp_format));
|
||||
if (idp->idp_format != version) return 0;
|
||||
control_copy_byte(OIDPROM_BASE, (caddr_t) idp, sizeof(struct idprom));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define build_pte(pa, flags) ((pa >>PGSHIFT) | PG_SYSTEM | PG_VALID | flags)
|
||||
|
||||
void sun3_vm_init()
|
||||
{
|
||||
unsigned int monitor_memory = 0;
|
||||
vm_offset_t pte_proto, temp_seg, va, eva, sva, pte;
|
||||
extern char start, etext[], end[];
|
||||
unsigned char sme;
|
||||
int valid;
|
||||
|
||||
pmeg_init();
|
||||
|
||||
virtual_avail = sun3_round_page(end);
|
||||
virtual_end = sun3_round_page(VM_MAX_KERNEL_ADDRESS);
|
||||
|
||||
if (romp->romvecVersion >=1)
|
||||
monitor_memory = *romp->memorySize - *romp->memoryAvail;
|
||||
|
||||
mon_printf("%d bytes stolen by monitor\n", monitor_memory);
|
||||
|
||||
avail_start = virtual_avail - KERNBASE; /* XXX */
|
||||
avail_end = sun3_trunc_page(*romp->memoryAvail);
|
||||
|
||||
/* msgbuf */
|
||||
avail_end -= NBPG;
|
||||
pte_proto = build_pte(avail_end, PG_NC|PG_WRITE);
|
||||
set_pte(virtual_avail, pte_proto);
|
||||
msgbufp = (struct msgbuf *) virtual_avail;
|
||||
virtual_avail += NBPG;
|
||||
msgbufmapped = 1;
|
||||
|
||||
/*
|
||||
* vpages array:
|
||||
* just some virtual addresses for temporary mappings
|
||||
* in the pmap modue
|
||||
*/
|
||||
|
||||
tmp_vpages[0] = virtual_avail;
|
||||
virtual_avail += NBPG;
|
||||
tmp_vpages[1] = virtual_avail;
|
||||
virtual_avail += NBPG;
|
||||
|
||||
/*
|
||||
* we need to kill off a segment to handle the stupid non-contexted
|
||||
* pmeg
|
||||
*
|
||||
*/
|
||||
|
||||
temp_seg = sun3_round_seg(virtual_avail);
|
||||
mon_printf("%d virtual bytes lost allocating temporary segment for pmap\n",
|
||||
temp_seg - virtual_avail);
|
||||
virtual_avail = temp_seg + NBSG;
|
||||
set_temp_seg_addr(temp_seg);
|
||||
|
||||
/*
|
||||
* preserve/protect monitor:
|
||||
* need to preserve/protect pmegs used to map monitor between
|
||||
* MONSTART, MONEND.
|
||||
* free up any pmegs in this range which are
|
||||
* deal with the awful MONSHORTSEG/MONSHORTPAGE
|
||||
*/
|
||||
|
||||
for (va = MONSTART; va < MONEND; va += NBSG) {
|
||||
sme = get_segmap(va);
|
||||
if (sme == SEGINV) {
|
||||
va = sun3_round_seg(va);
|
||||
continue;
|
||||
}
|
||||
eva = sun3_round_seg(va);
|
||||
if (eva > MONEND)
|
||||
eva = MONEND;
|
||||
valid = 0;
|
||||
sva = va;
|
||||
for (; va < eva; va += NBPG) {
|
||||
pte = get_pte(va);
|
||||
if (pte & PG_VALID) {
|
||||
valid++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
pmeg_steal(sme);
|
||||
else {
|
||||
printf("freed pmeg for monitor segment %d\n",
|
||||
sun3_trunc_seg(sva));
|
||||
set_segmap(sva, SEGINV);
|
||||
}
|
||||
va = eva;
|
||||
}
|
||||
|
||||
/*
|
||||
* MONSHORTSEG contains MONSHORTPAGE which is some stupid page
|
||||
* allocated by the monitor. One page, in an otherwise empty segment.
|
||||
*
|
||||
* basically we are stealing the rest of the segment in hopes of using
|
||||
* it to map devices or something. Really isn't much else you can do with
|
||||
* it. Could put msgbuf's va up there, but i'd prefer if it was in
|
||||
* the range of acceptable kernel vm, and not in space.
|
||||
*
|
||||
*/
|
||||
|
||||
sme = get_segmap(MONSHORTSEG);
|
||||
pmeg_steal(sme);
|
||||
high_segment_free_start = MONSHORTSEG;
|
||||
high_segment_free_end = MONSHORTPAGE;
|
||||
|
||||
for (va = high_segment_free_start; va < high_segment_free_end;
|
||||
va+= NBPG) {
|
||||
set_pte(va, PG_INVAL);
|
||||
}
|
||||
|
||||
mon_printf("kernel virtual address begin:\t %d\n", virtual_avail);
|
||||
mon_printf("kernel virtual address end:\t %d\n", virtual_end);
|
||||
mon_printf("physical memory begin:\t %d\n", avail_start);
|
||||
mon_printf("physical memory end:\t %d\n", avail_end);
|
||||
|
||||
/*
|
||||
* leave protecting kernel and all that for post pmap_bootstrap()
|
||||
* so we can use pmap_protect()
|
||||
*/
|
||||
}
|
||||
|
||||
void sun3_verify_hardware()
|
||||
{
|
||||
unsigned char cpu_machine_id;
|
||||
unsigned char arch;
|
||||
int cpu_match = 0;
|
||||
|
||||
if (!idprom_fetch(&identity_prom, IDPROM_VERSION))
|
||||
panic("idprom fetch failed");
|
||||
arch = identity_prom.idp_machtype & CPU_ARCH_MASK;
|
||||
if (!(arch & SUN3_ARCH))
|
||||
panic("not a sun3?");
|
||||
cpu_machine_id = identity_prom.idp_machtype & SUN3_IMPL_MASK;
|
||||
switch (cpu_machine_id) {
|
||||
case SUN3_MACH_160:
|
||||
#ifdef SUN3_160
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_50 :
|
||||
#ifdef SUN3_50
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_260:
|
||||
#ifdef SUN3_260
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_110:
|
||||
#ifdef SUN3_110
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_60 :
|
||||
#ifdef SUN3_60
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_E :
|
||||
#ifdef SUN3_E
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
panic("unknown sun3 model");
|
||||
}
|
||||
if (!cpu_match)
|
||||
panic("kernel not configured for this sun3 model");
|
||||
}
|
||||
|
||||
void sun3_bootstrap()
|
||||
|
@ -42,11 +239,11 @@ void sun3_bootstrap()
|
|||
* so we've bailed and done it in locore right before this routine :)
|
||||
*/
|
||||
|
||||
for (i=0; i < 11; i++) {
|
||||
mon_putchar(hello[i]);
|
||||
}
|
||||
mon_printf("%s\n", hello);
|
||||
mon_printf("\nPROM Version: %d\n", romp->romvecVersion);
|
||||
|
||||
sun3_verify_hardware();
|
||||
|
||||
initialize_vector_table(); /* point interrupts/exceptions to our table */
|
||||
|
||||
sun3_vm_init(); /* handle kernel mapping problems, etc */
|
||||
|
|
|
@ -2,20 +2,11 @@
|
|||
#include "sys/types.h"
|
||||
#include "sys/reboot.h"
|
||||
#include "sys/buf.h"
|
||||
#include "../include/control.h"
|
||||
|
||||
#include "../include/mon.h"
|
||||
#include "../dev/idprom.h"
|
||||
|
||||
|
||||
int idprom_fetch(idp, version)
|
||||
struct idprom *idp;
|
||||
int version;
|
||||
{
|
||||
control_copy_byte(OIDPROM_BASE, (caddr_t) idp, sizeof(idp->idp_format));
|
||||
if (idp->idp_format != version) return 0;
|
||||
control_copy_byte(OIDPROM_BASE, (caddr_t) idp, sizeof(struct idprom));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cold;
|
||||
|
@ -30,6 +21,7 @@ void cpu_startup()
|
|||
|
||||
void consinit()
|
||||
{
|
||||
extern void cninit();
|
||||
mon_printf("determining console:");
|
||||
cninit();
|
||||
}
|
||||
|
|
|
@ -1,23 +1,31 @@
|
|||
#include "systm.h"
|
||||
#include "param.h"
|
||||
#include "proc.h"
|
||||
#include "malloc.h"
|
||||
#include "user.h"
|
||||
|
||||
#include "../include/pte.h"
|
||||
#include "../include/control.h"
|
||||
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vm_kern.h"
|
||||
#include "vm/vm_page.h"
|
||||
#include "vm/vm_statistics.h"
|
||||
|
||||
#include "../include/cpu.h"
|
||||
#include "../include/mon.h"
|
||||
#include "../include/vmparam.h"
|
||||
#include "../include/pmap.h"
|
||||
#include "machine/pte.h"
|
||||
#include "machine/control.h"
|
||||
|
||||
#include "machine/cpu.h"
|
||||
#include "machine/mon.h"
|
||||
#include "machine/vmparam.h"
|
||||
#include "machine/pmap.h"
|
||||
|
||||
extern int memavail;
|
||||
extern vm_offset_t virtual_avail, virtual_end;
|
||||
/*
|
||||
* globals needed by the vm system
|
||||
*
|
||||
* [frankly the stupid vm system should allocate these]
|
||||
*/
|
||||
|
||||
vm_offset_t virtual_avail, virtual_end;
|
||||
vm_offset_t avail_start, avail_end;
|
||||
|
||||
/* current_projects:
|
||||
*
|
||||
|
@ -140,7 +148,7 @@ static struct context_state context_array[NCONTEXT];
|
|||
/* location to store virtual addresses
|
||||
* to be used in copy/zero operations
|
||||
*/
|
||||
vm_offset_t vpage[2];
|
||||
vm_offset_t tmp_vpages[2];
|
||||
|
||||
/* context support */
|
||||
|
||||
|
@ -172,7 +180,7 @@ void pv_init __P((void));
|
|||
|
||||
void sun3_protection_init __P((void));
|
||||
|
||||
void pmap_bootstrap __P((vm_offset_t kernel_end, int hole));
|
||||
void pmap_bootstrap __P((void));
|
||||
void pmap_init __P((vm_offset_t phys_start, vm_offset_t phys_end));
|
||||
|
||||
void pmap_common_init __P((pmap_t pmap));
|
||||
|
@ -475,7 +483,6 @@ unsigned char pv_compute_cache(head)
|
|||
pv_entry_t head;
|
||||
{
|
||||
pv_entry_t pv;
|
||||
unsigned char cflags;
|
||||
int cread, cwrite, ccache, clen;
|
||||
|
||||
cread = cwrite = ccache = clen = 0;
|
||||
|
@ -494,7 +501,7 @@ int pv_compute_modified(head)
|
|||
pv_entry_t head;
|
||||
{
|
||||
pv_entry_t pv;
|
||||
int modified, saved_context;
|
||||
int modified;
|
||||
vm_offset_t pte;
|
||||
unsigned int seg;
|
||||
|
||||
|
@ -523,7 +530,6 @@ void pv_remove_all(pa)
|
|||
vm_offset_t pa;
|
||||
{
|
||||
pv_entry_t npv,head,last;
|
||||
int saved_context;
|
||||
|
||||
head = pa_to_pvp(pa);
|
||||
for (npv = head ; npv != NULL; last= npv, npv = npv->pv_next ) {
|
||||
|
@ -540,7 +546,6 @@ unsigned char pv_link(pmap, pa, va, flags)
|
|||
unsigned char nflags;
|
||||
pv_entry_t last,pv,head,npv;
|
||||
|
||||
if (flags
|
||||
head = pv = pa_to_pvp(pa);
|
||||
PMAP_LOCK();
|
||||
if (pv->pv_pmap == NULL) { /* not currently "managed" */
|
||||
|
@ -616,8 +621,6 @@ void pv_unlink(pmap, pa, va)
|
|||
vm_offset_t pa, va;
|
||||
{
|
||||
pv_entry_t pv,pv_list,dead,last;
|
||||
int context;
|
||||
vm_offset_t pte;
|
||||
unsigned char saved_flags,nflags;
|
||||
|
||||
pv_list = pa_to_pvp(pa);
|
||||
|
@ -721,16 +724,8 @@ void pmap_common_init(pmap)
|
|||
simple_lock_init(&pmap->pm_lock);
|
||||
}
|
||||
|
||||
void pmap_bootstrap(firstaddr, loadaddr)
|
||||
vm_offset_t firstaddr;
|
||||
vm_offset_t loadaddr;
|
||||
vm_offset_t msg
|
||||
void pmap_bootstrap()
|
||||
{
|
||||
vm_offset_t seg_begin, seg_end,vmx;
|
||||
int i;
|
||||
|
||||
virtual_avail = sun3_round_page(kernel_end); /* set in sun3_init */
|
||||
virtual_end = sun3_round_page(VM_MAX_KERNEL_ADDRESS);
|
||||
|
||||
sun3_protection_init();
|
||||
/* after setting up some structures */
|
||||
|
@ -738,19 +733,9 @@ void pmap_bootstrap(firstaddr, loadaddr)
|
|||
kernel_pmap = &kernel_pmap_store;
|
||||
pmap_common_init(kernel_pmap);
|
||||
|
||||
pmeg_init();
|
||||
/* pmeg_init();*/
|
||||
context_init();
|
||||
|
||||
seg_begin = sun3_trunc_seg(MONSTART);
|
||||
seg_end = sun3_round_seg(MONEND);
|
||||
|
||||
/* protect MMU */
|
||||
for (vmx = seg_begin; vmx < seg_end; vmx+=NBSEG) {
|
||||
i = mmu_segment_to_pmeg(vmx); /* XXXX */
|
||||
pmeg_steal(i); /* XXXXX */
|
||||
}
|
||||
/* do something about MONSHORTPAGE/MONSHORTSEG */
|
||||
/* do something about device pages in monitor space */
|
||||
/* unmap everything else, and copy into all contexts*/
|
||||
}
|
||||
/*
|
||||
|
@ -956,8 +941,8 @@ void pmap_remove_range_contextless(pmap, sva, eva,pmegp)
|
|||
int sp,ep,i;
|
||||
vm_offset_t pte,va;
|
||||
|
||||
sp = PTE_NUM(sva);
|
||||
ep = PTE_NUM(eva);
|
||||
sp = VA_PTE_NUM(sva);
|
||||
ep = VA_PTE_NUM(eva);
|
||||
va = sva;
|
||||
for (i = sp; i < ep; i++) {
|
||||
pte = get_pte_pmeg(pmegp->pmeg_index, i);
|
||||
|
@ -1333,15 +1318,15 @@ void pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr)
|
|||
void pmap_copy_page(src, dst)
|
||||
vm_offset_t src, dst;
|
||||
{
|
||||
vm_offset_t pte,v;
|
||||
vm_offset_t pte;
|
||||
|
||||
pte = PG_VALID |PG_SYSTEM|PG_WRITE|PG_NC|PG_MMEM| (src >>PGSHIFT);
|
||||
set_pte(vpage[0], pte);
|
||||
set_pte(tmp_vpages[0], pte);
|
||||
pte = PG_VALID |PG_SYSTEM|PG_WRITE|PG_NC|PG_MMEM| (dst >>PGSHIFT);
|
||||
set_pte(vpage[1], pte);
|
||||
bcopy(vpage[0], vpage[1], NBPG);
|
||||
set_pte(vpage[0], PG_INVAL);
|
||||
set_pte(vpage[0], PG_INVAL);
|
||||
set_pte(tmp_vpages[1], pte);
|
||||
bcopy((char *) tmp_vpages[0], (char *) tmp_vpages[1], NBPG);
|
||||
set_pte(tmp_vpages[0], PG_INVAL);
|
||||
set_pte(tmp_vpages[0], PG_INVAL);
|
||||
}
|
||||
/*
|
||||
* Routine: pmap_extract
|
||||
|
@ -1364,7 +1349,7 @@ pmap_extract(pmap, va)
|
|||
panic("pmap: pmap_extract() failed on kernel va");
|
||||
pte = get_pte(va);
|
||||
if (pte & PG_VALID)
|
||||
return PA_PTE(pte);
|
||||
return PG_PA(pte);
|
||||
panic("pmap: pmap_extract() failed on invalid kernel va");
|
||||
}
|
||||
seg = VA_SEGNUM(va);
|
||||
|
@ -1372,7 +1357,7 @@ pmap_extract(pmap, va)
|
|||
panic("pmap: pmap_extract() failed on user va");
|
||||
if (get_pte_val(pmap, va,&pte)) {
|
||||
if (pte & PG_VALID)
|
||||
return PA_PTE(pte);
|
||||
return PG_PA(pte);
|
||||
}
|
||||
panic("pmap: pmap_extract() failed on invalid user va");
|
||||
}
|
||||
|
@ -1452,7 +1437,7 @@ void pmap_protect_range_mmu(pmap, sva, eva,pte_proto)
|
|||
vm_offset_t sva, eva;
|
||||
vm_offset_t pte_proto;
|
||||
{
|
||||
int saved_context,i;
|
||||
int saved_context;
|
||||
unsigned int sme,nflags;
|
||||
pmeg_t pmegp;
|
||||
vm_offset_t va,pte;
|
||||
|
@ -1566,9 +1551,9 @@ void pmap_zero_page(pa)
|
|||
vm_offset_t pte;
|
||||
|
||||
pte = PG_VALID |PG_SYSTEM|PG_WRITE|PG_NC|PG_MMEM| (pa >>PGSHIFT);
|
||||
set_pte(vpage[0], pte);
|
||||
bzero(vpage[0], NBPG);
|
||||
set_pte(vpage[0], PG_INVAL);
|
||||
set_pte(tmp_vpages[0], pte);
|
||||
bzero((char *) tmp_vpages[0], NBPG);
|
||||
set_pte(tmp_vpages[0], PG_INVAL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,3 +2,9 @@
|
|||
ether_output() {}
|
||||
|
||||
|
||||
char *memcpy(char *from, char *to, unsigned int size)
|
||||
{
|
||||
bcopy(to, from, size);
|
||||
return to;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,33 @@
|
|||
#include <machine/cpufunc.h>
|
||||
#include <machine/mon.h>
|
||||
#include "systm.h"
|
||||
#include "param.h"
|
||||
|
||||
#include "vm/vm.h"
|
||||
|
||||
#include "machine/cpufunc.h"
|
||||
#include "machine/cpu.h"
|
||||
#include "machine/mon.h"
|
||||
#include "machine/control.h"
|
||||
#include "machine/pte.h"
|
||||
#include "machine/pmap.h"
|
||||
|
||||
#include "vector.h"
|
||||
|
||||
#include "../dev/idprom.h"
|
||||
|
||||
|
||||
|
||||
unsigned int *old_vector_table;
|
||||
|
||||
static struct idprom identity_prom;
|
||||
|
||||
int msgbufmapped = 0;
|
||||
struct msgbuf *msgbufp = NULL;
|
||||
|
||||
extern vm_offset_t tmp_vpages[];
|
||||
|
||||
vm_offset_t high_segment_free_start = 0;
|
||||
vm_offset_t high_segment_free_end = 0;
|
||||
|
||||
static void initialize_vector_table()
|
||||
{
|
||||
int i;
|
||||
|
@ -17,19 +40,193 @@ static void initialize_vector_table()
|
|||
setvbr(vector_table);
|
||||
}
|
||||
|
||||
void sun3_vm_init()
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* initialize vpage[2]
|
||||
* allocate msgbuf physical memory
|
||||
* possibly allocate virtual segment for temp_seg_addr
|
||||
* get/compute information about available physical memory
|
||||
* get/compute information about start/end of kernel virtual addresses
|
||||
* will this actually work or will it have problems because of this supposed
|
||||
* wierd thing with (word or short?) aligned addresses
|
||||
*
|
||||
* needs checksumming support as well
|
||||
*/
|
||||
|
||||
int idprom_fetch(idp, version)
|
||||
struct idprom *idp;
|
||||
int version;
|
||||
{
|
||||
control_copy_byte(OIDPROM_BASE, (caddr_t) idp, sizeof(idp->idp_format));
|
||||
if (idp->idp_format != version) return 0;
|
||||
control_copy_byte(OIDPROM_BASE, (caddr_t) idp, sizeof(struct idprom));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define build_pte(pa, flags) ((pa >>PGSHIFT) | PG_SYSTEM | PG_VALID | flags)
|
||||
|
||||
void sun3_vm_init()
|
||||
{
|
||||
unsigned int monitor_memory = 0;
|
||||
vm_offset_t pte_proto, temp_seg, va, eva, sva, pte;
|
||||
extern char start, etext[], end[];
|
||||
unsigned char sme;
|
||||
int valid;
|
||||
|
||||
pmeg_init();
|
||||
|
||||
virtual_avail = sun3_round_page(end);
|
||||
virtual_end = sun3_round_page(VM_MAX_KERNEL_ADDRESS);
|
||||
|
||||
if (romp->romvecVersion >=1)
|
||||
monitor_memory = *romp->memorySize - *romp->memoryAvail;
|
||||
|
||||
mon_printf("%d bytes stolen by monitor\n", monitor_memory);
|
||||
|
||||
avail_start = virtual_avail - KERNBASE; /* XXX */
|
||||
avail_end = sun3_trunc_page(*romp->memoryAvail);
|
||||
|
||||
/* msgbuf */
|
||||
avail_end -= NBPG;
|
||||
pte_proto = build_pte(avail_end, PG_NC|PG_WRITE);
|
||||
set_pte(virtual_avail, pte_proto);
|
||||
msgbufp = (struct msgbuf *) virtual_avail;
|
||||
virtual_avail += NBPG;
|
||||
msgbufmapped = 1;
|
||||
|
||||
/*
|
||||
* vpages array:
|
||||
* just some virtual addresses for temporary mappings
|
||||
* in the pmap modue
|
||||
*/
|
||||
|
||||
tmp_vpages[0] = virtual_avail;
|
||||
virtual_avail += NBPG;
|
||||
tmp_vpages[1] = virtual_avail;
|
||||
virtual_avail += NBPG;
|
||||
|
||||
/*
|
||||
* we need to kill off a segment to handle the stupid non-contexted
|
||||
* pmeg
|
||||
*
|
||||
*/
|
||||
|
||||
temp_seg = sun3_round_seg(virtual_avail);
|
||||
mon_printf("%d virtual bytes lost allocating temporary segment for pmap\n",
|
||||
temp_seg - virtual_avail);
|
||||
virtual_avail = temp_seg + NBSG;
|
||||
set_temp_seg_addr(temp_seg);
|
||||
|
||||
/*
|
||||
* preserve/protect monitor:
|
||||
* need to preserve/protect pmegs used to map monitor between
|
||||
* MONSTART, MONEND.
|
||||
* free up any pmegs in this range which are
|
||||
* deal with the awful MONSHORTSEG/MONSHORTPAGE
|
||||
*/
|
||||
|
||||
for (va = MONSTART; va < MONEND; va += NBSG) {
|
||||
sme = get_segmap(va);
|
||||
if (sme == SEGINV) {
|
||||
va = sun3_round_seg(va);
|
||||
continue;
|
||||
}
|
||||
eva = sun3_round_seg(va);
|
||||
if (eva > MONEND)
|
||||
eva = MONEND;
|
||||
valid = 0;
|
||||
sva = va;
|
||||
for (; va < eva; va += NBPG) {
|
||||
pte = get_pte(va);
|
||||
if (pte & PG_VALID) {
|
||||
valid++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
pmeg_steal(sme);
|
||||
else {
|
||||
printf("freed pmeg for monitor segment %d\n",
|
||||
sun3_trunc_seg(sva));
|
||||
set_segmap(sva, SEGINV);
|
||||
}
|
||||
va = eva;
|
||||
}
|
||||
|
||||
/*
|
||||
* MONSHORTSEG contains MONSHORTPAGE which is some stupid page
|
||||
* allocated by the monitor. One page, in an otherwise empty segment.
|
||||
*
|
||||
* basically we are stealing the rest of the segment in hopes of using
|
||||
* it to map devices or something. Really isn't much else you can do with
|
||||
* it. Could put msgbuf's va up there, but i'd prefer if it was in
|
||||
* the range of acceptable kernel vm, and not in space.
|
||||
*
|
||||
*/
|
||||
|
||||
sme = get_segmap(MONSHORTSEG);
|
||||
pmeg_steal(sme);
|
||||
high_segment_free_start = MONSHORTSEG;
|
||||
high_segment_free_end = MONSHORTPAGE;
|
||||
|
||||
for (va = high_segment_free_start; va < high_segment_free_end;
|
||||
va+= NBPG) {
|
||||
set_pte(va, PG_INVAL);
|
||||
}
|
||||
|
||||
mon_printf("kernel virtual address begin:\t %d\n", virtual_avail);
|
||||
mon_printf("kernel virtual address end:\t %d\n", virtual_end);
|
||||
mon_printf("physical memory begin:\t %d\n", avail_start);
|
||||
mon_printf("physical memory end:\t %d\n", avail_end);
|
||||
|
||||
/*
|
||||
* leave protecting kernel and all that for post pmap_bootstrap()
|
||||
* so we can use pmap_protect()
|
||||
*/
|
||||
}
|
||||
|
||||
void sun3_verify_hardware()
|
||||
{
|
||||
unsigned char cpu_machine_id;
|
||||
unsigned char arch;
|
||||
int cpu_match = 0;
|
||||
|
||||
if (!idprom_fetch(&identity_prom, IDPROM_VERSION))
|
||||
panic("idprom fetch failed");
|
||||
arch = identity_prom.idp_machtype & CPU_ARCH_MASK;
|
||||
if (!(arch & SUN3_ARCH))
|
||||
panic("not a sun3?");
|
||||
cpu_machine_id = identity_prom.idp_machtype & SUN3_IMPL_MASK;
|
||||
switch (cpu_machine_id) {
|
||||
case SUN3_MACH_160:
|
||||
#ifdef SUN3_160
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_50 :
|
||||
#ifdef SUN3_50
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_260:
|
||||
#ifdef SUN3_260
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_110:
|
||||
#ifdef SUN3_110
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_60 :
|
||||
#ifdef SUN3_60
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
case SUN3_MACH_E :
|
||||
#ifdef SUN3_E
|
||||
cpu_match++;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
panic("unknown sun3 model");
|
||||
}
|
||||
if (!cpu_match)
|
||||
panic("kernel not configured for this sun3 model");
|
||||
}
|
||||
|
||||
void sun3_bootstrap()
|
||||
|
@ -42,11 +239,11 @@ void sun3_bootstrap()
|
|||
* so we've bailed and done it in locore right before this routine :)
|
||||
*/
|
||||
|
||||
for (i=0; i < 11; i++) {
|
||||
mon_putchar(hello[i]);
|
||||
}
|
||||
mon_printf("%s\n", hello);
|
||||
mon_printf("\nPROM Version: %d\n", romp->romvecVersion);
|
||||
|
||||
sun3_verify_hardware();
|
||||
|
||||
initialize_vector_table(); /* point interrupts/exceptions to our table */
|
||||
|
||||
sun3_vm_init(); /* handle kernel mapping problems, etc */
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
#include "buf.h"
|
||||
#include "user.h"
|
||||
|
||||
#include "../include/cpu.h"
|
||||
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vm_kern.h"
|
||||
#include "pte.h"
|
||||
|
||||
#include "machine/cpu.h"
|
||||
#include "machine/pte.h"
|
||||
|
||||
extern vm_map_t phys_map;
|
||||
|
||||
|
|
Loading…
Reference in New Issue