ReactOS  0.4.14-dev-376-gaedba84
sysbus.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for sysbus.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI HalpTranslateSystemBusAddress (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
ULONG NTAPI HalpGetRootInterruptVector (IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
 
ULONG NTAPI HalpGetSystemInterruptVector (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file sysbus.c.

Function Documentation

◆ HalpGetRootInterruptVector()

ULONG NTAPI HalpGetRootInterruptVector ( IN ULONG  BusInterruptLevel,
IN ULONG  BusInterruptVector,
OUT PKIRQL  Irql,
OUT PKAFFINITY  Affinity 
)

Definition at line 115 of file sysbus.c.

119 {
120  UCHAR SystemVector;
121 
122  /* Validate the IRQ */
123  if (BusInterruptLevel > 23)
124  {
125  /* Invalid vector */
126  DPRINT1("IRQ %lx is too high!\n", BusInterruptLevel);
127  return 0;
128  }
129 
130  /* Get the system vector */
131  SystemVector = HalpIrqToVector((UCHAR)BusInterruptLevel);
132 
133  /* Return the IRQL and affinity */
134  *Irql = HalpVectorToIrql(SystemVector);
137 
138  /* Return the vector */
139  return SystemVector;
140 }
_In_ ULONG _In_ ULONG BusInterruptLevel
Definition: halfuncs.h:170
KAFFINITY HalpDefaultInterruptAffinity
Definition: processor.c:18
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR FASTCALL HalpIrqToVector(UCHAR Irq)
Definition: apic.c:225
KIRQL FASTCALL HalpVectorToIrql(UCHAR Vector)
Definition: apic.c:238
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
#define DPRINT1
Definition: precomp.h:8

Referenced by HalpGetSystemInterruptVector().

◆ HalpGetSystemInterruptVector()

ULONG NTAPI HalpGetSystemInterruptVector ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN ULONG  BusInterruptLevel,
IN ULONG  BusInterruptVector,
OUT PKIRQL  Irql,
OUT PKAFFINITY  Affinity 
)

Definition at line 144 of file sysbus.c.

150 {
151  ULONG Vector;
152 
153  /* Get the root vector */
156  Irql,
157  Affinity);
158 
159  /* Check if the vector is owned by the HAL and fail if it is */
160  if (HalpIDTUsageFlags[Vector].Flags & IDT_REGISTERED) DPRINT1("Vector %lx is ALREADY IN USE!\n", Vector);
162 }
_In_ ULONG _In_ ULONG BusInterruptLevel
Definition: halfuncs.h:170
IDTUsageFlags HalpIDTUsageFlags[256]
Definition: usage.c:19
_In_ ULONG _In_ ULONG _In_ ULONG BusInterruptVector
Definition: halfuncs.h:170
_Out_ PKIRQL Irql
Definition: csq.h:179
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define IDT_REGISTERED
Definition: halp.h:19
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
ULONG NTAPI HalpGetRootInterruptVector(IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
Definition: sysbus.c:115
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG Vector
Definition: iofuncs.h:798
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1

◆ HalpTranslateSystemBusAddress()

BOOLEAN NTAPI HalpTranslateSystemBusAddress ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 21 of file sysbus.c.

26 {
28 
29  /* Check what kind of address space this is */
30  switch (*AddressSpace)
31  {
32  /* Memory address */
33  case 0:
34 
35  /* Loop all prefetch memory */
36  for (Range = &BusHandler->BusAddresses->PrefetchMemory;
37  Range;
38  Range = Range->Next)
39  {
40  /* Check if it's in a valid range */
41  if ((BusAddress.QuadPart >= Range->Base) &&
42  (BusAddress.QuadPart <= Range->Limit))
43  {
44  /* Get out */
45  break;
46  }
47  }
48 
49  /* Check if we haven't found anything yet */
50  if (!Range)
51  {
52  /* Loop all bus memory */
53  for (Range = &BusHandler->BusAddresses->Memory;
54  Range;
55  Range = Range->Next)
56  {
57  /* Check if it's in a valid range */
58  if ((BusAddress.QuadPart >= Range->Base) &&
59  (BusAddress.QuadPart <= Range->Limit))
60  {
61  /* Get out */
62  break;
63  }
64  }
65  }
66 
67  /* Done */
68  break;
69 
70  /* I/O Space */
71  case 1:
72 
73  /* Loop all bus I/O memory */
74  for (Range = &BusHandler->BusAddresses->IO;
75  Range;
76  Range = Range->Next)
77  {
78  /* Check if it's in a valid range */
79  if ((BusAddress.QuadPart >= Range->Base) &&
80  (BusAddress.QuadPart <= Range->Limit))
81  {
82  /* Get out */
83  break;
84  }
85  }
86 
87  /* Done */
88  break;
89  }
90 
91  /* Check if we found a range */
92  if (Range)
93  {
94  /* Do the translation and return the kind of address space this is */
97  (*AddressSpace != Range->SystemAddressSpace))
98  {
99  /* Different than what the old HAL would do */
100  DPRINT1("Translation of %I64x is %I64x %s\n",
102  Range->SystemAddressSpace ? "In I/O Space" : "In RAM");
103  }
104  *AddressSpace = Range->SystemAddressSpace;
105  return TRUE;
106  }
107 
108  /* Nothing found */
109  DPRINT1("Translation of %I64x failed!\n", BusAddress.QuadPart);
110  return FALSE;
111 }
#define TRUE
Definition: types.h:120
_In_ ULONG _In_ PHYSICAL_ADDRESS BusAddress
Definition: iofuncs.h:2268
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2268
smooth NULL
Definition: ftsmooth.c:416
Definition: range.c:39
#define DPRINT1
Definition: precomp.h:8
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by HalpRegisterInternalBusHandlers(), and HalpTranslateIsaBusAddress().