Skip to content

Commit

Permalink
linux/: only try the libsmbios stuff on x86
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Jones <[email protected]>
  • Loading branch information
vathpela committed Aug 19, 2016
1 parent 82a104c commit 764b204
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
5 changes: 4 additions & 1 deletion fwupdate.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ BuildRequires: efivar-devel >= %{efivar_version}
BuildRequires: gnu-efi gnu-efi-devel
BuildRequires: pesign
BuildRequires: elfutils popt-devel git gettext pkgconfig
BuildRequires: systemd libsmbios-devel
BuildRequires: systemd
%ifarch x86_64 %{ix86}
BuildRequires: libsmbios-devel
%endif
ExclusiveArch: x86_64 %{ix86} aarch64
Source0: https://github.com/rhinstaller/fwupdate/releases/download/%{name}-%{version}/%{name}-%{version}.tar.bz2

Expand Down
13 changes: 12 additions & 1 deletion linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ include $(TOPDIR)/Make.defaults

LIB_LIBS= pthread
BIN_LIBS= popt pthread
PKLIBS = efivar efiboot libsmbios_c
PKLIBS = efivar efiboot
HAVE_LIBSMBIOS=no
ifeq ($(ARCH),x86_64)
HAVE_LIBSMBIOS=yes
endif
ifeq ($(ARCH),ia32)
HAVE_LIBSMBIOS=yes
endif
CFLAGS ?= -g -O0
PJONES =
BIN_CCLDFLAGS = $(foreach lib,$(BIN_LIBS),-l$(lib)) \
Expand All @@ -18,6 +25,10 @@ LIB_CCLDFLAGS = $(foreach lib,$(LIB_LIBS),-l$(lib)) \
$(shell pkg-config --libs-only-l --libs-only-other $(pklib))) \
$(LDFLAGS) -shared -fPIC -Wl,-z,relro,-z,now

ifeq ($(HAVE_LIBSMBIOS),yes)
PKLIBS += libsmbios_c
CFLAGS += -DFWUPDATE_HAVE_LIBSMBIOS__
endif
BUILDFLAGS := $(CFLAGS) -Wall -Wextra -Werror -Wno-error=cpp \
-Wno-unused-result -Wno-unused-function \
-Wsign-compare -Werror=sign-compare \
Expand Down
12 changes: 12 additions & 0 deletions linux/libfwup.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@
static int verbose;
#include "error.h"

#ifdef FWUPDATE_HAVE_LIBSMBIOS__
#include </usr/include/smbios_c/token.h>

#define DELL_CAPSULE_FIRMWARE_UPDATES_ENABLED 0x0461
#define DELL_CAPSULE_FIRMWARE_UPDATES_DISABLED 0x0462
#endif

static char *arch_names_32[] = {
#if defined(__x86_64__) || defined(__i386__) || defined(__i686__)
Expand Down Expand Up @@ -98,6 +101,7 @@ efidp_end_entire(efidp_header *dp)
int
fwup_esrt_disabled(void)
{
#ifdef FWUPDATE_HAVE_LIBSMBIOS__
if (!token_is_bool(DELL_CAPSULE_FIRMWARE_UPDATES_DISABLED))
return -1;
if (!token_is_active(DELL_CAPSULE_FIRMWARE_UPDATES_DISABLED))
Expand All @@ -107,6 +111,9 @@ fwup_esrt_disabled(void)
return -2;
}
return 2;
#else
return -1;
#endif
}

/*
Expand All @@ -122,6 +129,7 @@ fwup_esrt_disabled(void)
int
fwup_enable_esrt(void)
{
#ifdef FWUPDATE_HAVE_LIBSMBIOS__
int rc;
rc = fwup_supported();
/* can't enable or already enabled */
Expand All @@ -148,6 +156,10 @@ fwup_enable_esrt(void)
return -3;
}
return 2;
#else
errno = ENOSYS;
return -1;
#endif
}

/*
Expand Down

0 comments on commit 764b204

Please sign in to comment.