Date: Thu, 22 Jan 2015 22:04:43 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r277539 - head/sys/powerpc/ofw Message-ID: <201501222204.t0MM4hBx038874@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Thu Jan 22 22:04:43 2015 New Revision: 277539 URL: https://svnweb.freebsd.org/changeset/base/277539 Log: Allow use of a pre-instantiated RTAS as well as a self-instantiated one. This lets the kernel boot on RTAS-based systems by being kexec'ed from Linux. Modified: head/sys/powerpc/ofw/rtas.c Modified: head/sys/powerpc/ofw/rtas.c ============================================================================== --- head/sys/powerpc/ofw/rtas.c Thu Jan 22 21:41:41 2015 (r277538) +++ head/sys/powerpc/ofw/rtas.c Thu Jan 22 22:04:43 2015 (r277539) @@ -86,12 +86,6 @@ rtas_setup(void *junk) return; } OF_package_to_path(rtas, path, sizeof(path)); - rtasi = OF_open(path); - if (rtasi == 0) { - rtas = 0; - printf("Error initializing RTAS: could not open node\n"); - return; - } mtx_init(&rtas_mtx, "RTAS", NULL, MTX_SPIN); @@ -110,7 +104,7 @@ rtas_setup(void *junk) * It must be 4KB-aligned and not cross a 256 MB boundary. */ - OF_getprop(rtas, "rtas-size", &rtas_size, sizeof(rtas_size)); + OF_getencprop(rtas, "rtas-size", &rtas_size, sizeof(rtas_size)); rtas_size = round_page(rtas_size); rtas_bounce_virt = contigmalloc(rtas_size + PAGE_SIZE, M_RTAS, 0, 0, ulmin(platform_real_maxaddr(), BUS_SPACE_MAXADDR_32BIT), @@ -125,15 +119,32 @@ rtas_setup(void *junk) * Instantiate RTAS. We always use the 32-bit version. */ - result = OF_call_method("instantiate-rtas", rtasi, 1, 1, - (cell_t)rtas_private_data, &rtas_ptr); - OF_close(rtasi); - - if (result != 0) { - rtas = 0; - rtas_ptr = 0; - printf("Error initializing RTAS (%d)\n", result); - return; + if (OF_hasprop(rtas, "linux,rtas-entry") && + OF_hasprop(rtas, "linux,rtas-base")) { + OF_getencprop(rtas, "linux,rtas-base", &rtas_ptr, + sizeof(rtas_ptr)); + rtas_private_data = rtas_ptr; + OF_getencprop(rtas, "linux,rtas-entry", &rtas_ptr, + sizeof(rtas_ptr)); + } else { + rtasi = OF_open(path); + if (rtasi == 0) { + rtas = 0; + printf("Error initializing RTAS: could not open " + "node\n"); + return; + } + + result = OF_call_method("instantiate-rtas", rtasi, 1, 1, + (cell_t)rtas_private_data, &rtas_ptr); + OF_close(rtasi); + + if (result != 0) { + rtas = 0; + rtas_ptr = 0; + printf("Error initializing RTAS (%d)\n", result); + return; + } } rtas_entry = (uintptr_t)(rtas_ptr); @@ -252,7 +263,7 @@ rtas_token_lookup(const char *method) if (!rtas_exists()) return (-1); - if (OF_getprop(rtas, method, &token, sizeof(token)) == -1) + if (OF_getencprop(rtas, method, &token, sizeof(token)) == -1) return (-1); return (token);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501222204.t0MM4hBx038874>