~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/xc/lib/xc_private.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************************************
2
 
 * xc_private.c
3
 
 * 
4
 
 * Helper functions for the rest of the library.
5
 
 */
6
 
 
7
 
#include "xc_private.h"
8
 
 
9
 
int init_pfn_mapper(void)
10
 
{
11
 
    return open("/dev/mem", O_RDWR);
12
 
}
13
 
 
14
 
int close_pfn_mapper(int pm_handle)
15
 
{
16
 
    return close(pm_handle);
17
 
}
18
 
 
19
 
void *map_pfn(int pm_handle, unsigned long pfn)
20
 
{
21
 
    void *vaddr = mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE,
22
 
                       MAP_SHARED, pm_handle, pfn << PAGE_SHIFT);
23
 
    if ( vaddr == MAP_FAILED )
24
 
        return NULL;
25
 
    return vaddr;
26
 
}
27
 
 
28
 
void unmap_pfn(int pm_handle, void *vaddr)
29
 
{
30
 
    (void)munmap(vaddr, PAGE_SIZE);
31
 
}