forked from Imagelibrary/rtems
libmisc/rtems-fdt: Support prop map items up to the size of uintptr_t
Updates #4729
This commit is contained in:
@@ -694,6 +694,12 @@ const char *rtems_fdt_entry_name(rtems_fdt_handle* handle, int id);
|
||||
*/
|
||||
int rtems_fdt_entry_offset(rtems_fdt_handle* handle, int id);
|
||||
|
||||
/*
|
||||
* Helper function to convert the void* property result of unknown
|
||||
* length to an unsigned int pointer value.
|
||||
*/
|
||||
uintptr_t rtems_fdt_get_offset_len_uintptr(const void* prop, int offset, int len);
|
||||
|
||||
/*
|
||||
* Helper function to convert the void* property result to a 32bit unsigned int.
|
||||
*/
|
||||
|
||||
@@ -1063,18 +1063,33 @@ rtems_fdt_prop_map(const char* const path,
|
||||
return length;
|
||||
}
|
||||
|
||||
if (length != sizeof (uintptr_t))
|
||||
if (length > sizeof (uintptr_t))
|
||||
{
|
||||
rtems_fdt_release_handle (&fdt);
|
||||
return -RTEMS_FDT_ERR_BADPATH;
|
||||
}
|
||||
|
||||
values[item] = rtems_fdt_get_uintptr(prop);
|
||||
values[item] = rtems_fdt_get_offset_len_uintptr(prop, 0, length);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uintptr_t
|
||||
rtems_fdt_get_offset_len_uintptr (const void* prop, int offset, int len)
|
||||
{
|
||||
const uint8_t* p = prop;
|
||||
uintptr_t value = 0;
|
||||
int b;
|
||||
if (len <= sizeof(uintptr_t)) {
|
||||
for (b = 0; b < len; ++b) {
|
||||
value = (value << 8) | (uintptr_t) p[offset++];
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
rtems_fdt_get_offset_uint32 (const void* prop, int offset)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user