Stefan Reinauer has uploaded this change for review.

View Change

Add AmigaOS suppport to flashrom

Change-Id: I3e4a3885f88313aad019454fdbdf4be176b35330
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
---
M Makefile
M cli_classic.c
M flash.h
M helpers.c
M os.h
M platform.h
M udelay.c
7 files changed, 109 insertions(+), 4 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/43/54943/1
diff --git a/Makefile b/Makefile
index b8b40ca..c486c12 100644
--- a/Makefile
+++ b/Makefile
@@ -135,6 +135,89 @@
override LDFLAGS += -L/usr/local/lib
endif

+ifeq ($(TARGET_OS), AmigaOS)
+override CPPFLAGS += -m68000 -mcrt=clib2
+override LIBS += -mcrt=clib2 -lamiga -lm -lunix
+# Bus Pirate, Serprog and PonyProg are not supported under AmigaOS (missing serial support).
+ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
+else
+override CONFIG_BUSPIRATE_SPI = no
+endif
+ifeq ($(CONFIG_SERPROG), yes)
+UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
+else
+override CONFIG_SERPROG = no
+endif
+ifeq ($(CONFIG_PONY_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
+else
+override CONFIG_PONY_SPI = no
+endif
+# Digilent SPI, Dediprog, Developerbox, USB-Blaster, PICkit2, CH341A and FT2232 are not supported under AmigaOS (missing USB support).
+ifeq ($(CONFIG_DIGILENT_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_DIGILENT_SPI=yes
+else
+override CONFIG_DIGILENT_SPI = no
+endif
+ifeq ($(CONFIG_DEDIPROG), yes)
+UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
+else
+override CONFIG_DEDIPROG = no
+endif
+ifeq ($(CONFIG_DEVELOPERBOX_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_DEVELOPERBOX_SPI=yes
+else
+override CONFIG_DEVELOPERBOX_SPI = no
+endif
+ifeq ($(CONFIG_ENE_LPC), yes)
+UNSUPPORTED_FEATURES += CONFIG_ENE_LPC=yes
+else
+override CONFIG_ENE_LPC = no
+endif
+ifeq ($(CONFIG_FT2232_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_FT2232_SPI=yes
+else
+override CONFIG_FT2232_SPI = no
+endif
+ifeq ($(CONFIG_MEC1308), yes)
+UNSUPPORTED_FEATURES += CONFIG_MEC1308=yes
+else
+override CONFIG_MEC1308 = no
+endif
+ifeq ($(CONFIG_USBBLASTER_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_USBBLASTER_SPI=yes
+else
+override CONFIG_USBBLASTER_SPI = no
+endif
+ifeq ($(CONFIG_PICKIT2_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
+else
+override CONFIG_PICKIT2_SPI = no
+endif
+ifeq ($(CONFIG_CH341A_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
+else
+override CONFIG_CH341A_SPI = no
+endif
+ifeq ($(CONFIG_RAIDEN_DEBUG_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_RAIDEN_DEBUG_SPI=yes
+else
+override CONFIG_RAIDEN_DEBUG_SPI = no
+endif
+ifeq ($(CONFIG_STLINKV3_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_STLINKV3_SPI=yes
+else
+override CONFIG_STLINKV3_SPI = no
+endif
+# libjaylink is also not available for DOS
+ifeq ($(CONFIG_JLINK_SPI), yes)
+UNSUPPORTED_FEATURES += CONFIG_JLINK_SPI=yes
+else
+override CONFIG_JLINK_SPI = no
+endif
+endif
+
ifeq ($(TARGET_OS), DOS)
EXEC_SUFFIX := .exe
# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
diff --git a/cli_classic.c b/cli_classic.c
index 5fd8092..31fac36 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -154,6 +154,11 @@
return 0;
}

+#if IS_AMIGA
+#define ARGV_TYPE (const char **)
+#else
+#define ARGV_TYPE
+#endif
int main(int argc, char *argv[])
{
const struct flashchip *chip = NULL;
@@ -260,7 +265,7 @@
/* FIXME: Delay all operation_specified checks until after command
* line parsing to allow --help overriding everything else.
*/
- while ((opt = getopt_long(argc, argv, optstring,
+ while ((opt = getopt_long(argc, ARGV_TYPE argv, optstring,
long_options, &option_index)) != EOF) {
switch (opt) {
case 'r':
diff --git a/flash.h b/flash.h
index dd8e156..c2fef2c 100644
--- a/flash.h
+++ b/flash.h
@@ -52,6 +52,11 @@
/* TODO: check using code for correct usage of types */
typedef uintptr_t chipaddr;
#define PRIxPTR_WIDTH ((int)(sizeof(uintptr_t)*2))
+/* Standard Amiga toolchain defines PRIxPTR wrong. */
+#ifdef __AMIGA__
+#undef PRIxPTR
+#define PRIxPTR "x"
+#endif

int register_shutdown(int (*function) (void *data), void *data);
void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len);
@@ -326,7 +331,7 @@
void tolower_string(char *str);
uint8_t reverse_byte(uint8_t x);
void reverse_bytes(uint8_t *dst, const uint8_t *src, size_t length);
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || IS_AMIGA
char* strtok_r(char *str, const char *delim, char **nextp);
char *strndup(const char *str, size_t size);
#endif
diff --git a/helpers.c b/helpers.c
index 289848d..56d881c 100644
--- a/helpers.c
+++ b/helpers.c
@@ -84,7 +84,7 @@
}

/* FIXME: Find a better solution for MinGW. Maybe wrap strtok_s (C11) if it becomes available */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || IS_AMIGA
char* strtok_r(char *str, const char *delim, char **nextp)
{
if (str == NULL)
diff --git a/os.h b/os.h
index ddfa46b..ba45da0 100644
--- a/os.h
+++ b/os.h
@@ -55,6 +55,9 @@
// GNU Hurd
#elif defined(__gnu_hurd__)
#define __FLASHROM_OS__ "Hurd"
+// AmigaOS
+#elif defined(__AMIGA__)
+#define __FLASHROM_OS__ "AmigaOS"
// Linux
#elif defined(__linux__)
// There are various flags in use on Android apparently. __ANDROID__ seems to be the most trustworthy.
diff --git a/platform.h b/platform.h
index 751957c..5d74f9a 100644
--- a/platform.h
+++ b/platform.h
@@ -36,6 +36,11 @@
#else
#define IS_WINDOWS 0
#endif
+#if defined(__AMIGA__)
+#define IS_AMIGA 1
+#else
+#define IS_AMIGA 0
+#endif

// Likewise for target architectures
#if defined (__i386__) || defined (__x86_64__) || defined(__amd64__)
@@ -122,6 +127,10 @@
#define __FLASHROM_LITTLE_ENDIAN__ 1
#endif

+#elif IS_M68K
+
+#define __FLASHROM_BIG_ENDIAN__ 1
+
#elif IS_SPARC
/* SPARC is big endian in general (but allows to access data in little endian too). */
#define __FLASHROM_BIG_ENDIAN__ 1
diff --git a/udelay.c b/udelay.c
index 6c0efc4..b4f700d 100644
--- a/udelay.c
+++ b/udelay.c
@@ -226,7 +226,7 @@
{
#if IS_WINDOWS
Sleep((usecs + 999) / 1000);
-#elif defined(__DJGPP__)
+#elif defined(__DJGPP__) || IS_AMIGA
sleep(usecs / 1000000);
usleep(usecs % 1000000);
#else

To view, visit change 54943. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I3e4a3885f88313aad019454fdbdf4be176b35330
Gerrit-Change-Number: 54943
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Reinauer <stefan.reinauer@coreboot.org>
Gerrit-MessageType: newchange