Date: Wed, 23 Sep 2020 04:09:03 +0000 (UTC) From: Brandon Bergren <bdragon@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366063 - head/sys/powerpc/ofw Message-ID: <202009230409.08N493LH066524@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdragon Date: Wed Sep 23 04:09:02 2020 New Revision: 366063 URL: https://svnweb.freebsd.org/changeset/base/366063 Log: [PowerPC64LE] Fix RTAS LE calls in pseries. Similar to OPAL calls, switch to big endian to do calls to RTAS. (Missed this one when I was doing the bulk commit of PowerPC64LE support.) Sponsored by: Tag1 Consulting, Inc. Modified: head/sys/powerpc/ofw/ofwcall64.S head/sys/powerpc/ofw/rtas.c Modified: head/sys/powerpc/ofw/ofwcall64.S ============================================================================== --- head/sys/powerpc/ofw/ofwcall64.S Wed Sep 23 03:19:20 2020 (r366062) +++ head/sys/powerpc/ofw/ofwcall64.S Wed Sep 23 04:09:02 2020 (r366063) @@ -296,9 +296,29 @@ ASENTRY_NOPROF(rtascall) std %r6,16(%r1) /* Save MSR */ std %r9,24(%r1) /* Save reference PC for high 32 bits */ +#ifdef __LITTLE_ENDIAN__ + /* Atomic context switch w/ endian change */ + li %r7, 0 + mtmsrd %r7, 1 /* Clear PSL_EE|PSL_RI */ + addis %r7,%r2,TOC_REF(rtasmsr)@ha + ld %r7,TOC_REF(rtasmsr)@l(%r7) + ld %r7,0(%r7) + mtsrr0 %r5 + mtsrr1 %r7 + LOAD_LR_NIA +1: + mflr %r5 + addi %r5, %r5, (2f-1b) + mtlr %r5 + li %r5, 0 + rfid +2: + RETURN_TO_NATIVE_ENDIAN +#else /* Finally, branch to RTAS */ mtctr %r5 bctrl +#endif /* * Reload stack pointer, MSR, reg PC from the reg save area in r1. We Modified: head/sys/powerpc/ofw/rtas.c ============================================================================== --- head/sys/powerpc/ofw/rtas.c Wed Sep 23 03:19:20 2020 (r366062) +++ head/sys/powerpc/ofw/rtas.c Wed Sep 23 04:09:02 2020 (r366063) @@ -29,6 +29,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/endian.h> #include <sys/param.h> #include <sys/kernel.h> #include <sys/lock.h> @@ -90,7 +91,7 @@ rtas_setup(void *junk) /* RTAS must be called with everything turned off in MSR */ rtasmsr = mfmsr(); - rtasmsr &= ~(PSL_IR | PSL_DR | PSL_EE | PSL_SE); + rtasmsr &= ~(PSL_IR | PSL_DR | PSL_EE | PSL_SE | PSL_LE); #ifdef __powerpc64__ rtasmsr &= ~PSL_SF; #endif @@ -215,17 +216,17 @@ rtas_call_method(cell_t token, int nargs, int nreturns if (!rtas_exists() || nargs + nreturns > 12) return (-1); - args.token = token; + args.token = htobe32(token); va_start(ap, nreturns); mtx_lock_spin(&rtas_mtx); rtas_bounce_offset = 0; - args.nargs = nargs; - args.nreturns = nreturns; + args.nargs = htobe32(nargs); + args.nreturns = htobe32(nreturns); for (n = 0; n < nargs; n++) - args.args_n_results[n] = va_arg(ap, cell_t); + args.args_n_results[n] = htobe32(va_arg(ap, cell_t)); argsptr = rtas_real_map(&args, sizeof(args)); @@ -250,7 +251,7 @@ rtas_call_method(cell_t token, int nargs, int nreturns return (result); for (n = nargs; n < nargs + nreturns; n++) - *va_arg(ap, cell_t *) = args.args_n_results[n]; + *va_arg(ap, cell_t *) = be32toh(args.args_n_results[n]); return (result); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009230409.08N493LH066524>