mirror of https://github.com/lianthony/NT4.0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
204 lines
4.6 KiB
204 lines
4.6 KiB
/*++
|
|
|
|
|
|
Copyright (C) 1989-1995 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
pxsysbus.c
|
|
|
|
Abstract:
|
|
|
|
Author:
|
|
|
|
Environment:
|
|
|
|
Revision History:
|
|
Jim Wooldridge - IBM
|
|
- ported to PowerPC
|
|
9/26/95 Steve Johns - Motorola
|
|
- use BusInterruptLevel instead of BusInterruptVector
|
|
|
|
|
|
--*/
|
|
|
|
#include "halp.h"
|
|
|
|
#include "eisa.h"
|
|
#include "pxmemctl.h"
|
|
#include "pxsiosup.h"
|
|
#include "pxsystyp.h"
|
|
|
|
KIRQL HalpTranslateVectorToIrql(IN ULONG Vector);
|
|
|
|
|
|
BOOLEAN
|
|
HalpTranslateSystemBusAddress(
|
|
IN PBUS_HANDLER BusHandler,
|
|
IN PBUS_HANDLER RootHandler,
|
|
IN PHYSICAL_ADDRESS BusAddress,
|
|
IN OUT PULONG AddressSpace,
|
|
OUT PPHYSICAL_ADDRESS TranslatedAddress
|
|
);
|
|
|
|
ULONG
|
|
HalpGetSystemInterruptVector(
|
|
IN PBUS_HANDLER BusHandler,
|
|
IN PBUS_HANDLER RootHandler,
|
|
IN ULONG BusInterruptLevel,
|
|
IN ULONG BusInterruptVector,
|
|
OUT PKIRQL Irql,
|
|
OUT PKAFFINITY Affinity
|
|
);
|
|
|
|
|
|
#ifdef ALLOC_PRAGMA
|
|
#pragma alloc_text(PAGE,HalpGetSystemInterruptVector)
|
|
#endif
|
|
|
|
|
|
BOOLEAN
|
|
HalpTranslateSystemBusAddress(
|
|
IN PBUS_HANDLER BusHandler,
|
|
IN PBUS_HANDLER RootHandler,
|
|
IN PHYSICAL_ADDRESS BusAddress,
|
|
IN OUT PULONG AddressSpace,
|
|
OUT PPHYSICAL_ADDRESS TranslatedAddress
|
|
)
|
|
|
|
/*++
|
|
|
|
Routine Description:
|
|
|
|
This function translates a bus-relative address space and address into
|
|
a system physical address.
|
|
|
|
Arguments:
|
|
|
|
BusAddress - Supplies the bus-relative address
|
|
|
|
AddressSpace - Supplies the address space number.
|
|
Returns the host address space number.
|
|
|
|
AddressSpace == 0 => memory space
|
|
AddressSpace == 1 => I/O space
|
|
|
|
TranslatedAddress - Supplies a pointer to return the translated address
|
|
|
|
Return Value:
|
|
|
|
A return value of TRUE indicates that a system physical address
|
|
corresponding to the supplied bus relative address and bus address
|
|
number has been returned in TranslatedAddress.
|
|
|
|
A return value of FALSE occurs if the translation for the address was
|
|
not possible
|
|
|
|
--*/
|
|
|
|
{
|
|
PSUPPORTED_RANGE pRange;
|
|
|
|
pRange = NULL;
|
|
switch (*AddressSpace) {
|
|
case 0:
|
|
// verify memory address is within buses memory limits
|
|
for (pRange = &BusHandler->BusAddresses->PrefetchMemory; pRange; pRange = pRange->Next) {
|
|
if (BusAddress.QuadPart >= pRange->Base &&
|
|
BusAddress.QuadPart <= pRange->Limit) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!pRange) {
|
|
for (pRange = &BusHandler->BusAddresses->Memory; pRange; pRange = pRange->Next) {
|
|
if (BusAddress.QuadPart >= pRange->Base &&
|
|
BusAddress.QuadPart <= pRange->Limit) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
// verify IO address is within buses IO limits
|
|
for (pRange = &BusHandler->BusAddresses->IO; pRange; pRange = pRange->Next) {
|
|
if (BusAddress.QuadPart >= pRange->Base &&
|
|
BusAddress.QuadPart <= pRange->Limit) {
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (pRange) {
|
|
TranslatedAddress->QuadPart = BusAddress.QuadPart + pRange->SystemBase;
|
|
*AddressSpace = pRange->SystemAddressSpace;
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
ULONG
|
|
HalpGetSystemInterruptVector(
|
|
IN PBUS_HANDLER BusHandler,
|
|
IN PBUS_HANDLER RootHandler,
|
|
IN ULONG BusInterruptLevel,
|
|
IN ULONG BusInterruptVector,
|
|
OUT PKIRQL Irql,
|
|
OUT PKAFFINITY Affinity
|
|
)
|
|
|
|
/*++
|
|
|
|
Routine Description:
|
|
|
|
Arguments:
|
|
|
|
BusInterruptLevel - Supplies the bus specific interrupt level.
|
|
|
|
BusInterruptVector - Supplies the bus specific interrupt vector.
|
|
|
|
Irql - Returns the system request priority.
|
|
|
|
Affinity - Returns the system wide irq affinity.
|
|
|
|
Return Value:
|
|
|
|
Returns the system interrupt vector corresponding to the specified device.
|
|
|
|
--*/
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER( BusHandler );
|
|
UNREFERENCED_PARAMETER( RootHandler );
|
|
UNREFERENCED_PARAMETER( BusInterruptVector );
|
|
|
|
|
|
if (BusInterruptLevel > HIGHEST_8259_VECTOR) {
|
|
//
|
|
// Invalid BusInterruptLevel, so return Affinity of 0x0000;
|
|
//
|
|
*Affinity = 0;
|
|
return(DEVICE_VECTORS);
|
|
|
|
} else {
|
|
|
|
*Affinity = 1;
|
|
|
|
//
|
|
// Translate BusInterruptLevel to IRQL
|
|
//
|
|
*Irql = HalpTranslateVectorToIrql(BusInterruptLevel);
|
|
|
|
//
|
|
// The vector is equal to the specified bus level + DEVICE_VECTORS.
|
|
//
|
|
return(BusInterruptLevel + DEVICE_VECTORS);
|
|
|
|
}
|
|
}
|
|
|