diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2010-07-13 05:32:19 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2010-07-13 05:32:19 +0000 |
commit | 2127edd2e4b37d0e5b88e5d8eed4f87e927f83da (patch) | |
tree | 735db4c7a37fa272b6302d00e5a8c7e4c1bf84cb /sys/powerpc/aim/machdep.c | |
parent | 0ac6bad14a01affb256183801472e3a26ef32a4e (diff) | |
download | FreeBSD-src-2127edd2e4b37d0e5b88e5d8eed4f87e927f83da.zip FreeBSD-src-2127edd2e4b37d0e5b88e5d8eed4f87e927f83da.tar.gz |
MFppc64:
Kernel sources for 64-bit PowerPC, along with build-system changes to keep
32-bit kernels compiling (build system changes for 64-bit kernels are
coming later). Existing 32-bit PowerPC kernel configurations must be
updated after this change to specify their architecture.
Diffstat (limited to 'sys/powerpc/aim/machdep.c')
-rw-r--r-- | sys/powerpc/aim/machdep.c | 91 |
1 files changed, 61 insertions, 30 deletions
diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c index 45d9418..a2f13ef 100644 --- a/sys/powerpc/aim/machdep.c +++ b/sys/powerpc/aim/machdep.c @@ -105,7 +105,9 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_pager.h> #include <machine/altivec.h> +#ifndef __powerpc64__ #include <machine/bat.h> +#endif #include <machine/cpu.h> #include <machine/elf.h> #include <machine/fpu.h> @@ -130,7 +132,11 @@ extern vm_offset_t ksym_start, ksym_end; #endif int cold = 1; +#ifdef __powerpc64__ +int cacheline_size = 128; +#else int cacheline_size = 32; +#endif int hw_direct_map = 1; struct pcpu __pcpu[MAXCPU]; @@ -146,24 +152,18 @@ SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size, CTLFLAG_RD, &cacheline_size, 0, ""); -u_int powerpc_init(u_int, u_int, u_int, void *); - -int save_ofw_mapping(void); -int restore_ofw_mapping(void); - -void install_extint(void (*)(void)); +uintptr_t powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *); int setfault(faultbuf); /* defined in locore.S */ -void asm_panic(char *); - long Maxmem = 0; long realmem = 0; struct pmap ofw_pmap; -extern int ofmsr; +#ifndef __powerpc64__ struct bat battable[16]; +#endif struct kva_md_info kmi; @@ -210,9 +210,14 @@ cpu_startup(void *dummy) printf("Physical memory chunk(s):\n"); for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) { - int size1 = phys_avail[indx + 1] - phys_avail[indx]; - - printf("0x%08x - 0x%08x, %d bytes (%d pages)\n", + vm_offset_t size1 = + phys_avail[indx + 1] - phys_avail[indx]; + + #ifdef __powerpc64__ + printf("0x%16lx - 0x%16lx, %ld bytes (%ld pages)\n", + #else + printf("0x%08x - 0x%08x, %d bytes (%ld pages)\n", + #endif phys_avail[indx], phys_avail[indx + 1] - 1, size1, size1 / PAGE_SIZE); } @@ -235,21 +240,27 @@ cpu_startup(void *dummy) extern char kernel_text[], _end[]; +#ifndef __powerpc64__ +/* Bits for running on 64-bit systems in 32-bit mode. */ extern void *testppc64, *testppc64size; extern void *restorebridge, *restorebridgesize; extern void *rfid_patch, *rfi_patch1, *rfi_patch2; +extern void *trapcode64; +#endif + #ifdef SMP extern void *rstcode, *rstsize; #endif -extern void *trapcode, *trapcode64, *trapsize; +extern void *trapcode, *trapsize; extern void *alitrap, *alisize; extern void *dsitrap, *dsisize; extern void *decrint, *decrsize; extern void *extint, *extsize; extern void *dblow, *dbsize; -u_int -powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) +uintptr_t +powerpc_init(vm_offset_t startkernel, vm_offset_t endkernel, + vm_offset_t basekernel, void *mdp) { struct pcpu *pc; vm_offset_t end; @@ -257,9 +268,11 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) size_t trap_offset; void *kmdp; char *env; - uint32_t msr, scratch; + register_t msr, scratch; uint8_t *cache_check; + #ifndef __powerpc64__ int ppc64; + #endif end = 0; kmdp = NULL; @@ -346,9 +359,9 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) case IBM970FX: case IBM970MP: case IBM970GX: - scratch = mfspr64upper(SPR_HID5,msr); + scratch = mfspr(SPR_HID5); scratch &= ~HID5_970_DCBZ_SIZE_HI; - mtspr64(SPR_HID5, scratch, mfspr(SPR_HID5), msr); + mtspr(SPR_HID5, scratch); break; } @@ -390,6 +403,7 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) cacheline_size = 32; } + #ifndef __powerpc64__ /* * Figure out whether we need to use the 64 bit PMAP. This works by * executing an instruction that is only legal on 64-bit PPC (mtmsrd), @@ -449,6 +463,11 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) generictrap = &trapcode; } + #else /* powerpc64 */ + cpu_features |= PPC_FEATURE_64; + generictrap = &trapcode; + #endif + #ifdef SMP bcopy(&rstcode, (void *)(EXC_RST + trap_offset), (size_t)&rstsize); #else @@ -466,9 +485,13 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) bcopy(generictrap, (void *)EXC_TRC, (size_t)&trapsize); bcopy(generictrap, (void *)EXC_BPT, (size_t)&trapsize); #endif - bcopy(&dsitrap, (void *)(EXC_DSI + trap_offset), (size_t)&dsisize); bcopy(&alitrap, (void *)(EXC_ALI + trap_offset), (size_t)&alisize); + bcopy(&dsitrap, (void *)(EXC_DSI + trap_offset), (size_t)&dsisize); bcopy(generictrap, (void *)EXC_ISI, (size_t)&trapsize); + #ifdef __powerpc64__ + bcopy(generictrap, (void *)EXC_DSE, (size_t)&trapsize); + bcopy(generictrap, (void *)EXC_ISE, (size_t)&trapsize); + #endif bcopy(generictrap, (void *)EXC_EXI, (size_t)&trapsize); bcopy(generictrap, (void *)EXC_FPU, (size_t)&trapsize); bcopy(generictrap, (void *)EXC_DECR, (size_t)&trapsize); @@ -524,7 +547,7 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) */ thread0.td_pcb = (struct pcb *) ((thread0.td_kstack + thread0.td_kstack_pages * PAGE_SIZE - - sizeof(struct pcb)) & ~15); + sizeof(struct pcb)) & ~15UL); bzero((void *)thread0.td_pcb, sizeof(struct pcb)); pc->pc_curpcb = thread0.td_pcb; @@ -537,7 +560,8 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) "Boot flags requested debugger"); #endif - return (((uintptr_t)thread0.td_pcb - 16) & ~15); + return (((uintptr_t)thread0.td_pcb - + (sizeof(struct callframe) - 3*sizeof(register_t))) & ~15UL); } void @@ -614,7 +638,7 @@ cpu_halt(void) void cpu_idle(int busy) { - uint32_t msr; + register_t msr; uint16_t vers; msr = mfmsr(); @@ -623,7 +647,7 @@ cpu_idle(int busy) #ifdef INVARIANTS if ((msr & PSL_EE) != PSL_EE) { struct thread *td = curthread; - printf("td msr %x\n", td->td_md.md_saved_msr); + printf("td msr %#lx\n", (u_long)td->td_md.md_saved_msr); panic("ints disabled in idleproc!"); } #endif @@ -710,7 +734,10 @@ kdb_cpu_set_singlestep(void) void cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz) { - +#ifdef __powerpc64__ +/* Copy the SLB contents from the current CPU */ +memcpy(pcpu->pc_slb, PCPU_GET(slb), sizeof(pcpu->pc_slb)); +#endif } void @@ -767,12 +794,6 @@ kcopy(const void *src, void *dst, size_t len) return (0); } -void -asm_panic(char *pstr) -{ - panic(pstr); -} - int db_trap_glue(struct trapframe *); /* Called from trap_subr.S */ int @@ -793,3 +814,13 @@ db_trap_glue(struct trapframe *frame) return (0); } + +#ifndef __powerpc64__ + +uint64_t +va_to_vsid(pmap_t pm, vm_offset_t va) +{ + return ((pm->pm_sr[(uintptr_t)va >> ADDR_SR_SHFT]) & SR_VSID_MASK); +} + +#endif |