util: add smmstoretool for editing SMMSTORE

Offline SMMSTORE variable modification tool.  Can be used to
pre-configure ROM image or debug EFI state stored in a dump.

Change-Id: I6c1c06f1d0c39c13b5be76a3070f09b715aca6e0
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79080
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
Sergii Dmytruk
2023-11-17 19:31:20 +02:00
committed by Martin L Roth
parent 7a51acfbe9
commit 04bd965143
21 changed files with 1730 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
# SPDX-License-Identifier: GPL-2.0-or-later
PRG := smmstoretool
TOP ?= $(abspath ../..)
ROOT := $(TOP)/src
MDE := $(ROOT)/vendorcode/intel/edk2/UDK2017/MdePkg/Include/
CC ?= $(CROSS_COMPILE)gcc
HOSTCC ?= $(CC)
INSTALL ?= /usr/bin/env install
PREFIX ?= /usr/local
HOSTCFLAGS ?= $(CFLAGS)
HOSTCFLAGS += -Wall -Wextra -MMD -MP -O3
HOSTCFLAGS += -I $(ROOT)/commonlib/bsd/include
HOSTCFLAGS += -I $(ROOT)/vendorcode/intel/edk2/
HOSTCFLAGS += -I $(MDE)
HOSTLDFLAGS ?= $(LDFLAGS)
MACHINE := $(shell uname -m)
ifeq ($(MACHINE),x86_64)
HOSTCFLAGS += -I $(MDE)/X64
else ifeq ($(patsubst i%86,Ia32,$(MACHINE)),Ia32)
HOSTCFLAGS += -I $(MDE)/Ia32
else
$(error Unsupported machine: '$(MACHINE)')
endif
SRC := data.c fv.c guids.c main.c storage.c utils.c vs.c
OBJ := $(SRC:.c=.o)
DEP := $(SRC:.c=.o.d)
.PHONY: all debug clean install
all: $(PRG)
debug: HOSTCFLAGS += -O0 -g
debug: HOSTLDFLAGS += -g
debug: all
install: $(PRG)
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin/
$(INSTALL) $^ $(DESTDIR)$(PREFIX)/bin/
clean:
-$(RM) $(PRG) $(OBJ) $(DEP)
$(PRG): $(OBJ)
$(HOSTCC) -o $@ $^ $(HOSTLDFLAGS)
%.o: %.c
$(HOSTCC) $(HOSTCFLAGS) -c -o $@ -MF $@.d $<
-include $(DEP)