device: simplify structure of handles array
Force the inclusion of a `DEVICE_HANDLE_SEP` at the end of the devicetree dependency section of the array. This lets us simplify the implementation of `device_required_handles_get`, as there is only one symbol the section ends with. This does not use any extra ROM as the array is padded out to the original size with `DEVICE_HANDLE_ENDS` anyway. Also adds a description of the array format where the array is instantiated. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
b5c4140afb
commit
ec331c6fe2
2 changed files with 19 additions and 3 deletions
|
@ -478,8 +478,7 @@ device_required_handles_get(const struct device *dev,
|
|||
if (rv != NULL) {
|
||||
size_t i = 0;
|
||||
|
||||
while ((rv[i] != DEVICE_HANDLE_ENDS)
|
||||
&& (rv[i] != DEVICE_HANDLE_SEP)) {
|
||||
while (rv[i] != DEVICE_HANDLE_SEP) {
|
||||
++i;
|
||||
}
|
||||
*count = i;
|
||||
|
@ -674,6 +673,22 @@ static inline bool device_is_ready(const struct device *dev)
|
|||
* in a distinct pass1 section (which will be replaced by
|
||||
* postprocessing).
|
||||
*
|
||||
* Before processing in gen_handles.py, the array format is:
|
||||
* {
|
||||
* DEVICE_ORDINAL (or DEVICE_HANDLE_NULL if not a devicetree node),
|
||||
* List of devicetree dependency ordinals (if any),
|
||||
* DEVICE_HANDLE_SEP,
|
||||
* List of injected dependency ordinals (if any),
|
||||
* }
|
||||
*
|
||||
* After processing in gen_handles.py, the format is updated to:
|
||||
* {
|
||||
* List of existing devicetree dependency handles (if any),
|
||||
* DEVICE_HANDLE_SEP,
|
||||
* List of injected dependency ordinals (if any),
|
||||
* DEVICE_HANDLE_NULL padding to original length (at least one)
|
||||
* }
|
||||
*
|
||||
* It is also (experimentally) necessary to provide explicit alignment
|
||||
* on each object. Otherwise x86-64 builds will introduce padding
|
||||
* between objects in the same input section in individual object
|
||||
|
|
|
@ -294,10 +294,11 @@ def main():
|
|||
dep_paths.append(dn.path)
|
||||
else:
|
||||
dep_paths.append('(%s)' % dn.path)
|
||||
# Force separator to signal start of injected dependencies
|
||||
hdls.append(DEVICE_HANDLE_SEP)
|
||||
if len(hs.ext_deps) > 0:
|
||||
# TODO: map these to something smaller?
|
||||
ext_paths.extend(map(str, hs.ext_deps))
|
||||
hdls.append(DEVICE_HANDLE_SEP)
|
||||
hdls.extend(hs.ext_deps)
|
||||
|
||||
# When CONFIG_USERSPACE is enabled the pre-built elf is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue