ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

arb_comn.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS PCI Bus Driver
00003  * LICENSE:         BSD - See COPYING.ARM in the top level directory
00004  * FILE:            drivers/bus/pci/arb/arb_comn.c
00005  * PURPOSE:         Common Arbitration Code
00006  * PROGRAMMERS:     ReactOS Portable Systems Group
00007  */
00008 
00009 /* INCLUDES *******************************************************************/
00010 
00011 #include <pci.h>
00012 #define NDEBUG
00013 #include <debug.h>
00014 
00015 /* GLOBALS ********************************************************************/
00016 
00017 PCHAR PciArbiterNames[] =
00018 {
00019     "I/O Port",
00020     "Memory",
00021     "Interrupt",
00022     "Bus Number"
00023 };
00024 
00025 /* FUNCTIONS ******************************************************************/
00026 
00027 VOID
00028 NTAPI
00029 PciArbiterDestructor(IN PPCI_ARBITER_INSTANCE Arbiter)
00030 {
00031     /* This function is not yet implemented */
00032     UNIMPLEMENTED;
00033     while (TRUE);
00034 }
00035 
00036 NTSTATUS
00037 NTAPI
00038 PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension)
00039 {
00040     PPCI_INTERFACE CurrentInterface, *Interfaces;
00041     PPCI_PDO_EXTENSION PdoExtension;
00042     PPCI_ARBITER_INSTANCE ArbiterInterface;
00043     NTSTATUS Status;
00044     PCI_SIGNATURE ArbiterType;
00045     ASSERT_FDO(FdoExtension);
00046 
00047     /* Loop all the arbiters */
00048     for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_BusNumber; ArbiterType++)
00049     {
00050         /* Check if this is the extension for the Root PCI Bus */
00051         if (!PCI_IS_ROOT_FDO(FdoExtension))
00052         {
00053             /* Get the PDO extension */
00054             PdoExtension = FdoExtension->PhysicalDeviceObject->DeviceExtension;
00055             ASSERT_PDO(PdoExtension);
00056 
00057             /* Skip this bus if it does subtractive decode */
00058             if (PdoExtension->Dependent.type1.SubtractiveDecode)
00059             {
00060                 DPRINT1("PCI Not creating arbiters for subtractive bus %d\n",
00061                         PdoExtension->Dependent.type1.SubtractiveDecode);
00062                 continue;
00063             }
00064         }
00065 
00066         /* Query all the registered arbiter interfaces */
00067         Interfaces = PciInterfaces;
00068         while (*Interfaces)
00069         {
00070             /* Find the one that matches the arbiter currently being setup */
00071             CurrentInterface = *Interfaces;
00072             if (CurrentInterface->Signature == ArbiterType) break;
00073             Interfaces++;
00074         }
00075 
00076         /* Check if the required arbiter was not found in the list */
00077         if (!*Interfaces)
00078         {
00079             /* Skip this arbiter and try the next one */
00080             DPRINT1("PCI - FDO ext 0x%08x no %s arbiter.\n",
00081                     FdoExtension,
00082                     PciArbiterNames[ArbiterType - PciArb_Io]);
00083             continue;
00084         }
00085 
00086         /* An arbiter was found, allocate an instance for it */
00087         Status = STATUS_INSUFFICIENT_RESOURCES;
00088         ArbiterInterface = ExAllocatePoolWithTag(PagedPool,
00089                                                  sizeof(PCI_ARBITER_INSTANCE),
00090                                                  PCI_POOL_TAG);
00091         if (!ArbiterInterface) break;
00092 
00093         /* Setup the instance */
00094         ArbiterInterface->BusFdoExtension = FdoExtension;
00095         ArbiterInterface->Interface = CurrentInterface;
00096         swprintf(ArbiterInterface->InstanceName,
00097                  L"PCI %S (b=%02x)",
00098                  PciArbiterNames[ArbiterType - PciArb_Io],
00099                  FdoExtension->BaseBus);
00100 
00101         /* Call the interface initializer for it */
00102         Status = CurrentInterface->Initializer(ArbiterInterface);
00103         if (!NT_SUCCESS(Status)) break;
00104 
00105         /* Link it with this FDO */
00106         PcipLinkSecondaryExtension(&FdoExtension->SecondaryExtension,
00107                                    &FdoExtension->SecondaryExtLock,
00108                                    &ArbiterInterface->Header,
00109                                    ArbiterType,
00110                                    PciArbiterDestructor);
00111 
00112         /* This arbiter is now initialized, move to the next one */
00113         DPRINT1("PCI - FDO ext 0x%08x %S arbiter initialized (context 0x%08x).\n",
00114                 FdoExtension,
00115                 L"ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name,
00116                 ArbiterInterface);
00117         Status = STATUS_SUCCESS;
00118     }
00119 
00120     /* Return to caller */
00121     return Status;
00122 }
00123 
00124 NTSTATUS
00125 NTAPI
00126 PciInitializeArbiterRanges(IN PPCI_FDO_EXTENSION DeviceExtension,
00127                            IN PCM_RESOURCE_LIST Resources)
00128 {
00129     PPCI_PDO_EXTENSION PdoExtension;
00130     //CM_RESOURCE_TYPE DesiredType;
00131     PVOID Instance;
00132     PCI_SIGNATURE ArbiterType;
00133 
00134     /* Arbiters should not already be initialized */
00135     if (DeviceExtension->ArbitersInitialized)
00136     {
00137         /* Duplicated start request, fail initialization */
00138         DPRINT1("PCI Warning hot start FDOx %08x, resource ranges not checked.\n", DeviceExtension);
00139         return STATUS_INVALID_DEVICE_REQUEST;
00140     }
00141 
00142     /* Check for non-root FDO */
00143     if (!PCI_IS_ROOT_FDO(DeviceExtension))
00144     {
00145         /* Grab the PDO */
00146         PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension->PhysicalDeviceObject->DeviceExtension;
00147         ASSERT_PDO(PdoExtension);
00148 
00149         /* Check if this is a subtractive bus */
00150         if (PdoExtension->Dependent.type1.SubtractiveDecode)
00151         {
00152             /* There is nothing to do regarding arbitration of resources */
00153             DPRINT1("PCI Skipping arbiter initialization for subtractive bridge FDOX %p\n", DeviceExtension);
00154             return STATUS_SUCCESS;
00155         }
00156     }
00157 
00158     /* Loop all arbiters */
00159     for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_Memory; ArbiterType++)
00160     {
00161         /* Pick correct resource type for each arbiter */
00162         if (ArbiterType == PciArb_Io)
00163         {
00164             /* I/O Port */
00165             //DesiredType = CmResourceTypePort;
00166         }
00167         else if (ArbiterType == PciArb_Memory)
00168         {
00169             /* Device RAM */
00170             //DesiredType = CmResourceTypeMemory;
00171         }
00172         else
00173         {
00174             /* Ignore anything else */
00175             continue;
00176         }
00177 
00178         /* Find an arbiter of this type */
00179         Instance = PciFindNextSecondaryExtension(&DeviceExtension->SecondaryExtension,
00180                                                  ArbiterType);
00181         if (Instance)
00182         {
00183             /*
00184              * Now we should initialize it, not yet implemented because Arb
00185              * library isn't yet implemented, not even the headers.
00186              */
00187             UNIMPLEMENTED;
00188             //while (TRUE);
00189         }
00190         else
00191         {
00192             /* The arbiter was not found, this is an error! */
00193             DPRINT1("PCI - FDO ext 0x%08x %s arbiter (REQUIRED) is missing.\n",
00194                     DeviceExtension,
00195                     PciArbiterNames[ArbiterType - PciArb_Io]);
00196         }
00197     }
00198 
00199     /* Arbiters are now initialized */
00200     DeviceExtension->ArbitersInitialized = TRUE;
00201     return STATUS_SUCCESS;
00202 }
00203 
00204 /* EOF */

Generated on Sun May 27 2012 04:27:29 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.