From 8fc9d76d8ee163f31df99c413b171a4e5fc88344 Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 23 Feb 2018 23:01:55 +0000 Subject: [PATCH] - Made ACPICABase a global variable (again!) so that PCI can be used without ACPI. - Embedded the IRQ routing table list structure in the class's private data structure, instead of keeping it in a local variable that will be deallocated after the class is initialised! git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@55053 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/all-pc/hidds/pcipc/driverclass.c | 41 ++++++++++++++++++++++------------- arch/all-pc/hidds/pcipc/pci.h | 13 +++++------ arch/all-pc/hidds/pcipc/pciconf2.c | 6 ++--- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/arch/all-pc/hidds/pcipc/driverclass.c b/arch/all-pc/hidds/pcipc/driverclass.c index 433cead997..d5af5aad88 100644 --- a/arch/all-pc/hidds/pcipc/driverclass.c +++ b/arch/all-pc/hidds/pcipc/driverclass.c @@ -1,5 +1,5 @@ /* - Copyright © 2004-2017, The AROS Development Team. All rights reserved. + Copyright © 2004-2018, The AROS Development Team. All rights reserved. $Id$ Desc: PCI direct driver for i386 native. @@ -37,6 +37,21 @@ #define HiddPCIDeviceAttrBase (PSD(cl)->hidd_PCIDeviceAB) /* + * N.B. Do not move/remove/refactor the following variable unless you fully + * understand the implications. It must be an explicit global variable for the + * following reasons: + * - Linking with the linklib: acpica.library is a stack-call library, which + * means that its functions are always called through a stub linklib. + * Linking with the linklib will fail if ACPICABase is not a global variable. + * - acpica.library is optional: this class must still be able to run if + * acpica.library is unavailable. If ACPICABase is not defined as a global + * variable, the autoinit system will create one. However, in that case the + * autoinit system will also take over the opening of the library, and not + * allow this class to be loaded if the library isn't found. + */ +struct Library *ACPICABase; + +/* We overload the New method in order to introduce the Hidd Name and HardwareName attributes. */ @@ -71,7 +86,10 @@ void PCPCI__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) switch (idx) { case aoHidd_PCIDriver_IRQRoutingTable: - *msg->storage = (IPTR)PSD(cl)->pcipc_irqRoutingTable; + if (IsListEmpty(&PSD(cl)->pcipc_irqRoutingTable)) + *msg->storage = (IPTR)NULL; + else + *msg->storage = (IPTR)&PSD(cl)->pcipc_irqRoutingTable; break; default: @@ -296,22 +314,21 @@ static int PCPCI_InitClass(LIBBASETYPEPTR LIBBASE) struct pcipc_staticdata *_psd = &LIBBASE->psd; struct pHidd_PCI_AddHardwareDriver msg, *pmsg = &msg; OOP_Object *pci; - struct MinList routing_list; - NEWLIST(&routing_list); + NEWLIST(&_psd->pcipc_irqRoutingTable); D(bug("[PCI.PC] %s()\n", __func__)); - /* Open ACPI and cache the pointer to the MCFG table.. */ + /* Open ACPI and cache the pointer to the MCFG table */ ACPICABase = OpenLibrary("acpica.library", 0); + if (ACPICABase) AcpiGetTable(ACPI_SIG_MCFG, 1, (ACPI_TABLE_HEADER **)&_psd->pcipc_acpiMcfgTbl); _psd->hiddPCIDriverAB = OOP_ObtainAttrBase(IID_Hidd_PCIDriver); _psd->hiddAB = OOP_ObtainAttrBase(IID_Hidd); _psd->hidd_PCIDeviceAB = OOP_ObtainAttrBase(IID_Hidd_PCIDevice); - _psd->pcipc_irqRoutingTable = NULL; - + if (_psd->hiddPCIDriverAB == 0 || _psd->hiddAB == 0 || _psd->hidd_PCIDeviceAB == 0) { D(bug("[PCI.PC] %s: ObtainAttrBases failed\n", __func__)); @@ -319,12 +336,8 @@ static int PCPCI_InitClass(LIBBASETYPEPTR LIBBASE) } if (ACPICABase) - AcpiGetDevices("PNP0A03", PCPCI_ACPIDeviceCallback, &routing_list, NULL); - - if (!IsListEmpty(&routing_list)) - { - _psd->pcipc_irqRoutingTable = &routing_list; - } + AcpiGetDevices("PNP0A03", PCPCI_ACPIDeviceCallback, + &_psd->pcipc_irqRoutingTable, NULL); /* Default to using config mechanism 1 */ _psd->ReadConfigLong = ReadConfig1Long; @@ -347,8 +360,6 @@ static int PCPCI_InitClass(LIBBASETYPEPTR LIBBASE) static int PCPCI_ExpungeClass(LIBBASETYPEPTR LIBBASE) { - struct pcipc_staticdata *_psd = &LIBBASE->psd; - D(bug("[PCI.PC] %s()\n", __func__)); OOP_ReleaseAttrBase(IID_Hidd_PCIDevice); diff --git a/arch/all-pc/hidds/pcipc/pci.h b/arch/all-pc/hidds/pcipc/pci.h index 7a0443c4a3..0e46c42758 100644 --- a/arch/all-pc/hidds/pcipc/pci.h +++ b/arch/all-pc/hidds/pcipc/pci.h @@ -1,3 +1,8 @@ +/* + Copyright © 1995-2018, The AROS Development Team. All rights reserved. + $Id$ +*/ + #ifndef _PCI_H #define _PCI_H @@ -28,8 +33,6 @@ #endif - - struct pcipc_staticdata { OOP_AttrBase hiddPCIDriverAB; @@ -44,9 +47,8 @@ struct pcipc_staticdata void (*WriteConfigLong)(UBYTE bus, UBYTE dev, UBYTE sub, UWORD reg, ULONG val); /* ACPI related */ - struct Library *pcipc_acpiBase; ACPI_TABLE_MCFG *pcipc_acpiMcfgTbl; - struct MinList *pcipc_irqRoutingTable; + struct MinList pcipc_irqRoutingTable; }; struct pcibase @@ -59,9 +61,6 @@ struct pcibase #define PSD(cl) (&((struct pcibase*)cl->UserData)->psd) #define _psd PSD(cl) -#undef ACPICABase -#define ACPICABase (_psd->pcipc_acpiBase) - /* PCI configuration mechanism 1 registers */ #define PCI_AddressPort 0x0cf8 #define PCI_DataPort 0x0cfc diff --git a/arch/all-pc/hidds/pcipc/pciconf2.c b/arch/all-pc/hidds/pcipc/pciconf2.c index 350eb47af5..a66421b746 100644 --- a/arch/all-pc/hidds/pcipc/pciconf2.c +++ b/arch/all-pc/hidds/pcipc/pciconf2.c @@ -1,5 +1,5 @@ /* - Copyright © 2004-2017, The AROS Development Team. All rights reserved. + Copyright © 2004-2018, The AROS Development Team. All rights reserved. $Id$ Desc: PCI configuration mechanism 2 access functions @@ -89,7 +89,7 @@ static BOOL PCIPC_ProbeMech1Conf(struct pcipc_staticdata *psd) void PCIPC_ProbeConfMech(struct pcipc_staticdata *psd) { /* - * All newer boards support atleast mechanism 1. + * All newer boards support at least mechanism 1. * We probe for it first, because on some machines (e.g. MacMini), PCI_MechSelect is * used by the chipset as a reset register (and perhaps some other proprietary control). * Writing 0x01 to it makes the machine's cold reboot mechanism stop working. @@ -125,7 +125,7 @@ void PCIPC_ProbeConfMech(struct pcipc_staticdata *psd) } /* - * Newer systems may have empty bus 0. In this case SanityCheck() will fail. We + * Newer systems may have an empty bus 0. In this case SanityCheck() will fail. We * assume configuration type 1 for such systems. * Probably SanityCheck() should be revised or removed at all. */ -- 2.11.4.GIT