From 6e0d241913b81d04684b5ad60a4554f9e9178855 Mon Sep 17 00:00:00 2001
From: Jonathon Hall <jonathon.hall@puri.sm>
Date: Mon, 28 Nov 2022 15:06:16 -0500
Subject: [PATCH] ioport: Add ioport module (inb, outb)

Add ioport module, enable for librem_mini_v2.  Only inb and outb are
included, inw/outw/inl/outl aren't needed.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
---
 Makefile                                    |  1 +
 boards/librem_mini_v2/librem_mini_v2.config |  1 +
 modules/ioport                              | 22 +++++++++++++++++++++
 3 files changed, 24 insertions(+)
 create mode 100644 modules/ioport

diff --git a/Makefile b/Makefile
index 33bb8901..e7e078b8 100644
--- a/Makefile
+++ b/Makefile
@@ -499,6 +499,7 @@ bin_modules-$(CONFIG_OPENSSL) += openssl
 bin_modules-$(CONFIG_TPM2_TOOLS) += tpm2-tools
 bin_modules-$(CONFIG_BASH) += bash
 bin_modules-$(CONFIG_POWERPC_UTILS) += powerpc-utils
+bin_modules-$(CONFIG_IOPORT) += ioport
 
 $(foreach m, $(bin_modules-y), \
 	$(call map,initrd_bin_add,$(call bins,$m)) \
diff --git a/boards/librem_mini_v2/librem_mini_v2.config b/boards/librem_mini_v2/librem_mini_v2.config
index d430b058..744b0655 100644
--- a/boards/librem_mini_v2/librem_mini_v2.config
+++ b/boards/librem_mini_v2/librem_mini_v2.config
@@ -11,6 +11,7 @@ CONFIG_CRYPTSETUP2=y
 CONFIG_FLASHROM=y
 CONFIG_FLASHTOOLS=y
 CONFIG_GPG2=y
+CONFIG_IOPORT=y
 CONFIG_KEXEC=y
 CONFIG_UTIL_LINUX=y
 CONFIG_LVM2=y
diff --git a/modules/ioport b/modules/ioport
new file mode 100644
index 00000000..9d59fb70
--- /dev/null
+++ b/modules/ioport
@@ -0,0 +1,22 @@
+modules-$(CONFIG_IOPORT) += ioport
+
+ioport_version := 1.2
+ioport_dir := ioport-$(ioport_version)
+ioport_tar := ioport-$(ioport_version).tar.gz
+ioport_url := https://people.redhat.com/rjones/ioport/files/$(ioport_tar)
+ioport_hash := 7fac1c4b61eb9411275de0e1e7d7a8c3f34166f64f16413f50741e8fce2b8dc0
+
+ioport_configure := CFLAGS=-Os ./configure \
+	$(CROSS_TOOLS) \
+	--prefix "/" \
+	--host i386-elf-linux
+
+ioport_target := \
+	$(MAKE_JOBS) $(CROSS_TOOLS) inb && \
+	$(MAKE) -C "$(build)/$(ioport_dir)" all-local
+
+ioport_output := \
+	inb \
+	outb
+
+ioport_depends := $(musl_dep)