win-pvdrivers

view xenpci/memory.c @ 15:7f0f866dced6

wean xenbus.c off of global variables

rename some variables from deviceData to xpdd for brevity
some whitespace fixes
author Andy Grover <andy@groveronline.com>
date Wed Nov 28 16:49:26 2007 -0800 (2007-11-28)
parents 435e5753300f
children daa0a9b0fef0
line source
1 #include "xenpci.h"
2 #include <hypercall.h>
4 static pgentry_t *demand_map_pgt;
5 static void *demand_map_area_start;
7 PVOID
8 map_frames(PULONG f, ULONG n)
9 {
10 unsigned long x;
11 unsigned long y = 0;
12 mmu_update_t mmu_updates[16];
13 int rc;
15 for (x = 0; x <= 1024 - n; x += y + 1) {
16 for (y = 0; y < n; y++)
17 if (demand_map_pgt[x+y] & _PAGE_PRESENT)
18 break;
19 if (y == n)
20 break;
21 }
22 if (y != n) {
23 KdPrint((__DRIVER_NAME " Failed to map %ld frames!\n", n));
24 return NULL;
25 }
27 for (y = 0; y < n; y++) {
28 //mmu_updates[y].ptr = virt_to_mach(&demand_map_pgt[x + y]);
29 mmu_updates[y].ptr = MmGetPhysicalAddress(&demand_map_pgt[x + y]).QuadPart;
30 mmu_updates[y].val = (f[y] << PAGE_SHIFT) | L1_PROT;
31 }
33 rc = HYPERVISOR_mmu_update(mmu_updates, n, NULL, DOMID_SELF);
34 if (rc < 0) {
35 KdPrint((__DRIVER_NAME " Map %ld failed: %d.\n", n, rc));
36 return NULL;
37 } else {
38 return (PVOID)(ULONG)((ULONG)demand_map_area_start + x * PAGE_SIZE);
39 }
40 }