zephyr/drivers/hwinfo/hwinfo_handlers.c
Arvin Farahmand 98a0ccd5c5 drivers: hwinfo: Add reset cause support
Add `hwinfo_get_reset_cause` and `hwinfo_clear_reset_cause` to retrieve
and to clear cause of system reset on supported platforms.

Different platforms can provide different causes of reset, however
there is a great deal of overlap. `enum reset_cause` can be expanded in
the future to support additional reasons, as additional platforms are
supported.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-06-08 10:16:17 +02:00

47 lines
1.1 KiB
C

/*
* Copyright (c) 2018 Alexander Wachter
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <syscall_handler.h>
#include <drivers/hwinfo.h>
ssize_t z_vrfy_hwinfo_get_device_id(uint8_t *buffer, size_t length)
{
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buffer, length));
return z_impl_hwinfo_get_device_id((uint8_t *)buffer, (size_t)length);
}
#include <syscalls/hwinfo_get_device_id_mrsh.c>
int z_vrfy_hwinfo_get_reset_cause(uint32_t *cause)
{
int ret;
uint32_t cause_copy;
ret = z_impl_hwinfo_get_reset_cause(&cause_copy);
Z_OOPS(z_user_to_copy(cause, &cause_copy, sizeof(uint32_t)));
return ret;
}
#include <syscalls/hwinfo_get_reset_cause_mrsh.c>
int z_vrfy_hwinfo_clear_reset_cause(void)
{
return z_impl_hwinfo_clear_reset_cause();
}
#include <syscalls/hwinfo_clear_reset_cause_mrsh.c>
int z_vrfy_hwinfo_get_supported_reset_cause(uint32_t *supported)
{
int ret;
uint32_t supported_copy;
ret = z_impl_hwinfo_get_supported_reset_cause(&supported_copy);
Z_OOPS(z_user_to_copy(supported, &supported_copy, sizeof(uint32_t)));
return ret;
}
#include <syscalls/hwinfo_get_supported_reset_cause_mrsh.c>