2017-12-08 18:50:46 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
|
|
|
* Copyright (c) 2015 Runtime Inc
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-05-07 12:12:11 +08:00
|
|
|
#define DT_DRV_COMPAT fixed_partitions
|
|
|
|
|
2022-07-02 19:20:23 +08:00
|
|
|
#include <zephyr/device.h>
|
includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.
The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.
NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-25 15:58:46 +08:00
|
|
|
#include <zephyr/kernel.h>
|
2022-05-06 17:12:04 +08:00
|
|
|
#include <zephyr/storage/flash_map.h>
|
2017-12-08 18:50:46 +08:00
|
|
|
|
2022-07-04 13:51:20 +08:00
|
|
|
#define FLASH_AREA_FOO(part) \
|
|
|
|
{.fa_id = DT_FIXED_PARTITION_ID(part), \
|
|
|
|
.fa_off = DT_REG_ADDR(part), \
|
|
|
|
.fa_dev = DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_FIXED_PARTITION(part)), \
|
2020-05-07 12:12:11 +08:00
|
|
|
.fa_size = DT_REG_SIZE(part),},
|
|
|
|
|
2020-09-21 21:48:49 +08:00
|
|
|
#define FOREACH_PARTITION(n) DT_FOREACH_CHILD(DT_DRV_INST(n), FLASH_AREA_FOO)
|
2020-05-07 12:12:11 +08:00
|
|
|
|
2022-03-17 05:07:43 +08:00
|
|
|
/* We iterate over all compatible 'fixed-partitions' nodes and
|
2020-05-07 12:12:11 +08:00
|
|
|
* use DT_FOREACH_CHILD to iterate over all the partitions for that
|
2022-03-17 05:07:43 +08:00
|
|
|
* 'fixed-partitions' node. This way we build a global partition map
|
2020-05-07 12:12:11 +08:00
|
|
|
*/
|
2017-12-08 18:50:46 +08:00
|
|
|
const struct flash_area default_flash_map[] = {
|
2020-09-21 21:48:49 +08:00
|
|
|
DT_INST_FOREACH_STATUS_OKAY(FOREACH_PARTITION)
|
2017-12-08 18:50:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const int flash_map_entries = ARRAY_SIZE(default_flash_map);
|
|
|
|
const struct flash_area *flash_map = default_flash_map;
|