sysinfo: Add API for accessing data elements
This commit introduces a new API to the sysinfo module, allowing access
to data elements. This is particularly useful for handling data with
multiple instances, such as MAC addresses.
Signed-off-by: Baocheng Su <baocheng.su@siemens.com>
diff --git a/include/sysinfo.h b/include/sysinfo.h
index 14e923c..2866ac2 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -152,6 +152,7 @@
/* For show_board_info() */
SYSID_BOARD_MODEL,
SYSID_BOARD_MANUFACTURER,
+ SYSID_BOARD_MAC_ADDR,
SYSID_PRIOR_STAGE_VERSION,
SYSID_PRIOR_STAGE_DATE,
@@ -222,6 +223,30 @@
int (*get_data)(struct udevice *dev, int id, void **data, size_t *size);
/**
+ * get_item_count() - Get the item count of the specific data area that
+ * describes the hardware setup.
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ *
+ * Return: non-negative item count if OK, -ve on error.
+ */
+ int (*get_item_count)(struct udevice *dev, int id);
+
+ /**
+ * get_data_by_index() - Get a data value by index from the platform.
+ *
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ * @index: The item index, starting from 0.
+ * @data: Pointer to the address of the data area.
+ * @size: Pointer to the size of the data area.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*get_data_by_index)(struct udevice *dev, int id, int index,
+ void **data, size_t *size);
+
+ /**
* get_fit_loadable - Get the name of an image to load from FIT
* This function can be used to provide the image names based on runtime
* detection. A classic use-case would when DTBOs are used to describe
@@ -305,6 +330,32 @@
int sysinfo_get_data(struct udevice *dev, int id, void **data, size_t *size);
/**
+ * sysinfo_get_item_count() - Get the item count of the specific data area that
+ * describes the hardware setup.
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ *
+ * Return: non-negative item count if OK, -EPERM if called before
+ * sysinfo_detect(), else -ve on error.
+ */
+int sysinfo_get_item_count(struct udevice *dev, int id);
+
+/**
+ * sysinfo_get_data_by_index() - Get a data value by index from the platform.
+ *
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ * @index: The item index, starting from 0.
+ * @data: Pointer to the address of the data area.
+ * @size: Pointer to the size of the data area.
+ *
+ * Return: 0 if OK, -EPERM if called before sysinfo_detect(), else -ve on
+ * error.
+ */
+int sysinfo_get_data_by_index(struct udevice *dev, int id, int index,
+ void **data, size_t *size);
+
+/**
* sysinfo_get() - Return the sysinfo device for the sysinfo in question.
* @devp: Pointer to structure to receive the sysinfo device.
*
@@ -365,6 +416,18 @@
return -ENOSYS;
}
+static inline int sysinfo_get_item_count(struct udevice *dev, int id)
+{
+ return -ENOSYS;
+}
+
+static inline int sysinfo_get_data_by_index(struct udevice *dev, int id,
+ int index, void **data,
+ size_t *size)
+{
+ return -ENOSYS;
+}
+
static inline int sysinfo_get(struct udevice **devp)
{
return -ENOSYS;