1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
--- vmmon-only/freebsd/hostif.c.orig Thu Jul 12 22:05:29 2001
+++ vmmon-only/freebsd/hostif.c Thu Jul 12 22:14:09 2001
@@ -55,7 +55,11 @@
#include <vm/vm.h>
#include <vm/vm_param.h>
+#if __FreeBSD_version >= 500018
+#include <sys/mutex.h>
+#else
#include <sys/lock.h>
+#endif
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_page.h>
@@ -107,7 +111,16 @@
paddr = (vm_offset_t)addr;
m = PHYS_TO_VM_PAGE(paddr);
+#if __FreeBSD_version >= 500021
+ GIANT_REQUIRED;
+#elif __FreeBSD_version >= 500013
+ mtx_lock(&vm_mtx);
+#endif
vm_page_wire(m);
+#if __FreeBSD_version >= 500021
+#elif __FreeBSD_version >= 500013
+ mtx_unlock(&vm_mtx);
+#endif
return 0;
}
@@ -120,7 +133,16 @@
paddr = (vm_offset_t)addr;
m = PHYS_TO_VM_PAGE(paddr);
+#if __FreeBSD_version >= 500021
+ GIANT_REQUIRED;
+#elif __FreeBSD_version >= 500013
+ mtx_lock(&vm_mtx);
+#endif
vm_page_unwire(m, 1);
+#if __FreeBSD_version >= 500021
+#elif __FreeBSD_version >= 500013
+ mtx_unlock(&vm_mtx);
+#endif
return 0;
}
@@ -1066,10 +1088,19 @@
return NULL;
}
paddr = vtophys(addr);
+#if __FreeBSD_version >= 500021
+ GIANT_REQUIRED;
+#elif __FreeBSD_version >= 500013
+ mtx_lock(&vm_mtx);
+#endif
ka->kaddr = kmem_alloc_pageable(kernel_map, PAGE_SIZE);
ka->map = PHYS_TO_VM_PAGE(paddr);
vm_page_wire(ka->map);
pmap_kenter(ka->kaddr, paddr);
+#if __FreeBSD_version >= 500021
+#elif __FreeBSD_version >= 500013
+ mtx_unlock(&vm_mtx);
+#endif
return ka->kaddr;
}
@@ -1079,9 +1110,18 @@
if (ka->map==NULL)
return 0;
+#if __FreeBSD_version >= 500021
+ GIANT_REQUIRED;
+#elif __FreeBSD_version >= 500013
+ mtx_lock(&vm_mtx);
+#endif
vm_page_unwire(ka->map, 1);
pmap_kremove(ka->kaddr);
kmem_free(kernel_map, ka->kaddr, PAGE_SIZE);
+#if __FreeBSD_version >= 500021
+#elif __FreeBSD_version >= 500013
+ mtx_unlock(&vm_mtx);
+#endif
ka->kaddr = 0;
ka->map = NULL;
return 0;
|