drivers: hwinfo: Add device EUI64 ID support
Some devices, mostly with radio support, have an EUI64 ID (unique and
attributed by IEEE), in addition to the standard device ID.
Add support for reading it through the hwinfo API. As the size is always
the same (8 bytes), there is no need to pass the size in the function,
nor return the number of bytes copied.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
diff --git a/drivers/hwinfo/hwinfo_handlers.c b/drivers/hwinfo/hwinfo_handlers.c
index 02058f9..a1eb9e2 100644
--- a/drivers/hwinfo/hwinfo_handlers.c
+++ b/drivers/hwinfo/hwinfo_handlers.c
@@ -15,6 +15,14 @@
}
#include <syscalls/hwinfo_get_device_id_mrsh.c>
+ssize_t z_vrfy_hwinfo_get_device_eui64(uint8_t *buffer)
+{
+ K_OOPS(K_SYSCALL_MEMORY_WRITE(buffer, 8));
+
+ return z_impl_hwinfo_get_device_eui64((uint8_t *)buffer);
+}
+#include <syscalls/hwinfo_get_device_eui64_mrsh.c>
+
int z_vrfy_hwinfo_get_reset_cause(uint32_t *cause)
{
int ret;
diff --git a/drivers/hwinfo/hwinfo_weak_impl.c b/drivers/hwinfo/hwinfo_weak_impl.c
index c951d63..a21745d 100644
--- a/drivers/hwinfo/hwinfo_weak_impl.c
+++ b/drivers/hwinfo/hwinfo_weak_impl.c
@@ -11,6 +11,11 @@
return -ENOSYS;
}
+int __weak z_impl_hwinfo_get_device_eui64(uint8_t *buffer)
+{
+ return -ENOSYS;
+}
+
int __weak z_impl_hwinfo_get_reset_cause(uint32_t *cause)
{
return -ENOSYS;
diff --git a/include/zephyr/drivers/hwinfo.h b/include/zephyr/drivers/hwinfo.h
index df412cd..4683562 100644
--- a/include/zephyr/drivers/hwinfo.h
+++ b/include/zephyr/drivers/hwinfo.h
@@ -96,6 +96,22 @@
ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length);
/**
+ * @brief Copy the device EUI64 to a buffer
+ *
+ * This routine copies the device EUI64 (8 bytes) to the buffer.
+ * The EUI64 depends on the hardware and is guaranteed unique.
+ *
+ * @param buffer Buffer of 8 bytes to write the ID to.
+ *
+ * @retval zero if successful.
+ * @retval -ENOSYS if there is no implementation for the particular device.
+ * @retval any negative value on driver specific errors.
+ */
+__syscall int hwinfo_get_device_eui64(uint8_t *buffer);
+
+int z_impl_hwinfo_get_device_eui64(uint8_t *buffer);
+
+/**
* @brief Retrieve cause of device reset.
*
* @param cause OR'd @ref reset_cause "reset cause" flags