From 5a1f692161cbd2199a741fc022efa7ae95db97e2 Mon Sep 17 00:00:00 2001 From: gwr Date: Fri, 17 Oct 1997 03:25:05 +0000 Subject: [PATCH] Sync. with the sun3x (mostly cosmetic changes). --- sys/arch/sun3/dev/idprom.c | 47 +++++++++++++++++------------------ sys/arch/sun3/sun3/bus_subr.c | 32 +++++++++++++----------- sys/arch/sun3/sun3/idprom.c | 47 +++++++++++++++++------------------ 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/sys/arch/sun3/dev/idprom.c b/sys/arch/sun3/dev/idprom.c index 218005394cbd..dd811c53e0f6 100644 --- a/sys/arch/sun3/dev/idprom.c +++ b/sys/arch/sun3/dev/idprom.c @@ -1,4 +1,4 @@ -/* $NetBSD: idprom.c,v 1.20 1997/10/06 19:58:06 gwr Exp $ */ +/* $NetBSD: idprom.c,v 1.21 1997/10/17 03:26:20 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -57,25 +57,17 @@ */ struct idprom identity_prom; -/* - * This is called very early during startup to - * get a copy of the idprom from control space. - */ +static int idprom_hostid __P((void)); + void idprom_init() { - struct idprom *idp; - char *dst; + u_char *dst; vm_offset_t src; int len, x, xorsum; - union { - long l; - char c[4]; - } hid; /* Copy the IDPROM contents and do the checksum. */ - idp = &identity_prom; - dst = (char*)idp; + dst = (u_char *) &identity_prom; src = IDPROM_BASE; len = IDPROM_SIZE; xorsum = 0; /* calculated as xor of data */ @@ -87,10 +79,23 @@ idprom_init() } while (--len > 0); if (xorsum != 0) - mon_printf("idprom: bad checksum=%d\n", xorsum); - if (idp->idp_format < 1) - mon_printf("idprom: bad version=%d\n", idp->idp_format); + mon_printf("idprom: bad checksum\n"); + if (identity_prom.idp_format < 1) + mon_printf("idprom: bad version\n"); + hostid = idprom_hostid(); +} + +static int +idprom_hostid() +{ + struct idprom *idp; + union { + long l; + char c[4]; + } hid; + + idp = &identity_prom; /* * Construct the hostid from the idprom contents. * This appears to be the way SunOS does it. @@ -99,19 +104,13 @@ idprom_init() hid.c[1] = idp->idp_serialnum[0]; hid.c[2] = idp->idp_serialnum[1]; hid.c[3] = idp->idp_serialnum[2]; - hostid = hid.l; + return (hid.l); } void idprom_etheraddr(eaddrp) u_char *eaddrp; { - u_char *src, *dst; - int len = 6; - src = identity_prom.idp_etheraddr; - dst = eaddrp; - - do *dst++ = *src++; - while (--len > 0); + bcopy(identity_prom.idp_etheraddr, eaddrp, 6); } diff --git a/sys/arch/sun3/sun3/bus_subr.c b/sys/arch/sun3/sun3/bus_subr.c index d6b63af72fa4..349270d29edf 100644 --- a/sys/arch/sun3/sun3/bus_subr.c +++ b/sys/arch/sun3/sun3/bus_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: bus_subr.c,v 1.2 1997/04/25 18:06:45 gwr Exp $ */ +/* $NetBSD: bus_subr.c,v 1.3 1997/10/17 03:25:05 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -153,7 +153,8 @@ static const int bustype_to_ptetype[4] = { * Try the access using peek_* * Clean up temp. mapping */ -int bus_peek(bustype, paddr, sz) +int +bus_peek(bustype, paddr, sz) int bustype, paddr, sz; { int off, pte, rv; @@ -194,7 +195,7 @@ int bus_peek(bustype, paddr, sz) /* All mappings in tmp_vpages are non-cached, so no flush. */ set_pte(pgva, PG_INVAL); - return rv; + return (rv); } static const int bustype_to_pmaptype[4] = { @@ -205,22 +206,22 @@ static const int bustype_to_pmaptype[4] = { }; void * -bus_mapin(bustype, paddr, sz) - int bustype, paddr, sz; +bus_mapin(bustype, pa, sz) + int bustype, pa, sz; { - int off, pa, pmt; vm_offset_t va, retval; + int off; if (bustype & ~3) return (NULL); - off = paddr & PGOFSET; - pa = paddr - off; + off = pa & PGOFSET; + pa -= off; sz += off; - sz = round_page(sz); + sz = m68k_round_page(sz); - pmt = bustype_to_pmaptype[bustype]; - pmt |= PMAP_NC; /* non-cached */ + pa |= bustype_to_pmaptype[bustype]; + pa |= PMAP_NC; /* non-cached */ /* Get some kernel virtual address space. */ va = kmem_alloc_wait(kernel_map, sz); @@ -229,15 +230,16 @@ bus_mapin(bustype, paddr, sz) retval = va + off; /* Map it to the specified bus. */ -#if 0 /* XXX */ +#if 0 /* This has a problem with wrap-around... */ - pmap_map((int)va, pa | pmt, pa + sz, VM_PROT_ALL); + pmap_map((int)va, pa, pa + sz, VM_PROT_ALL); #else do { - pmap_enter(pmap_kernel(), va, pa | pmt, VM_PROT_ALL, FALSE); + pmap_enter(pmap_kernel(), va, pa, VM_PROT_ALL, FALSE); va += NBPG; pa += NBPG; - } while ((sz -= NBPG) > 0); + sz -= NBPG; + } while (sz > 0); #endif return ((void*)retval); diff --git a/sys/arch/sun3/sun3/idprom.c b/sys/arch/sun3/sun3/idprom.c index 218005394cbd..dd811c53e0f6 100644 --- a/sys/arch/sun3/sun3/idprom.c +++ b/sys/arch/sun3/sun3/idprom.c @@ -1,4 +1,4 @@ -/* $NetBSD: idprom.c,v 1.20 1997/10/06 19:58:06 gwr Exp $ */ +/* $NetBSD: idprom.c,v 1.21 1997/10/17 03:26:20 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -57,25 +57,17 @@ */ struct idprom identity_prom; -/* - * This is called very early during startup to - * get a copy of the idprom from control space. - */ +static int idprom_hostid __P((void)); + void idprom_init() { - struct idprom *idp; - char *dst; + u_char *dst; vm_offset_t src; int len, x, xorsum; - union { - long l; - char c[4]; - } hid; /* Copy the IDPROM contents and do the checksum. */ - idp = &identity_prom; - dst = (char*)idp; + dst = (u_char *) &identity_prom; src = IDPROM_BASE; len = IDPROM_SIZE; xorsum = 0; /* calculated as xor of data */ @@ -87,10 +79,23 @@ idprom_init() } while (--len > 0); if (xorsum != 0) - mon_printf("idprom: bad checksum=%d\n", xorsum); - if (idp->idp_format < 1) - mon_printf("idprom: bad version=%d\n", idp->idp_format); + mon_printf("idprom: bad checksum\n"); + if (identity_prom.idp_format < 1) + mon_printf("idprom: bad version\n"); + hostid = idprom_hostid(); +} + +static int +idprom_hostid() +{ + struct idprom *idp; + union { + long l; + char c[4]; + } hid; + + idp = &identity_prom; /* * Construct the hostid from the idprom contents. * This appears to be the way SunOS does it. @@ -99,19 +104,13 @@ idprom_init() hid.c[1] = idp->idp_serialnum[0]; hid.c[2] = idp->idp_serialnum[1]; hid.c[3] = idp->idp_serialnum[2]; - hostid = hid.l; + return (hid.l); } void idprom_etheraddr(eaddrp) u_char *eaddrp; { - u_char *src, *dst; - int len = 6; - src = identity_prom.idp_etheraddr; - dst = eaddrp; - - do *dst++ = *src++; - while (--len > 0); + bcopy(identity_prom.idp_etheraddr, eaddrp, 6); }