[Skiboot] [PATCH 5/7] external/common: Add x86 code reenable building pflash
Cyril Bur
cyril.bur at au1.ibm.com
Tue Aug 11 17:58:25 AEST 2015
This allows for manipulation of flash image files on an x86 system before
flashing. This may prove useful for development.
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
external/common/arch_flash_x86.c | 52 +++++++++++++++++++++++++++++++++++++
external/common/arch_flash_x86_io.h | 0
external/pflash/rules.mk | 5 ++++
3 files changed, 57 insertions(+)
create mode 100644 external/common/arch_flash_x86.c
create mode 100644 external/common/arch_flash_x86_io.h
diff --git a/external/common/arch_flash_x86.c b/external/common/arch_flash_x86.c
new file mode 100644
index 0000000..29c0229
--- /dev/null
+++ b/external/common/arch_flash_x86.c
@@ -0,0 +1,52 @@
+/* Copyright 2013-2015 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include <libflash/file.h>
+
+#include "arch_flash.h"
+
+int arch_flash_init(struct blocklevel_device **r_bl, const char *file)
+{
+ struct blocklevel_device *new_bl;
+
+ /* Must have passed through a file to operate on */
+ if (!file) {
+ fprintf(stderr, "Cannot operate without a file\n");
+ return -1;
+ }
+
+ file_init_path(file, NULL, &new_bl);
+ if (!new_bl)
+ return -1;
+
+ *r_bl = new_bl;
+ return 0;
+}
+
+void arch_flash_close(struct blocklevel_device *bl, const char *file)
+{
+ file_exit_close(bl);
+}
diff --git a/external/common/arch_flash_x86_io.h b/external/common/arch_flash_x86_io.h
new file mode 100644
index 0000000..e69de29
diff --git a/external/pflash/rules.mk b/external/pflash/rules.mk
index 6671f15..f3af124 100644
--- a/external/pflash/rules.mk
+++ b/external/pflash/rules.mk
@@ -8,9 +8,14 @@ ifeq ($(ARCH),ARCH_POWERPC)
arch = powerpc
ARCH_OBJS = common/arch_flash_common.o common/arch_flash_powerpc.o
else
+ifeq ($(ARCH),ARCH_X86)
+arch = x86
+ARCH_OBJS = common/arch_flash_common.o common/arch_flash_x86.o
+else
$(error Unsupported architecture $(ARCH))
endif
endif
+endif
.DEFAULT_GOAL := all
--
2.5.0
More information about the Skiboot
mailing list