Changeset a35b458 in mainline for kernel/genarch/src/ofw
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- kernel/genarch/src/ofw
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/ofw/ebus.c
r3061bc1 ra35b458 55 55 if (!prop) 56 56 return false; 57 57 58 58 ranges = prop->size / sizeof(ofw_ebus_range_t); 59 59 range = prop->value; 60 60 61 61 unsigned int i; 62 62 63 63 for (i = 0; i < ranges; i++) { 64 64 if (reg->space != range[i].child_space) … … 67 67 range[i].size)) { 68 68 ofw_pci_reg_t pci_reg; 69 69 70 70 pci_reg.space = range[i].parent_space; 71 71 pci_reg.addr = range[i].parent_base + 72 72 (reg->addr - range[i].child_base); 73 73 pci_reg.size = reg->size; 74 74 75 75 return ofw_pci_apply_ranges(node->parent, &pci_reg, pa); 76 76 } … … 86 86 ofw_tree_property_t *prop; 87 87 ofw_tree_node_t *controller; 88 88 89 89 prop = ofw_tree_getprop(node, "interrupt-map"); 90 90 if (!prop || !prop->value) … … 93 93 ofw_ebus_intr_map_t *intr_map = prop->value; 94 94 size_t count = prop->size / sizeof(ofw_ebus_intr_map_t); 95 95 96 96 assert(count); 97 97 98 98 prop = ofw_tree_getprop(node, "interrupt-map-mask"); 99 99 if (!prop || !prop->value) 100 100 return false; 101 101 102 102 ofw_ebus_intr_mask_t *intr_mask = prop->value; 103 103 104 104 assert(prop->size == sizeof(ofw_ebus_intr_mask_t)); 105 105 106 106 uint32_t space = reg->space & intr_mask->space_mask; 107 107 uint32_t addr = reg->addr & intr_mask->addr_mask; 108 108 uint32_t intr = interrupt & intr_mask->intr_mask; 109 109 110 110 unsigned int i; 111 111 for (i = 0; i < count; i++) { … … 127 127 if (!controller) 128 128 return false; 129 129 130 130 if (str_cmp(ofw_tree_node_name(controller), "pci") != 0) { 131 131 /* -
kernel/genarch/src/ofw/ofw_tree.c
r3061bc1 ra35b458 70 70 return &node->property[i]; 71 71 } 72 72 73 73 return NULL; 74 74 } … … 87 87 if ((!prop) || (prop->size < 2)) 88 88 return NULL; 89 89 90 90 return prop->value; 91 91 } … … 110 110 return cur; 111 111 } 112 112 113 113 /* 114 114 * Disambigued name not found. … … 122 122 return cur; 123 123 } 124 124 125 125 return NULL; 126 126 } … … 141 141 ofw_tree_property_t *prop = 142 142 ofw_tree_getprop(cur, "device_type"); 143 143 144 144 if ((!prop) || (!prop->value)) 145 145 continue; 146 146 147 147 if (str_cmp(prop->value, dtype) == 0) 148 148 return cur; 149 149 } 150 150 151 151 return NULL; 152 152 } … … 170 170 if (cur->node_handle == handle) 171 171 return cur; 172 172 173 173 if (cur->child) { 174 174 ofw_tree_node_t *node = … … 178 178 } 179 179 } 180 180 181 181 return NULL; 182 182 } … … 197 197 ofw_tree_property_t *prop = 198 198 ofw_tree_getprop(cur, "device_type"); 199 199 200 200 if ((!prop) || (!prop->value)) 201 201 continue; 202 202 203 203 if (str_cmp(prop->value, dtype) == 0) 204 204 return cur; 205 205 } 206 206 207 207 return NULL; 208 208 } … … 223 223 ofw_tree_property_t *prop = 224 224 ofw_tree_getprop(cur, "name"); 225 225 226 226 if ((!prop) || (!prop->value)) 227 227 continue; 228 228 229 229 if (str_cmp(prop->value, name) == 0) 230 230 return cur; 231 231 } 232 232 233 233 return NULL; 234 234 } … … 246 246 if (path[0] != '/') 247 247 return NULL; 248 248 249 249 ofw_tree_node_t *node = ofw_root; 250 250 size_t j; 251 251 252 252 for (size_t i = 1; (i < str_size(path)) && (node); i = j + 1) { 253 253 for (j = i; (j < str_size(path)) && (path[j] != '/'); j++); 254 254 255 255 /* Skip extra slashes */ 256 256 if (i == j) 257 257 continue; 258 258 259 259 char buf[NAME_BUF_LEN + 1]; 260 260 memcpy(buf, &path[i], j - i); … … 262 262 node = ofw_tree_find_child(node, buf); 263 263 } 264 264 265 265 return node; 266 266 } … … 285 285 ofw_tree_property_t *prop = 286 286 ofw_tree_getprop(cur, "device_type"); 287 287 288 288 if ((prop) && (prop->value) && (str_cmp(prop->value, dtype) == 0)) { 289 289 bool ret = walker(cur, arg); … … 291 291 return false; 292 292 } 293 293 294 294 if (cur->child) { 295 295 bool ret = … … 299 299 } 300 300 } 301 301 302 302 return true; 303 303 } … … 336 336 { 337 337 ofw_tree_node_t *node = (ofw_tree_node_t *) data; 338 338 339 339 /* Compute serialized data size */ 340 340 *size = 0; … … 342 342 *size += str_size(node->property[i].name) + 1 + 343 343 sizeof(node->property[i].size) + node->property[i].size; 344 344 345 345 if (dry_run) 346 346 return NULL; 347 347 348 348 void *dump = malloc(*size, FRAME_ATOMIC); 349 349 if (dump == NULL) { … … 351 351 return NULL; 352 352 } 353 353 354 354 /* Serialize the data */ 355 355 size_t pos = 0; … … 358 358 str_cpy(dump + pos, *size - pos, node->property[i].name); 359 359 pos += str_size(node->property[i].name) + 1; 360 360 361 361 /* Value size */ 362 362 memcpy(dump + pos, &node->property[i].size, 363 363 sizeof(node->property[i].size)); 364 364 pos += sizeof(node->property[i].size); 365 365 366 366 /* Value */ 367 367 memcpy(dump + pos, node->property[i].value, … … 369 369 pos += node->property[i].size; 370 370 } 371 371 372 372 return ((void *) dump); 373 373 } … … 385 385 { 386 386 char *cur_path = (char *) malloc(PATH_MAX_LEN, 0); 387 387 388 388 for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) { 389 389 if ((cur->parent) && (path)) … … 391 391 else 392 392 snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name); 393 393 394 394 sysinfo_set_item_gen_data(cur_path, NULL, ofw_sysinfo_properties, 395 395 (void *) cur); 396 396 397 397 if (cur->child) 398 398 ofw_tree_node_sysinfo(cur->child, cur_path); 399 399 } 400 400 401 401 free(cur_path); 402 402 } -
kernel/genarch/src/ofw/pci.c
r3061bc1 ra35b458 63 63 return false; 64 64 } 65 65 66 66 ranges = prop->size / sizeof(ofw_pci_range_t); 67 67 range = prop->value; 68 68 69 69 unsigned int i; 70 70 71 71 for (i = 0; i < ranges; i++) { 72 72 if ((reg->space & PCI_SPACE_MASK) != … … 95 95 return true; 96 96 } 97 97 98 98 ofw_tree_property_t *prop; 99 99 ofw_pci_reg_t *assigned_address; 100 100 size_t assigned_addresses; 101 101 102 102 prop = ofw_tree_getprop(node, "assigned-addresses"); 103 103 if (!prop) 104 104 panic("Cannot find 'assigned-addresses' property."); 105 105 106 106 assigned_addresses = prop->size / sizeof(ofw_pci_reg_t); 107 107 assigned_address = prop->value; 108 108 109 109 unsigned int i; 110 110 111 111 for (i = 0; i < assigned_addresses; i++) { 112 112 if ((assigned_address[i].space & PCI_REG_MASK) == … … 118 118 } 119 119 } 120 120 121 121 return false; 122 122 } -
kernel/genarch/src/ofw/sbus.c
r3061bc1 ra35b458 46 46 ofw_sbus_range_t *range; 47 47 size_t ranges; 48 48 49 49 /* 50 50 * The SBUS support is very rudimentary in that we simply assume … … 55 55 if (!node->parent || node->parent->parent) 56 56 return false; 57 57 58 58 prop = ofw_tree_getprop(node, "ranges"); 59 59 if (!prop) 60 60 return false; 61 61 62 62 ranges = prop->size / sizeof(ofw_sbus_range_t); 63 63 range = prop->value; 64 64 65 65 unsigned int i; 66 66 67 67 for (i = 0; i < ranges; i++) { 68 68 if (overlaps(reg->addr, reg->size, range[i].child_base, … … 73 73 } 74 74 } 75 75 76 76 return false; 77 77 }
Note:
See TracChangeset
for help on using the changeset viewer.
