diff options
Diffstat (limited to 'common/recipes-core/fruid')
-rw-r--r-- | common/recipes-core/fruid/files/Makefile | 26 | ||||
-rw-r--r-- | common/recipes-core/fruid/files/fruid-util.c | 145 | ||||
-rw-r--r-- | common/recipes-core/fruid/fruid_0.1.bb | 55 |
3 files changed, 226 insertions, 0 deletions
diff --git a/common/recipes-core/fruid/files/Makefile b/common/recipes-core/fruid/files/Makefile new file mode 100644 index 0000000..5c6aff4 --- /dev/null +++ b/common/recipes-core/fruid/files/Makefile @@ -0,0 +1,26 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +all: fruid-util + +fruid: fruid-util.c + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o fruid-util diff --git a/common/recipes-core/fruid/files/fruid-util.c b/common/recipes-core/fruid/files/fruid-util.c new file mode 100644 index 0000000..3c8d2e1 --- /dev/null +++ b/common/recipes-core/fruid/files/fruid-util.c @@ -0,0 +1,145 @@ +/* + * Copyright 2015-present Facebook. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <openbmc/fruid.h> +#include <openbmc/pal.h> + +/* Print the FRUID in detail */ +void print_fruid_info(fruid_info_t *fruid, const char *name) +{ + /* Print format */ + printf("%-27s: %s", "\nFRU Information", + name /* Name of the FRU device */ ); + printf("%-27s: %s", "\n---------------", "------------------"); + + if (fruid->chassis.flag) { + printf("%-27s: %s", "\nChassis Type",fruid->chassis.type_str); + printf("%-27s: %s", "\nChassis Part",fruid->chassis.part); + printf("%-27s: %s", "\nChassis Serial Number",fruid->chassis.serial); + printf("%-27s: %s", "\nChassis Custom Data",fruid->chassis.custom); + } + + if (fruid->board.flag) { + printf("%-27s: %s", "\nBoard Mfg Time",fruid->board.mfg_time_str); + printf("%-27s: %s", "\nBoard Manufacturer",fruid->board.mfg); + printf("%-27s: %s", "\nBoard Name",fruid->board.name); + printf("%-27s: %s", "\nBoard Serial Number",fruid->board.serial); + printf("%-27s: %s", "\nBoard Part",fruid->board.part); + printf("%-27s: %s", "\nBoard FRU ID",fruid->board.fruid); + printf("%-27s: %s", "\nBoard Custom Data",fruid->board.custom); + } + + if (fruid->product.flag) { + printf("%-27s: %s", "\nProduct Manufacturer",fruid->product.mfg); + printf("%-27s: %s", "\nProduct Name",fruid->product.name); + printf("%-27s: %s", "\nProduct Part",fruid->product.part); + printf("%-27s: %s", "\nProduct Version",fruid->product.version); + printf("%-27s: %s", "\nProduct Serial Number",fruid->product.serial); + printf("%-27s: %s", "\nProduct Asset Tag",fruid->product.asset_tag); + printf("%-27s: %s", "\nProduct FRU ID",fruid->product.fruid); + printf("%-27s: %s", "\nProduct Custom Data",fruid->product.custom); + } + + printf("\n"); +} + +/* Populate and print fruid_info by parsing the fru's binary dump */ +void get_fruid_info(uint8_t fru, char *path, char* name) { + int ret; + fruid_info_t fruid; + + ret = fruid_parse(path, &fruid); + if (ret) { + fprintf(stderr, "Failed print FRUID for %s\nCheck syslog for errors!\n", + name); + } else { + print_fruid_info(&fruid, name); + free_fruid_info(&fruid); + } + +} + +static int +print_usage() { + printf("Usage: fruid-util [ %s ]\n", pal_fru_list); +} + +/* Utility to just print the FRUID */ +int main(int argc, char * argv[]) { + + int ret; + uint8_t fru; + char path[64] = {0}; + char name[64] = {0}; + + if (argc != 2) { + print_usage(); + exit(-1); + } + + ret = pal_get_fru_id(argv[1], &fru); + if (ret < 0) { + print_usage(); + return ret; + } + + if (fru == 0) { + fru = 1; + while (fru <= MAX_NUM_FRUS) { + ret = pal_get_fruid_path(fru, path); + if (ret < 0) { + return ret; + } + + ret = pal_get_fruid_name(fru, name); + if (ret < 0) { + return ret; + } + + if (fru == FRU_NIC) { + printf("fruid-util does not support nic\n"); + exit(-1); + } + + get_fruid_info(fru, path, name); + + fru++; + } + } else { + ret = pal_get_fruid_path(fru, path); + if (ret < 0) { + return ret; + } + + ret = pal_get_fruid_name(fru, name); + if (ret < 0) { + return ret; + } + + if (fru == FRU_NIC) { + printf("fruid-util does not support nic\n"); + exit(-1); + } + + get_fruid_info(fru, path, name); + } + + return 0; +} diff --git a/common/recipes-core/fruid/fruid_0.1.bb b/common/recipes-core/fruid/fruid_0.1.bb new file mode 100644 index 0000000..604845f --- /dev/null +++ b/common/recipes-core/fruid/fruid_0.1.bb @@ -0,0 +1,55 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA + +SUMMARY = "IPMI FRUID Utilities" +DESCRIPTION = "Util for ipmi fruid" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://fruid-util.c;beginline=4;endline=16;md5=da35978751a9d71b73679307c4d296ec" + +LDFLAGS = " -lfruid -lpal " +DEPENDS = "libfruid libpal " + +SRC_URI = "file://Makefile \ + file://fruid-util.c \ + " + +S = "${WORKDIR}" + +binfiles = "fruid-util \ + " + +pkgdir = "fruid" + +do_install() { + dst="${D}/usr/local/fbpackages/${pkgdir}" + bin="${D}/usr/local/bin" + install -d $dst + install -d $bin + for f in ${binfiles}; do + install -m 755 $f ${dst}/$f + ln -snf ../fbpackages/${pkgdir}/$f ${bin}/$f + done +} + +FBPACKAGEDIR = "${prefix}/local/fbpackages" + +FILES_${PN} = "${FBPACKAGEDIR}/fruid ${prefix}/local/bin" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" |