From owner-svn-src-projects@FreeBSD.ORG Mon Feb 15 15:19:15 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 881CF106566C; Mon, 15 Feb 2010 15:19:15 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E4398FC17; Mon, 15 Feb 2010 15:19:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1FFJFJq037634; Mon, 15 Feb 2010 15:19:15 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1FFJFBd037632; Mon, 15 Feb 2010 15:19:15 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201002151519.o1FFJFBd037632@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 15 Feb 2010 15:19:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203927 - projects/ppc64/sys/powerpc/ofw X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2010 15:19:15 -0000 Author: nwhitehorn Date: Mon Feb 15 15:19:15 2010 New Revision: 203927 URL: http://svn.freebsd.org/changeset/base/203927 Log: Add an ofw_interpret method for real-mode OF. This lets power-off and reset work on 64-bit systems. Modified: projects/ppc64/sys/powerpc/ofw/ofw_real.c Modified: projects/ppc64/sys/powerpc/ofw/ofw_real.c ============================================================================== --- projects/ppc64/sys/powerpc/ofw/ofw_real.c Mon Feb 15 15:10:21 2010 (r203926) +++ projects/ppc64/sys/powerpc/ofw/ofw_real.c Mon Feb 15 15:19:15 2010 (r203927) @@ -99,6 +99,8 @@ static ssize_t ofw_real_package_to_path( size_t len); static int ofw_real_call_method(ofw_t, ihandle_t instance, const char *method, int nargs, int nreturns, cell_t *args_and_returns); +static int ofw_real_interpret(ofw_t ofw, const char *cmd, int nreturns, + unsigned long *returns); static ihandle_t ofw_real_open(ofw_t, const char *device); static void ofw_real_close(ofw_t, ihandle_t instance); static ssize_t ofw_real_read(ofw_t, ihandle_t instance, void *addr, size_t len); @@ -127,6 +129,7 @@ static ofw_method_t ofw_real_methods[] = OFWMETHOD(ofw_test, ofw_real_test), OFWMETHOD(ofw_call_method, ofw_real_call_method), + OFWMETHOD(ofw_interpret, ofw_real_interpret), OFWMETHOD(ofw_open, ofw_real_open), OFWMETHOD(ofw_close, ofw_real_close), OFWMETHOD(ofw_read, ofw_real_read), @@ -719,6 +722,36 @@ ofw_real_call_method(ofw_t ofw, ihandle_ return (0); } +static int +ofw_real_interpret(ofw_t ofw, const char *cmd, int nreturns, + unsigned long *returns) +{ + static struct { + cell_t name; + cell_t nargs; + cell_t nreturns; + cell_t slot[16]; + } args; + cell_t status; + int i = 0, j = 0; + + args.name = (cell_t)(uintptr_t)"interpret"; + args.nargs = 1; + + ofw_real_start(); + args.nreturns = ++nreturns; + args.slot[i++] = ofw_real_map(cmd, strlen(cmd) + 1); + if (openfirmware(&args) == -1) { + ofw_real_stop(); + return (-1); + } + status = args.slot[i++]; + while (i < 1 + nreturns) + returns[j++] = args.slot[i++]; + ofw_real_stop(); + return (status); +} + /* * Device I/O functions */