direct-io.hg

view xen/arch/powerpc/of_handler/rtas.c @ 15490:06a32f040d64

[POWERPC][FIRMWARE] Firmware can now provide an RTAS stub

If the firmwares devtree contains a /rtas node, then firmware will
supply the interfaces that will allow a small RTAS stub to be
instantiated. The RTAS stub is simply an hvcall that passes the RTAS
command block to the hypervisor.

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Sun Jun 03 10:39:31 2007 -0400 (2007-06-03)
parents
children
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright (C) IBM Corp. 2007
17 *
18 * Authors: Jimi Xenidis <jimix@watson.ibm.com>
19 */
21 #include "ofh.h"
22 #include <stdarg.h>
23 #include <xen/lib.h>
24 extern char _rtas_image_start[];
25 extern char _rtas_image_end[];
27 static int
28 rtas_instantiate_rtas(u32 nargs, u32 nrets, s32 argp[], s32 retp[], ulong b)
29 {
30 if (nargs == 1) {
31 if (nrets == 1) {
32 void *rtas_base_address = (void *)(ulong)argp[0];
33 u32 sz = (_rtas_image_end - _rtas_image_start);
35 memcpy(rtas_base_address,
36 DRELA(&_rtas_image_start[0], b), sz);
37 retp[0] = (ulong)rtas_base_address;
39 return OF_SUCCESS;
40 }
41 }
42 return OF_FAILURE;
43 }
46 static struct ofh_methods _rtas_methods[] = {
47 { "instantiate-rtas", rtas_instantiate_rtas },
48 { NULL, NULL},
49 };
51 static struct ofh_ihandle _ih_rtas = {
52 .ofi_methods = _rtas_methods,
53 };
55 static int rtas_open(u32 b)
56 {
57 u32 ih = DRELA((u32)&_ih_rtas, b);
59 return ih;
60 }
62 void ofh_rtas_init(ulong b)
63 {
64 static const char path[] = "/rtas";
65 ofdn_t n;
66 void *m = ofd_mem(b);
67 u32 sz;
69 n = ofd_node_find(m, DRELA(&path[0], b));
70 if (n <= 0)
71 return;
73 sz = (_rtas_image_end - _rtas_image_start);
74 /* Round size up to a multiple of 0x1000 */
75 sz = ALIGN_UP(sz, PAGE_SIZE);
77 ofd_prop_add(m, n, DRELA((const char *)"rtas-size", b),
78 &sz, sizeof(sz));
80 /* create an IO node */
81 ofd_io_create(m, n, (ulong)rtas_open);
82 }