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
| void dev_configure(void) { struct resource *res; struct device *root; struct device *child;
set_vga_bridge_bits();
printk(BIOS_INFO, "Allocating resources...\n");
root = &dev_root; // 根设备
/* * Each domain should create resources which contain the entire address * space for IO, MEM, and PREFMEM resources in the domain. The * allocation of device resources will be done from this address space. */
/* Read the resources for the entire tree. */ // 先读一次 printk(BIOS_INFO, "Reading resources...\n"); read_resources(root->link_list); printk(BIOS_INFO, "Done reading resources.\n");
// 打印设备树的资源 print_resource_tree(root, BIOS_SPEW, "After reading.");
/* Compute resources for all domains. */ // 计算资源 for (child = root->link_list->children; child; child = child->sibling) { if (!(child->path.type == DEVICE_PATH_DOMAIN)) continue; post_log_path(child); for (res = child->resource_list; res; res = res->next) { if (res->flags & IORESOURCE_FIXED) continue; if (res->flags & IORESOURCE_MEM) { compute_resources(child->link_list, res, IORESOURCE_TYPE_MASK, IORESOURCE_MEM); continue; } if (res->flags & IORESOURCE_IO) { compute_resources(child->link_list, res, IORESOURCE_TYPE_MASK, IORESOURCE_IO); continue; } } }
/* For all domains. */ for (child = root->link_list->children; child; child=child->sibling) if (child->path.type == DEVICE_PATH_DOMAIN) avoid_fixed_resources(child); // 此函数作用? 感觉是对范围的限制
/* Store the computed resource allocations into device registers ... */ printk(BIOS_INFO, "Setting resources...\n"); for (child = root->link_list->children; child; child = child->sibling) { if (!(child->path.type == DEVICE_PATH_DOMAIN)) continue; post_log_path(child); // 分mem和io两种资源 for (res = child->resource_list; res; res = res->next) { if (res->flags & IORESOURCE_FIXED) continue; if (res->flags & IORESOURCE_MEM) { allocate_resources(child->link_list, res, IORESOURCE_TYPE_MASK, IORESOURCE_MEM); continue; } if (res->flags & IORESOURCE_IO) { allocate_resources(child->link_list, res, IORESOURCE_TYPE_MASK, IORESOURCE_IO); continue; } } } assign_resources(root->link_list); printk(BIOS_INFO, "Done setting resources.\n"); print_resource_tree(root, BIOS_SPEW, "After assigning values.");
printk(BIOS_INFO, "Done allocating resources.\n"); }
|