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

bus.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS HAL
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            hal/halx86/generic/bus.c
00005  * PURPOSE:         Bus Support Routines
00006  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 
00011 #include <hal.h>
00012 #define NDEBUG
00013 #include <debug.h>
00014 
00015 /* GLOBALS *******************************************************************/
00016 
00017 ULONG HalpBusType;
00018 
00019 /* PRIVATE FUNCTIONS *********************************************************/
00020 
00021 VOID
00022 NTAPI
00023 HalpRegisterKdSupportFunctions(VOID)
00024 {
00025     /* Register PCI Device Functions */
00026     KdSetupPciDeviceForDebugging = HalpSetupPciDeviceForDebugging;
00027     KdReleasePciDeviceforDebugging = HalpReleasePciDeviceForDebugging;
00028 
00029     /* Register memory functions */
00030     KdMapPhysicalMemory64 = HalpMapPhysicalMemory64;
00031     KdUnmapVirtualAddress = HalpUnmapVirtualAddress;
00032 
00033     /* Register ACPI stub */
00034     KdCheckPowerButton = HalpCheckPowerButton;
00035 }
00036 
00037 NTSTATUS
00038 NTAPI
00039 HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath,
00040                         IN PUNICODE_STRING DriverClassName,
00041                         IN PDRIVER_OBJECT DriverObject,
00042                         IN PDEVICE_OBJECT DeviceObject,
00043                         IN INTERFACE_TYPE BusType,
00044                         IN ULONG BusNumber,
00045                         IN ULONG SlotNumber,
00046                         IN OUT PCM_RESOURCE_LIST *AllocatedResources)
00047 {
00048     BUS_HANDLER BusHandler;
00049     PAGED_CODE();
00050 
00051     /* Only PCI is supported */
00052     if (BusType != PCIBus) return STATUS_NOT_IMPLEMENTED;
00053 
00054     /* Setup fake PCI Bus handler */
00055     RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
00056     BusHandler.BusNumber = BusNumber;
00057 
00058     /* Call the PCI function */
00059     return HalpAssignPCISlotResources(&BusHandler,
00060                                       &BusHandler,
00061                                       RegistryPath,
00062                                       DriverClassName,
00063                                       DriverObject,
00064                                       DeviceObject,
00065                                       SlotNumber,
00066                                       AllocatedResources);
00067 }
00068 
00069 BOOLEAN
00070 NTAPI
00071 HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType,
00072                         IN ULONG BusNumber,
00073                         IN PHYSICAL_ADDRESS BusAddress,
00074                         IN OUT PULONG AddressSpace,
00075                         OUT PPHYSICAL_ADDRESS TranslatedAddress)
00076 {
00077     /* Translation is easy */
00078     TranslatedAddress->QuadPart = BusAddress.QuadPart;
00079     return TRUE;
00080 }
00081 
00082 ULONG
00083 NTAPI
00084 HalpGetSystemInterruptVector(IN ULONG BusNumber,
00085                              IN ULONG BusInterruptLevel,
00086                              IN ULONG BusInterruptVector,
00087                              OUT PKIRQL Irql,
00088                              OUT PKAFFINITY Affinity)
00089 {
00090     ULONG Vector = IRQ2VECTOR(BusInterruptLevel);
00091     *Irql = (KIRQL)VECTOR2IRQL(Vector);
00092     *Affinity = 0xFFFFFFFF;
00093     return Vector;
00094 }
00095 
00096 BOOLEAN
00097 NTAPI
00098 HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress,
00099                               IN OUT PULONG AddressSpace,
00100                               OUT PPHYSICAL_ADDRESS TranslatedAddress,
00101                               IN OUT PULONG_PTR Context,
00102                               IN BOOLEAN NextBus)
00103 {
00104     /* Make sure we have a context */
00105     if (!Context) return FALSE;
00106 
00107     /* If we have data in the context, then this shouldn't be a new lookup */
00108     if ((*Context) && (NextBus == TRUE)) return FALSE;
00109 
00110     /* Return bus data */
00111     TranslatedAddress->QuadPart = BusAddress.QuadPart;
00112 
00113     /* Set context value and return success */
00114     *Context = 1;
00115     return TRUE;
00116 }
00117 
00118 VOID
00119 NTAPI
00120 HalpInitNonBusHandler(VOID)
00121 {
00122     /* These should be written by the PCI driver later, but we give defaults */
00123     HalPciTranslateBusAddress = HalpTranslateBusAddress;
00124     HalPciAssignSlotResources = HalpAssignSlotResources;
00125     HalFindBusAddressTranslation = HalpFindBusAddressTranslation;
00126 }
00127 
00128 /* PUBLIC FUNCTIONS **********************************************************/
00129 
00130 /*
00131  * @implemented
00132  */
00133 NTSTATUS
00134 NTAPI
00135 HalAdjustResourceList(IN PCM_RESOURCE_LIST Resources)
00136 {
00137     /* Deprecated, return success */
00138     return STATUS_SUCCESS;
00139 }
00140 
00141 /*
00142  * @implemented
00143  */
00144 NTSTATUS
00145 NTAPI
00146 HalAssignSlotResources(IN PUNICODE_STRING RegistryPath,
00147                        IN PUNICODE_STRING DriverClassName,
00148                        IN PDRIVER_OBJECT DriverObject,
00149                        IN PDEVICE_OBJECT DeviceObject,
00150                        IN INTERFACE_TYPE BusType,
00151                        IN ULONG BusNumber,
00152                        IN ULONG SlotNumber,
00153                        IN OUT PCM_RESOURCE_LIST *AllocatedResources)
00154 {
00155     /* Check the bus type */
00156     if (BusType != PCIBus)
00157     {
00158         /* Call our internal handler */
00159         return HalpAssignSlotResources(RegistryPath,
00160                                        DriverClassName,
00161                                        DriverObject,
00162                                        DeviceObject,
00163                                        BusType,
00164                                        BusNumber,
00165                                        SlotNumber,
00166                                        AllocatedResources);
00167     }
00168     else
00169     {
00170         /* Call the PCI registered function */
00171         return HalPciAssignSlotResources(RegistryPath,
00172                                          DriverClassName,
00173                                          DriverObject,
00174                                          DeviceObject,
00175                                          PCIBus,
00176                                          BusNumber,
00177                                          SlotNumber,
00178                                          AllocatedResources);
00179     }
00180 }
00181 
00182 /*
00183  * @implemented
00184  */
00185 ULONG
00186 NTAPI
00187 HalGetBusData(IN BUS_DATA_TYPE BusDataType,
00188               IN ULONG BusNumber,
00189               IN ULONG SlotNumber,
00190               IN PVOID Buffer,
00191               IN ULONG Length)
00192 {
00193     /* Call the extended function */
00194     return HalGetBusDataByOffset(BusDataType,
00195                                  BusNumber,
00196                                  SlotNumber,
00197                                  Buffer,
00198                                  0,
00199                                  Length);
00200 }
00201 
00202 /*
00203  * @implemented
00204  */
00205 ULONG
00206 NTAPI
00207 HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType,
00208                       IN ULONG BusNumber,
00209                       IN ULONG SlotNumber,
00210                       IN PVOID Buffer,
00211                       IN ULONG Offset,
00212                       IN ULONG Length)
00213 {
00214     BUS_HANDLER BusHandler;
00215 
00216     /* Look as the bus type */
00217     if (BusDataType == Cmos)
00218     {
00219         /* Call CMOS Function */
00220         return HalpGetCmosData(0, SlotNumber, Buffer, Length);
00221     }
00222     else if (BusDataType == EisaConfiguration)
00223     {
00224         /* FIXME: TODO */
00225         ASSERT(FALSE);
00226     }
00227     else if ((BusDataType == PCIConfiguration) &&
00228              (HalpPCIConfigInitialized) &&
00229              ((BusNumber >= HalpMinPciBus) && (BusNumber <= HalpMaxPciBus)))
00230     {
00231         /* Setup fake PCI Bus handler */
00232         RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
00233         BusHandler.BusNumber = BusNumber;
00234 
00235         /* Call PCI function */
00236         return HalpGetPCIData(&BusHandler,
00237                               &BusHandler,
00238                               *(PPCI_SLOT_NUMBER)&SlotNumber,
00239                               Buffer,
00240                               Offset,
00241                               Length);
00242     }
00243 
00244     /* Invalid bus */
00245     return 0;
00246 }
00247 
00248 /*
00249  * @implemented
00250  */
00251 ULONG
00252 NTAPI
00253 HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType,
00254                       IN ULONG BusNumber,
00255                       IN ULONG BusInterruptLevel,
00256                       IN ULONG BusInterruptVector,
00257                       OUT PKIRQL Irql,
00258                       OUT PKAFFINITY Affinity)
00259 {
00260     /* Call the system bus translator */
00261     return HalpGetSystemInterruptVector(BusNumber,
00262                                         BusInterruptLevel,
00263                                         BusInterruptVector,
00264                                         Irql,
00265                                         Affinity);
00266 }
00267 
00268 /*
00269  * @implemented
00270  */
00271 ULONG
00272 NTAPI
00273 HalSetBusData(IN BUS_DATA_TYPE BusDataType,
00274               IN ULONG BusNumber,
00275               IN ULONG SlotNumber,
00276               IN PVOID Buffer,
00277               IN ULONG Length)
00278 {
00279     /* Call the extended function */
00280     return HalSetBusDataByOffset(BusDataType,
00281                                  BusNumber,
00282                                  SlotNumber,
00283                                  Buffer,
00284                                  0,
00285                                  Length);
00286 }
00287 
00288 /*
00289  * @implemented
00290  */
00291 ULONG
00292 NTAPI
00293 HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType,
00294                       IN ULONG BusNumber,
00295                       IN ULONG SlotNumber,
00296                       IN PVOID Buffer,
00297                       IN ULONG Offset,
00298                       IN ULONG Length)
00299 {
00300     BUS_HANDLER BusHandler;
00301 
00302     /* Look as the bus type */
00303     if (BusDataType == Cmos)
00304     {
00305         /* Call CMOS Function */
00306         return HalpSetCmosData(0, SlotNumber, Buffer, Length);
00307     }
00308     else if ((BusDataType == PCIConfiguration) && (HalpPCIConfigInitialized))
00309     {
00310         /* Setup fake PCI Bus handler */
00311         RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
00312         BusHandler.BusNumber = BusNumber;
00313 
00314         /* Call PCI function */
00315         return HalpSetPCIData(&BusHandler,
00316                               &BusHandler,
00317                               *(PPCI_SLOT_NUMBER)&SlotNumber,
00318                               Buffer,
00319                               Offset,
00320                               Length);
00321     }
00322 
00323     /* Invalid bus */
00324     return 0;
00325 }
00326 
00327 /*
00328  * @implemented
00329  */
00330 BOOLEAN
00331 NTAPI
00332 HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType,
00333                        IN ULONG BusNumber,
00334                        IN PHYSICAL_ADDRESS BusAddress,
00335                        IN OUT PULONG AddressSpace,
00336                        OUT PPHYSICAL_ADDRESS TranslatedAddress)
00337 {
00338     /* Look as the bus type */
00339     if (InterfaceType == PCIBus)
00340     {
00341         /* Call the PCI registered function */
00342         return HalPciTranslateBusAddress(PCIBus,
00343                                          BusNumber,
00344                                          BusAddress,
00345                                          AddressSpace,
00346                                          TranslatedAddress);
00347     }
00348     else
00349     {
00350         /* Translation is easy */
00351         TranslatedAddress->QuadPart = BusAddress.QuadPart;
00352         return TRUE;
00353     }
00354 }
00355 
00356 /* EOF */

Generated on Sat May 26 2012 04:25:58 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.