Date: Sun, 7 Feb 2010 19:34:08 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r203626 - in projects/ppc64/sys: conf modules modules/hwpmc modules/sound/driver modules/uart powerpc/aim powerpc/include powerpc/powerpc powerpc64/powerpc64 Message-ID: <201002071934.o17JY8XY013775@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Sun Feb 7 19:34:08 2010 New Revision: 203626 URL: http://svn.freebsd.org/changeset/base/203626 Log: Make KLDs work correctly on powerpc64. Added: projects/ppc64/sys/powerpc64/powerpc64/mem.c (contents, props changed) Modified: projects/ppc64/sys/conf/kmod.mk projects/ppc64/sys/modules/Makefile projects/ppc64/sys/modules/hwpmc/Makefile projects/ppc64/sys/modules/sound/driver/Makefile projects/ppc64/sys/modules/uart/Makefile projects/ppc64/sys/powerpc/aim/swtch64.S projects/ppc64/sys/powerpc/include/param.h projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c Modified: projects/ppc64/sys/conf/kmod.mk ============================================================================== --- projects/ppc64/sys/conf/kmod.mk Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/conf/kmod.mk Sun Feb 7 19:34:08 2010 (r203626) @@ -124,7 +124,7 @@ CFLAGS+= ${DEBUG_FLAGS} CFLAGS+= -fno-omit-frame-pointer .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" CFLAGS+= -mlongcall -fno-omit-frame-pointer .endif Modified: projects/ppc64/sys/modules/Makefile ============================================================================== --- projects/ppc64/sys/modules/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -308,7 +308,7 @@ SUBDIR= ${_3dfx} \ ${_zfs} \ zlib \ -.if ${MACHINE_ARCH} != "powerpc" +.if ${MACHINE_ARCH} != "powerpc" && ${MACHINE_ARCH} != "powerpc64" _syscons= syscons _vpo= vpo .endif @@ -597,7 +597,7 @@ _wi= wi _xe= xe .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" _an= an _bm= bm _cpufreq= cpufreq Modified: projects/ppc64/sys/modules/hwpmc/Makefile ============================================================================== --- projects/ppc64/sys/modules/hwpmc/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/hwpmc/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -28,7 +28,7 @@ SRCS+= device_if.h bus_if.h SRCS+= hwpmc_ia64.c .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" SRCS+= hwpmc_powerpc.c .endif Modified: projects/ppc64/sys/modules/sound/driver/Makefile ============================================================================== --- projects/ppc64/sys/modules/sound/driver/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/sound/driver/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -15,7 +15,7 @@ SUBDIR+= audiocs .endif .endif -.if ${MACHINE_ARCH} == "powerpc" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" SUBDIR+= ai2s davbus .endif Modified: projects/ppc64/sys/modules/uart/Makefile ============================================================================== --- projects/ppc64/sys/modules/uart/Makefile Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/modules/uart/Makefile Sun Feb 7 19:34:08 2010 (r203626) @@ -16,6 +16,8 @@ SRCS= uart_bus_acpi.c ${uart_bus_ebus} u uart_if.c uart_if.h uart_subr.c uart_tty.c .if ${MACHINE} == "sun4v" SRCS+= uart_cpu_sparc64.c +.elif ${MACHINE} == "powerpc64" +SRCS+= uart_cpu_powerpc.c .else SRCS+= uart_cpu_${MACHINE}.c .endif Modified: projects/ppc64/sys/powerpc/aim/swtch64.S ============================================================================== --- projects/ppc64/sys/powerpc/aim/swtch64.S Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/powerpc/aim/swtch64.S Sun Feb 7 19:34:08 2010 (r203626) @@ -126,6 +126,8 @@ ENTRY(cpu_switch) mr %r16,%r5 /* and the new lock */ mr %r17,%r6 /* and the PCB */ + stdu %r1,-48(%r1) + lwz %r7,PCB_FLAGS(%r17) /* Save FPU context if needed */ andi. %r7, %r7, PCB_FPU @@ -147,6 +149,8 @@ ENTRY(cpu_switch) bl .pmap_deactivate /* Deactivate the current pmap */ nop + addi %r1,%r1,48 + std %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */ cpu_switchin: @@ -165,6 +169,8 @@ blocked_loop: ld %r17,TD_PCB(%r15) /* Store new current PCB */ std %r17,PC_CURPCB(%r7) + stdu %r1,-48(%r1) + mr %r3,%r15 /* Get new thread ptr */ bl .pmap_activate /* Activate the new address space */ nop @@ -188,6 +194,7 @@ blocked_loop: /* thread to restore is in r3 */ .L4: + addi %r1,%r1,48 mr %r3,%r17 /* Recover PCB ptr */ ld %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs. */ ld %r13,PCB_CONTEXT+1*8(%r3) @@ -272,9 +279,11 @@ ENTRY(fork_trampoline) ld %r3,CF_FUNC(%r1) ld %r4,CF_ARG0(%r1) ld %r5,CF_ARG1(%r1) + + stdu %r1,-48(%r1) bl .fork_exit nop - addi %r1,%r1,CF_SIZE-FSP /* Allow 8 bytes in front of + addi %r1,%r1,48+CF_SIZE-FSP /* Allow 8 bytes in front of trapframe to simulate FRAME_SETUP does when allocating space for a frame pointer/saved LR */ Modified: projects/ppc64/sys/powerpc/include/param.h ============================================================================== --- projects/ppc64/sys/powerpc/include/param.h Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/powerpc/include/param.h Sun Feb 7 19:34:08 2010 (r203626) @@ -76,7 +76,7 @@ * This does not reflect the optimal alignment, just the possibility * (within reasonable limits). */ -#define ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof (t) - 1)) == 0) +#define ALIGNED_POINTER(p, t) ((((uintptr_t)(p)) & (sizeof (t) - 1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an Modified: projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c Sun Feb 7 19:32:33 2010 (r203625) +++ projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c Sun Feb 7 19:34:08 2010 (r203626) @@ -125,7 +125,6 @@ elf_reloc_internal(linker_file_t lf, Elf int type, int local, elf_lookup_fn lookup) { Elf_Addr *where; - Elf_Half *hwhere; Elf_Addr addr; Elf_Addr addend; Elf_Word rtype, symidx; @@ -138,7 +137,6 @@ elf_reloc_internal(linker_file_t lf, Elf case ELF_RELOC_RELA: rela = (const Elf_Rela *)data; where = (Elf_Addr *) (relocbase + rela->r_offset); - hwhere = (Elf_Half *) (relocbase + rela->r_offset); addend = rela->r_addend; rtype = ELF_R_TYPE(rela->r_info); symidx = ELF_R_SYM(rela->r_info); @@ -152,7 +150,7 @@ elf_reloc_internal(linker_file_t lf, Elf case R_PPC_NONE: break; - case R_PPC_ADDR32: /* word32 S + A */ + case R_PPC64_ADDR64: /* doubleword64 S + A */ addr = lookup(lf, symidx, 1); if (addr == 0) return -1; @@ -160,43 +158,16 @@ elf_reloc_internal(linker_file_t lf, Elf *where = addr; break; - case R_PPC_ADDR16_LO: /* #lo(S) */ - addr = lookup(lf, symidx, 1); - if (addr == 0) - return -1; - /* - * addend values are sometimes relative to sections - * (i.e. .rodata) in rela, where in reality they - * are relative to relocbase. Detect this condition. - */ - if (addr > relocbase && addr <= (relocbase + addend)) - addr = relocbase + addend; - else - addr += addend; - *hwhere = addr & 0xffff; - break; + case R_PPC_RELATIVE: /* doubleword64 B + A */ + *where = elf_relocaddr(lf, relocbase + addend); + break; - case R_PPC_ADDR16_HA: /* #ha(S) */ + case R_PPC_JMP_SLOT: /* function descriptor copy */ addr = lookup(lf, symidx, 1); - if (addr == 0) - return -1; - /* - * addend values are sometimes relative to sections - * (i.e. .rodata) in rela, where in reality they - * are relative to relocbase. Detect this condition. - */ - if (addr > relocbase && addr <= (relocbase + addend)) - addr = relocbase + addend; - else - addr += addend; - *hwhere = ((addr >> 16) + ((addr & 0x8000) ? 1 : 0)) - & 0xffff; + memcpy(where, (Elf_Addr *)addr, 3*sizeof(Elf_Addr)); + __asm __volatile("dcbst 0,%0; sync" :: "r"(where) : "memory"); break; - case R_PPC_RELATIVE: /* word32 B + A */ - *where = elf_relocaddr(lf, relocbase + addend); - break; - default: printf("kldload: unexpected relocation type %d\n", (int) rtype); Added: projects/ppc64/sys/powerpc64/powerpc64/mem.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/ppc64/sys/powerpc64/powerpc64/mem.c Sun Feb 7 19:34:08 2010 (r203626) @@ -0,0 +1 @@ +link ../../powerpc/powerpc/mem.c \ No newline at end of file
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002071934.o17JY8XY013775>