1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 14:42:36 +02:00

Various cross-platform fixes

Improve compilation with libpayload (compiling flashrom.c and
linking is still broken):
 - disable Ponyprog (which enforced serial.c compilation)
 - make errno available where it is needed

Fix internal.c for non-x86 and enable cb parsing on ARM.

Fix mingw builds by using its __USE_MINGW_ANSI_STDIO macro
and gnu_printf definition for printf format style checking.
See http://sourceforge.net/apps/trac/mingw-w64/wiki/gnu%20printf
This requires inclusion of stdio.h in flash.h.

Fix order of libraries in the Makefile:
FEATURE_LIBS needs to come *after* PCILIBS in case ZLIB is needed by it.

Corresponding to flashrom svn r1697.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
Carl-Daniel Hailfinger 2013-07-13 23:21:05 +00:00 committed by Stefan Tauner
parent 6bf5fe78f1
commit 11990da1d3
6 changed files with 36 additions and 18 deletions

View File

@ -140,6 +140,9 @@ ifeq ($(TARGET_OS), MinGW)
EXEC_SUFFIX := .exe EXEC_SUFFIX := .exe
# MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs(). # MinGW doesn't have the ffs() function, but we can use gcc's __builtin_ffs().
FLASHROM_CFLAGS += -Dffs=__builtin_ffs FLASHROM_CFLAGS += -Dffs=__builtin_ffs
# Some functions provided by Microsoft do not work as described in C99 specifications. This macro fixes that
# for MinGW. See http://sourceforge.net/apps/trac/mingw-w64/wiki/printf%20and%20scanf%20family */
FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
# libusb-win32/libftdi stuff is usually installed in /usr/local. # libusb-win32/libftdi stuff is usually installed in /usr/local.
CPPFLAGS += -I/usr/local/include CPPFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib LDFLAGS += -L/usr/local/lib
@ -218,6 +221,7 @@ UNSUPPORTED_FEATURES += CONFIG_DUMMY=yes
else else
override CONFIG_DUMMY = no override CONFIG_DUMMY = no
endif endif
# Bus Pirate, Serprog and PonyProg are not supported with libpayload (missing serial support).
ifeq ($(CONFIG_BUSPIRATE_SPI), yes) ifeq ($(CONFIG_BUSPIRATE_SPI), yes)
UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes UNSUPPORTED_FEATURES += CONFIG_BUSPIRATE_SPI=yes
else else
@ -228,6 +232,11 @@ UNSUPPORTED_FEATURES += CONFIG_SERPROG=yes
else else
override CONFIG_SERPROG = no override CONFIG_SERPROG = no
endif endif
ifeq ($(CONFIG_PONY_SPI), yes)
UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
else
override CONFIG_PONY_SPI = no
endif
# Dediprog and FT2232 are not supported with libpayload (missing libusb support) # Dediprog and FT2232 are not supported with libpayload (missing libusb support)
ifeq ($(CONFIG_DEDIPROG), yes) ifeq ($(CONFIG_DEDIPROG), yes)
UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
@ -632,7 +641,7 @@ ifeq ($(ARCH), x86)
endif endif
$(PROGRAM)$(EXEC_SUFFIX): $(OBJS) $(PROGRAM)$(EXEC_SUFFIX): $(OBJS)
$(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(FEATURE_LIBS) $(LIBS) $(PCILIBS) $(USBLIBS) $(CC) $(LDFLAGS) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJS) $(LIBS) $(PCILIBS) $(FEATURE_LIBS) $(USBLIBS)
libflashrom.a: $(LIBFLASHROM_OBJS) libflashrom.a: $(LIBFLASHROM_OBJS)
$(AR) rcs $@ $^ $(AR) rcs $@ $^

View File

@ -25,6 +25,7 @@
#define __FLASH_H__ 1 #define __FLASH_H__ 1
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
@ -286,7 +287,12 @@ enum msglevel {
MSG_SPEW = 5, MSG_SPEW = 5,
}; };
/* Let gcc and clang check for correct printf-style format strings. */ /* Let gcc and clang check for correct printf-style format strings. */
int print(enum msglevel level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); int print(enum msglevel level, const char *fmt, ...)
#ifdef __MINGW32__
__attribute__((format(gnu_printf, 2, 3)));
#else
__attribute__((format(printf, 2, 3)));
#endif
#define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */ #define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */
#define msg_perr(...) print(MSG_ERROR, __VA_ARGS__) /* programmer errors */ #define msg_perr(...) print(MSG_ERROR, __VA_ARGS__) /* programmer errors */
#define msg_cerr(...) print(MSG_ERROR, __VA_ARGS__) /* chip errors */ #define msg_cerr(...) print(MSG_ERROR, __VA_ARGS__) /* chip errors */

View File

@ -1168,7 +1168,7 @@ int read_buf_from_file(unsigned char *buf, unsigned long size,
return 1; return 1;
} }
if (image_stat.st_size != size) { if (image_stat.st_size != size) {
msg_gerr("Error: Image size (%jd B) doesn't match the flash chip's size (%ld B)!\n", msg_gerr("Error: Image size (%jd B) doesn't match the flash chip's size (%lu B)!\n",
(intmax_t)image_stat.st_size, size); (intmax_t)image_stat.st_size, size);
fclose(image); fclose(image);
return 1; return 1;

View File

@ -35,14 +35,13 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#if !defined (__DJGPP__) && !defined(__LIBPAYLOAD__) #if !defined (__DJGPP__) && !defined(__LIBPAYLOAD__)
/* No file access needed/possible to get hardware access permissions. */
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#if !defined (__DJGPP__)
#include <errno.h>
#endif
#include "flash.h" #include "flash.h"
#include "hwaccess.h" #include "hwaccess.h"

View File

@ -172,8 +172,10 @@ int internal_init(void)
int not_a_laptop = 0; int not_a_laptop = 0;
const char *board_vendor = NULL; const char *board_vendor = NULL;
const char *board_model = NULL; const char *board_model = NULL;
#if defined (__i386__) || defined (__x86_64__) || defined (__arm__)
const char *cb_vendor = NULL; const char *cb_vendor = NULL;
const char *cb_model = NULL; const char *cb_model = NULL;
#endif
char *arg; char *arg;
arg = extract_programmer_param("boardenable"); arg = extract_programmer_param("boardenable");
@ -254,7 +256,7 @@ int internal_init(void)
return 1; return 1;
} }
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__) || defined (__arm__)
if ((cb_parse_table(&cb_vendor, &cb_model) == 0) && (board_vendor != NULL) && (board_model != NULL)) { if ((cb_parse_table(&cb_vendor, &cb_model) == 0) && (board_vendor != NULL) && (board_model != NULL)) {
if (strcasecmp(board_vendor, cb_vendor) || strcasecmp(board_model, cb_model)) { if (strcasecmp(board_vendor, cb_vendor) || strcasecmp(board_model, cb_model)) {
msg_pwarn("Warning: The mainboard IDs set by -p internal:mainboard (%s:%s) do not\n" msg_pwarn("Warning: The mainboard IDs set by -p internal:mainboard (%s:%s) do not\n"
@ -265,7 +267,9 @@ int internal_init(void)
msg_pinfo("Continuing anyway.\n"); msg_pinfo("Continuing anyway.\n");
} }
} }
#endif
#if defined(__i386__) || defined(__x86_64__)
dmi_init(); dmi_init();
/* In case Super I/O probing would cause pretty explosions. */ /* In case Super I/O probing would cause pretty explosions. */

View File

@ -24,14 +24,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include "flash.h" #include "flash.h"
#include "hwaccess.h" #include "hwaccess.h"
/* Do we need any file access or ioctl for physmap or MSR? */
#if !defined(__DJGPP__) && !defined(__LIBPAYLOAD__) #if !defined(__DJGPP__) && !defined(__LIBPAYLOAD__)
/* No file access needed/possible to get mmap access permissions or access MSR. */
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#endif #endif
#ifdef __DJGPP__ #ifdef __DJGPP__
@ -120,15 +120,6 @@ void *sys_physmap(unsigned long phys_addr, size_t len)
void physunmap(void *virt_addr, size_t len) void physunmap(void *virt_addr, size_t len)
{ {
} }
int setup_cpu_msr(int cpu)
{
return 0;
}
void cleanup_cpu_msr(void)
{
}
#elif defined(__MACH__) && defined(__APPLE__) #elif defined(__MACH__) && defined(__APPLE__)
#define MEM_DEV "DirectHW" #define MEM_DEV "DirectHW"
@ -569,6 +560,15 @@ int libpayload_wrmsr(int addr, msr_t msr)
_wrmsr(addr, msr.lo | ((unsigned long long)msr.hi << 32)); _wrmsr(addr, msr.lo | ((unsigned long long)msr.hi << 32));
return 0; return 0;
} }
int setup_cpu_msr(int cpu)
{
return 0;
}
void cleanup_cpu_msr(void)
{
}
#else #else
/* default MSR implementation */ /* default MSR implementation */
msr_t rdmsr(int addr) msr_t rdmsr(int addr)