/* Cast away the const as the attribute is part of a larger structure */
part = (struct sram_partition *)container_of(attr, struct sram_partition, battr);
/* Cast away the const as the attribute is part of a larger structure */
part = (struct sram_partition *)container_of(attr, struct sram_partition, battr);
if (block->pool) {
ret = sram_add_pool(sram, block, start, part); if (ret) return ret;
} if (block->export) {
ret = sram_add_export(sram, block, start, part); if (ret) return ret;
} if (block->protect_exec) {
ret = sram_check_protect_exec(sram, block, part); if (ret) return ret;
ret = sram_add_pool(sram, block, start, part); if (ret) return ret;
part = &sram->partition[sram->partitions - 1]; for (; sram->partitions; sram->partitions--, part--) { if (part->battr.size)
device_remove_bin_file(sram->dev, &part->battr);
if (part->pool &&
gen_pool_avail(part->pool) < gen_pool_size(part->pool))
dev_err(sram->dev, "removed pool while SRAM allocated\n");
}
}
/* * We need an additional block to mark the end of the memory region * after the reserved blocks from the dt are processed.
*/
nblocks = (np) ? of_get_available_child_count(np) + 1 : 1;
rblocks = kcalloc(nblocks, sizeof(*rblocks), GFP_KERNEL); if (!rblocks) return -ENOMEM;
ret = of_address_to_resource(child, 0, &child_res); if (ret < 0) {
dev_err(sram->dev, "could not get address for node %pOF\n",
child); goto err_chunks;
}
if (child_res.start < res->start || child_res.end > res->end) {
dev_err(sram->dev, "reserved block %pOF outside the sram area\n",
child);
ret = -EINVAL; goto err_chunks;
}
/* the last chunk marks the end of the region */
rblocks[nblocks - 1].start = size;
rblocks[nblocks - 1].size = 0;
list_add_tail(&rblocks[nblocks - 1].list, &reserve_list);
list_sort(NULL, &reserve_list, sram_reserve_cmp);
if (exports) {
sram->partition = devm_kcalloc(sram->dev,
exports, sizeof(*sram->partition),
GFP_KERNEL); if (!sram->partition) {
ret = -ENOMEM; goto err_chunks;
}
}
cur_start = 0;
list_for_each_entry(block, &reserve_list, list) { /* can only happen if sections overlap */ if (block->start < cur_start) {
dev_err(sram->dev, "block at 0x%x starts after current offset 0x%lx\n",
block->start, cur_start);
ret = -EINVAL;
sram_free_partitions(sram); goto err_chunks;
}
if ((block->export || block->pool || block->protect_exec) &&
block->size) {
ret = sram_add_partition(sram, block,
res->start + block->start); if (ret) {
sram_free_partitions(sram); goto err_chunks;
}
}
/* current start is in a reserved block, so continue after it */ if (block->start == cur_start) {
cur_start = block->start + block->size; continue;
}
/* * allocate the space between the current starting * address and the following reserved block, or the * end of the region.
*/
cur_size = block->start - cur_start;
/* * SYSRAM contains areas that are not accessible by the * kernel, such as the first 256K that is reserved for TZ. * Accesses to those areas (including speculative accesses) * trigger SErrors. As such we must map only the areas of * SYSRAM specified in the device tree.
*/ staticconststruct sram_config tegra_sysram_config = {
.map_only_reserved = true,
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.