[PATCH 4/9] Display VERSION partition info on BMC machines

Cyril Bur cyril.bur at au1.ibm.com
Tue Dec 15 17:51:28 AEDT 2015


On Tue, 15 Dec 2015 14:15:25 +1100
Samuel Mendoza-Jonas <sam.mj at au1.ibm.com> wrote:

> On supported platforms read the VERSION partition on startup and display
> the available versions strings in the System Information screen.
> 
> This adds a skeleton hostboot.c to support possible additional BMC
> platform support.
> 

Reviewed-by: Cyril Bur <cyril.bur at au1.ibm.com>
> Signed-off-by: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
> ---
>  discover/Makefile.am          | 14 ++++++++++++++
>  discover/hostboot.c           | 14 ++++++++++++++
>  discover/hostboot.h           | 16 ++++++++++++++++
>  discover/platform-powerpc.c   | 10 ++++++++++
>  lib/pb-protocol/pb-protocol.c | 23 +++++++++++++++++++++++
>  lib/types/types.h             |  2 ++
>  ui/ncurses/nc-sysinfo.c       |  7 +++++++
>  7 files changed, 86 insertions(+)
>  create mode 100644 discover/hostboot.c
>  create mode 100644 discover/hostboot.h
> 
> diff --git a/discover/Makefile.am b/discover/Makefile.am
> index 1672035..f55f1cd 100644
> --- a/discover/Makefile.am
> +++ b/discover/Makefile.am
> @@ -79,7 +79,21 @@ discover_platform_ro_SOURCES = \
>  	discover/ipmi.h \
>  	discover/dt.c \
>  	discover/dt.h \
> +	discover/hostboot.h \
>  	discover/platform-powerpc.c
>  
> +discover_platform_ro_CPPFLAGS = \
> +	$(AM_CPPFLAGS)
> +
> +if ENABLE_MTD
> +discover_platform_ro_SOURCES += \
> +	discover/hostboot.c
> +
> +discover_platform_ro_LDFLAGS = \
> +	$(core_lib) \
> +	$(UDEV_LIBS)
> +
> +endif
> +
>  discover_platform_ro_LINK = \
>  	$(LD) -r -o $@
> diff --git a/discover/hostboot.c b/discover/hostboot.c
> new file mode 100644
> index 0000000..8ea5ef3
> --- /dev/null
> +++ b/discover/hostboot.c
> @@ -0,0 +1,14 @@
> +#include <string.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +
> +#include <log/log.h>
> +#include <talloc/talloc.h>
> +#include <flash/flash.h>
> +
> +#include "hostboot.h"
> +
> +int hostboot_load_versions(struct system_info *info)
> +{
> +	return flash_read_version(info, &info->platform_versions);
> +}
> diff --git a/discover/hostboot.h b/discover/hostboot.h
> new file mode 100644
> index 0000000..9ef5f7a
> --- /dev/null
> +++ b/discover/hostboot.h
> @@ -0,0 +1,16 @@
> +#ifndef HOSTBOOT_H
> +#define HOSTBOOT_H
> +
> +#include "config.h"
> +#include <types/types.h>
> +
> +#if MTD_SUPPORT
> +int hostboot_load_versions(struct system_info *info);
> +#else
> +static inline int hostboot_load_versions(struct system_info *info)
> +{
> +	(void)info;
> +	return -1;
> +}
> +#endif
> +#endif /* HOSTBOOT_H */
> diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
> index 23e63c1..a36f451 100644
> --- a/discover/platform-powerpc.c
> +++ b/discover/platform-powerpc.c
> @@ -14,7 +14,9 @@
>  #include <list/list.h>
>  #include <log/log.h>
>  #include <process/process.h>
> +#include <types/types.h>
>  
> +#include "hostboot.h"
>  #include "platform.h"
>  #include "ipmi.h"
>  #include "dt.h"
> @@ -43,6 +45,7 @@ struct platform_powerpc {
>  				bool persistent);
>  	int 		(*set_os_boot_sensor)(
>  				struct platform_powerpc *platform);
> +	int		(*get_platform_versions)(struct system_info *info);
>  };
>  
>  static const char *known_params[] = {
> @@ -1057,6 +1060,9 @@ static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
>  		sysinfo->identifier = talloc_steal(sysinfo, buf);
>  	talloc_free(filename);
>  
> +	if (platform->get_platform_versions)
> +		sysinfo->n_versions = platform->get_platform_versions(sysinfo);
> +
>  	return 0;
>  }
>  
> @@ -1095,6 +1101,10 @@ static bool probe(struct platform *p, void *ctx)
>  		pb_log("platform: no IPMI parameter support\n");
>  	}
>  
> +	rc = stat("/proc/device-tree/bmc", &statbuf);
> +	if (!rc)
> +		platform->get_platform_versions = hostboot_load_versions;
> +
>  	return true;
>  }
>  
> diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
> index 7d45f51..336a2ef 100644
> --- a/lib/pb-protocol/pb-protocol.c
> +++ b/lib/pb-protocol/pb-protocol.c
> @@ -225,6 +225,10 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo)
>  		4 + optional_strlen(sysinfo->identifier) +
>  		4 + 4;
>  
> +	len +=	4;
> +	for (i = 0; i < sysinfo->n_versions; i++)
> +		len += 4 + optional_strlen(sysinfo->platform_versions[i]);
> +
>  	for (i = 0; i < sysinfo->n_interfaces; i++) {
>  		struct interface_info *if_info = sysinfo->interfaces[i];
>  		len +=	4 + if_info->hwaddr_size +
> @@ -391,6 +395,12 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo,
>  	pos += pb_protocol_serialise_string(pos, sysinfo->type);
>  	pos += pb_protocol_serialise_string(pos, sysinfo->identifier);
>  
> +	*(uint32_t *)pos = __cpu_to_be32(sysinfo->n_versions);
> +	pos += sizeof(uint32_t);
> +
> +	for (i = 0; i < sysinfo->n_versions; i++)
> +		pos += pb_protocol_serialise_string(pos, sysinfo->platform_versions[i]);
> +
>  	*(uint32_t *)pos = __cpu_to_be32(sysinfo->n_interfaces);
>  	pos += sizeof(uint32_t);
>  
> @@ -786,6 +796,7 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo,
>  	unsigned int len, i;
>  	const char *pos;
>  	int rc = -1;
> +	char *tmp;
>  
>  	len = message->payload_len;
>  	pos = message->payload;
> @@ -797,6 +808,18 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo,
>  	if (read_string(sysinfo, &pos, &len, &sysinfo->identifier))
>  		goto out;
>  
> +	/* versions strings for openpower platforms */
> +	if (read_u32(&pos, &len, &sysinfo->n_versions))
> +		goto out;
> +
> +	sysinfo->platform_versions = talloc_array(sysinfo, char *,
> +						sysinfo->n_versions);
> +	for (i = 0; i < sysinfo->n_versions; i++) {
> +		if (read_string(sysinfo, &pos, &len, &tmp))
> +			goto out;
> +		sysinfo->platform_versions[i] = talloc_strdup(sysinfo, tmp);
> +	}
> +
>  	/* number of interfaces */
>  	if (read_u32(&pos, &len, &sysinfo->n_interfaces))
>  		goto out;
> diff --git a/lib/types/types.h b/lib/types/types.h
> index 6a2c258..6927a1c 100644
> --- a/lib/types/types.h
> +++ b/lib/types/types.h
> @@ -93,6 +93,8 @@ struct blockdev_info {
>  struct system_info {
>  	char			*type;
>  	char			*identifier;
> +	char			**platform_versions;
> +	unsigned int		n_versions;
>  	struct interface_info	**interfaces;
>  	unsigned int		n_interfaces;
>  	struct blockdev_info	**blockdevs;
> diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c
> index ac8ece7..9666921 100644
> --- a/ui/ncurses/nc-sysinfo.c
> +++ b/ui/ncurses/nc-sysinfo.c
> @@ -64,6 +64,13 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
>  	line("%-12s %s", _("System type:"), sysinfo->type ?: "");
>  	line("%-12s %s", _("System id:"),   sysinfo->identifier ?: "");
>  
> +	line(NULL);
> +	line("%s", _("Platform versions:"));
> +	for (i = 0; i < sysinfo->n_versions; i++) {
> +		line("%s", sysinfo->platform_versions[i] ?: "");
> +	}
> +
> +
>  	if (sysinfo->n_blockdevs) {
>  		line(NULL);
>  		line(_("Storage devices"));



More information about the Petitboot mailing list