static int con_initialise(struct XenDevice *xendev)

{

    struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);

    int limit;



    if (xenstore_read_int(con->console, "ring-ref", &con->ring_ref) == -1)

	return -1;

    if (xenstore_read_int(con->console, "port", &con->xendev.remote_port) == -1)

	return -1;

    if (xenstore_read_int(con->console, "limit", &limit) == 0)

	con->buffer.max_capacity = limit;



    if (!xendev->dev) {

        con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,

                                          XC_PAGE_SIZE,

                                          PROT_READ|PROT_WRITE,

                                          con->ring_ref);

    } else {

        con->sring = xengnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom,

                                             con->ring_ref,

                                             PROT_READ|PROT_WRITE);

    }

    if (!con->sring)

	return -1;



    xen_be_bind_evtchn(&con->xendev);

    if (con->chr) {

        if (qemu_chr_fe_claim(con->chr) == 0) {

            qemu_chr_add_handlers(con->chr, xencons_can_receive,

                                  xencons_receive, NULL, con);

        } else {

            xen_be_printf(xendev, 0,

                          "xen_console_init error chardev %s already used\n",

                          con->chr->label);

            con->chr = NULL;

        }

    }



    xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",

		  con->ring_ref,

		  con->xendev.remote_port,

		  con->xendev.local_port,

		  con->buffer.max_capacity);

    return 0;

}

static int con_initialise(struct XenDevice *xendev)

{

    struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);

    int limit;



    if (xenstore_read_int(con->console, "ring-ref", &con->ring_ref) == -1)

	return -1;

    if (xenstore_read_int(con->console, "port", &con->xendev.remote_port) == -1)

	return -1;

    if (xenstore_read_int(con->console, "limit", &limit) == 0)

	con->buffer.max_capacity = limit;



    if (!xendev->dev) {

        con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,

                                          XC_PAGE_SIZE,

                                          PROT_READ|PROT_WRITE,

                                          con->ring_ref);

    } else {

        con->sring = xengnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom,

                                             con->ring_ref,

                                             PROT_READ|PROT_WRITE);

    }

    if (!con->sring)

	return -1;



    xen_be_bind_evtchn(&con->xendev);

    if (con->chr) {

        if (qemu_chr_fe_claim(con->chr) == 0) {

            qemu_chr_add_handlers(con->chr, xencons_can_receive,

                                  xencons_receive, NULL, con);

        } else {

            xen_be_printf(xendev, 0,

                          "xen_console_init error chardev %s already used\n",

                          con->chr->label);

            con->chr = NULL;

        }

    }



    xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",

		  con->ring_ref,

		  con->xendev.remote_port,

		  con->xendev.local_port,

		  con->buffer.max_capacity);

    return 0;

}

        con->sring = xc_map_foreign_range(xen_xc, con->xendev.dom,                                           XC_PAGE_SIZE,                                           PROT_READ|PROT_WRITE,                                           con->ring_ref);
static int FUNC_0(struct XenDevice *VAR_0)

{

    struct XenConsole *VAR_1 = container_of(VAR_0, struct XenConsole, VAR_0);

    int VAR_2;



    if (xenstore_read_int(VAR_1->console, "ring-ref", &VAR_1->ring_ref) == -1)

	return -1;

    if (xenstore_read_int(VAR_1->console, "port", &VAR_1->VAR_0.remote_port) == -1)

	return -1;

    if (xenstore_read_int(VAR_1->console, "VAR_2", &VAR_2) == 0)

	VAR_1->buffer.max_capacity = VAR_2;



    if (!VAR_0->dev) {

        VAR_1->sring = xc_map_foreign_range(xen_xc, VAR_1->VAR_0.dom,

                                          XC_PAGE_SIZE,

                                          PROT_READ|PROT_WRITE,

                                          VAR_1->ring_ref);

    } else {

        VAR_1->sring = xengnttab_map_grant_ref(VAR_0->gnttabdev, VAR_1->VAR_0.dom,

                                             VAR_1->ring_ref,

                                             PROT_READ|PROT_WRITE);

    }

    if (!VAR_1->sring)

	return -1;



    xen_be_bind_evtchn(&VAR_1->VAR_0);

    if (VAR_1->chr) {

        if (qemu_chr_fe_claim(VAR_1->chr) == 0) {

            qemu_chr_add_handlers(VAR_1->chr, xencons_can_receive,

                                  xencons_receive, NULL, VAR_1);

        } else {

            xen_be_printf(VAR_0, 0,

                          "xen_console_init error chardev %s already used\n",

                          VAR_1->chr->label);

            VAR_1->chr = NULL;

        }

    }



    xen_be_printf(VAR_0, 1, "ring mfn %d, remote port %d, local port %d, VAR_2 %zd\n",

		  VAR_1->ring_ref,

		  VAR_1->VAR_0.remote_port,

		  VAR_1->VAR_0.local_port,

		  VAR_1->buffer.max_capacity);

    return 0;

}

static int FUNC_0(struct XenDevice *VAR_0)
{ struct XenConsole *VAR_1 = container_of(VAR_0, struct XenConsole, VAR_0); int VAR_2; if (xenstore_read_int(VAR_1->console, "ring-ref", &VAR_1->ring_ref) == -1)
return -1; if (xenstore_read_int(VAR_1->console, "port", &VAR_1->VAR_0.remote_port) == -1)
return -1; if (xenstore_read_int(VAR_1->console, "VAR_2", &VAR_2) == 0)
VAR_1->buffer.max_capacity = VAR_2; if (!VAR_0->dev) { VAR_1->sring = xc_map_foreign_range(xen_xc, VAR_1->VAR_0.dom,
XC_PAGE_SIZE,
PROT_READ|PROT_WRITE,
VAR_1->ring_ref); } else { VAR_1->sring = xengnttab_map_grant_ref(VAR_0->gnttabdev, VAR_1->VAR_0.dom,
VAR_1->ring_ref,
PROT_READ|PROT_WRITE); } if (!VAR_1->sring)
return -1; xen_be_bind_evtchn(&VAR_1->VAR_0); if (VAR_1->chr) { if (qemu_chr_fe_claim(VAR_1->chr) == 0) { qemu_chr_add_handlers(VAR_1->chr, xencons_can_receive,
xencons_receive, NULL, VAR_1); } else { xen_be_printf(VAR_0, 0,
"xen_console_init error chardev %s already used\n",
VAR_1->chr->label); VAR_1->chr = NULL; } } xen_be_printf(VAR_0, 1, "ring mfn %d, remote port %d, local port %d, VAR_2 %zd\n",
VAR_1->ring_ref,
VAR_1->VAR_0.remote_port,
VAR_1->VAR_0.local_port,
VAR_1->buffer.max_capacity); return 0; }