Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3508
-gerrit
commit 10ed74c6d50a969f5d82ed8056a9940c1178bef7 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Thu Jun 20 20:25:21 2013 +0300
Add simple_device_t
Declare the functions that may be used in both romstage and ramstage to use simple_device_t instead. This will later allow to define PCI access functions for ramstage using the inlined functions from romstage.
Change-Id: I32ff622883ceee4628e6b1b01023b970e379113f Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/arch/x86/include/arch/io.h | 71 +++++++++++++++++---------------- src/arch/x86/include/arch/pcie_config.h | 18 ++++----- 2 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/src/arch/x86/include/arch/io.h b/src/arch/x86/include/arch/io.h index 29c8339..33d124a 100644 --- a/src/arch/x86/include/arch/io.h +++ b/src/arch/x86/include/arch/io.h @@ -206,14 +206,15 @@ static inline int log2f(int value)
#define PNP_DEV(PORT, FUNC) (((PORT) << 8) | (FUNC))
-typedef unsigned device_t; /* pci and pci_mmio need to have different ways to have dev */ +typedef unsigned int simple_device_t; +typedef simple_device_t device_t;
/* FIXME: We need to make the coreboot to run at 64bit mode, So when read/write memory above 4G, * We don't need to set %fs, and %gs anymore * Before that We need to use %gs, and leave %fs to other RAM access */
-static inline __attribute__((always_inline)) uint8_t pci_io_read_config8(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint8_t pci_io_read_config8(simple_device_t dev, unsigned where) { unsigned addr; #if !CONFIG_PCI_IO_CFG_EXT @@ -226,14 +227,14 @@ static inline __attribute__((always_inline)) uint8_t pci_io_read_config8(device_ }
#if CONFIG_MMCONF_SUPPORT -static inline __attribute__((always_inline)) uint8_t pci_mmio_read_config8(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint8_t pci_mmio_read_config8(simple_device_t dev, unsigned where) { unsigned addr; addr = CONFIG_MMCONF_BASE_ADDRESS | dev | where; return read8(addr); } #endif -static inline __attribute__((always_inline)) uint8_t pci_read_config8(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint8_t pci_read_config8(simple_device_t dev, unsigned where) { #if CONFIG_MMCONF_SUPPORT_DEFAULT return pci_mmio_read_config8(dev, where); @@ -242,7 +243,7 @@ static inline __attribute__((always_inline)) uint8_t pci_read_config8(device_t d #endif }
-static inline __attribute__((always_inline)) uint16_t pci_io_read_config16(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint16_t pci_io_read_config16(simple_device_t dev, unsigned where) { unsigned addr; #if !CONFIG_PCI_IO_CFG_EXT @@ -255,7 +256,7 @@ static inline __attribute__((always_inline)) uint16_t pci_io_read_config16(devic }
#if CONFIG_MMCONF_SUPPORT -static inline __attribute__((always_inline)) uint16_t pci_mmio_read_config16(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint16_t pci_mmio_read_config16(simple_device_t dev, unsigned where) { unsigned addr; addr = CONFIG_MMCONF_BASE_ADDRESS | dev | (where & ~1); @@ -263,7 +264,7 @@ static inline __attribute__((always_inline)) uint16_t pci_mmio_read_config16(dev } #endif
-static inline __attribute__((always_inline)) uint16_t pci_read_config16(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint16_t pci_read_config16(simple_device_t dev, unsigned where) { #if CONFIG_MMCONF_SUPPORT_DEFAULT return pci_mmio_read_config16(dev, where); @@ -273,7 +274,7 @@ static inline __attribute__((always_inline)) uint16_t pci_read_config16(device_t }
-static inline __attribute__((always_inline)) uint32_t pci_io_read_config32(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint32_t pci_io_read_config32(simple_device_t dev, unsigned where) { unsigned addr; #if !CONFIG_PCI_IO_CFG_EXT @@ -286,7 +287,7 @@ static inline __attribute__((always_inline)) uint32_t pci_io_read_config32(devic }
#if CONFIG_MMCONF_SUPPORT -static inline __attribute__((always_inline)) uint32_t pci_mmio_read_config32(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint32_t pci_mmio_read_config32(simple_device_t dev, unsigned where) { unsigned addr; addr = CONFIG_MMCONF_BASE_ADDRESS | dev | (where & ~3); @@ -294,7 +295,7 @@ static inline __attribute__((always_inline)) uint32_t pci_mmio_read_config32(dev } #endif
-static inline __attribute__((always_inline)) uint32_t pci_read_config32(device_t dev, unsigned where) +static inline __attribute__((always_inline)) uint32_t pci_read_config32(simple_device_t dev, unsigned where) { #if CONFIG_MMCONF_SUPPORT_DEFAULT return pci_mmio_read_config32(dev, where); @@ -303,7 +304,7 @@ static inline __attribute__((always_inline)) uint32_t pci_read_config32(device_t #endif }
-static inline __attribute__((always_inline)) void pci_io_write_config8(device_t dev, unsigned where, uint8_t value) +static inline __attribute__((always_inline)) void pci_io_write_config8(simple_device_t dev, unsigned where, uint8_t value) { unsigned addr; #if !CONFIG_PCI_IO_CFG_EXT @@ -316,7 +317,7 @@ static inline __attribute__((always_inline)) void pci_io_write_config8(device_t }
#if CONFIG_MMCONF_SUPPORT -static inline __attribute__((always_inline)) void pci_mmio_write_config8(device_t dev, unsigned where, uint8_t value) +static inline __attribute__((always_inline)) void pci_mmio_write_config8(simple_device_t dev, unsigned where, uint8_t value) { unsigned addr; addr = CONFIG_MMCONF_BASE_ADDRESS | dev | where; @@ -324,7 +325,7 @@ static inline __attribute__((always_inline)) void pci_mmio_write_config8(device_ } #endif
-static inline __attribute__((always_inline)) void pci_write_config8(device_t dev, unsigned where, uint8_t value) +static inline __attribute__((always_inline)) void pci_write_config8(simple_device_t dev, unsigned where, uint8_t value) { #if CONFIG_MMCONF_SUPPORT_DEFAULT pci_mmio_write_config8(dev, where, value); @@ -334,7 +335,7 @@ static inline __attribute__((always_inline)) void pci_write_config8(device_t dev }
-static inline __attribute__((always_inline)) void pci_io_write_config16(device_t dev, unsigned where, uint16_t value) +static inline __attribute__((always_inline)) void pci_io_write_config16(simple_device_t dev, unsigned where, uint16_t value) { unsigned addr; #if !CONFIG_PCI_IO_CFG_EXT @@ -347,7 +348,7 @@ static inline __attribute__((always_inline)) void pci_io_write_config16(device_t }
#if CONFIG_MMCONF_SUPPORT -static inline __attribute__((always_inline)) void pci_mmio_write_config16(device_t dev, unsigned where, uint16_t value) +static inline __attribute__((always_inline)) void pci_mmio_write_config16(simple_device_t dev, unsigned where, uint16_t value) { unsigned addr; addr = CONFIG_MMCONF_BASE_ADDRESS | dev | (where & ~1); @@ -355,7 +356,7 @@ static inline __attribute__((always_inline)) void pci_mmio_write_config16(device } #endif
-static inline __attribute__((always_inline)) void pci_write_config16(device_t dev, unsigned where, uint16_t value) +static inline __attribute__((always_inline)) void pci_write_config16(simple_device_t dev, unsigned where, uint16_t value) { #if CONFIG_MMCONF_SUPPORT_DEFAULT pci_mmio_write_config16(dev, where, value); @@ -365,7 +366,7 @@ static inline __attribute__((always_inline)) void pci_write_config16(device_t de }
-static inline __attribute__((always_inline)) void pci_io_write_config32(device_t dev, unsigned where, uint32_t value) +static inline __attribute__((always_inline)) void pci_io_write_config32(simple_device_t dev, unsigned where, uint32_t value) { unsigned addr; #if !CONFIG_PCI_IO_CFG_EXT @@ -378,7 +379,7 @@ static inline __attribute__((always_inline)) void pci_io_write_config32(device_t }
#if CONFIG_MMCONF_SUPPORT -static inline __attribute__((always_inline)) void pci_mmio_write_config32(device_t dev, unsigned where, uint32_t value) +static inline __attribute__((always_inline)) void pci_mmio_write_config32(simple_device_t dev, unsigned where, uint32_t value) { unsigned addr; addr = CONFIG_MMCONF_BASE_ADDRESS | dev | (where & ~3); @@ -386,7 +387,7 @@ static inline __attribute__((always_inline)) void pci_mmio_write_config32(device } #endif
-static inline __attribute__((always_inline)) void pci_write_config32(device_t dev, unsigned where, uint32_t value) +static inline __attribute__((always_inline)) void pci_write_config32(simple_device_t dev, unsigned where, uint32_t value) { #if CONFIG_MMCONF_SUPPORT_DEFAULT pci_mmio_write_config32(dev, where, value); @@ -395,23 +396,23 @@ static inline __attribute__((always_inline)) void pci_write_config32(device_t de #endif }
-static inline __attribute__((always_inline)) void pci_or_config8(device_t dev, unsigned where, uint8_t value) +static inline __attribute__((always_inline)) void pci_or_config8(simple_device_t dev, unsigned where, uint8_t value) { pci_write_config8(dev, where, pci_read_config8(dev, where) | value); }
-static inline __attribute__((always_inline)) void pci_or_config16(device_t dev, unsigned where, uint16_t value) +static inline __attribute__((always_inline)) void pci_or_config16(simple_device_t dev, unsigned where, uint16_t value) { pci_write_config16(dev, where, pci_read_config16(dev, where) | value); }
-static inline __attribute__((always_inline)) void pci_or_config32(device_t dev, unsigned where, uint32_t value) +static inline __attribute__((always_inline)) void pci_or_config32(simple_device_t dev, unsigned where, uint32_t value) { pci_write_config32(dev, where, pci_read_config32(dev, where) | value); }
#define PCI_DEV_INVALID (0xffffffffU) -static inline device_t pci_io_locate_device(unsigned pci_id, device_t dev) +static inline simple_device_t pci_io_locate_device(unsigned pci_id, simple_device_t dev) { for(; dev <= PCI_DEV(255, 31, 7); dev += PCI_DEV(0,0,1)) { unsigned int id; @@ -423,7 +424,7 @@ static inline device_t pci_io_locate_device(unsigned pci_id, device_t dev) return PCI_DEV_INVALID; }
-static inline device_t pci_locate_device(unsigned pci_id, device_t dev) +static inline simple_device_t pci_locate_device(unsigned pci_id, simple_device_t dev) { for(; dev <= PCI_DEV(255|(((1<<CONFIG_PCI_BUS_SEGN_BITS)-1)<<8), 31, 7); dev += PCI_DEV(0,0,1)) { unsigned int id; @@ -435,9 +436,9 @@ static inline device_t pci_locate_device(unsigned pci_id, device_t dev) return PCI_DEV_INVALID; }
-static inline device_t pci_locate_device_on_bus(unsigned pci_id, unsigned bus) +static inline simple_device_t pci_locate_device_on_bus(unsigned pci_id, unsigned bus) { - device_t dev, last; + simple_device_t dev, last;
dev = PCI_DEV(bus, 0, 0); last = PCI_DEV(bus, 31, 7); @@ -453,53 +454,53 @@ static inline device_t pci_locate_device_on_bus(unsigned pci_id, unsigned bus) }
/* Generic functions for pnp devices */ -static inline __attribute__((always_inline)) void pnp_write_config(device_t dev, uint8_t reg, uint8_t value) +static inline __attribute__((always_inline)) void pnp_write_config(simple_device_t dev, uint8_t reg, uint8_t value) { unsigned port = dev >> 8; outb(reg, port ); outb(value, port +1); }
-static inline __attribute__((always_inline)) uint8_t pnp_read_config(device_t dev, uint8_t reg) +static inline __attribute__((always_inline)) uint8_t pnp_read_config(simple_device_t dev, uint8_t reg) { unsigned port = dev >> 8; outb(reg, port); return inb(port +1); }
-static inline __attribute__((always_inline)) void pnp_set_logical_device(device_t dev) +static inline __attribute__((always_inline)) void pnp_set_logical_device(simple_device_t dev) { unsigned device = dev & 0xff; pnp_write_config(dev, 0x07, device); }
-static inline __attribute__((always_inline)) void pnp_set_enable(device_t dev, int enable) +static inline __attribute__((always_inline)) void pnp_set_enable(simple_device_t dev, int enable) { pnp_write_config(dev, 0x30, enable?0x1:0x0); }
-static inline __attribute__((always_inline)) int pnp_read_enable(device_t dev) +static inline __attribute__((always_inline)) int pnp_read_enable(simple_device_t dev) { return !!pnp_read_config(dev, 0x30); }
-static inline __attribute__((always_inline)) void pnp_set_iobase(device_t dev, unsigned index, unsigned iobase) +static inline __attribute__((always_inline)) void pnp_set_iobase(simple_device_t dev, unsigned index, unsigned iobase) { pnp_write_config(dev, index + 0, (iobase >> 8) & 0xff); pnp_write_config(dev, index + 1, iobase & 0xff); }
-static inline __attribute__((always_inline)) uint16_t pnp_read_iobase(device_t dev, unsigned index) +static inline __attribute__((always_inline)) uint16_t pnp_read_iobase(simple_device_t dev, unsigned index) { return ((uint16_t)(pnp_read_config(dev, index)) << 8) | pnp_read_config(dev, index + 1); }
-static inline __attribute__((always_inline)) void pnp_set_irq(device_t dev, unsigned index, unsigned irq) +static inline __attribute__((always_inline)) void pnp_set_irq(simple_device_t dev, unsigned index, unsigned irq) { pnp_write_config(dev, index, irq); }
-static inline __attribute__((always_inline)) void pnp_set_drq(device_t dev, unsigned index, unsigned drq) +static inline __attribute__((always_inline)) void pnp_set_drq(simple_device_t dev, unsigned index, unsigned drq) { pnp_write_config(dev, index, drq & 0xff); } diff --git a/src/arch/x86/include/arch/pcie_config.h b/src/arch/x86/include/arch/pcie_config.h index 672457d..61afd7f 100644 --- a/src/arch/x86/include/arch/pcie_config.h +++ b/src/arch/x86/include/arch/pcie_config.h @@ -20,7 +20,7 @@ #define DEFAULT_PCIEXBAR CONFIG_MMCONF_BASE_ADDRESS
static inline __attribute__ ((always_inline)) -u8 pcie_read_config8(device_t dev, unsigned int where) +u8 pcie_read_config8(simple_device_t dev, unsigned int where) { unsigned long addr; addr = DEFAULT_PCIEXBAR | dev | where; @@ -28,7 +28,7 @@ u8 pcie_read_config8(device_t dev, unsigned int where) }
static inline __attribute__ ((always_inline)) -u16 pcie_read_config16(device_t dev, unsigned int where) +u16 pcie_read_config16(simple_device_t dev, unsigned int where) { unsigned long addr; addr = DEFAULT_PCIEXBAR | dev | where; @@ -36,7 +36,7 @@ u16 pcie_read_config16(device_t dev, unsigned int where) }
static inline __attribute__ ((always_inline)) -u32 pcie_read_config32(device_t dev, unsigned int where) +u32 pcie_read_config32(simple_device_t dev, unsigned int where) { unsigned long addr; addr = DEFAULT_PCIEXBAR | dev | where; @@ -44,7 +44,7 @@ u32 pcie_read_config32(device_t dev, unsigned int where) }
static inline __attribute__ ((always_inline)) -void pcie_write_config8(device_t dev, unsigned int where, u8 value) +void pcie_write_config8(simple_device_t dev, unsigned int where, u8 value) { unsigned long addr; addr = DEFAULT_PCIEXBAR | dev | where; @@ -52,7 +52,7 @@ void pcie_write_config8(device_t dev, unsigned int where, u8 value) }
static inline __attribute__ ((always_inline)) -void pcie_write_config16(device_t dev, unsigned int where, u16 value) +void pcie_write_config16(simple_device_t dev, unsigned int where, u16 value) { unsigned long addr; addr = DEFAULT_PCIEXBAR | dev | where; @@ -60,7 +60,7 @@ void pcie_write_config16(device_t dev, unsigned int where, u16 value) }
static inline __attribute__ ((always_inline)) -void pcie_write_config32(device_t dev, unsigned int where, u32 value) +void pcie_write_config32(simple_device_t dev, unsigned int where, u32 value) { unsigned long addr; addr = DEFAULT_PCIEXBAR | dev | where; @@ -68,21 +68,21 @@ void pcie_write_config32(device_t dev, unsigned int where, u32 value) }
static inline __attribute__ ((always_inline)) -void pcie_or_config8(device_t dev, unsigned int where, u8 ormask) +void pcie_or_config8(simple_device_t dev, unsigned int where, u8 ormask) { u8 value = pcie_read_config8(dev, where); pcie_write_config8(dev, where, value | ormask); }
static inline __attribute__ ((always_inline)) -void pcie_or_config16(device_t dev, unsigned int where, u16 ormask) +void pcie_or_config16(simple_device_t dev, unsigned int where, u16 ormask) { u16 value = pcie_read_config16(dev, where); pcie_write_config16(dev, where, value | ormask); }
static inline __attribute__ ((always_inline)) -void pcie_or_config32(device_t dev, unsigned int where, u32 ormask) +void pcie_or_config32(simple_device_t dev, unsigned int where, u32 ormask) { u32 value = pcie_read_config32(dev, where); pcie_write_config32(dev, where, value | ormask);