~ubuntu-branches/ubuntu/intrepid/xen-3.3/intrepid-proposed

« back to all changes in this revision

Viewing changes to tools/xenstore/xenstored_netbsd.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2008-08-14 10:28:57 UTC
  • Revision ID: james.westby@ubuntu.com-20080814102857-a832fn5gowurz5do
Tags: upstream-3.3.0
ImportĀ upstreamĀ versionĀ 3.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *
 
3
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 
4
 * Use is subject to license terms.
 
5
 *
 
6
 * Copyright (C) 2005 Rusty Russell IBM Corporation
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU General Public License as
 
10
 * published by the Free Software Foundation, version 2 of the
 
11
 * License.
 
12
 */
 
13
 
 
14
#include <fcntl.h>
 
15
#include <unistd.h>
 
16
#include <stdlib.h>
 
17
#include <sys/mman.h>
 
18
 
 
19
#include "xenstored_core.h"
 
20
 
 
21
#define XENSTORED_PROC_KVA  "/dev/xsd_kva"
 
22
#define XENSTORED_PROC_PORT "/kern/xen/xsd_port"
 
23
 
 
24
evtchn_port_t xenbus_evtchn(void)
 
25
{
 
26
        int fd;
 
27
        int rc;
 
28
        evtchn_port_t port; 
 
29
        char str[20]; 
 
30
 
 
31
        fd = open(XENSTORED_PROC_PORT, O_RDONLY); 
 
32
        if (fd == -1)
 
33
                return -1;
 
34
 
 
35
        rc = read(fd, str, sizeof(str)); 
 
36
        if (rc == -1)
 
37
        {
 
38
                int err = errno;
 
39
                close(fd);
 
40
                errno = err;
 
41
                return -1;
 
42
        }
 
43
 
 
44
        str[rc] = '\0'; 
 
45
        port = strtoul(str, NULL, 0); 
 
46
 
 
47
        close(fd); 
 
48
        return port;
 
49
}
 
50
 
 
51
void *xenbus_map(void)
 
52
{
 
53
        int fd;
 
54
        void *addr;
 
55
 
 
56
        fd = open(XENSTORED_PROC_KVA, O_RDWR);
 
57
        if (fd == -1)
 
58
                return NULL;
 
59
 
 
60
        addr = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE,
 
61
                MAP_SHARED, fd, 0);
 
62
 
 
63
        if (addr == MAP_FAILED)
 
64
                addr = NULL;
 
65
 
 
66
        close(fd);
 
67
 
 
68
        return addr;
 
69
}
 
70
 
 
71
void xenbus_notify_running(void)
 
72
{
 
73
}