*参照元 [#lbfea9f0] #backlinks *説明 [#d2a38b35] -パス: [[linux-4.4.1/drivers/of/of_reserved_mem.c]] -FIXME: これは何? --説明 **引数 [#maa4204e] -unsigned long node -- -const char *uname -- -phys_addr_t *res_base -- --[[linux-4.4.1/phys_addr_t]] -phys_addr_t *res_size -- **返り値 [#w8476e30] -int -- **参考 [#m3de13f1] *実装 [#s74636f2] /** * res_mem_alloc_size() - allocate reserved memory described by 'size', 'align' * and 'alloc-ranges' properties */ static int __init __reserved_mem_alloc_size(unsigned long node, const char *uname, phys_addr_t *res_base, phys_addr_t *res_size) { int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32); phys_addr_t start = 0, end = 0; phys_addr_t base = 0, align = 0, size; int len; const __be32 *prop; int nomap; int ret; - --[[linux-4.4.1/dt_root_addr_cells(global)]] --[[linux-4.4.1/dt_root_size_cells(global)]] prop = of_get_flat_dt_prop(node, "size", &len); if (!prop) return -EINVAL; - --[[linux-4.4.1/of_get_flat_dt_prop()]] if (len != dt_root_size_cells * sizeof(__be32)) { pr_err("Reserved memory: invalid size property in '%s' node.\n", uname); return -EINVAL; } size = dt_mem_next_cell(dt_root_size_cells, &prop); - --[[linux-4.4.1/pr_err()]] --[[linux-4.4.1/dt_mem_next_call()]] nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL; - --[[linux-4.4.1/of_get_flat_dt_prop()]] prop = of_get_flat_dt_prop(node, "alignment", &len); if (prop) { if (len != dt_root_addr_cells * sizeof(__be32)) { pr_err("Reserved memory: invalid alignment property in '%s' node.\n", uname); return -EINVAL; } align = dt_mem_next_cell(dt_root_addr_cells, &prop); } /* Need adjust the alignment to satisfy the CMA requirement */ if (IS_ENABLED(CONFIG_CMA) && of_flat_dt_is_compatible(node, "shared-dma-pool")) align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order)); prop = of_get_flat_dt_prop(node, "alloc-ranges", &len); if (prop) { if (len % t_len != 0) { pr_err("Reserved memory: invalid alloc-ranges property in '%s', skipping node.\n", uname); return -EINVAL; } base = 0; while (len > 0) { start = dt_mem_next_cell(dt_root_addr_cells, &prop); end = start + dt_mem_next_cell(dt_root_size_cells, &prop); ret = early_init_dt_alloc_reserved_memory_arch(size, align, start, end, nomap, &base); if (ret == 0) { pr_debug("Reserved memory: allocated memory for '%s' node: base %pa, size %ld MiB\n", uname, &base, (unsigned long)size / SZ_1M); break; } len -= t_len; } - --[[linux-4.4.1/early_init_dt_alloc_reserved_memory_arch()]] --[[linux-4.4.1/pr_debug()]] } else { ret = early_init_dt_alloc_reserved_memory_arch(size, align, 0, 0, nomap, &base); if (ret == 0) pr_debug("Reserved memory: allocated memory for '%s' node: base %pa, size %ld MiB\n", uname, &base, (unsigned long)size / SZ_1M); } if (base == 0) { pr_info("Reserved memory: failed to allocate memory for node '%s'\n", uname); return -ENOMEM; } - --[[linux-4.4.1/pr_info()]] *res_base = base; *res_size = size; return 0; } *コメント [#se0690c8]