Lines Matching +full:mem +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0
43 * of_fdt_limit_memory - limit the number of regions in the /memory node
82 static void *unflatten_dt_alloc(void **mem, unsigned long size, in unflatten_dt_alloc() argument
87 *mem = PTR_ALIGN(*mem, align); in unflatten_dt_alloc()
88 res = *mem; in unflatten_dt_alloc()
89 *mem += size; in unflatten_dt_alloc()
96 void **mem, in populate_properties() argument
105 pprev = &np->properties; in populate_properties()
127 pp = unflatten_dt_alloc(mem, sizeof(struct property), in populate_properties()
133 * ePAPR-style "phandle" properties, or the in populate_properties()
140 if (!np->phandle) in populate_properties()
141 np->phandle = be32_to_cpup(val); in populate_properties()
149 np->phandle = be32_to_cpup(val); in populate_properties()
151 pp->name = (char *)pname; in populate_properties()
152 pp->length = sz; in populate_properties()
153 pp->value = (__be32 *)val; in populate_properties()
155 pprev = &pp->next; in populate_properties()
175 len = (pa - ps) + 1; in populate_properties()
176 pp = unflatten_dt_alloc(mem, sizeof(struct property) + len, in populate_properties()
179 pp->name = "name"; in populate_properties()
180 pp->length = len; in populate_properties()
181 pp->value = pp + 1; in populate_properties()
183 memcpy(pp->value, ps, len - 1); in populate_properties()
184 ((char *)pp->value)[len - 1] = 0; in populate_properties()
185 pr_debug("fixed up name for %s -> %s\n", in populate_properties()
186 nodename, (char *)pp->value); in populate_properties()
193 void **mem, in populate_node() argument
210 np = unflatten_dt_alloc(mem, sizeof(struct device_node) + len, in populate_node()
215 np->full_name = fn = ((char *)np) + sizeof(*np); in populate_node()
220 np->parent = dad; in populate_node()
221 np->sibling = dad->child; in populate_node()
222 dad->child = np; in populate_node()
226 populate_properties(blob, offset, mem, np, pathp, dryrun); in populate_node()
228 np->name = of_get_property(np, "name", NULL); in populate_node()
229 if (!np->name) in populate_node()
230 np->name = "<NULL>"; in populate_node()
241 /* In-depth first */ in reverse_nodes()
242 child = parent->child; in reverse_nodes()
246 child = child->sibling; in reverse_nodes()
250 child = parent->child; in reverse_nodes()
251 parent->child = NULL; in reverse_nodes()
253 next = child->sibling; in reverse_nodes()
255 child->sibling = parent->child; in reverse_nodes()
256 parent->child = child; in reverse_nodes()
262 * unflatten_dt_nodes - Alloc and populate a device_node from the flat tree
264 * @mem: Memory chunk to use for allocating device nodes and properties
271 void *mem, in unflatten_dt_nodes() argument
279 void *base = mem; in unflatten_dt_nodes() local
280 bool dryrun = !base; in unflatten_dt_nodes()
287 * We're unflattening device sub-tree if @dad is valid. There are in unflatten_dt_nodes()
302 if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH - 1)) in unflatten_dt_nodes()
309 ret = populate_node(blob, offset, &mem, nps[depth], in unflatten_dt_nodes()
320 if (offset < 0 && offset != -FDT_ERR_NOTFOUND) { in unflatten_dt_nodes()
322 return -EINVAL; in unflatten_dt_nodes()
332 return mem - base; in unflatten_dt_nodes()
336 * __unflatten_device_tree - create tree of device_nodes from flat blob
344 * unflattens a device-tree, creating the tree of struct device_node. It also
345 * fills the "name" and "type" pointers of the nodes so the normal device-tree
358 void *mem; in __unflatten_device_tree() local
364 pr_debug(" -> unflatten_device_tree()\n"); in __unflatten_device_tree()
390 mem = dt_alloc(size + 4, __alignof__(struct device_node)); in __unflatten_device_tree()
391 if (!mem) in __unflatten_device_tree()
394 memset(mem, 0, size); in __unflatten_device_tree()
396 *(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef); in __unflatten_device_tree()
398 pr_debug(" unflattening %p...\n", mem); in __unflatten_device_tree()
401 ret = unflatten_dt_nodes(blob, mem, dad, mynodes); in __unflatten_device_tree()
403 if (be32_to_cpup(mem + size) != 0xdeadbeef) in __unflatten_device_tree()
405 be32_to_cpup(mem + size)); in __unflatten_device_tree()
415 pr_debug(" <- unflatten_device_tree()\n"); in __unflatten_device_tree()
416 return mem; in __unflatten_device_tree()
427 * of_fdt_unflatten_tree - create tree of device_nodes from flat blob
432 * unflattens the device-tree passed by the firmware, creating the
434 * pointers of the nodes so the normal device-tree walking functions
444 void *mem; in of_fdt_unflatten_tree() local
447 mem = __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc, in of_fdt_unflatten_tree()
451 return mem; in of_fdt_unflatten_tree()
466 * fdt_reserve_elfcorehdr() - reserves memory for elf core header
490 * early_init_fdt_scan_reserved_mem() - create reserved memory regions
499 u64 base, size; in early_init_fdt_scan_reserved_mem() local
509 fdt_get_mem_rsv(initial_boot_params, n, &base, &size); in early_init_fdt_scan_reserved_mem()
512 memblock_reserve(base, size); in early_init_fdt_scan_reserved_mem()
519 * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob
532 * of_scan_flat_dt - scan flattened tree blob and call callback on each.
536 * This function is used to scan the flattened device-tree, it is
547 int offset, rc = 0, depth = -1; in of_scan_flat_dt()
552 for (offset = fdt_next_node(blob, -1, &depth); in of_scan_flat_dt()
563 * of_scan_flat_dt_subnodes - scan sub-nodes of a node call callback on each.
568 * This function is used to scan sub-nodes of a node.
592 * of_get_flat_dt_subnode_by_name - get the subnode by given name
596 * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
605 * of_get_flat_dt_root - find the root node in the flat blob
613 * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
625 * of_fdt_is_compatible - Return true if given node from the given blob has
631 * Return: a non-zero value on match with smaller values returned for more
650 cplen -= l; in of_fdt_is_compatible()
657 * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
667 * of_flat_dt_match - Return true if node matches a list of compatible values
687 * of_get_flat_dt_phandle - Given a node in the flat blob, return the phandle
706 * of_flat_dt_match_machine - Iterate match tables to find matching machine.
741 size -= strlen(prop) + 1; in of_flat_dt_match_machine()
771 * early_init_dt_check_for_initrd - Decode initrd location from flat tree
785 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); in early_init_dt_check_for_initrd()
790 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); in early_init_dt_check_for_initrd()
799 phys_initrd_size = end - start; in early_init_dt_check_for_initrd()
805 * early_init_dt_check_for_elfcorehdr - Decode elfcorehdr location from flat
830 static unsigned long chosen_node_offset = -FDT_ERR_NOTFOUND;
833 * The main usage of linux,usable-memory-range is for crash dump kernel.
834 * Originally, the number of usable-memory regions is one. Now there may
836 * To make compatibility with existing user-space and older kdump, the low
837 * region is always the last range of linux,usable-memory-range if exist.
842 * early_init_dt_check_for_usable_mem_range - Decode usable memory range
855 pr_debug("Looking for usable-memory-range property... "); in early_init_dt_check_for_usable_mem_range()
857 prop = of_get_flat_dt_prop(node, "linux,usable-memory-range", &len); in early_init_dt_check_for_usable_mem_range()
863 rgn[i].base = dt_mem_next_cell(dt_root_addr_cells, &prop); in early_init_dt_check_for_usable_mem_range()
866 pr_debug("cap_mem_regions[%d]: base=%pa, size=%pa\n", in early_init_dt_check_for_usable_mem_range()
867 i, &rgn[i].base, &rgn[i].size); in early_init_dt_check_for_usable_mem_range()
870 memblock_cap_memory_range(rgn[0].base, rgn[0].size); in early_init_dt_check_for_usable_mem_range()
872 memblock_add(rgn[i].base, rgn[i].size); in early_init_dt_check_for_usable_mem_range()
890 return -ENOENT; in early_init_dt_scan_chosen_stdout()
892 p = fdt_getprop(fdt, offset, "stdout-path", &l); in early_init_dt_scan_chosen_stdout()
894 p = fdt_getprop(fdt, offset, "linux,stdout-path", &l); in early_init_dt_scan_chosen_stdout()
896 return -ENOENT; in early_init_dt_scan_chosen_stdout()
901 l = q - p; in early_init_dt_scan_chosen_stdout()
903 /* Get the node specified by stdout-path */ in early_init_dt_scan_chosen_stdout()
906 pr_warn("earlycon: stdout-path %.*s not found\n", l, p); in early_init_dt_scan_chosen_stdout()
911 if (!match->compatible[0]) in early_init_dt_scan_chosen_stdout()
914 if (fdt_node_check_compatible(fdt, offset, match->compatible)) in early_init_dt_scan_chosen_stdout()
918 if (!ret || ret == -EALREADY) in early_init_dt_scan_chosen_stdout()
921 return -ENODEV; in early_init_dt_scan_chosen_stdout()
926 * early_init_dt_scan_root - fetch the top level address and size cells
935 return -ENODEV; in early_init_dt_scan_root()
940 prop = of_get_flat_dt_prop(node, "#size-cells", NULL); in early_init_dt_scan_root()
945 prop = of_get_flat_dt_prop(node, "#address-cells", NULL); in early_init_dt_scan_root()
962 * early_init_dt_scan_memory - Look for and parse memory nodes
982 reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); in early_init_dt_scan_memory()
994 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { in early_init_dt_scan_memory()
995 u64 base, size; in early_init_dt_scan_memory() local
997 base = dt_mem_next_cell(dt_root_addr_cells, ®); in early_init_dt_scan_memory()
1002 pr_debug(" - %llx, %llx\n", base, size); in early_init_dt_scan_memory()
1004 early_init_dt_add_memory_arch(base, size); in early_init_dt_scan_memory()
1011 if (memblock_mark_hotplug(base, size)) in early_init_dt_scan_memory()
1012 pr_warn("failed to mark hotplug range 0x%llx - 0x%llx\n", in early_init_dt_scan_memory()
1013 base, base + size); in early_init_dt_scan_memory()
1038 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); in early_init_dt_scan_chosen()
1043 fdt_nop_property(initial_boot_params, node, "rng-seed"); in early_init_dt_scan_chosen()
1086 void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) in early_init_dt_add_memory_arch() argument
1090 if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { in early_init_dt_add_memory_arch()
1091 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1092 base, base + size); in early_init_dt_add_memory_arch()
1096 if (!PAGE_ALIGNED(base)) { in early_init_dt_add_memory_arch()
1097 size -= PAGE_SIZE - (base & ~PAGE_MASK); in early_init_dt_add_memory_arch()
1098 base = PAGE_ALIGN(base); in early_init_dt_add_memory_arch()
1102 if (base > MAX_MEMBLOCK_ADDR) { in early_init_dt_add_memory_arch()
1103 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1104 base, base + size); in early_init_dt_add_memory_arch()
1108 if (base + size - 1 > MAX_MEMBLOCK_ADDR) { in early_init_dt_add_memory_arch()
1109 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1110 ((u64)MAX_MEMBLOCK_ADDR) + 1, base + size); in early_init_dt_add_memory_arch()
1111 size = MAX_MEMBLOCK_ADDR - base + 1; in early_init_dt_add_memory_arch()
1114 if (base + size < phys_offset) { in early_init_dt_add_memory_arch()
1115 pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1116 base, base + size); in early_init_dt_add_memory_arch()
1119 if (base < phys_offset) { in early_init_dt_add_memory_arch()
1120 pr_warn("Ignoring memory range 0x%llx - 0x%llx\n", in early_init_dt_add_memory_arch()
1121 base, phys_offset); in early_init_dt_add_memory_arch()
1122 size -= phys_offset - base; in early_init_dt_add_memory_arch()
1123 base = phys_offset; in early_init_dt_add_memory_arch()
1125 memblock_add(base, size); in early_init_dt_add_memory_arch()
1148 /* Setup flat device-tree pointer */ in early_init_dt_verify()
1153 /* Initialize {size,address}-cells info */ in early_init_dt_verify()
1172 /* Handle linux,usable-memory-range property */ in early_init_dt_scan_nodes()
1204 * unflatten_device_tree - create tree of device_nodes from flat blob
1206 * unflattens the device-tree passed by the firmware, creating the
1208 * pointers of the nodes so the normal device-tree walking functions
1227 __dtb_empty_root_end - __dtb_empty_root_begin) { in unflatten_device_tree()
1245 * unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob
1247 * Copies and unflattens the device-tree passed by the firmware, creating the
1249 * pointers of the nodes so the normal device-tree walking functions
1251 * reserved such is the case when the FDT is built-in to the kernel init