summaryrefslogtreecommitdiffstats
path: root/kmem.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2013-07-14 05:49:19 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2013-07-14 05:49:19 +0200
commitf000eb0d43193ef8225f947226d9cd3deb00115b (patch)
tree96fba301e5e63012f7655f4277b191036f5964b3 /kmem.c
parent7ec4581ad37b88bbb300ac00850603433a8cdfe9 (diff)
downloadpcitool-f000eb0d43193ef8225f947226d9cd3deb00115b.tar.gz
pcitool-f000eb0d43193ef8225f947226d9cd3deb00115b.tar.bz2
pcitool-f000eb0d43193ef8225f947226d9cd3deb00115b.tar.xz
pcitool-f000eb0d43193ef8225f947226d9cd3deb00115b.zip
Support pre-allocated memory with memmap in KMem
Diffstat (limited to 'kmem.c')
-rw-r--r--kmem.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/kmem.c b/kmem.c
index d693b60..64f593a 100644
--- a/kmem.c
+++ b/kmem.c
@@ -91,13 +91,19 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type
kh.align = alignment;
kh.use = use;
- if ((type&PCILIB_KMEM_TYPE_MASK) != PCILIB_KMEM_TYPE_PAGE) {
+ if ((type&PCILIB_KMEM_TYPE_MASK) == PCILIB_KMEM_TYPE_REGION) {
+ kh.align = 0;
+ } else if ((type&PCILIB_KMEM_TYPE_MASK) != PCILIB_KMEM_TYPE_PAGE) {
kh.size += alignment;
}
-
+
for ( i = 0; i < nmemb; i++) {
kh.item = i;
kh.flags = flags;
+
+ if ((type&PCILIB_KMEM_TYPE_MASK) == PCILIB_KMEM_TYPE_REGION) {
+ kh.pa = alignment + i * size;
+ }
ret = ioctl(ctx->handle, PCIDRIVER_IOC_KMEM_ALLOC, &kh);
if (ret) {