From 6a732582c75639e9fe954de66274ae1f0feffd37 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Wed, 13 Aug 2008 02:41:29 +0000 Subject: [PATCH] Here we start to see the good design of 3. In v2, there were pci ops in all stages, blighting everything with the same code, compiled different ways. In this change, we see that: - basic conf ops are compiled into stage0, where they are used. - they are called directly from initram - they are used to initialize the pci_cf8_conf1 structure in stage 2, but the call still goes to stage0! one copy of the code. Signed-off-by: Ronald G. Minnich Acked-by: Carl-Daniel Hailfinger git-svn-id: svn://coreboot.org/repository/coreboot-v3@752 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- arch/x86/pci_ops_auto.c | 12 ++++++++++++ arch/x86/pci_ops_conf1.c | 30 ++++++++++-------------------- include/device/pci_ops.h | 10 ++++++++++ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/arch/x86/pci_ops_auto.c b/arch/x86/pci_ops_auto.c index 1fbc0f4c8c..9475309c98 100644 --- a/arch/x86/pci_ops_auto.c +++ b/arch/x86/pci_ops_auto.c @@ -7,6 +7,18 @@ #include #include + +const struct pci_bus_operations pci_cf8_conf1 = { + .read8 = pci_conf1_read_config8, + .read16 = pci_conf1_read_config16, + .read32 = pci_conf1_read_config32, + .write8 = pci_conf1_write_config8, + .write16 = pci_conf1_write_config16, + .write32 = pci_conf1_write_config32, + .find = pci_conf1_find_device, +}; + + /* * Before we decide to use direct hardware access mechanisms, we try to do some * trivial checks to ensure it at least _seems_ to be working -- we just test diff --git a/arch/x86/pci_ops_conf1.c b/arch/x86/pci_ops_conf1.c index f50413ec0e..1263ed029c 100644 --- a/arch/x86/pci_ops_conf1.c +++ b/arch/x86/pci_ops_conf1.c @@ -56,37 +56,37 @@ #define CONFIG_CMD(bdf, where) (0x80000000 | (bdf) | ((where & 0xff) & ~3) | ((where & 0xf00)<<16) ) #endif -static u8 pci_conf1_read_config8(u32 bdf, int where) +u8 pci_conf1_read_config8(u32 bdf, int where) { outl(CONFIG_CMD(bdf, where), 0xCF8); return inb(0xCFC + (where & 3)); } -static u16 pci_conf1_read_config16(u32 bdf, int where) +u16 pci_conf1_read_config16(u32 bdf, int where) { outl(CONFIG_CMD(bdf, where), 0xCF8); return inw(0xCFC + (where & 2)); } -static u32 pci_conf1_read_config32(u32 bdf, int where) +u32 pci_conf1_read_config32(u32 bdf, int where) { outl(CONFIG_CMD(bdf, where), 0xCF8); return inl(0xCFC); } -static void pci_conf1_write_config8(u32 bdf, int where, u8 value) +void pci_conf1_write_config8(u32 bdf, int where, u8 value) { outl(CONFIG_CMD(bdf, where), 0xCF8); outb(value, 0xCFC + (where & 3)); } -static void pci_conf1_write_config16(u32 bdf, int where, u16 value) +void pci_conf1_write_config16(u32 bdf, int where, u16 value) { outl(CONFIG_CMD(bdf, where), 0xCF8); outw(value, 0xCFC + (where & 2)); } -static void pci_conf1_write_config32(u32 bdf, int where, u32 value) +void pci_conf1_write_config32(u32 bdf, int where, u32 value) { outl(CONFIG_CMD(bdf, where), 0xCF8); outl(value, 0xCFC); @@ -111,7 +111,7 @@ static void pci_conf1_write_config32(u32 bdf, int where, u32 value) * @return 1 if found, 0 otherwise */ -static int find_on_bus(u16 bus, u16 vid, u16 did, u32 *busdevfn) +int pci_conf1_find_on_bus(u16 bus, u16 vid, u16 did, u32 *busdevfn) { u16 devfn; @@ -139,7 +139,7 @@ static int find_on_bus(u16 bus, u16 vid, u16 did, u32 *busdevfn) if (hdr == PCI_HEADER_TYPE_BRIDGE || hdr == PCI_HEADER_TYPE_CARDBUS) { unsigned int busses; busses = pci_conf1_read_config32(confaddr, PCI_PRIMARY_BUS); - if (find_on_bus((busses >> 8) & 0xFF, vid, did, busdevfn)) + if (pci_conf1_find_on_bus((busses >> 8) & 0xFF, vid, did, busdevfn)) return 1; } } @@ -147,17 +147,7 @@ static int find_on_bus(u16 bus, u16 vid, u16 did, u32 *busdevfn) return 0; } -static int pci_find_device(u16 vid, u16 did, u32 * dev) +int pci_conf1_find_device(u16 vid, u16 did, u32 * dev) { - return find_on_bus(0, vid, did, dev); + return pci_conf1_find_on_bus(0, vid, did, dev); } - -const struct pci_bus_operations pci_cf8_conf1 = { - .read8 = pci_conf1_read_config8, - .read16 = pci_conf1_read_config16, - .read32 = pci_conf1_read_config32, - .write8 = pci_conf1_write_config8, - .write16 = pci_conf1_write_config16, - .write32 = pci_conf1_write_config32, - .find = pci_find_device, -}; diff --git a/include/device/pci_ops.h b/include/device/pci_ops.h index 6398b9218c..516c94e4bf 100644 --- a/include/device/pci_ops.h +++ b/include/device/pci_ops.h @@ -21,6 +21,7 @@ #include #include #include +#include u8 pci_read_config8(struct device * dev, unsigned where); u16 pci_read_config16(struct device * dev, unsigned where); @@ -29,4 +30,13 @@ void pci_write_config8(struct device * dev, unsigned where, u8 val); void pci_write_config16(struct device * dev, unsigned where, u16 val); void pci_write_config32(struct device * dev, unsigned where, u32 val); +SHARED(pci_conf1_read_config8, u8, u32 bdf, int where); +SHARED(pci_conf1_read_config16, u16, u32 bdf, int where); +SHARED(pci_conf1_read_config32, u32, u32 bdf, int where); +SHARED(pci_conf1_write_config8, void , u32 bdf, int where, u8 value); +SHARED(pci_conf1_write_config16, void, u32 bdf, int where, u16 value); +SHARED(pci_conf1_write_config32, void, u32 bdf, int where, u32 value); +SHARED(pci_conf1_find_on_bus, int, u16 bus, u16 vid, u16 did, u32 *busdevfn); +SHARED(pci_conf1_find_device, int, u16 vid, u16 did, u32 * dev); + #endif /* DEVICE_PCI_OPS_H */