diff options
Diffstat (limited to 'meta-facebook/meta-yosemite/recipes-yosemite/me-util')
3 files changed, 167 insertions, 0 deletions
diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile new file mode 100644 index 0000000..941ef10 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/Makefile @@ -0,0 +1,10 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +all: me-util + +me-util: me-util.o + $(CC) $(CFLAGS) -pthread -lipmi -lipmb -lbic -lpal -std=c99 -o $@ $^ $(LDFLAGS) + +.PHONY: clean + +clean: + rm -rf *.o me-util diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c new file mode 100644 index 0000000..3a181b2 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/files/me-util.c @@ -0,0 +1,119 @@ +/* + * me-util + * + * 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 <unistd.h> +#include <errno.h> +#include <syslog.h> +#include <stdint.h> +#include <pthread.h> +#include <string.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <facebook/bic.h> +#include <openbmc/ipmi.h> + +#define LOGFILE "/tmp/me-util.log" + +static void +print_usage_help(void) { + printf("Usage: me-util <slot1|slot2|slot3|slot4> <[0..n]data_bytes_to_send>\n"); +} + +int +main(int argc, char **argv) { + uint8_t slot_id; + uint8_t tbuf[256] = {0x00}; + uint8_t rbuf[256] = {0x00}; + uint8_t tlen = 0; + uint8_t rlen = 0; + int i; + int ret; + int logfd; + int len; + char log[128]; + char temp[8]; + + if (argc < 3) { + goto err_exit; + } + + if (!strcmp(argv[1], "slot1")) { + slot_id = 1; + } else if (!strcmp(argv[1] , "slot2")) { + slot_id = 2; + } else if (!strcmp(argv[1] , "slot3")) { + slot_id = 3; + } else if (!strcmp(argv[1] , "slot4")) { + slot_id = 4; + } else { + goto err_exit; + } + + for (i = 2; i < argc; i++) { + tbuf[tlen++] = (uint8_t)strtoul(argv[i], NULL, 0); + } + +#if 1 + ret = bic_me_xmit(slot_id, tbuf, tlen, rbuf, &rlen); + if (ret) { + return ret; + } +#endif + + // memcpy(rbuf, tbuf, tlen); + //rlen = tlen; + + + memset(log, 0, 128); + for (i = 0; i < rlen; i++) { + printf("%02X ", rbuf[i]); + memset(temp, 0, 8); + sprintf(temp, "%02X ", rbuf[i]); + strcat(log, temp); + } + printf("\n"); + sprintf(temp, "\n"); + strcat(log, temp); + + errno = 0; + + logfd = open(LOGFILE, O_CREAT | O_WRONLY); + if (logfd < 0) { + syslog(LOG_WARNING, "Opening a tmp file failed. errno: %d", errno); + return -1; + } + + len = write(logfd, log, strlen(log)); + if (len != strlen(log)) { + syslog(LOG_WARNING, "Error writing the log to the file"); + return -1; + } + + close(logfd); + + return 0; +err_exit: + print_usage_help(); + return -1; +} diff --git a/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb new file mode 100644 index 0000000..02219f2 --- /dev/null +++ b/meta-facebook/meta-yosemite/recipes-yosemite/me-util/me-util_0.1.bb @@ -0,0 +1,38 @@ +# Copyright 2015-present Facebook. All Rights Reserved. +SUMMARY = "Management Engine Utility" +DESCRIPTION = "Util for communicating to Intel ME" +SECTION = "base" +PR = "r1" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://me-util.c;beginline=4;endline=16;md5=b395943ba8a0717a83e62ca123a8d238" + +SRC_URI = "file://me-util.c \ + file://Makefile \ + " + +S = "${WORKDIR}" + +binfiles = "me-util \ + " + +pkgdir = "me-util" + +DEPENDS = " libbic libpal " + +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}/me-util ${prefix}/local/bin" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" |