Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc Arrange some machine-dependent code.
details: https://anonhg.NetBSD.org/src/rev/21aca4b3bd68
branches: trunk
changeset: 573057:21aca4b3bd68
user: shige <shige%NetBSD.org@localhost>
date: Tue Jan 18 17:11:25 2005 +0000
description:
Arrange some machine-dependent code.
- ibm40x_machdep.c: ibm40x specific
. ibm40x_memsize_init
. mem_regions
. other functions are moved to machdep.c or ibm4xx_machdep.c.
- ibm4xx_machdep.c: ibm4xx specific
. ibm4xx_init (moved from ibm40x_machdep.c)
. ibm4xx_install_extint (moved from ibm40x_machdep.c)
. ibm4xx_cpu_startup (moved from ibm40x_machdep.c:ibm4xx_startup)
. ibm4xx_dumpsys
diffstat:
sys/arch/powerpc/ibm4xx/ibm40x_machdep.c | 331 +-----------------------------
sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c | 337 +++++++++++++++++++++++++++++++
sys/arch/powerpc/include/ibm4xx/cpu.h | 27 +-
3 files changed, 362 insertions(+), 333 deletions(-)
diffs (truncated from 763 to 300 lines):
diff -r 0988a0c29984 -r 21aca4b3bd68 sys/arch/powerpc/ibm4xx/ibm40x_machdep.c
--- a/sys/arch/powerpc/ibm4xx/ibm40x_machdep.c Tue Jan 18 16:56:24 2005 +0000
+++ b/sys/arch/powerpc/ibm4xx/ibm40x_machdep.c Tue Jan 18 17:11:25 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $ */
+/* $NetBSD: ibm40x_machdep.c,v 1.4 2005/01/18 17:11:25 shige Exp $ */
/*
* Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -67,354 +67,41 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $");
-
-#include "opt_compat_netbsd.h"
-#include "opt_ddb.h"
-#include "opt_kgdb.h"
-#include "opt_ipkdb.h"
+__KERNEL_RCSID(0, "$NetBSD: ibm40x_machdep.c,v 1.4 2005/01/18 17:11:25 shige Exp $");
#include <sys/param.h>
-#include <sys/buf.h>
#include <sys/exec.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/mount.h>
-#include <sys/msgbuf.h>
-#include <sys/proc.h>
-#include <sys/reboot.h>
-#include <sys/sa.h>
-#include <sys/syscallargs.h>
-#include <sys/syslog.h>
#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/user.h>
-#include <sys/boot_flag.h>
-#include <sys/properties.h>
-#include <sys/ksyms.h>
-
-#include <uvm/uvm_extern.h>
-#include <net/netisr.h>
-
-#if defined(DDB)
-#include <machine/db_machdep.h>
-#include <ddb/db_extern.h>
-#endif
-
-#if defined(KGDB)
-#include <sys/kgdb.h>
-#endif
-
-#if defined(IPKDB)
-#include <ipkdb/ipkdb.h>
-#endif
-
-#include <machine/bus.h>
-#include <machine/trap.h>
#include <machine/powerpc.h>
-#include <powerpc/spr.h>
-#include <powerpc/ibm4xx/dcr405gp.h>
/*
* Global variables used here and there
*/
-struct vm_map *exec_map = NULL;
-struct vm_map *mb_map = NULL;
-struct vm_map *phys_map = NULL;
-
-char machine[] = MACHINE; /* from <machine/param.h> */
-char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */
-
-#define MEMREGIONS 8
+#define MEMREGIONS (8)
struct mem_region physmemr[MEMREGIONS]; /* Hard code memory */
struct mem_region availmemr[MEMREGIONS];/* Who's supposed to set these up? */
-extern struct user *proc0paddr;
-
-paddr_t msgbuf_paddr;
-vaddr_t msgbuf_vaddr;
-
-
void
ibm40x_memsize_init(u_int memsize, u_int startkernel)
{
- /* Initialize cache info for memcpy, etc. */
- cpu_probe_cache();
+ /* Initialize cache info for memcpy, etc. */
+ cpu_probe_cache();
memset(physmemr, 0, sizeof physmemr);
memset(availmemr, 0, sizeof availmemr);
+
+ /* Setup physical memory */
physmemr[0].start = 0;
physmemr[0].size = memsize & ~PGOFSET;
- /* Lower memory reserved by eval board BIOS */
+
+ /* Setup availabl memory, lower memory reserved by evb-BIOS */
availmemr[0].start = startkernel;
availmemr[0].size = memsize - availmemr[0].start;
}
void
-ibm4xx_init(void (*handler)(void))
-{
- extern int defaulttrap, defaultsize;
- extern int sctrap, scsize;
- extern int alitrap, alisize;
- extern int dsitrap, dsisize;
- extern int isitrap, isisize;
- extern int mchktrap, mchksize;
- extern int tlbimiss4xx, tlbim4size;
- extern int tlbdmiss4xx, tlbdm4size;
- extern int pitfitwdog, pitfitwdogsize;
- extern int debugtrap, debugsize;
- extern int errata51handler, errata51size;
-#ifdef DDB
- extern int ddblow, ddbsize;
-#endif
-#ifdef IPKDB
- extern int ipkdblow, ipkdbsize;
-#endif
- uintptr_t exc;
- struct cpu_info * const ci = curcpu();
-
- /* Initialize cache info for memcpy, etc. */
- cpu_probe_cache();
-
- /*
- * Initialize lwp0 and current pcb and pmap pointers.
- */
- KASSERT(ci != NULL);
- KASSERT(curcpu() == ci);
- lwp0.l_cpu = ci;
- lwp0.l_addr = proc0paddr;
- memset(lwp0.l_addr, 0, sizeof *lwp0.l_addr);
- KASSERT(lwp0.l_cpu != NULL);
-
- curpcb = &proc0paddr->u_pcb;
- memset(curpcb, 0, sizeof(*curpcb));
- curpcb->pcb_pm = pmap_kernel();
-
- /*
- * Set up trap vectors
- */
- for (exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100)
- switch (exc) {
- default:
- memcpy((void *)exc, &defaulttrap, (size_t)&defaultsize);
- break;
- case EXC_EXI:
- /*
- * This one is (potentially) installed during autoconf
- */
- break;
- case EXC_SC:
- memcpy((void *)EXC_SC, &sctrap, (size_t)&scsize);
- break;
- case EXC_ALI:
- memcpy((void *)EXC_ALI, &alitrap, (size_t)&alisize);
- break;
- case EXC_DSI:
- memcpy((void *)EXC_DSI, &dsitrap, (size_t)&dsisize);
- break;
- case EXC_ISI:
- memcpy((void *)EXC_ISI, &isitrap, (size_t)&isisize);
- break;
- case EXC_MCHK:
- memcpy((void *)EXC_MCHK, &mchktrap, (size_t)&mchksize);
- break;
- case EXC_ITMISS:
- memcpy((void *)EXC_ITMISS, &tlbimiss4xx,
- (size_t)&tlbim4size);
- break;
- case EXC_DTMISS:
- memcpy((void *)EXC_DTMISS, &tlbdmiss4xx,
- (size_t)&tlbdm4size);
- break;
- /*
- * EXC_PIT, EXC_FIT, EXC_WDOG handlers
- * are spaced by 0x10 bytes only..
- */
- case EXC_PIT:
- memcpy((void *)EXC_PIT, &pitfitwdog,
- (size_t)&pitfitwdogsize);
- break;
- case EXC_DEBUG:
- memcpy((void *)EXC_DEBUG, &debugtrap,
- (size_t)&debugsize);
- break;
- case EXC_DTMISS|EXC_ALI:
- /* PPC405GP Rev D errata item 51 */
- memcpy((void *)(EXC_DTMISS|EXC_ALI), &errata51handler,
- (size_t)&errata51size);
- break;
-#if defined(DDB) || defined(IPKDB)
- case EXC_PGM:
-#if defined(DDB)
- memcpy((void *)exc, &ddblow, (size_t)&ddbsize);
-#elif defined(IPKDB)
- memcpy((void *)exc, &ipkdblow, (size_t)&ipkdbsize);
-#endif
-#endif /* DDB | IPKDB */
- break;
- }
-
- __syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
- mtspr(SPR_EVPR, 0); /* Set Exception vector base */
-
- consinit();
-
- /* Handle trap instruction as PGM exception */
- {
- int dbcr0;
- asm volatile("mfspr %0,%1":"=r"(dbcr0):"K"(SPR_DBCR0));
- asm volatile("mtspr %0,%1"::"K"(SPR_DBCR0),"r"(dbcr0 & ~DBCR0_TDE));
- }
-
- /*
- * external interrupt handler install
- */
- if (handler)
- ibm4xx_install_extint(handler);
-
- /*
- * Now enable translation (and machine checks/recoverable interrupts).
- */
- asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0; isync"
- : : "r"(0), "K"(PSL_IR|PSL_DR));
- /* XXXX PSL_ME - With ME set kernel gets stuck... */
-
- KASSERT(curcpu() == ci);
-}
-
-void
-ibm4xx_install_extint(void (*handler)(void))
-{
- extern int extint, extsize;
- extern u_long extint_call;
- u_long offset = (u_long)handler - (u_long)&extint_call;
- int msr;
-
-#ifdef DIAGNOSTIC
- if (offset > 0x1ffffff)
- panic("install_extint: too far away");
-#endif
- asm volatile ("mfmsr %0; wrteei 0" : "=r"(msr));
- extint_call = (extint_call & 0xfc000003) | offset;
- memcpy((void *)EXC_EXI, &extint, (size_t)&extsize);
- __syncicache((void *)&extint_call, sizeof extint_call);
- __syncicache((void *)EXC_EXI, (int)&extsize);
- asm volatile ("mtmsr %0" :: "r"(msr));
-}
-
-/*
- * Machine dependent startup code.
- */
-
-char msgbuf[MSGBUFSIZE];
-
-void
-ibm4xx_startup(const char *model)
-{
- vaddr_t minaddr, maxaddr;
- char pbuf[9];
-
- KASSERT(curcpu() != NULL);
- KASSERT(lwp0.l_cpu != NULL);
- KASSERT(curcpu()->ci_intstk != 0);
- KASSERT(curcpu()->ci_intrdepth == -1);
-
- /*
- * Initialize error message buffer (at end of core).
- */
-#if 0 /* For some reason this fails... --Artem
- * Besides, do we really have to put it at the end of core?
- * Let's use static buffer for now
- */
- if (!(msgbuf_vaddr = uvm_km_alloc(kernel_map, round_page(MSGBUFSIZE))))
- panic("startup: no room for message buffer");
- for (i = 0; i < btoc(MSGBUFSIZE); i++)
- pmap_kenter_pa(msgbuf_vaddr + i * PAGE_SIZE,
- msgbuf_paddr + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE);
- initmsgbuf((caddr_t)msgbuf_vaddr, round_page(MSGBUFSIZE));
-#else
- initmsgbuf((caddr_t)msgbuf, round_page(MSGBUFSIZE));
-#endif
-
- printf("%s", version);
- if (model != NULL)
- printf("Model: %s\n", model);
-
- format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
- printf("total memory = %s\n", pbuf);
-
- minaddr = 0;
Home |
Main Index |
Thread Index |
Old Index