diff options
author | Travis Geiselbrecht <geist@foobox.com> | 2023-07-05 23:30:52 -0700 |
---|---|---|
committer | Travis Geiselbrecht <geist@foobox.com> | 2023-10-15 14:41:30 -0700 |
commit | 6b7d0ab627f642d55c83518c63a81ce656723d1b (patch) | |
tree | 5151586d6af489ad442e184d19e7f226a1cd6922 | |
parent | 284f83af11784e646492427ffd17e612018ac726 (diff) | |
download | lk-6b7d0ab627f642d55c83518c63a81ce656723d1b.tar.gz |
[lib][fdtwalk] add code to skip a cpu if disabled
Some RISC-V cpus come up disabled, skip enumerating them.
-rw-r--r-- | lib/fdtwalk/fdtwalk.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/fdtwalk/fdtwalk.c b/lib/fdtwalk/fdtwalk.c index 2ca506af..17f4f8fb 100644 --- a/lib/fdtwalk/fdtwalk.c +++ b/lib/fdtwalk/fdtwalk.c @@ -77,6 +77,21 @@ static status_t read_base_len_pair(const uint8_t *prop_ptr, size_t prop_len, return NO_ERROR; } +// returns true or false if a particular property is a particular value +static bool check_prop_is_val_string(const void *fdt, int offset, const char *prop, const char *val) { + int lenp; + const uint8_t *prop_ptr = fdt_getprop(fdt, offset, prop, &lenp); + if (!prop_ptr || lenp <= 0) { + return false; + } + + if (strncmp(val, (const char *)prop_ptr, strlen(val)) == 0) { + return true; + } + + return false; +} + status_t fdt_walk(const void *fdt, const struct fdt_walk_callbacks *cb) { int err = fdt_check_header(fdt); if (err != 0) { @@ -202,8 +217,13 @@ status_t fdt_walk(const void *fdt, const struct fdt_walk_callbacks *cb) { PANIC_UNIMPLEMENTED; } - LTRACEF("calling cpu callback with id %#x\n", id); - cb->cpu(id, cb->cpucookie); + // is it disabled? + if (check_prop_is_val_string(fdt, offset, "status", "disabled")) { + LTRACEF("cpu id %#x is disabled, skipping...\n", id); + } else { + LTRACEF("calling cpu callback with id %#x\n", id); + cb->cpu(id, cb->cpucookie); + } } } |