Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygensysbus.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/sysbus.c 00005 * PURPOSE: 00006 * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <hal.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 /* GLOBALS ********************************************************************/ 00016 00017 /* PRIVATE FUNCTIONS **********************************************************/ 00018 00019 BOOLEAN 00020 NTAPI 00021 HalpTranslateSystemBusAddress(IN PBUS_HANDLER BusHandler, 00022 IN PBUS_HANDLER RootHandler, 00023 IN PHYSICAL_ADDRESS BusAddress, 00024 IN OUT PULONG AddressSpace, 00025 OUT PPHYSICAL_ADDRESS TranslatedAddress) 00026 { 00027 PSUPPORTED_RANGE Range = NULL; 00028 00029 /* Check what kind of address space this is */ 00030 switch (*AddressSpace) 00031 { 00032 /* Memory address */ 00033 case 0: 00034 00035 /* Loop all prefetech memory */ 00036 for (Range = &BusHandler->BusAddresses->PrefetchMemory; 00037 Range; 00038 Range = Range->Next) 00039 { 00040 /* Check if it's in a valid range */ 00041 if ((BusAddress.QuadPart >= Range->Base) && 00042 (BusAddress.QuadPart <= Range->Limit)) 00043 { 00044 /* Get out */ 00045 break; 00046 } 00047 } 00048 00049 /* Check if we haven't found anything yet */ 00050 if (!Range) 00051 { 00052 /* Loop all bus memory */ 00053 for (Range = &BusHandler->BusAddresses->Memory; 00054 Range; 00055 Range = Range->Next) 00056 { 00057 /* Check if it's in a valid range */ 00058 if ((BusAddress.QuadPart >= Range->Base) && 00059 (BusAddress.QuadPart <= Range->Limit)) 00060 { 00061 /* Get out */ 00062 break; 00063 } 00064 } 00065 } 00066 00067 /* Done */ 00068 break; 00069 00070 /* I/O Space */ 00071 case 1: 00072 00073 /* Loop all bus I/O memory */ 00074 for (Range = &BusHandler->BusAddresses->IO; 00075 Range; 00076 Range = Range->Next) 00077 { 00078 /* Check if it's in a valid range */ 00079 if ((BusAddress.QuadPart >= Range->Base) && 00080 (BusAddress.QuadPart <= Range->Limit)) 00081 { 00082 /* Get out */ 00083 break; 00084 } 00085 } 00086 00087 /* Done */ 00088 break; 00089 } 00090 00091 /* Check if we found a range */ 00092 if (Range) 00093 { 00094 /* Do the translation and return the kind of address space this is */ 00095 TranslatedAddress->QuadPart = BusAddress.QuadPart + Range->SystemBase; 00096 if ((TranslatedAddress->QuadPart != BusAddress.QuadPart) || 00097 (*AddressSpace != Range->SystemAddressSpace)) 00098 { 00099 /* Different than what the old HAL would do */ 00100 DPRINT1("Translation of %I64x is %I64x %s\n", 00101 BusAddress.QuadPart, TranslatedAddress->QuadPart, 00102 Range->SystemAddressSpace ? "In I/O Space" : "In RAM"); 00103 } 00104 *AddressSpace = Range->SystemAddressSpace; 00105 return TRUE; 00106 } 00107 00108 /* Nothing found */ 00109 DPRINT1("Translation of %I64x failed!\n", BusAddress.QuadPart); 00110 return FALSE; 00111 } 00112 00113 ULONG 00114 NTAPI 00115 HalpGetRootInterruptVector(IN ULONG BusInterruptLevel, 00116 IN ULONG BusInterruptVector, 00117 OUT PKIRQL Irql, 00118 OUT PKAFFINITY Affinity) 00119 { 00120 UCHAR SystemVector; 00121 00122 /* Validate the IRQ */ 00123 if (BusInterruptLevel > 23) 00124 { 00125 /* Invalid vector */ 00126 DPRINT1("IRQ %lx is too high!\n", BusInterruptLevel); 00127 return 0; 00128 } 00129 00130 /* Get the system vector */ 00131 SystemVector = HalpIrqToVector((UCHAR)BusInterruptLevel); 00132 00133 /* Return the IRQL and affinity */ 00134 *Irql = HalpVectorToIrql(SystemVector); 00135 *Affinity = HalpDefaultInterruptAffinity; 00136 ASSERT(HalpDefaultInterruptAffinity); 00137 00138 /* Return the vector */ 00139 return SystemVector; 00140 } 00141 00142 ULONG 00143 NTAPI 00144 HalpGetSystemInterruptVector(IN PBUS_HANDLER BusHandler, 00145 IN PBUS_HANDLER RootHandler, 00146 IN ULONG BusInterruptLevel, 00147 IN ULONG BusInterruptVector, 00148 OUT PKIRQL Irql, 00149 OUT PKAFFINITY Affinity) 00150 { 00151 ULONG Vector; 00152 00153 /* Get the root vector */ 00154 Vector = HalpGetRootInterruptVector(BusInterruptLevel, 00155 BusInterruptVector, 00156 Irql, 00157 Affinity); 00158 00159 /* Check if the vector is owned by the HAL and fail if it is */ 00160 if (HalpIDTUsageFlags[Vector].Flags & IDT_REGISTERED) DPRINT1("Vector %lx is ALREADY IN USE!\n", Vector); 00161 return (HalpIDTUsageFlags[Vector].Flags & IDT_REGISTERED) ? 0 : Vector; 00162 } 00163 00164 /* EOF */ Generated on Mon May 28 2012 04:28:33 for ReactOS by
1.7.6.1
|