/*++ Copyright (c) 1993 Digital Equipment Corporation Module Name: alpha.h Abstract: The Alpha hardware specific header file. Author: Joe Notarangelo 31-Mar-1992 (based on mips.h by Dave Cutler) Revision History: Jeff McLeman (mcleman) 21-Jul-1992 Add bus types for ISA and EISA Thomas Van Baak (tvb) 9-Jul-1992 Created proper Alpha Exception and Trap structure definitions. --*/ #ifndef _ALPHAH_ #define _ALPHAH_ // begin_ntddk begin_nthal begin_ntndis #if defined(_ALPHA_) // // Define maximum size of flush multple TB request. // #define FLUSH_MULTIPLE_MAXIMUM 16 // // Indicate that the MIPS compiler supports the pragma textout construct. // #define ALLOC_PRAGMA 1 // end_ntndis // // Include the alpha instruction definitions // #include "alphaops.h" // // Include reference machine definitions. // #include "alpharef.h" // end_ntddk // // Define intrinsic PAL calls and their prototypes // void __di(void); void __MB(void); void __dtbis(void *); void __ei(void); void *__rdpcr(void); void *__rdthread(void); void __ssir(unsigned long); unsigned char __swpirql(unsigned char); void __tbia(void); void __tbis(void *); void __tbisasn(void *, unsigned long); #ifdef _M_ALPHA #pragma intrinsic(__di) #pragma intrinsic(__MB) #pragma intrinsic(__dtbis) #pragma intrinsic(__ei) #pragma intrinsic(__rdpcr) #pragma intrinsic(__rdthread) #pragma intrinsic(__ssir) #pragma intrinsic(__swpirql) #pragma intrinsic(__tbia) #pragma intrinsic(__tbis) #pragma intrinsic(__tbisasn) #endif // // Define Alpha Axp Processor Ids. // #if !defined(PROCESSOR_ALPHA_21064) #define PROCESSOR_ALPHA_21064 (21064) #endif // !PROCESSOR_ALPHA_21064 #if !defined(PROCESSOR_ALPHA_21164) #define PROCESSOR_ALPHA_21164 (21164) #endif // !PROCESSOR_ALPHA_21164 #if !defined(PROCESSOR_ALPHA_21066) #define PROCESSOR_ALPHA_21066 (21066) #endif // !PROCESSOR_ALPHA_21066 #if !defined(PROCESSOR_ALPHA_21068) #define PROCESSOR_ALPHA_21068 (21068) #endif // !PROCESSOR_ALPHA_21068 // end_nthal // // Define Processor Control Region Structure. // typedef VOID (*PKTRAP_ROUTINE)( VOID ); // begin_ntddk begin_nthal begin_ntndis // // Define function decoration depending on whether a driver, a file system, // or a kernel component is being built. // #if (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)) && !defined (_BLDR_) #define NTKERNELAPI DECLSPEC_IMPORT #else #define NTKERNELAPI #endif // // Define function decoration depending on whether the HAL or other kernel // component is being build. // #if !defined(_NTHAL_) && !defined(_BLDR_) #define NTHALAPI DECLSPEC_IMPORT #else #define NTHALAPI #endif // end_ntndis // // Define macro to generate import names. // #define IMPORT_NAME(name) __imp_##name // // Define length of interrupt vector table. // #define MAXIMUM_VECTOR 256 // // Define bus error routine type. // struct _EXCEPTION_RECORD; struct _KEXCEPTION_FRAME; struct _KTRAP_FRAME; typedef BOOLEAN (*PKBUS_ERROR_ROUTINE) ( IN struct _EXCEPTION_RECORD *ExceptionRecord, IN struct _KEXCEPTION_FRAME *ExceptionFrame, IN struct _KTRAP_FRAME *TrapFrame ); #define PCR_MINOR_VERSION 1 #define PCR_MAJOR_VERSION 1 typedef struct _KPCR { // // Major and minor version numbers of the PCR. // ULONG MinorVersion; ULONG MajorVersion; // // Start of the architecturally defined section of the PCR. This section // may be directly addressed by vendor/platform specific PAL/HAL code and will // not change from version to version of NT. // // PALcode information. // ULONGLONG PalBaseAddress; ULONG PalMajorVersion; ULONG PalMinorVersion; ULONG PalSequenceVersion; ULONG PalMajorSpecification; ULONG PalMinorSpecification; // // Firmware restart information. // ULONGLONG FirmwareRestartAddress; PVOID RestartBlock; // // Reserved per-processor region for the PAL (3K bytes). // ULONGLONG PalReserved[384]; // // Panic Stack Address. // ULONG PanicStack; // // Processor parameters. // ULONG ProcessorType; ULONG ProcessorRevision; ULONG PhysicalAddressBits; ULONG MaximumAddressSpaceNumber; ULONG PageSize; ULONG FirstLevelDcacheSize; ULONG FirstLevelDcacheFillSize; ULONG FirstLevelIcacheSize; ULONG FirstLevelIcacheFillSize; // // System Parameters. // ULONG FirmwareRevisionId; UCHAR SystemType[8]; ULONG SystemVariant; ULONG SystemRevision; UCHAR SystemSerialNumber[16]; ULONG CycleClockPeriod; ULONG SecondLevelCacheSize; ULONG SecondLevelCacheFillSize; ULONG ThirdLevelCacheSize; ULONG ThirdLevelCacheFillSize; ULONG FourthLevelCacheSize; ULONG FourthLevelCacheFillSize; // // Pointer to processor control block. // struct _KPRCB *Prcb; // // Processor identification. // CCHAR Number; KAFFINITY SetMember; // // Reserved per-processor region for the HAL (.5K bytes). // ULONGLONG HalReserved[64]; // // IRQL mapping tables. // ULONG IrqlTable[8]; #define SFW_IMT_ENTRIES 4 #define HDW_IMT_ENTRIES 128 struct _IRQLMASK { USHORT IrqlTableIndex; // synchronization irql level USHORT IDTIndex; // vector in IDT } IrqlMask[SFW_IMT_ENTRIES + HDW_IMT_ENTRIES]; // // Interrupt Dispatch Table (IDT). // PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR]; // // Reserved vectors mask, these vectors cannot be attached to via // standard interrupt objects. // ULONG ReservedVectors; // // Complement of processor affinity mask. // KAFFINITY NotMember; ULONG InterruptInProgress; ULONG DpcRequested; // // Pointer to machine check handler // PKBUS_ERROR_ROUTINE MachineCheckError; // // DPC Stack. // ULONG DpcStack; // // End of the architecturally defined section of the PCR. This section // may be directly addressed by vendor/platform specific HAL code and will // not change from version to version of NT. Some of these values are // reserved for chip-specific palcode. // end_ntddk end_nthal // // // Start of the operating system release dependent section of the PCR. // This section may change from release to release and should not be // addressed by vendor/platform specific HAL code. ULONG Spare1; // // Current process id. // ULONG CurrentPid; // // Spare field. // ULONG Spare2; // // System service dispatch start and end address used by get/set context. // ULONG SystemServiceDispatchStart; ULONG SystemServiceDispatchEnd; // // Pointer to Idle thread. // struct _KTHREAD *IdleThread; } KPCR, *PKPCR; // ntddk nthal // // Define Processor Status Register structure // typedef struct _PSR { ULONG MODE: 1; ULONG INTERRUPT_ENABLE: 1; ULONG IRQL: 3; } PSR, *PPSR; // // Define Interrupt Enable Register structure // typedef struct _IE { ULONG SoftwareInterruptEnables: 2; ULONG HardwareInterruptEnables: 6; } IE, *PIE; // // Define pte for nt on alpha // typedef struct _HARDWARE_PTE { ULONG Valid: 1; ULONG Owner: 1; ULONG Dirty: 1; ULONG reserved: 1; ULONG Global: 1; ULONG GranularityHint: 2; ULONG Write: 1; ULONG CopyOnWrite: 1; ULONG PageFrameNumber: 23; } HARDWARE_PTE, *PHARDWARE_PTE; #define HARDWARE_PTE_DIRTY_MASK 0x4 // // Define initialize page directory base // #define INITIALIZE_DIRECTORY_TABLE_BASE(dirbase, pfn) \ ((PHARDWARE_PTE)(dirbase))->PageFrameNumber = pfn; \ ((PHARDWARE_PTE)(dirbase))->Global = 0; \ ((PHARDWARE_PTE)(dirbase))->Dirty = 1; \ ((PHARDWARE_PTE)(dirbase))->Valid = 1; // begin_nthal // // Define the Alpha save area used in the ARC restart block. // // N.B. - it is assumed that the ARC save area within the restart block // will remain allocated on an 8 byte boundary. // typedef struct _ALPHA_RESTART_SAVE_AREA { // // Control information // ULONG HaltReason; PVOID LogoutFrame; ULONGLONG PalBase; // // Integer Save State // ULONGLONG IntV0; ULONGLONG IntT0; ULONGLONG IntT1; ULONGLONG IntT2; ULONGLONG IntT3; ULONGLONG IntT4; ULONGLONG IntT5; ULONGLONG IntT6; ULONGLONG IntT7; ULONGLONG IntS0; ULONGLONG IntS1; ULONGLONG IntS2; ULONGLONG IntS3; ULONGLONG IntS4; ULONGLONG IntS5; ULONGLONG IntFp; ULONGLONG IntA0; ULONGLONG IntA1; ULONGLONG IntA2; ULONGLONG IntA3; ULONGLONG IntA4; ULONGLONG IntA5; ULONGLONG IntT8; ULONGLONG IntT9; ULONGLONG IntT10; ULONGLONG IntT11; ULONGLONG IntRa; ULONGLONG IntT12; ULONGLONG IntAT; ULONGLONG IntGp; ULONGLONG IntSp; ULONGLONG IntZero; // // Floating Point Save State // ULONGLONG Fpcr; ULONGLONG FltF0; ULONGLONG FltF1; ULONGLONG FltF2; ULONGLONG FltF3; ULONGLONG FltF4; ULONGLONG FltF5; ULONGLONG FltF6; ULONGLONG FltF7; ULONGLONG FltF8; ULONGLONG FltF9; ULONGLONG FltF10; ULONGLONG FltF11; ULONGLONG FltF12; ULONGLONG FltF13; ULONGLONG FltF14; ULONGLONG FltF15; ULONGLONG FltF16; ULONGLONG FltF17; ULONGLONG FltF18; ULONGLONG FltF19; ULONGLONG FltF20; ULONGLONG FltF21; ULONGLONG FltF22; ULONGLONG FltF23; ULONGLONG FltF24; ULONGLONG FltF25; ULONGLONG FltF26; ULONGLONG FltF27; ULONGLONG FltF28; ULONGLONG FltF29; ULONGLONG FltF30; ULONGLONG FltF31; // // Architected Internal Processor State. // ULONG Asn; ULONG GeneralEntry; ULONG Iksp; ULONG InterruptEntry; ULONG Kgp; ULONG Mces; ULONG MemMgmtEntry; ULONG PanicEntry; ULONG Pcr; ULONG Pdr; ULONG Psr; ULONG ReiRestartAddress; ULONG Sirr; ULONG SyscallEntry; ULONG Teb; ULONG Thread; // // Processor Implementation-dependent State. // ULONGLONG PerProcessorState[175]; // allocate 2K maximum restart block } ALPHA_RESTART_SAVE_AREA, *PALPHA_RESTART_SAVE_AREA; // // Define some constants for bus type // #define MACHINE_TYPE_ISA 0 #define MACHINE_TYPE_EISA 2 // // Define pointer to Processor Control Registers // #define PCR ((PKPCR)__rdpcr()) #define KI_USER_SHARED_DATA 0xff000000 #define SharedUserData ((KUSER_SHARED_DATA * const) KI_USER_SHARED_DATA) // begin_ntddk // // length of dispatch code in interrupt template // #define DISPATCH_LENGTH 4 // // Define IRQL levels across the architecture. // #define PASSIVE_LEVEL 0 #define LOW_LEVEL 0 #define APC_LEVEL 1 #define DISPATCH_LEVEL 2 #define HIGH_LEVEL 7 #define SYNCH_LEVEL (IPI_LEVEL-1) // end_ntddk end_nthal #define KiProfileIrql PROFILE_LEVEL // enable portable code // // Define interrupt levels that cannot be connected // #define ILLEGAL_LEVEL ( (1<<0) | (1<PreviousMode) #define KeGetDcacheFillSize() PCR->FirstLevelDcacheFillSize // // Test if executing DPC. // BOOLEAN KeIsExecutingDpc ( VOID ); // begin_ntddk // // Get address of current PRCB. // #define KeGetCurrentPrcb() (PCR->Prcb) // // Get current processor number. // #define KeGetCurrentProcessorNumber() KeGetCurrentPrcb()->Number // end_ntddk // // Define interface to get pcr address // PKPCR KeGetPcr(VOID); // end_nthal // // Data cache, instruction cache, I/O buffer, and write buffer flush routine // prototypes. // VOID KeSweepDcache ( IN BOOLEAN AllProcessors ); #define KeSweepCurrentDcache() \ HalSweepDcache(); VOID KeSweepIcache ( IN BOOLEAN AllProcessors ); VOID KeSweepIcacheRange ( IN BOOLEAN AllProcessors, IN PVOID BaseAddress, IN ULONG Length ); #define KeSweepCurrentIcache() \ HalSweepIcache(); VOID KeFlushIcacheRange ( IN BOOLEAN AllProcessors, IN PVOID BaseAddress, IN ULONG Length ); // begin_ntddk begin_ntndis begin_nthal // // Cache and write buffer flush functions. // VOID KeFlushIoBuffers ( IN PMDL Mdl, IN BOOLEAN ReadOperation, IN BOOLEAN DmaOperation ); // end_ntddk end_ntndis // // Clock, profile, and interprocessor interrupt functions. // struct _KEXCEPTION_FRAME; struct _KTRAP_FRAME; NTKERNELAPI VOID KeIpiInterrupt ( IN struct _KTRAP_FRAME *TrapFrame ); NTKERNELAPI VOID KeProfileInterrupt ( IN struct _KTRAP_FRAME *TrapFrame ); NTKERNELAPI VOID KeProfileInterruptWithSource ( IN struct _KTRAP_FRAME *TrapFrame, IN KPROFILE_SOURCE ProfileSource ); NTKERNELAPI VOID KeUpdateRuntime ( IN struct _KTRAP_FRAME *TrapFrame ); NTKERNELAPI VOID KeUpdateSystemTime ( IN struct _KTRAP_FRAME *TrapFrame ); // // The following function prototypes are exported for use in MP HALs. // #if defined(NT_UP) #define KiAcquireSpinLock(SpinLock) #else VOID KiAcquireSpinLock ( IN PKSPIN_LOCK SpinLock ); #endif #if defined(NT_UP) #define KiReleaseSpinLock(SpinLock) #else VOID KiReleaseSpinLock ( IN PKSPIN_LOCK SpinLock ); #endif // end_nthal // // Fill TB entry. // #define KeFillEntryTb(Pte, Virtual, Invalid) \ if (Invalid != FALSE) { \ KeFlushSingleTb(Virtual, FALSE, FALSE, Pte, *Pte); \ } // // Define machine-specific external references. // extern ULONG KiInterruptTemplate[]; // // Define machine-dependent function protoypes. // VOID KeFlushDcache ( IN BOOLEAN AllProcessors, IN PVOID BaseAddress OPTIONAL, IN ULONG Length ); ULONG KiCopyInformation ( IN OUT PEXCEPTION_RECORD ExceptionRecord1, IN PEXCEPTION_RECORD ExceptionRecord2 ); BOOLEAN KiEmulateByteWord( IN OUT PEXCEPTION_RECORD ExceptionRecord, IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, IN OUT struct _KTRAP_FRAME *TrapFrame ); BOOLEAN KiEmulateFloating ( IN OUT PEXCEPTION_RECORD ExceptionRecord, IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, IN OUT struct _KTRAP_FRAME *TrapFrame, IN OUT PSW_FPCR SoftwareFpcr ); BOOLEAN KiEmulateReference ( IN OUT PEXCEPTION_RECORD ExceptionRecord, IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, IN OUT struct _KTRAP_FRAME *TrapFrame, IN BOOLEAN QuadwordOnly ); BOOLEAN KiFloatingException ( IN OUT PEXCEPTION_RECORD ExceptionRecord, IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, IN OUT struct _KTRAP_FRAME *TrapFrame, IN BOOLEAN ImpreciseTrap, OUT PULONG SoftFpcrCopy ); ULONGLONG KiGetRegisterValue ( IN ULONG Register, IN struct _KEXCEPTION_FRAME *ExceptionFrame, IN struct _KTRAP_FRAME *TrapFrame ); VOID KiSetFloatingStatus ( IN OUT PEXCEPTION_RECORD ExceptionRecord ); VOID KiSetRegisterValue ( IN ULONG Register, IN ULONGLONG Value, OUT struct _KEXCEPTION_FRAME *ExceptionFrame, OUT struct _KTRAP_FRAME *TrapFrame ); VOID KiRequestSoftwareInterrupt ( KIRQL RequestIrql ); // // Define query system time macro. // #define KiQuerySystemTime(CurrentTime) \ *(PULONGLONG)(CurrentTime) = SharedUserData->SystemTime // // Define query tick count macro. // // begin_ntddk begin_nthal #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) #define KeQueryTickCount(CurrentCount ) \ *(PULONGLONG)(CurrentCount) = **((volatile ULONGLONG **)(&KeTickCount)); #else #define KiQueryTickCount(CurrentCount) \ *(PULONGLONG)(CurrentCount) = KeTickCount; VOID KeQueryTickCount ( OUT PLARGE_INTEGER CurrentCount ); #endif // end_ntddk end_nthal #define KiQueryLowTickCount() (ULONG)KeTickCount #define KiQueryInterruptTime(CurrentTime) \ *(PULONGLONG)(CurrentTime) = SharedUserData->InterruptTime // // Define executive macros for acquiring and releasing executive spinlocks. // These macros can ONLY be used by executive components and NOT by drivers. // Drivers MUST use the kernel interfaces since they must be MP enabled on // all systems. // // KeRaiseIrql is one instruction shorter than KeAcquireSpinLock on Alpha UP. // KeLowerIrql is one instruction shorter than KeReleaseSpinLock. // // begin_ntddk begin_ntifs #if defined(NT_UP) && !defined(_NTDDK_) && !defined(_NTIFS_) #define ExAcquireSpinLock(Lock, OldIrql) KeRaiseIrql(DISPATCH_LEVEL, (OldIrql)) #define ExReleaseSpinLock(Lock, OldIrql) KeLowerIrql((OldIrql)) #define ExAcquireSpinLockAtDpcLevel(Lock) #define ExReleaseSpinLockFromDpcLevel(Lock) #else #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql)) #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql)) #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock) #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock) #endif // end_ntddk end_ntifs // // The acquire and release fast lock macros disable and enable interrupts // on UP nondebug systems. On MP or debug systems, the spinlock routines // are used. // // N.B. Extreme caution should be observed when using these routines. // #if defined(_M_ALPHA) #define _disable() __di() #define _enable() __ei() #endif #if defined(NT_UP) && !DBG #define ExAcquireFastLock(Lock, OldIrql) \ ExAcquireSpinLock(Lock, OldIrql) #else #define ExAcquireFastLock(Lock, OldIrql) \ ExAcquireSpinLock(Lock, OldIrql) #endif #if defined(NT_UP) && !DBG #define ExReleaseFastLock(Lock, OldIrql) \ ExReleaseSpinLock(Lock, OldIrql) #else #define ExReleaseFastLock(Lock, OldIrql) \ ExReleaseSpinLock(Lock, OldIrql) #endif // // Alpha function definitions // //++ // // BOOLEAN // KiIsThreadNumericStateSaved( // IN PKTHREAD Address // ) // // This call is used on a not running thread to see if it's numeric // state has been saved in it's context information. On alpha the // numeric state is always saved. // //-- #define KiIsThreadNumericStateSaved(a) TRUE //++ // // VOID // KiRundownThread( // IN PKTHREAD Address // ) // //-- #define KiRundownThread(a) // // Define macro to test if x86 feature is present. // // N.B. All x86 features test TRUE on Alpha systems. // #define Isx86FeaturePresent(_f_) TRUE // begin_ntddk begin_nthal begin_ntndis #endif // _ALPHA_ // end_ntddk end_nthal end_ntndis #endif // _ALPHAH_