index
:
litmus-rt.git
archive/unc-master-3.0
archived-2013.1
archived-private-master
archived-semi-part
demo
ecrts-pgm-final
ecrts14-pgm-final
gpusync-rtss12
gpusync/staging
linux-tip
litmus2008-patch-series
master
pgm
prop/litmus-signals
prop/robust-tie-break
staging
test
tracing-devel
v2.6.34-with-arm-patches
v2015.1
wip-2011.2-bbb
wip-2011.2-bbb-trace
wip-2012.3-gpu
wip-2012.3-gpu-preport
wip-2012.3-gpu-rtss13
wip-2012.3-gpu-sobliv-budget-w-kshark
wip-aedzl-final
wip-aedzl-revised
wip-arbit-deadline
wip-aux-tasks
wip-bbb
wip-bbb-prio-don
wip-better-break
wip-binary-heap
wip-budget
wip-color
wip-color-jlh
wip-d10-hz1000
wip-default-clustering
wip-dissipation-jerickso
wip-dissipation2-jerickso
wip-ecrts14-pgm
wip-edf-hsb
wip-edf-os
wip-edf-tie-break
wip-edzl-critique
wip-edzl-final
wip-edzl-revised
wip-events
wip-extra-debug
wip-fix-switch-jerickso
wip-fix3
wip-fmlp-dequeue
wip-ft-irq-flag
wip-gpu-cleanup
wip-gpu-interrupts
wip-gpu-rtas12
wip-gpu-rtss12
wip-gpu-rtss12-srp
wip-gpusync-merge
wip-ikglp
wip-k-fmlp
wip-kernel-coloring
wip-kernthreads
wip-klmirqd-to-aux
wip-kshark
wip-litmus-3.2
wip-litmus2011.2
wip-litmus3.0-2011.2
wip-master-2.6.33-rt
/*
* IOMMU helper functions for the free area management
*/
#include <linux/export.h>
#include <linux/bitmap.h>
#include <linux/bug.h>
int
iommu_is_span_boundary
(
unsigned int
index
,
unsigned int
nr
,
unsigned long
shift
,
unsigned long
boundary_size
)
{
BUG_ON
(!
is_power_of_2
(
boundary_size
));
shift
= (
shift
+
index
) & (
boundary_size
-
1
);
return
shift
+
nr
>
boundary_size
;
}
unsigned long
iommu_area_alloc
(
unsigned long
*
map
,
unsigned long
size
,
unsigned long
start
,
unsigned int
nr
,
unsigned long
shift
,
unsigned long
boundary_size
,
unsigned long
align_mask
)
{
unsigned long
index
;
/* We don't want the last of the limit */
size
-=
1
;
again
:
index
=
bitmap_find_next_zero_area
(
map
,
size
,
start
,
nr
,
align_mask
);
if
(
index
<
size
) {
if
(
iommu_is_span_boundary
(
index
,
nr
,
shift
,
boundary_size
)) {
/* we could do more effectively */
start
=
index
+
1
;
goto
again
;
}
bitmap_set
(
map
,
index
,
nr
);
return
index
;
}
return
-
1
;
}
EXPORT_SYMBOL
(
iommu_area_alloc
);