* from: Utah Hdr: autoconf.c 1.31 91/01/21
*
* from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93
- * $Id: autoconf.c,v 1.1.1.1 1995/10/18 10:39:17 deraadt Exp $
+ * $Id: autoconf.c,v 1.2 1996/05/01 18:15:48 pefo Exp $
*/
/*
u_long bootdev; /* should be dev_t, but not until 32 bits */
static char devname[][2] = {
- 's','d', /* 0 = rz */
+ 's','d', /* 0 = sd */
'x','x', /* 1 = unused */
'x','x', /* 2 = unused */
'x','x', /* 3 = unused */
/*
* Look at the string 'cp' and decode the boot device.
- * Boot names can be something like 'rz(0,0,0)vmunix' or '5/rz0/vmunix'.
+ * Boot names look like: scsi()disk(n)rdisk()partition(1)\bsd
*/
void
makebootdev(cp)
- register char *cp;
+ char *cp;
{
int majdev, unit, part, ctrl;
+ char dv[8];
- if (*cp >= '0' && *cp <= '9') {
- /* XXX should be able to specify controller */
- if (cp[1] != '/' || cp[4] < '0' || cp[4] > '9')
- goto defdev;
- unit = cp[4] - '0';
- if (cp[5] >= 'a' && cp[5] <= 'h')
- part = cp[5] - 'a';
- else
- part = 0;
- cp += 2;
- for (majdev = 0; majdev < sizeof(devname)/sizeof(devname[0]);
- majdev++) {
- if (cp[0] == devname[majdev][0] &&
- cp[1] == devname[majdev][1]) {
- bootdev = MAKEBOOTDEV(majdev, 0, 0, unit, part);
- return;
- }
+ bootdev = B_DEVMAGIC;
+
+ dv[0] = *cp;
+ ctrl = getpno(&cp);
+ if(*cp++ == ')') {
+ dv[1] = *cp;
+ unit = getpno(&cp);
+
+ for (majdev = 0; majdev < sizeof(devname)/sizeof(devname[0]); majdev++)
+ if (dv[0] == devname[majdev][0] &&
+ dv[1] == devname[majdev][1] && cp[0] == ')')
+ bootdev = MAKEBOOTDEV(majdev, 0, ctrl, unit,0);
+ }
+}
+getpno(cp)
+ char **cp;
+{
+ int val = 0;
+ char *cx = *cp;
+
+ while(*cx && *cx != '(')
+ cx++;
+ if(*cx == '(') {
+ cx++;
+ while(*cx && *cx != ')') {
+ val = val * 10 + *cx - '0';
+ cx++;
}
- goto defdev;
}
- for (majdev = 0; majdev < sizeof(devname)/sizeof(devname[0]); majdev++)
- if (cp[0] == devname[majdev][0] &&
- cp[1] == devname[majdev][1] &&
- cp[2] == '(')
- goto fndmaj;
-defdev:
- bootdev = B_DEVMAGIC;
- return;
-
-fndmaj:
- for (ctrl = 0, cp += 3; *cp >= '0' && *cp <= '9'; )
- ctrl = ctrl * 10 + *cp++ - '0';
- if (*cp == ',')
- cp++;
- for (unit = 0; *cp >= '0' && *cp <= '9'; )
- unit = unit * 10 + *cp++ - '0';
- if (*cp == ',')
- cp++;
- for (part = 0; *cp >= '0' && *cp <= '9'; )
- part = part * 10 + *cp++ - '0';
- if (*cp != ')')
- goto defdev;
- bootdev = MAKEBOOTDEV(majdev, 0, ctrl, unit, part);
+ *cp = cx;
+ return val;
}
* from: Utah Hdr: clock.c 1.18 91/01/21
*
* from: @(#)clock.c 8.1 (Berkeley) 6/10/93
- * $Id: clock.c,v 1.1.1.1 1995/10/18 10:39:17 deraadt Exp $
+ * $Id: clock.c,v 1.2 1996/05/01 18:15:51 pefo Exp $
*/
#include <sys/param.h>
/* Definition of the driver for autoconfig. */
static int clockmatch __P((struct device *, void *, void *));
static void clockattach __P((struct device *, struct device *, void *));
-struct cfdriver clockcd =
- { NULL, "clock", clockmatch, clockattach, DV_DULL,
- sizeof(struct clock_softc) };
+
+struct cfattach clock_ca = {
+ sizeof(struct clock_softc), clockmatch, clockattach
+};
+struct cfdriver clock_cd = {
+ NULL, "clock", DV_DULL, NULL, 0
+};
void mcclock_attach __P((struct device *, struct device *, void *));
cpu_initclocks()
{
extern int tickadj;
- struct clock_softc *csc = (struct clock_softc *)clockcd.cd_devs[0];
+ struct clock_softc *csc = (struct clock_softc *)clock_cd.cd_devs[0];
hz = 100; /* 100 Hz */
tick = 1000000 / hz; /* number of micro-seconds between interrupts */
time_t base;
{
struct tod_time c;
- struct clock_softc *csc = (struct clock_softc *)clockcd.cd_devs[0];
+ struct clock_softc *csc = (struct clock_softc *)clock_cd.cd_devs[0];
register int days, yr;
long deltat;
int badbase, s;
resettodr()
{
struct tod_time c;
- struct clock_softc *csc = (struct clock_softc *)clockcd.cd_devs[0];
+ struct clock_softc *csc = (struct clock_softc *)clock_cd.cd_devs[0];
register int t, t2;
int s;
#include <sys/device.h>
#include <machine/autoconf.h>
+#include <machine/pio.h>
#include <pica/pica/clockvar.h>
#include <pica/pica/picatype.h>
-/* $OpenBSD: conf.c,v 1.3 1996/02/21 12:53:51 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.4 1996/05/01 18:15:55 pefo Exp $ */
/*
* Copyright (c) 1992, 1993
* SUCH DAMAGE.
*
* from: @(#)conf.c 8.2 (Berkeley) 11/14/93
- * $Id: conf.c,v 1.3 1996/02/21 12:53:51 mickey Exp $
+ * $Id: conf.c,v 1.4 1996/05/01 18:15:55 pefo Exp $
*/
#include <sys/param.h>
bdev_decl(sw);
#include "sd.h"
bdev_decl(sd);
+#include "cd.h"
+bdev_decl(cd);
#include "fdc.h"
-#define fdopen Fdopen
bdev_decl(fd);
-#undef fdopen
struct bdevsw bdevsw[] =
{
bdev_disk_init(NSD,sd), /* 0: SCSI disk */
bdev_swap_init(1,sw), /* 1: should be here swap pseudo-dev */
bdev_disk_init(NVND,vnd), /* 2: vnode disk driver */
- bdev_notdef(), /* 3: */
+ bdev_disk_init(NCD,cd), /* 3: SCSI CD-ROM */
bdev_notdef(), /* 4: */
bdev_notdef(), /* 5: */
bdev_notdef(), /* 6: */
-#define fdopen Fdopen
bdev_disk_init(NFDC,fd), /* 7: Floppy disk driver */
-#undef fdopen
bdev_notdef(), /* 8: */
bdev_notdef(), /* 9: */
bdev_notdef(), /* 10: */
#include "st.h"
cdev_decl(st);
#include "fdc.h"
-#define fdopen Fdopen
bdev_decl(fd);
-#undef fdopen
cdev_decl(vnd);
#include "bpfilter.h"
cdev_decl(bpf);
#include "pc.h"
cdev_decl(pc);
cdev_decl(pms);
+cdev_decl(cd);
/* open, close, read, ioctl */
cdev_decl(ipl);
+<<<<<<< 1.2
+#define cdev_gen_ipf(c,n) { \
+ dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
+ (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
+ (dev_type_stop((*))) nullop, 0, (dev_type_select((*))) enodev, \
+ (dev_type_mmap((*))) enodev, 0 }
+=======
+>>>>>>> 1.3
#ifdef IPFILTER
#define NIPF 1
#else
cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */
cdev_log_init(1,log), /* 6: /dev/klog */
cdev_fd_init(1,fd), /* 7: file descriptor pseudo-dev */
- cdev_notdef(), /* 8: SCSI CD */
+ cdev_disk_init(NCD,cd), /* 8: SCSI CD */
cdev_disk_init(NSD,sd), /* 9: SCSI disk */
cdev_tape_init(NST,st), /* 10: SCSI tape */
cdev_disk_init(NVND,vnd), /* 11: vnode disk */
cdev_bpftun_init(NBPFILTER,bpf),/* 12: berkeley packet filter */
-#define fdopen Fdopen
cdev_disk_init(NFDC,fd), /* 13: Floppy disk */
-#undef fdopen
cdev_pc_init(1,pc), /* 14: builtin pc style console dev */
cdev_mouse_init(1,pms), /* 15: builtin PS2 style mouse */
cdev_lpt_init(NLPT,lpt), /* 16: lpt paralell printer interface */
/* Definition of the driver for autoconfig. */
static int cpumatch(struct device *, void *, void *);
static void cpuattach(struct device *, struct device *, void *);
-struct cfdriver cpucd =
- { NULL, "cpu", cpumatch, cpuattach, DV_DULL, sizeof (struct device) };
+
+struct cfattach cpu_ca = {
+ sizeof(struct device), cpumatch, cpuattach
+};
+struct cfdriver cpu_cd = {
+ NULL, "cpu", DV_DULL, NULL, 0
+};
static int cpuprint __P((void *, char *pnp));
struct confargs *ca = aux;
/* make sure that we're looking for a CPU. */
- if (strcmp(ca->ca_name, cpucd.cd_name) != 0)
+ if (strcmp(ca->ca_name, cpu_cd.cd_name) != 0)
return (0);
return (1);
/* If it's not a.out, maybe it's ELF. (This wants to
be moved up to the machine independent code as soon
as possible.) XXX */
+#if 0
return pmax_elf_makecmds (p, epp);
+#else
+ return ENOEXEC;
+#endif
#ifdef COMPAT_09
epp -> ep_taddr = 0x1000;
/* was this the boot device ? */
int
dk_establish(dk, dev)
- struct dkdevice *dk;
+ struct disk *dk;
struct device *dev;
{
#ifdef NOTDEF
epp->ep_daddr = vaddr;
epp->ep_dsize += ph.memsz;
/* Read the data from the file... */
+#if 1
+ offset -= (vaddr & (NBPG - 1));
+ length += (vaddr & (NBPG - 1));
+ vaddr &= ~(NBPG - 1);
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
length, vaddr,
epp->ep_vp, offset, prot);
+ length = roundup (length, NBPG);
+ if (residue) {
+ residue = (ph.vaddr + ph.memsz)
+ - (vaddr + length);
+ }
+#else
+ offset -= (vaddr & (NBPG - 1));
+ vaddr &= ~(NBPG - 1);
+ length = roundup (length + ph.vaddr - vaddr, NBPG);
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn,
+ length, vaddr, epp->ep_vp,
+ offset, prot);
if (residue) {
- vaddr &= ~(NBPG - 1);
- offset &= ~(NBPG - 1);
- length = roundup (length + ph.vaddr
- - vaddr, NBPG);
residue = (ph.vaddr + ph.memsz)
- (vaddr + length);
}
+#endif
} else {
vaddr &= ~(NBPG - 1);
offset &= ~(NBPG - 1);
* v 1.1 89/07/10 14:27:41 nelson Exp SPRITE (DECWRL)
*
* from: @(#)locore.s 8.5 (Berkeley) 1/4/94
- * $Id: locore.S,v 1.2 1995/10/30 13:38:02 deraadt Exp $
+ * $Id: locore.S,v 1.3 1996/05/01 18:16:05 pefo Exp $
*/
/*
#include <machine/param.h>
#include <machine/psl.h>
-#include <machine/reg.h>
-#include <machine/machAsmDefs.h>
+#include <machine/asm.h>
+#include <machine/regnum.h>
#include <machine/pte.h>
#include "assym.h"
eret
.set at
-/*
- * GCC2 seems to want to call __main in main() for some reason.
- */
-LEAF(__main)
- j ra
- nop
-END(__main)
-
/*
* Primitives
*/
nop
END(bzero)
-/*
- * fillw(pat, addr, count)
- */
-LEAF(fillw)
-1:
- addiu a2, a2, -1
- sh a0, 0(a1)
- bne a2,zero, 1b
- addiu a1, a1, 2
-
- jr ra
- nop
-END(fillw)
/*
* bcmp(s1, s2, n)
*/
move v0, zero
END(copystr)
+/*
+ * fillw(pat, addr, count)
+ */
+LEAF(fillw)
+1:
+ addiu a2, a2, -1
+ sh a0, 0(a1)
+ bne a2,zero, 1b
+ addiu a1, a1, 2
+
+ jr ra
+ nop
+END(fillw)
+
/*
* Copy a null terminated string from the user address space into
* the kernel address space.
*----------------------------------------------------------------------------
*/
LEAF(MachHitFlushDCache)
+ beq a1, zero, 2f
addu a1, 127 # Align
addu a1, a1, a0
and a0, a0, -128
bne a1, zero, 1b
addu a0, 128
+2:
j ra
nop
END(MachHitFlushDCache)
* SUCH DAMAGE.
*
* from: @(#)machdep.c 8.3 (Berkeley) 1/12/94
- * $Id: machdep.c,v 1.5 1996/01/05 16:18:09 deraadt Exp $
+ * $Id: machdep.c,v 1.6 1996/05/01 18:16:09 pefo Exp $
*/
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
#include <machine/cpu.h>
#include <machine/reg.h>
+#include <machine/pio.h>
#include <machine/psl.h>
#include <machine/pte.h>
#include <machine/autoconf.h>
break;
}
-#if 0
/* look at argv[0] and compute bootdev */
makebootdev(argv[0]);
-#endif
/*
* Look at arguments passed to us and compute boothowto.
#endif
if (argc > 1) {
for (i = 1; i < argc; i++) {
- for (cp = argv[i]; *cp; cp++) {
- switch (*cp) {
- case 'a': /* autoboot */
- boothowto &= ~RB_SINGLE;
- break;
-
- case 'd': /* use compiled in default root */
- boothowto |= RB_DFLTROOT;
- break;
-
- case 'm': /* mini root present in memory */
- boothowto |= RB_MINIROOT;
- break;
-
- case 'n': /* ask for names */
- boothowto |= RB_ASKNAME;
- break;
-
- case 'N': /* don't ask for names */
- boothowto &= ~RB_ASKNAME;
- break;
- }
+ if(strncmp("OSLOADOPTIONS=",argv[i],14) == 0) {
+ for (cp = argv[i]+14; *cp; cp++) {
+ switch (*cp) {
+ case 'a': /* autoboot */
+ boothowto &= ~RB_SINGLE;
+ break;
+
+ case 'd': /* use compiled in default root */
+ boothowto |= RB_DFLTROOT;
+ break;
+
+ case 'm': /* mini root present in memory */
+ boothowto |= RB_MINIROOT;
+ break;
+
+ case 'n': /* ask for names */
+ boothowto |= RB_ASKNAME;
+ break;
+
+ case 'N': /* don't ask for names */
+ boothowto &= ~RB_ASKNAME;
+ break;
+ }
+ }
}
}
}
bzero((caddr_t)p->p_md.md_regs, (FSR + 1) * sizeof(int));
p->p_md.md_regs[SP] = stack;
p->p_md.md_regs[PC] = pack->ep_entry & ~3;
+ p->p_md.md_regs[T9] = pack->ep_entry & ~3; /* abicall req */
p->p_md.md_regs[PS] = PSL_USERSET;
p->p_md.md_flags & ~MDP_FPUSED;
if (machFPCurProcPtr == p)
machFPCurProcPtr = (struct proc *)0;
+ p->p_md.md_ss_addr = 0;
}
/*
regs[A3] = (int)catcher;
regs[PC] = (int)catcher;
+ regs[T9] = (int)catcher;
regs[SP] = (int)fp;
/*
* Signal trampoline code is at base of user stack.
static int mbmatch __P((struct device *, void *, void *));
static void mbattach __P((struct device *, struct device *, void *));
static int mbprint __P((void *, char *));
-struct cfdriver mainbuscd =
- { NULL, "mainbus", mbmatch, mbattach, DV_DULL,
- sizeof (struct mainbus_softc) };
+
+struct cfattach mainbus_ca = {
+ sizeof(struct device), mbmatch, mbattach
+};
+struct cfdriver mainbus_cd = {
+ NULL, "mainbus", DV_DULL, NULL, 0
+};
void mb_intr_establish __P((struct confargs *, int (*)(void *), void *));
void mb_intr_disestablish __P((struct confargs *));
* SUCH DAMAGE.
*
* from: @(#)kadb.c 8.1 (Berkeley) 6/10/93
- * $Id: minidebug.c,v 1.1.1.1 1995/10/18 10:39:18 deraadt Exp $
+ * $Id: minidebug.c,v 1.2 1996/05/01 18:16:13 pefo Exp $
*/
/*
break;
default:
+ cnputc('\a');
break;
}
printf("\n# ");
int i;
/* compute next address after current location */
- va = MachEmulateBranch(locr0, locr0[PC], 0, 1);
+ if(mdbpeek(locr0[PC]) != 0) {
+ va = MachEmulateBranch(locr0, locr0[PC], 0, mdbpeek(locr0[PC]));
+ }
+ else {
+ va = locr0[PC] + 4;
+ }
if (mdb_ss_addr) {
printf("mdbsetsstep: breakpoint already set at %x (va %x)\n",
mdb_ss_addr, va);
#include <sys/device.h>
#include <machine/cpu.h>
+#include <machine/pio.h>
#include <machine/autoconf.h>
#include <pica/pica/pica.h>
int picamatch(struct device *, void *, void *);
void picaattach(struct device *, struct device *, void *);
int picaprint(void *, char *);
-struct cfdriver picacd =
- { NULL, "pica", picamatch, picaattach, DV_DULL, sizeof (struct pica_softc) };
+
+struct cfattach pica_ca = {
+ sizeof(struct device), picamatch, picaattach
+};
+struct cfdriver pica_cd = {
+ NULL, "pica", DV_DULL, NULL, 0
+};
void pica_intr_establish __P((struct confargs *, int (*)(void *), void *));
void pica_intr_disestablish __P((struct confargs *));
struct confargs *ca = aux;
/* Make sure that we're looking for a PICA. */
- if (strcmp(ca->ca_name, picacd.cd_name) != 0)
+ if (strcmp(ca->ca_name, pica_cd.cd_name) != 0)
return (0);
/* Make sure that unit exists. */
pica_cvtaddr(ca)
struct confargs *ca;
{
- struct pica_softc *sc = picacd.cd_devs[0];
+ struct pica_softc *sc = pica_cd.cd_devs[0];
return(sc->sc_devs[ca->ca_slot].ps_base + ca->ca_offset);
intr_handler_t handler;
void *val;
{
- struct pica_softc *sc = picacd.cd_devs[0];
+ struct pica_softc *sc = pica_cd.cd_devs[0];
int slot;
pica_intr_disestablish(ca)
struct confargs *ca;
{
- struct pica_softc *sc = picacd.cd_devs[0];
+ struct pica_softc *sc = pica_cd.cd_devs[0];
int slot;
* SUCH DAMAGE.
*
* from: @(#)pmap.c 8.4 (Berkeley) 1/26/94
- * $Id: pmap.c,v 1.1.1.1 1995/10/18 10:39:18 deraadt Exp $
+ * $Id: pmap.c,v 1.2 1996/05/01 18:16:17 pefo Exp $
*/
/*
vm_size_t mem_size; /* memory size in bytes */
vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss)*/
vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */
-int picapagesperpage; /* PAGE_SIZE / NBPG */
#ifdef ATTR
char *pmap_attributes; /* reference and modify bits */
#endif
virtual_avail = VM_MIN_KERNEL_ADDRESS;
virtual_end = VM_MIN_KERNEL_ADDRESS + Sysmapsize * NBPG;
/* XXX need to decide how to set cnt.v_page_size */
- picapagesperpage = 1;
simple_lock_init(&pmap_kernel()->pm_lock);
pmap_kernel()->pm_count = 1;
pmap_zero_page(VM_PAGE_TO_PHYS(mem));
pmap->pm_segtab = stp = (struct segtab *)
MACH_PHYS_TO_CACHED(VM_PAGE_TO_PHYS(mem));
- i = picapagesperpage * (NBPG / sizeof(struct segtab));
+ i = NBPG / sizeof(struct segtab);
s = splimp();
while (--i != 0) {
stp++;
* Check if they are cache index compatible. If not
* remove all mappings, flush the cache and set page
* to be mapped uncached. Caching will be restored
- * when pages are mapped compatible again.
+ * when pages are mapped compatible again. NOT!
*/
for (npv = pv; npv; npv = npv->pv_next) {
/*
* Check cache aliasing incompatibility
*/
if((npv->pv_va & machCacheAliasMask) != (va & machCacheAliasMask)) {
+ printf("pmap_enter: creating uncached mapping.\n");
pmap_page_cache(pa,PV_UNCACHED);
MachFlushDCache(pv->pv_va, PAGE_SIZE);
npte = (npte & ~PG_CACHEMODE) | PG_UNCACHED;
pte = kvtopte(va);
npte |= vad_to_pfn(pa) | PG_ROPAGE | PG_G;
if (wired) {
- pmap->pm_stats.wired_count += picapagesperpage;
+ pmap->pm_stats.wired_count++;
npte |= PG_WIRED;
}
- i = picapagesperpage;
- do {
- if (!(pte->pt_entry & PG_V)) {
- pmap->pm_stats.resident_count++;
- } else {
+ if (!(pte->pt_entry & PG_V)) {
+ pmap->pm_stats.resident_count++;
+ } else {
#ifdef DIAGNOSTIC
- if (pte->pt_entry & PG_WIRED)
- panic("pmap_enter: kernel wired");
+ if (pte->pt_entry & PG_WIRED)
+ panic("pmap_enter: kernel wired");
#endif
- }
- /*
- * Update the same virtual address entry.
- */
- j = MachTLBUpdate(va, npte);
- pte->pt_entry = npte;
- va += NBPG;
- npte += vad_to_pfn(NBPG);
- pte++;
- } while (--i != 0);
+ }
+ /*
+ * Update the same virtual address entry.
+ */
+ j = MachTLBUpdate(va, npte);
+ pte->pt_entry = npte;
return;
}
*/
npte |= vad_to_pfn(pa);
if (wired) {
- pmap->pm_stats.wired_count += picapagesperpage;
+ pmap->pm_stats.wired_count++;
npte |= PG_WIRED;
}
#ifdef DEBUG
printf("\n");
}
#endif
- i = picapagesperpage;
- do {
- pte->pt_entry = npte;
- if (pmap->pm_tlbgen == tlbpid_gen)
- j = MachTLBUpdate(va | (pmap->pm_tlbpid <<
- VMMACH_TLB_PID_SHIFT), npte);
- va += NBPG;
- npte += vad_to_pfn(NBPG);
- pte++;
- } while (--i != 0);
+ if (!(pte->pt_entry & PG_V)) {
+ pmap->pm_stats.resident_count++;
+ }
+ pte->pt_entry = npte;
+ if (pmap->pm_tlbgen == tlbpid_gen)
+ j = MachTLBUpdate(va | (pmap->pm_tlbpid <<
+ VMMACH_TLB_PID_SHIFT), npte);
}
/*
pte += (va >> PGSHIFT) & (NPTEPG - 1);
}
- i = picapagesperpage;
if (!(pte->pt_entry & PG_WIRED) && p)
- pmap->pm_stats.wired_count += i;
+ pmap->pm_stats.wired_count++;
else if ((pte->pt_entry & PG_WIRED) && !p)
- pmap->pm_stats.wired_count -= i;
- do {
- if (pte->pt_entry & PG_V)
- pte->pt_entry = (pte->pt_entry & ~PG_WIRED) | p;
- pte++;
- } while (--i != 0);
+ pmap->pm_stats.wired_count--;
+
+ if (pte->pt_entry & PG_V)
+ pte->pt_entry = (pte->pt_entry & ~PG_WIRED) | p;
}
/*
splx(spl);
}
}
+
+/*
+ * Find first virtual address >= *vap that doesn't cause
+ * a cache alias conflict.
+ */
+void
+pmap_prefer(foff, vap)
+ register vm_offset_t foff;
+ register vm_offset_t *vap;
+{
+ register vm_offset_t va = *vap;
+ register long m, d;
+
+ m = 0x10000; /* Max aliased cache size */
+
+ d = foff - va;
+ d &= (m-1);
+ *vap = va + d;
+}
+
* From:
* Id: procfs_i386.c,v 4.1 1993/12/17 10:47:45 jsp Rel
*
- * $Id: process_machdep.c,v 1.1.1.1 1995/10/18 10:39:19 deraadt Exp $
+ * $Id: process_machdep.c,v 1.2 1996/05/01 18:16:20 pefo Exp $
*/
/*
struct proc *p;
struct reg *regs;
{
+ bcopy((caddr_t)p->p_md.md_regs, (caddr_t)regs, sizeof(struct reg));
return (0);
}
struct proc *p;
struct reg *regs;
{
+ bcopy((caddr_t)regs, (caddr_t)p->p_md.md_regs, sizeof(struct reg));
+/*XXX Clear to user set bits!! */
return (0);
}
process_sstep(p, sstep)
struct proc *p;
{
+ if(sstep)
+ cpu_singlestep(p);
return (0);
}
struct proc *p;
caddr_t addr;
{
+ p->p_md.md_regs[PC] = (int)addr;
return (0);
}
* from: Utah Hdr: trap.c 1.32 91/04/06
*
* from: @(#)trap.c 8.5 (Berkeley) 1/11/94
- * $Id: trap.c,v 1.4 1996/01/12 16:45:19 deraadt Exp $
+ * $Id: trap.c,v 1.5 1996/05/01 18:16:22 pefo Exp $
*/
#include <sys/param.h>
#include <machine/psl.h>
#include <machine/reg.h>
#include <machine/cpu.h>
+#include <machine/pio.h>
#include <machine/autoconf.h>
#include <machine/pte.h>
#include <machine/pmap.h>
locr0[V0] = i;
locr0[A3] = 1;
}
+ if(code == SYS_ptrace)
+ MachFlushCache();
done:
#ifdef SYSCALL_DEBUG
scdebug_ret(p, code, i, rval);
case T_BREAK+T_USER:
{
register unsigned va, instr;
+ struct uio uio;
+ struct iovec iov;
/* compute address of break instruction */
va = pc;
printf("trap: %s (%d) breakpoint %x at %x: (adr %x ins %x)\n",
p->p_comm, p->p_pid, instr, pc,
p->p_md.md_ss_addr, p->p_md.md_ss_instr); /* XXX */
-#endif
-#ifdef DEBUG
- if (instr == MACH_BREAK_BRKPT || instr == MACH_BREAK_SSTEP)
- goto err;
#endif
if (p->p_md.md_ss_addr != va || instr != MACH_BREAK_SSTEP) {
i = SIGTRAP;
break;
}
- /* restore original instruction and clear BP */
- i = suiword((caddr_t)va, p->p_md.md_ss_instr);
- if (i < 0) {
- vm_offset_t sa, ea;
- int rv;
+ /*
+ * Restore original instruction and clear BP
+ */
+ iov.iov_base = (caddr_t)&p->p_md.md_ss_instr;
+ iov.iov_len = sizeof(int);
+ uio.uio_iov = &iov;
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = (off_t)va;
+ uio.uio_resid = sizeof(int);
+ uio.uio_segflg = UIO_SYSSPACE;
+ uio.uio_rw = UIO_WRITE;
+ uio.uio_procp = curproc;
+ i = procfs_domem(p, p, NULL, &uio);
+ MachFlushCache();
- sa = trunc_page((vm_offset_t)va);
- ea = round_page((vm_offset_t)va+sizeof(int)-1);
- rv = vm_map_protect(&p->p_vmspace->vm_map, sa, ea,
- VM_PROT_DEFAULT, FALSE);
- if (rv == KERN_SUCCESS) {
- i = suiword((caddr_t)va, p->p_md.md_ss_instr);
- (void) vm_map_protect(&p->p_vmspace->vm_map,
- sa, ea, VM_PROT_READ|VM_PROT_EXECUTE,
- FALSE);
- }
- }
if (i < 0)
printf("Warning: can't restore instruction at %x: %x\n",
p->p_md.md_ss_addr, p->p_md.md_ss_instr);
+
p->p_md.md_ss_addr = 0;
i = SIGTRAP;
break;
InstFmt inst;
unsigned retAddr;
int condition;
- extern unsigned GetBranchDest();
+#define GetBranchDest(InstPtr, inst) \
+ ((unsigned)InstPtr + 4 + ((short)inst.IType.imm << 2))
- inst = *(InstFmt *)instPC;
+
+ if(allowNonBranch == 0) {
+ inst = *(InstFmt *)instPC;
+ }
+ else {
+ inst = *(InstFmt *)&allowNonBranch;
+ }
#if 0
printf("regsPtr=%x PC=%x Inst=%x fpcCsr=%x\n", regsPtr, instPC,
inst.word, fpcCSR); /* XXX */
case OP_BLTZAL:
case OP_BLTZALL:
if ((int)(regsPtr[inst.RType.rs]) < 0)
- retAddr = GetBranchDest((InstFmt *)instPC);
+ retAddr = GetBranchDest(instPC, inst);
else
retAddr = instPC + 8;
break;
case OP_BGEZAL:
case OP_BGEZALL:
if ((int)(regsPtr[inst.RType.rs]) >= 0)
- retAddr = GetBranchDest((InstFmt *)instPC);
+ retAddr = GetBranchDest(instPC, inst);
else
retAddr = instPC + 8;
break;
case OP_BEQ:
case OP_BEQL:
if (regsPtr[inst.RType.rs] == regsPtr[inst.RType.rt])
- retAddr = GetBranchDest((InstFmt *)instPC);
+ retAddr = GetBranchDest(instPC, inst);
else
retAddr = instPC + 8;
break;
case OP_BNE:
case OP_BNEL:
if (regsPtr[inst.RType.rs] != regsPtr[inst.RType.rt])
- retAddr = GetBranchDest((InstFmt *)instPC);
+ retAddr = GetBranchDest(instPC, inst);
else
retAddr = instPC + 8;
break;
case OP_BLEZ:
case OP_BLEZL:
if ((int)(regsPtr[inst.RType.rs]) <= 0)
- retAddr = GetBranchDest((InstFmt *)instPC);
+ retAddr = GetBranchDest(instPC, inst);
else
retAddr = instPC + 8;
break;
case OP_BGTZ:
case OP_BGTZL:
if ((int)(regsPtr[inst.RType.rs]) > 0)
- retAddr = GetBranchDest((InstFmt *)instPC);
+ retAddr = GetBranchDest(instPC, inst);
else
retAddr = instPC + 8;
break;
else
condition = !(fpcCSR & MACH_FPC_COND_BIT);
if (condition)
- retAddr = GetBranchDest((InstFmt *)instPC);
+ retAddr = GetBranchDest(instPC, inst);
else
retAddr = instPC + 8;
break;
return (retAddr);
}
-unsigned
-GetBranchDest(InstPtr)
- InstFmt *InstPtr;
-{
- return ((unsigned)InstPtr + 4 + ((short)InstPtr->IType.imm << 2));
-}
-
/*
* This routine is called by procxmt() to single step one instruction.
* We do this by storing a break instruction after the current instruction,
register unsigned va;
register int *locr0 = p->p_md.md_regs;
int i;
+ int bpinstr = MACH_BREAK_SSTEP;
+ int curinstr;
+ struct uio uio;
+ struct iovec iov;
+
+ /*
+ * Fetch what's at the current location.
+ */
+ iov.iov_base = (caddr_t)&curinstr;
+ iov.iov_len = sizeof(int);
+ uio.uio_iov = &iov;
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = (off_t)locr0[PC];
+ uio.uio_resid = sizeof(int);
+ uio.uio_segflg = UIO_SYSSPACE;
+ uio.uio_rw = UIO_READ;
+ uio.uio_procp = curproc;
+ procfs_domem(curproc, p, NULL, &uio);
/* compute next address after current location */
- va = MachEmulateBranch(locr0, locr0[PC], locr0[FSR], 1);
- if (p->p_md.md_ss_addr || p->p_md.md_ss_addr == va ||
- !useracc((caddr_t)va, 4, B_READ)) {
+ if(curinstr != 0) {
+ va = MachEmulateBranch(locr0, locr0[PC], locr0[FSR], curinstr);
+ }
+ else {
+ va = locr0[PC] + 4;
+ }
+ if (p->p_md.md_ss_addr) {
printf("SS %s (%d): breakpoint already set at %x (va %x)\n",
p->p_comm, p->p_pid, p->p_md.md_ss_addr, va); /* XXX */
return (EFAULT);
}
p->p_md.md_ss_addr = va;
- p->p_md.md_ss_instr = fuiword((caddr_t)va);
- i = suiword((caddr_t)va, MACH_BREAK_SSTEP);
- if (i < 0) {
- vm_offset_t sa, ea;
- int rv;
+ /*
+ * Fetch what's at the current location.
+ */
+ iov.iov_base = (caddr_t)&p->p_md.md_ss_instr;
+ iov.iov_len = sizeof(int);
+ uio.uio_iov = &iov;
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = (off_t)va;
+ uio.uio_resid = sizeof(int);
+ uio.uio_segflg = UIO_SYSSPACE;
+ uio.uio_rw = UIO_READ;
+ uio.uio_procp = curproc;
+ procfs_domem(curproc, p, NULL, &uio);
+
+ /*
+ * Store breakpoint instruction at the "next" location now.
+ */
+ iov.iov_base = (caddr_t)&bpinstr;
+ iov.iov_len = sizeof(int);
+ uio.uio_iov = &iov;
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = (off_t)va;
+ uio.uio_resid = sizeof(int);
+ uio.uio_segflg = UIO_SYSSPACE;
+ uio.uio_rw = UIO_WRITE;
+ uio.uio_procp = curproc;
+ i = procfs_domem(curproc, p, NULL, &uio);
+ MachFlushCache();
- sa = trunc_page((vm_offset_t)va);
- ea = round_page((vm_offset_t)va+sizeof(int)-1);
- rv = vm_map_protect(&p->p_vmspace->vm_map, sa, ea,
- VM_PROT_DEFAULT, FALSE);
- if (rv == KERN_SUCCESS) {
- i = suiword((caddr_t)va, MACH_BREAK_SSTEP);
- (void) vm_map_protect(&p->p_vmspace->vm_map,
- sa, ea, VM_PROT_READ|VM_PROT_EXECUTE, FALSE);
- }
- }
if (i < 0)
return (EFAULT);
#if 0
printf("SS %s (%d): breakpoint set at %x: %x (pc %x) br %x\n",
p->p_comm, p->p_pid, p->p_md.md_ss_addr,
- p->p_md.md_ss_instr, locr0[PC], fuword((caddr_t)va)); /* XXX */
+ p->p_md.md_ss_instr, locr0[PC], curinstr); /* XXX */
#endif
return (0);
}
* from: Utah Hdr: vm_machdep.c 1.21 91/04/06
*
* from: @(#)vm_machdep.c 8.3 (Berkeley) 1/4/94
- * $Id: vm_machdep.c,v 1.1.1.1 1995/10/18 10:39:19 deraadt Exp $
+ * $Id: vm_machdep.c,v 1.2 1996/05/01 18:16:25 pefo Exp $
*/
*
* All requests are (re)mapped into kernel VA space via the phys_map
*/
-vmapbuf(bp)
- register struct buf *bp;
+void
+vmapbuf(bp, len)
+ struct buf *bp;
+ vm_size_t len;
{
register caddr_t addr;
register vm_size_t sz;
addr = bp->b_saveaddr = bp->b_un.b_addr;
off = (int)addr & PGOFSET;
p = bp->b_proc;
- sz = round_page(bp->b_bcount + off);
+ sz = round_page(off + len);
kva = kmem_alloc_wait_align(phys_map, sz, (vm_size_t)addr & machCacheAliasMask);
bp->b_un.b_addr = (caddr_t) (kva + off);
sz = atop(sz);
* Free the io map PTEs associated with this IO operation.
* We also invalidate the TLB entries and restore the original b_addr.
*/
-vunmapbuf(bp)
- register struct buf *bp;
+void
+vunmapbuf(bp, len)
+ struct buf *bp;
+ vm_size_t len;
{
register caddr_t addr = bp->b_un.b_addr;
register vm_size_t sz;
if ((bp->b_flags & B_PHYS) == 0)
panic("vunmapbuf");
- sz = round_page(bp->b_bcount + ((int)addr & PGOFSET));
+ sz = round_page(len + ((int)addr & PGOFSET));
kva = (vm_offset_t)((int)addr & ~PGOFSET);
kmem_free_wakeup(phys_map, kva, sz);
bp->b_un.b_addr = bp->b_saveaddr;