Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iommu/iommu_gas.c
Context not available. | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#define RB_AUGMENT(entry) iommu_gas_augment_entry(entry) | #define RB_AUGMENT_CHECK(entry) iommu_gas_augment_entry(entry) | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
Context not available. | |||||
return (0); | return (0); | ||||
} | } | ||||
static void | static bool | ||||
iommu_gas_augment_entry(struct iommu_map_entry *entry) | iommu_gas_augment_entry(struct iommu_map_entry *entry) | ||||
{ | { | ||||
struct iommu_map_entry *child; | struct iommu_map_entry *child; | ||||
iommu_gaddr_t free_down; | iommu_gaddr_t free_left, free_right; | ||||
iommu_gaddr_t first, last, free_down; | |||||
free_down = 0; | |||||
if ((child = RB_LEFT(entry, rb_entry)) != NULL) { | if ((child = RB_LEFT(entry, rb_entry)) != NULL) { | ||||
free_down = MAX(free_down, child->free_down); | free_left = MAX(child->free_down, entry->start - child->last); | ||||
free_down = MAX(free_down, entry->start - child->last); | first = child->first; | ||||
entry->first = child->first; | } else { | ||||
} else | free_left = 0; | ||||
entry->first = entry->start; | first = entry->start; | ||||
} | |||||
if ((child = RB_RIGHT(entry, rb_entry)) != NULL) { | if ((child = RB_RIGHT(entry, rb_entry)) != NULL) { | ||||
free_down = MAX(free_down, child->free_down); | free_right = MAX(child->free_down, child->first - entry->end); | ||||
free_down = MAX(free_down, child->first - entry->end); | last = child->last; | ||||
entry->last = child->last; | } else { | ||||
} else | free_right = 0; | ||||
entry->last = entry->end; | last = entry->end; | ||||
} | |||||
free_down = MAX(free_left, free_right); | |||||
if (free_down == entry->free_down && | |||||
first == entry->first && | |||||
last == entry->last) | |||||
return (false); | |||||
entry->first = first; | |||||
entry->last = last; | |||||
entry->free_down = free_down; | entry->free_down = free_down; | ||||
return (true); | |||||
} | } | ||||
RB_GENERATE(iommu_gas_entries_tree, iommu_map_entry, rb_entry, | RB_GENERATE(iommu_gas_entries_tree, iommu_map_entry, rb_entry, | ||||
Context not available. |