PCI子系统之-resource插入算法
来源:互联网 发布:丁红玉的淘宝店 编辑:程序博客网 时间:2024/06/07 13:46
/*
* Insert a resource into the resource tree. If successful, return NULL,
* otherwise return the conflicting resource (compare to __request_resource())
*/
static struct resource * __insert_resource(struct resource *parent, struct resource *new)
{
struct resource *first, *next;
for (;; parent = first) {
first = __request_resource(parent, new);
if (!first)
return first;
if (first == parent)
return first;
if (WARN_ON(first == new))/* duplicated insertion */
return first;
if ((first->start > new->start) || (first->end < new->end))
break;
if ((first->start == new->start) && (first->end == new->end))
break;
}
for (next = first; ; next = next->sibling) {
/* Partial overlap? Bad, and unfixable */
if (next->start < new->start || next->end > new->end)
return next;
if (!next->sibling)
break;
if (next->sibling->start > new->end)
break;
}
new->parent = parent;
new->sibling = next->sibling;
new->child = first;
next->sibling = NULL;
for (next = first; next; next = next->sibling)
next->parent = new;
if (parent->child == first) {
parent->child = new;
} else {
next = parent->child;
while (next->sibling != first)
next = next->sibling;
next->sibling = new;
}
return NULL;
* Insert a resource into the resource tree. If successful, return NULL,
* otherwise return the conflicting resource (compare to __request_resource())
*/
static struct resource * __insert_resource(struct resource *parent, struct resource *new)
{
struct resource *first, *next;
for (;; parent = first) {
first = __request_resource(parent, new);
if (!first)
return first;
if (first == parent)
return first;
if (WARN_ON(first == new))/* duplicated insertion */
return first;
if ((first->start > new->start) || (first->end < new->end))
break;
if ((first->start == new->start) && (first->end == new->end))
break;
}
for (next = first; ; next = next->sibling) {
/* Partial overlap? Bad, and unfixable */
if (next->start < new->start || next->end > new->end)
return next;
if (!next->sibling)
break;
if (next->sibling->start > new->end)
break;
}
new->parent = parent;
new->sibling = next->sibling;
new->child = first;
next->sibling = NULL;
for (next = first; next; next = next->sibling)
next->parent = new;
if (parent->child == first) {
parent->child = new;
} else {
next = parent->child;
while (next->sibling != first)
next = next->sibling;
next->sibling = new;
}
return NULL;
}
==============================
struct resource {
resource_size_t start;
resource_size_t end;
const char *name;
unsigned long flags;
struct resource *parent, *sibling, *child;
};
http://blog.chinaunix.net/uid/10678279/cid-138364-list-1.html
- PCI子系统之-resource插入算法
- linux驱动结构pci之resource
- Linux子系统系列-PCI
- linux----pci子系统
- linux驱动子系统--PCI
- [知其然不知其所以然-20] pci resource allocation
- 算法之插入排序
- 算法之插入排序
- 算法之插入排序
- 算法之插入排序
- 算法之插入排序
- 算法之插入排序
- 算法之插入排序
- 算法之插入排序
- 算法之----插入排序
- 算法之插入排序
- 算法之插入排序
- 算法之插入排序
- 通过mysql学习mongodb语句
- java_main函数
- 后台控制页面隐藏
- Android实现ListView圆角效果
- org.apache.taglibs.standard.tlv.JstlCoreTLV
- PCI子系统之-resource插入算法
- 各种渗透,提权的经验和技巧总结(下)
- 记录自己用到的tcpdump命令
- c++ extra qualification
- 用rand()实现bigrand()和randint(l,u)
- java编程规范-注释
- redis 配置说明
- 常用 mysql函数查询
- linux 挂载分区后里面c c++可执行文件不能执行问题