fdt.c (3b1a2c97210b1edd1a999ff8c1f72ab28f7609f7) | fdt.c (24bbd929e6b9e62afd263c42b4318d3b603c956c) |
---|---|
1/* 2 * Functions for working with the Flattened Device Tree data format 3 * 4 * Copyright 2009 Benjamin Herrenschmidt, IBM Corp 5 * benh@kernel.crashing.org 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 154 unchanged lines hidden (view full) --- 163/** 164 * unflatten_dt_node - Alloc and populate a device_node from the flat tree 165 * @blob: The parent device tree blob 166 * @mem: Memory chunk to use for allocating device nodes and properties 167 * @p: pointer to node in flat tree 168 * @dad: Parent struct device_node 169 * @fpsize: Size of the node path up at the current depth. 170 */ | 1/* 2 * Functions for working with the Flattened Device Tree data format 3 * 4 * Copyright 2009 Benjamin Herrenschmidt, IBM Corp 5 * benh@kernel.crashing.org 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 154 unchanged lines hidden (view full) --- 163/** 164 * unflatten_dt_node - Alloc and populate a device_node from the flat tree 165 * @blob: The parent device tree blob 166 * @mem: Memory chunk to use for allocating device nodes and properties 167 * @p: pointer to node in flat tree 168 * @dad: Parent struct device_node 169 * @fpsize: Size of the node path up at the current depth. 170 */ |
171static void * unflatten_dt_node(const void *blob, | 171static void * unflatten_dt_node(void *blob, |
172 void *mem, 173 int *poffset, 174 struct device_node *dad, 175 struct device_node **nodepp, 176 unsigned long fpsize, 177 bool dryrun) 178{ 179 const __be32 *p; --- 193 unchanged lines hidden (view full) --- 373 * tree of struct device_node. It also fills the "name" and "type" 374 * pointers of the nodes so the normal device-tree walking functions 375 * can be used. 376 * @blob: The blob to expand 377 * @mynodes: The device_node tree created by the call 378 * @dt_alloc: An allocator that provides a virtual address to memory 379 * for the resulting tree 380 */ | 172 void *mem, 173 int *poffset, 174 struct device_node *dad, 175 struct device_node **nodepp, 176 unsigned long fpsize, 177 bool dryrun) 178{ 179 const __be32 *p; --- 193 unchanged lines hidden (view full) --- 373 * tree of struct device_node. It also fills the "name" and "type" 374 * pointers of the nodes so the normal device-tree walking functions 375 * can be used. 376 * @blob: The blob to expand 377 * @mynodes: The device_node tree created by the call 378 * @dt_alloc: An allocator that provides a virtual address to memory 379 * for the resulting tree 380 */ |
381static void __unflatten_device_tree(const void *blob, | 381static void __unflatten_device_tree(void *blob, |
382 struct device_node **mynodes, 383 void * (*dt_alloc)(u64 size, u64 align)) 384{ 385 unsigned long size; 386 int start; 387 void *mem; 388 389 pr_debug(" -> unflatten_device_tree()\n"); --- 46 unchanged lines hidden (view full) --- 436/** 437 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob 438 * 439 * unflattens the device-tree passed by the firmware, creating the 440 * tree of struct device_node. It also fills the "name" and "type" 441 * pointers of the nodes so the normal device-tree walking functions 442 * can be used. 443 */ | 382 struct device_node **mynodes, 383 void * (*dt_alloc)(u64 size, u64 align)) 384{ 385 unsigned long size; 386 int start; 387 void *mem; 388 389 pr_debug(" -> unflatten_device_tree()\n"); --- 46 unchanged lines hidden (view full) --- 436/** 437 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob 438 * 439 * unflattens the device-tree passed by the firmware, creating the 440 * tree of struct device_node. It also fills the "name" and "type" 441 * pointers of the nodes so the normal device-tree walking functions 442 * can be used. 443 */ |
444void of_fdt_unflatten_tree(const unsigned long *blob, | 444void of_fdt_unflatten_tree(unsigned long *blob, |
445 struct device_node **mynodes) 446{ 447 __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc); 448} 449EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree); 450 451/* Everything below here references initial_boot_params directly. */ 452int __initdata dt_root_addr_cells; --- 122 unchanged lines hidden (view full) --- 575void __init early_init_fdt_scan_reserved_mem(void) 576{ 577 int n; 578 u64 base, size; 579 580 if (!initial_boot_params) 581 return; 582 | 445 struct device_node **mynodes) 446{ 447 __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc); 448} 449EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree); 450 451/* Everything below here references initial_boot_params directly. */ 452int __initdata dt_root_addr_cells; --- 122 unchanged lines hidden (view full) --- 575void __init early_init_fdt_scan_reserved_mem(void) 576{ 577 int n; 578 u64 base, size; 579 580 if (!initial_boot_params) 581 return; 582 |
583 /* Reserve the dtb region */ 584 early_init_dt_reserve_memory_arch(__pa(initial_boot_params), 585 fdt_totalsize(initial_boot_params), 586 0); 587 | |
588 /* Process header /memreserve/ fields */ 589 for (n = 0; ; n++) { 590 fdt_get_mem_rsv(initial_boot_params, n, &base, &size); 591 if (!size) 592 break; 593 early_init_dt_reserve_memory_arch(base, size, 0); 594 } 595 596 of_scan_flat_dt(__fdt_scan_reserved_mem, NULL); 597 fdt_init_reserved_mem(); 598} 599 600/** | 583 /* Process header /memreserve/ fields */ 584 for (n = 0; ; n++) { 585 fdt_get_mem_rsv(initial_boot_params, n, &base, &size); 586 if (!size) 587 break; 588 early_init_dt_reserve_memory_arch(base, size, 0); 589 } 590 591 of_scan_flat_dt(__fdt_scan_reserved_mem, NULL); 592 fdt_init_reserved_mem(); 593} 594 595/** |
596 * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob 597 */ 598void __init early_init_fdt_reserve_self(void) 599{ 600 if (!initial_boot_params) 601 return; 602 603 /* Reserve the dtb region */ 604 early_init_dt_reserve_memory_arch(__pa(initial_boot_params), 605 fdt_totalsize(initial_boot_params), 606 0); 607} 608 609/** |
|
601 * of_scan_flat_dt - scan flattened tree blob and call callback on each. 602 * @it: callback function 603 * @data: context data pointer 604 * 605 * This function is used to scan the flattened device-tree, it is 606 * used to extract the memory information at boot before we can 607 * unflatten the tree 608 */ --- 537 unchanged lines hidden --- | 610 * of_scan_flat_dt - scan flattened tree blob and call callback on each. 611 * @it: callback function 612 * @data: context data pointer 613 * 614 * This function is used to scan the flattened device-tree, it is 615 * used to extract the memory information at boot before we can 616 * unflatten the tree 617 */ --- 537 unchanged lines hidden --- |