mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
hwaccess: replace flashrom specific macros by compiler defines
Replace the remaining IS_* macros with the associated compiler defines Change-Id: Ia0f022d12390722816066d292e1878824adc613c Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/58280 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
1379e54f51
commit
f42d2f72cc
@ -15,8 +15,6 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -31,8 +31,6 @@
|
|||||||
* should be turned on).
|
* should be turned on).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
|
1
dmi.c
1
dmi.c
@ -30,7 +30,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
|
|
||||||
|
2
flash.h
2
flash.h
@ -20,8 +20,6 @@
|
|||||||
#ifndef __FLASH_H__
|
#ifndef __FLASH_H__
|
||||||
#define __FLASH_H__ 1
|
#define __FLASH_H__ 1
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
29
hwaccess.c
29
hwaccess.c
@ -14,8 +14,6 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -34,7 +32,7 @@
|
|||||||
#include <sys/io.h>
|
#include <sys/io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IS_X86 && USE_DEV_IO
|
#if (defined (__i386__) || defined (__x86_64__) || defined(__amd64__)) && USE_DEV_IO
|
||||||
int io_fd;
|
int io_fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -50,9 +48,12 @@ static inline void sync_primitive(void)
|
|||||||
*
|
*
|
||||||
* See also https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/memory-barriers.txt
|
* See also https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/memory-barriers.txt
|
||||||
*/
|
*/
|
||||||
#if IS_PPC // cf. http://lxr.free-electrons.com/source/arch/powerpc/include/asm/barrier.h
|
// cf. http://lxr.free-electrons.com/source/arch/powerpc/include/asm/barrier.h
|
||||||
|
#if defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \
|
||||||
|
defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \
|
||||||
|
defined(_ARCH_PPC64) || defined(__ppc)
|
||||||
asm("eieio" : : : "memory");
|
asm("eieio" : : : "memory");
|
||||||
#elif IS_SPARC
|
#elif (__sparc__) || defined (__sparc)
|
||||||
#if defined(__sparc_v9__) || defined(__sparcv9)
|
#if defined(__sparc_v9__) || defined(__sparcv9)
|
||||||
/* Sparc V9 CPUs support three different memory orderings that range from x86-like TSO to PowerPC-like
|
/* Sparc V9 CPUs support three different memory orderings that range from x86-like TSO to PowerPC-like
|
||||||
* RMO. The modes can be switched at runtime thus to make sure we maintain the right order of access we
|
* RMO. The modes can be switched at runtime thus to make sure we maintain the right order of access we
|
||||||
@ -69,7 +70,7 @@ static inline void sync_primitive(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_X86 && !(defined(__DJGPP__) || defined(__LIBPAYLOAD__))
|
#if (defined (__i386__) || defined (__x86_64__) || defined(__amd64__)) && !(defined(__DJGPP__) || defined(__LIBPAYLOAD__))
|
||||||
static int release_io_perms(void *p)
|
static int release_io_perms(void *p)
|
||||||
{
|
{
|
||||||
#if defined (__sun)
|
#if defined (__sun)
|
||||||
@ -83,12 +84,10 @@ static int release_io_perms(void *p)
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get I/O permissions with automatic permission release on shutdown. */
|
/* Get I/O permissions with automatic permission release on shutdown. */
|
||||||
int rget_io_perms(void)
|
int rget_io_perms(void)
|
||||||
{
|
{
|
||||||
#if IS_X86 && !(defined(__DJGPP__) || defined(__LIBPAYLOAD__))
|
|
||||||
#if defined (__sun)
|
#if defined (__sun)
|
||||||
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
|
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
|
||||||
#elif USE_DEV_IO
|
#elif USE_DEV_IO
|
||||||
@ -111,13 +110,19 @@ int rget_io_perms(void)
|
|||||||
} else {
|
} else {
|
||||||
register_shutdown(release_io_perms, NULL);
|
register_shutdown(release_io_perms, NULL);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/* DJGPP and libpayload environments have full PCI port I/O permissions by default. */
|
|
||||||
/* PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM. */
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* DJGPP and libpayload environments have full PCI port I/O permissions by default. */
|
||||||
|
/* PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM. */
|
||||||
|
int rget_io_perms(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void mmio_writeb(uint8_t val, void *addr)
|
void mmio_writeb(uint8_t val, void *addr)
|
||||||
{
|
{
|
||||||
*(volatile uint8_t *) addr = val;
|
*(volatile uint8_t *) addr = val;
|
||||||
|
31
hwaccess.h
31
hwaccess.h
@ -20,8 +20,6 @@
|
|||||||
#ifndef __HWACCESS_H__
|
#ifndef __HWACCESS_H__
|
||||||
#define __HWACCESS_H__ 1
|
#define __HWACCESS_H__ 1
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#if NEED_PCI == 1
|
#if NEED_PCI == 1
|
||||||
/*
|
/*
|
||||||
* libpci headers use the variable name "index" which triggers shadowing
|
* libpci headers use the variable name "index" which triggers shadowing
|
||||||
@ -109,8 +107,7 @@ cpu_to_be(64)
|
|||||||
#define le_to_cpu32 cpu_to_le32
|
#define le_to_cpu32 cpu_to_le32
|
||||||
#define le_to_cpu64 cpu_to_le64
|
#define le_to_cpu64 cpu_to_le64
|
||||||
|
|
||||||
#if NEED_RAW_ACCESS == 1
|
#if NEED_RAW_ACCESS == 1 && (defined (__i386__) || defined (__x86_64__) || defined(__amd64__))
|
||||||
#if IS_X86
|
|
||||||
|
|
||||||
#include "hwaccess_x86_io.h"
|
#include "hwaccess_x86_io.h"
|
||||||
|
|
||||||
@ -140,31 +137,7 @@ int libpayload_wrmsr(int addr, msr_t msr);
|
|||||||
#define wrmsr libpayload_wrmsr
|
#define wrmsr libpayload_wrmsr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif IS_PPC
|
|
||||||
|
|
||||||
/* PCI port I/O is not yet implemented on PowerPC. */
|
#endif
|
||||||
|
|
||||||
#elif IS_MIPS
|
|
||||||
|
|
||||||
/* PCI port I/O is not yet implemented on MIPS. */
|
|
||||||
|
|
||||||
#elif IS_SPARC
|
|
||||||
|
|
||||||
/* PCI port I/O is not yet implemented on SPARC. */
|
|
||||||
|
|
||||||
#elif IS_ARM
|
|
||||||
|
|
||||||
/* Non memory mapped I/O is not supported on ARM. */
|
|
||||||
|
|
||||||
#elif IS_ARC
|
|
||||||
|
|
||||||
/* Non memory mapped I/O is not supported on ARC. */
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#error Unknown architecture, please check if it supports PCI port IO.
|
|
||||||
|
|
||||||
#endif /* IS_* */
|
|
||||||
#endif /* NEED_RAW_ACCESS == 1 */
|
|
||||||
|
|
||||||
#endif /* !__HWACCESS_H__ */
|
#endif /* !__HWACCESS_H__ */
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "platform.h"
|
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
#include "hwaccess.h"
|
#include "hwaccess.h"
|
||||||
|
|
||||||
|
@ -32,8 +32,6 @@
|
|||||||
* PICkit2 code: https://github.com/steve-m/avrdude/blob/master/pickit2.c
|
* PICkit2 code: https://github.com/steve-m/avrdude/blob/master/pickit2.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
57
platform.h
57
platform.h
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the flashrom project.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 Carl-Daniel Hailfinger
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Header file to determine target OS and CPU architecture.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PLATFORM_H__
|
|
||||||
#define __PLATFORM_H__ 1
|
|
||||||
|
|
||||||
// Likewise for target architectures
|
|
||||||
#if defined (__i386__) || defined (__x86_64__) || defined(__amd64__)
|
|
||||||
#define IS_X86 1
|
|
||||||
#elif defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips)
|
|
||||||
#define IS_MIPS 1
|
|
||||||
#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \
|
|
||||||
defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \
|
|
||||||
defined(_ARCH_PPC64) || defined(__ppc)
|
|
||||||
#define IS_PPC 1
|
|
||||||
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_ARM) || defined(_M_ARM) || defined(__arm) || \
|
|
||||||
defined(__aarch64__)
|
|
||||||
#define IS_ARM 1
|
|
||||||
#elif defined (__sparc__) || defined (__sparc)
|
|
||||||
#define IS_SPARC 1
|
|
||||||
#elif defined (__alpha__)
|
|
||||||
#define IS_ALPHA 1
|
|
||||||
#elif defined (__hppa__) || defined (__hppa)
|
|
||||||
#define IS_HPPA 1
|
|
||||||
#elif defined (__m68k__)
|
|
||||||
#define IS_M68K 1
|
|
||||||
#elif defined (__riscv)
|
|
||||||
#define IS_RISCV 1
|
|
||||||
#elif defined (__sh__)
|
|
||||||
#define IS_SH 1
|
|
||||||
#elif defined(__s390__) || defined(__s390x__) || defined(__zarch__)
|
|
||||||
#define IS_S390 1
|
|
||||||
#elif defined(__arc__)
|
|
||||||
#define IS_ARC 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !(IS_X86 || IS_MIPS || IS_PPC || IS_ARM || IS_SPARC || IS_ALPHA || IS_HPPA || IS_M68K || IS_RISCV || IS_SH || IS_S390 || IS_ARC)
|
|
||||||
#error Unknown architecture
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !__PLATFORM_H__ */
|
|
2
serial.c
2
serial.c
@ -15,8 +15,6 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if ! IS_WINDOWS /* stuff (presumably) needed for sockets only */
|
#if ! IS_WINDOWS /* stuff (presumably) needed for sockets only */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user