direct-io.hg

changeset 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 7205c65add2d
children 6750b1320159
files xen/arch/powerpc/of_handler/Makefile xen/arch/powerpc/of_handler/ofh.c xen/arch/powerpc/of_handler/rtas.c xen/arch/powerpc/of_handler/vdevice.c xen/arch/powerpc/of_handler/xen_hvcall.S xen/arch/powerpc/powerpc64/hypercall_table.S
line diff
     1.1 --- a/xen/arch/powerpc/of_handler/Makefile	Sun Jun 03 10:35:20 2007 -0400
     1.2 +++ b/xen/arch/powerpc/of_handler/Makefile	Sun Jun 03 10:39:31 2007 -0400
     1.3 @@ -16,6 +16,7 @@ obj-y += leap.o
     1.4  obj-y += memory.o
     1.5  obj-y += ofh.o
     1.6  obj-y += papr.o
     1.7 +obj-y += rtas.o
     1.8  obj-y += services.o
     1.9  obj-y += vdevice.o
    1.10  obj-y += xencomm.o
     2.1 --- a/xen/arch/powerpc/of_handler/ofh.c	Sun Jun 03 10:35:20 2007 -0400
     2.2 +++ b/xen/arch/powerpc/of_handler/ofh.c	Sun Jun 03 10:39:31 2007 -0400
     2.3 @@ -234,6 +234,7 @@ ofh_init(ulong b)
     2.4  
     2.5      ofh_service_init(b);
     2.6      ofh_chosen_init(b);
     2.7 +	ofh_rtas_init(b);
     2.8      ofh_options_init(b);
     2.9  }
    2.10  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/arch/powerpc/of_handler/rtas.c	Sun Jun 03 10:39:31 2007 -0400
     3.3 @@ -0,0 +1,82 @@
     3.4 +/*
     3.5 + * This program is free software; you can redistribute it and/or modify
     3.6 + * it under the terms of the GNU General Public License as published by
     3.7 + * the Free Software Foundation; either version 2 of the License, or
     3.8 + * (at your option) any later version.
     3.9 + *
    3.10 + * This program is distributed in the hope that it will be useful,
    3.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.13 + * GNU General Public License for more details.
    3.14 + *
    3.15 + * You should have received a copy of the GNU General Public License
    3.16 + * along with this program; if not, write to the Free Software
    3.17 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    3.18 + *
    3.19 + * Copyright (C) IBM Corp. 2007
    3.20 + *
    3.21 + * Authors: Jimi Xenidis <jimix@watson.ibm.com>
    3.22 + */
    3.23 +
    3.24 +#include "ofh.h"
    3.25 +#include <stdarg.h>
    3.26 +#include <xen/lib.h>
    3.27 +extern char _rtas_image_start[];
    3.28 +extern char _rtas_image_end[];
    3.29 +
    3.30 +static int
    3.31 +rtas_instantiate_rtas(u32 nargs, u32 nrets, s32 argp[], s32 retp[], ulong b)
    3.32 +{
    3.33 +    if (nargs == 1) {
    3.34 +        if (nrets == 1) {
    3.35 +            void *rtas_base_address = (void *)(ulong)argp[0];
    3.36 +            u32 sz = (_rtas_image_end - _rtas_image_start);
    3.37 +
    3.38 +            memcpy(rtas_base_address,
    3.39 +                   DRELA(&_rtas_image_start[0], b), sz);
    3.40 +            retp[0] = (ulong)rtas_base_address;
    3.41 +
    3.42 +            return OF_SUCCESS;
    3.43 +        }
    3.44 +    }
    3.45 +    return OF_FAILURE;
    3.46 +}
    3.47 +
    3.48 +
    3.49 +static struct ofh_methods _rtas_methods[] = {
    3.50 +    { "instantiate-rtas", rtas_instantiate_rtas },
    3.51 +    { NULL, NULL},
    3.52 +};
    3.53 +
    3.54 +static struct ofh_ihandle _ih_rtas = {
    3.55 +    .ofi_methods = _rtas_methods,
    3.56 +};
    3.57 +
    3.58 +static int rtas_open(u32 b)
    3.59 +{
    3.60 +    u32 ih = DRELA((u32)&_ih_rtas, b);
    3.61 +
    3.62 +    return ih;
    3.63 +}
    3.64 +
    3.65 +void ofh_rtas_init(ulong b)
    3.66 +{
    3.67 +    static const char path[] = "/rtas";
    3.68 +    ofdn_t n;
    3.69 +    void *m = ofd_mem(b);
    3.70 +    u32 sz;
    3.71 +
    3.72 +    n = ofd_node_find(m, DRELA(&path[0], b));
    3.73 +    if (n <= 0)
    3.74 +        return;
    3.75 +
    3.76 +    sz = (_rtas_image_end - _rtas_image_start);
    3.77 +    /* Round size up to a multiple of 0x1000 */
    3.78 +    sz = ALIGN_UP(sz, PAGE_SIZE);
    3.79 +
    3.80 +    ofd_prop_add(m, n, DRELA((const char *)"rtas-size", b),
    3.81 +                 &sz, sizeof(sz));
    3.82 +
    3.83 +    /* create an IO node */
    3.84 +    ofd_io_create(m, n, (ulong)rtas_open);
    3.85 +}
     4.1 --- a/xen/arch/powerpc/of_handler/vdevice.c	Sun Jun 03 10:35:20 2007 -0400
     4.2 +++ b/xen/arch/powerpc/of_handler/vdevice.c	Sun Jun 03 10:39:31 2007 -0400
     4.3 @@ -36,7 +36,7 @@ ofh_vty_init(ofdn_t chosen, ulong b)
     4.4  
     4.5      /* find the vty */
     4.6      n = ofd_node_find(mem,
     4.7 -                        DRELA((const char *)"/vdevice/vty", b));
     4.8 +                      DRELA((const char *)"/vdevice/vty", b));
     4.9      if (n > 0) {
    4.10          /* PAPR VTERM */
    4.11          ret = ofd_getprop(mem, n, DRELA((const char *)"reg", b),
     5.1 --- a/xen/arch/powerpc/of_handler/xen_hvcall.S	Sun Jun 03 10:35:20 2007 -0400
     5.2 +++ b/xen/arch/powerpc/of_handler/xen_hvcall.S	Sun Jun 03 10:39:31 2007 -0400
     5.3 @@ -1,19 +1,21 @@
     5.4  /*
     5.5 - * Copyright (C) 2005 Jimi Xenidis <jimix@watson.ibm.com>, IBM Corporation
     5.6 - *
     5.7   * This program is free software; you can redistribute it and/or modify
     5.8   * it under the terms of the GNU General Public License as published by
     5.9   * the Free Software Foundation; either version 2 of the License, or
    5.10   * (at your option) any later version.
    5.11 - * 
    5.12 + *
    5.13   * This program is distributed in the hope that it will be useful,
    5.14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.16   * GNU General Public License for more details.
    5.17 - * 
    5.18 + *
    5.19   * You should have received a copy of the GNU General Public License
    5.20   * along with this program; if not, write to the Free Software
    5.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    5.22 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    5.23 + *
    5.24 + * Copyright (C) IBM Corp. 2005, 2007
    5.25 + *
    5.26 + * Authors: Jimi Xenidis <jimix@watson.ibm.com>
    5.27   */
    5.28  
    5.29  #include <asm/config.h>
    5.30 @@ -26,3 +28,17 @@
    5.31  _GLOBAL(xen_hvcall)
    5.32      HSC
    5.33      blr
    5.34 +
    5.35 +/* The following stub will get instantiated as RTAS in the guest */	
    5.36 +#define H_RTAS_PROXY 23
    5.37 +    .p2align 3
    5.38 +    .global _rtas_image_start
    5.39 +    .global _rtas_image_end
    5.40 +_rtas_image_start:
    5.41 +    mr	r4,r3
    5.42 +    lis	r3,0xffff
    5.43 +    ori	r3,r3,H_RTAS_PROXY
    5.44 +    HSC
    5.45 +    blr
    5.46 +    nop
    5.47 +_rtas_image_end:
     6.1 --- a/xen/arch/powerpc/powerpc64/hypercall_table.S	Sun Jun 03 10:35:20 2007 -0400
     6.2 +++ b/xen/arch/powerpc/powerpc64/hypercall_table.S	Sun Jun 03 10:39:31 2007 -0400
     6.3 @@ -27,7 +27,7 @@
     6.4          .quad do_grant_table_op     /* 20 */
     6.5          .quad do_vm_assist
     6.6          .quad 0 /* do_update_va_mapping_otherdomain */
     6.7 -        .quad 0 /* do_switch_vm86 */
     6.8 +        .quad do_rtas_proxy /* do_switch_vm86 */
     6.9          .quad do_vcpu_op
    6.10          .quad do_ni_hypercall       /* 25 */
    6.11          .quad 0 /* do_mmuext_op */