mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 06:08:20 +00:00
cpukit/libmisc/rtems-fdt: Add shell read and write handler support
The handlers allow indirect access to FDT resources registered with the shell. Closes #5152
This commit is contained in:
@@ -54,6 +54,28 @@ void rtems_fdt_add_shell_command (void);
|
||||
*/
|
||||
rtems_fdt_handle* rtems_fdt_get_shell_handle (void);
|
||||
|
||||
/**
|
||||
* Write handler call to write from the address property.
|
||||
*/
|
||||
typedef void (*rtems_fdt_write_handler)(uintptr_t address, uint32_t value);
|
||||
|
||||
/**
|
||||
* Read handler call to read from the address property.
|
||||
*/
|
||||
typedef uint32_t (*rtems_fdt_read_handler)(uintptr_t address);
|
||||
|
||||
/**
|
||||
* Set the write handler returning the current handler.
|
||||
*/
|
||||
rtems_fdt_write_handler
|
||||
rtems_fdt_set_shell_write_handler (rtems_fdt_write_handler handler);
|
||||
|
||||
/**
|
||||
* Set the read handler returning the current handler.
|
||||
*/
|
||||
rtems_fdt_read_handler
|
||||
rtems_fdt_set_shell_read_handler (rtems_fdt_read_handler handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -70,20 +70,42 @@ static long rtems_fdt_test_timeout = 5;
|
||||
*/
|
||||
static rtems_fdt_handle cmd_fdt_handle;
|
||||
|
||||
/**
|
||||
* The write and read handlers.
|
||||
*/
|
||||
static void rtems_fdt_default_write (uintptr_t address, uint32_t value);
|
||||
static uint32_t rtems_fdt_default_read (uintptr_t address);
|
||||
|
||||
static rtems_fdt_write_handler write_handler = rtems_fdt_default_write;;
|
||||
static rtems_fdt_read_handler read_handler = rtems_fdt_default_read;
|
||||
|
||||
static void
|
||||
rtems_fdt_write (uintptr_t address, uint32_t value)
|
||||
rtems_fdt_default_write (uintptr_t address, uint32_t value)
|
||||
{
|
||||
volatile uint32_t* ap = (uint32_t*) address;
|
||||
*ap = value;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
rtems_fdt_read (uintptr_t address)
|
||||
rtems_fdt_default_read (uintptr_t address)
|
||||
{
|
||||
volatile uint32_t* ap = (uint32_t*) address;
|
||||
return *ap;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
rtems_fdt_write (uintptr_t address, uint32_t value)
|
||||
{
|
||||
write_handler (address, value);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
rtems_fdt_read (uintptr_t address)
|
||||
{
|
||||
return read_handler (address);
|
||||
}
|
||||
|
||||
static int
|
||||
rtems_fdt_wrong_number_of_args (void)
|
||||
{
|
||||
@@ -785,3 +807,19 @@ rtems_fdt_get_shell_handle (void)
|
||||
{
|
||||
return &cmd_fdt_handle;
|
||||
}
|
||||
|
||||
rtems_fdt_write_handler
|
||||
rtems_fdt_set_shell_write_handler (rtems_fdt_write_handler handler)
|
||||
{
|
||||
rtems_fdt_write_handler tmp = write_handler;
|
||||
write_handler = handler;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
rtems_fdt_read_handler
|
||||
rtems_fdt_set_shell_read_handler (rtems_fdt_read_handler handler)
|
||||
{
|
||||
rtems_fdt_read_handler tmp = read_handler;
|
||||
read_handler = handler;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user