Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

alpha.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1993 Digital Equipment Corporation 00004 00005 Module Name: 00006 00007 alpha.h 00008 00009 Abstract: 00010 00011 The Alpha hardware specific header file. 00012 00013 Author: 00014 00015 Joe Notarangelo 31-Mar-1992 (based on mips.h by Dave Cutler) 00016 00017 Revision History: 00018 00019 Jeff McLeman (mcleman) 21-Jul-1992 00020 Add bus types for ISA and EISA 00021 00022 Thomas Van Baak (tvb) 9-Jul-1992 00023 00024 Created proper Alpha Exception and Trap structure definitions. 00025 00026 --*/ 00027 00028 #ifndef _ALPHAH_ 00029 #define _ALPHAH_ 00030 00031 00032 // begin_ntddk begin_wdm begin_nthal begin_ntndis 00033 00034 #if defined(_ALPHA_) 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 // 00040 // Types to use to contain PFNs and their counts. 00041 // 00042 00043 typedef ULONG PFN_COUNT; 00044 00045 typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER; 00046 typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER; 00047 00048 // 00049 // Define maximum size of flush multiple TB request. 00050 // 00051 00052 #define FLUSH_MULTIPLE_MAXIMUM 16 00053 00054 // 00055 // Indicate that the Alpha compiler supports the pragma textout construct. 00056 // 00057 00058 #define ALLOC_PRAGMA 1 00059 00060 // end_ntndis 00061 // 00062 // Include the Alpha instruction definitions 00063 // 00064 00065 #include "alphaops.h" 00066 00067 // 00068 // Include reference machine definitions. 00069 // 00070 00071 #include "alpharef.h" 00072 00073 // end_ntddk end_wdm 00074 00075 // 00076 // Define intrinsic PAL calls and their prototypes 00077 // 00078 void __di(void); 00079 void __MB(void); 00080 void __dtbis(void *); 00081 void __ei(void); 00082 void *__rdpcr(void); 00083 void *__rdthread(void); 00084 void __ssir(unsigned long); 00085 unsigned char __swpirql(unsigned char); 00086 void __tbia(void); 00087 void __tbis(void *); 00088 void __tbisasn(void *, unsigned long); 00089 00090 #if defined(_M_ALPHA) || defined(_M_AXP64) 00091 #pragma intrinsic(__di) 00092 #pragma intrinsic(__MB) 00093 #pragma intrinsic(__dtbis) 00094 #pragma intrinsic(__ei) 00095 #pragma intrinsic(__rdpcr) 00096 #pragma intrinsic(__rdthread) 00097 #pragma intrinsic(__ssir) 00098 #pragma intrinsic(__swpirql) 00099 #pragma intrinsic(__tbia) 00100 #pragma intrinsic(__tbis) 00101 #pragma intrinsic(__tbisasn) 00102 #endif 00103 00104 // 00105 // Define Alpha Axp Processor Ids. 00106 // 00107 00108 #if !defined(PROCESSOR_ALPHA_21064) 00109 #define PROCESSOR_ALPHA_21064 (21064) 00110 #endif // !PROCESSOR_ALPHA_21064 00111 00112 #if !defined(PROCESSOR_ALPHA_21164) 00113 #define PROCESSOR_ALPHA_21164 (21164) 00114 #endif // !PROCESSOR_ALPHA_21164 00115 00116 #if !defined(PROCESSOR_ALPHA_21066) 00117 #define PROCESSOR_ALPHA_21066 (21066) 00118 #endif // !PROCESSOR_ALPHA_21066 00119 00120 #if !defined(PROCESSOR_ALPHA_21068) 00121 #define PROCESSOR_ALPHA_21068 (21068) 00122 #endif // !PROCESSOR_ALPHA_21068 00123 00124 #if !defined(PROCESSOR_ALPHA_21164PC) 00125 #define PROCESSOR_ALPHA_21164PC (21165) 00126 #endif // !PROCESSOR_ALPHA_21164PC 00127 00128 #if !defined(PROCESSOR_ALPHA_21264) 00129 #define PROCESSOR_ALPHA_21264 (21264) 00130 #endif // !PROCESSOR_ALPHA_21264 00131 00132 // end_nthal 00133 00134 // 00135 // Define Processor Control Region Structure. 00136 // 00137 00138 typedef 00139 VOID 00140 (*PKTRAP_ROUTINE)( 00141 VOID 00142 ); 00143 00144 // begin_ntddk begin_nthal 00145 // 00146 // Define macro to generate import names. 00147 // 00148 00149 #define IMPORT_NAME(name) __imp_##name 00150 00151 // 00152 // Define length of interrupt vector table. 00153 // 00154 00155 #define MAXIMUM_VECTOR 256 00156 00157 // 00158 // Define bus error routine type. 00159 // 00160 00161 struct _EXCEPTION_RECORD; 00162 struct _KEXCEPTION_FRAME; 00163 struct _KTRAP_FRAME; 00164 00165 typedef 00166 BOOLEAN 00167 (*PKBUS_ERROR_ROUTINE) ( 00168 IN struct _EXCEPTION_RECORD *ExceptionRecord, 00169 IN struct _KEXCEPTION_FRAME *ExceptionFrame, 00170 IN struct _KTRAP_FRAME *TrapFrame 00171 ); 00172 00173 00174 #define PCR_MINOR_VERSION 1 00175 #define PCR_MAJOR_VERSION 1 00176 00177 typedef struct _KPCR { 00178 00179 // 00180 // Major and minor version numbers of the PCR. 00181 // 00182 00183 ULONG MinorVersion; 00184 ULONG MajorVersion; 00185 00186 // 00187 // Start of the architecturally defined section of the PCR. This section 00188 // may be directly addressed by vendor/platform specific PAL/HAL code and will 00189 // not change from version to version of NT. 00190 00191 // 00192 // PALcode information. 00193 // 00194 00195 ULONGLONG PalBaseAddress; 00196 ULONG PalMajorVersion; 00197 ULONG PalMinorVersion; 00198 ULONG PalSequenceVersion; 00199 ULONG PalMajorSpecification; 00200 ULONG PalMinorSpecification; 00201 00202 // 00203 // Firmware restart information. 00204 // 00205 00206 ULONGLONG FirmwareRestartAddress; 00207 PVOID RestartBlock; 00208 00209 // 00210 // Reserved per-processor region for the PAL (3K-8 bytes). 00211 // 00212 00213 ULONGLONG PalReserved[383]; 00214 00215 // 00216 // Alignment fixup count updated by PAL and read by kernel. 00217 // 00218 00219 ULONGLONG PalAlignmentFixupCount; 00220 00221 // 00222 // Panic Stack Address. 00223 // 00224 00225 PVOID PanicStack; 00226 00227 // 00228 // Processor parameters. 00229 // 00230 00231 ULONG ProcessorType; 00232 ULONG ProcessorRevision; 00233 ULONG PhysicalAddressBits; 00234 ULONG MaximumAddressSpaceNumber; 00235 ULONG PageSize; 00236 ULONG FirstLevelDcacheSize; 00237 ULONG FirstLevelDcacheFillSize; 00238 ULONG FirstLevelIcacheSize; 00239 ULONG FirstLevelIcacheFillSize; 00240 00241 // 00242 // System Parameters. 00243 // 00244 00245 ULONG FirmwareRevisionId; 00246 UCHAR SystemType[8]; 00247 ULONG SystemVariant; 00248 ULONG SystemRevision; 00249 UCHAR SystemSerialNumber[16]; 00250 ULONG CycleClockPeriod; 00251 ULONG SecondLevelCacheSize; 00252 ULONG SecondLevelCacheFillSize; 00253 ULONG ThirdLevelCacheSize; 00254 ULONG ThirdLevelCacheFillSize; 00255 ULONG FourthLevelCacheSize; 00256 ULONG FourthLevelCacheFillSize; 00257 00258 // 00259 // Pointer to processor control block. 00260 // 00261 00262 struct _KPRCB *Prcb; 00263 00264 // 00265 // Processor identification. 00266 // 00267 00268 CCHAR Number; 00269 KAFFINITY SetMember; 00270 00271 // 00272 // Reserved per-processor region for the HAL (.5K bytes). 00273 // 00274 00275 ULONGLONG HalReserved[64]; 00276 00277 // 00278 // IRQL mapping tables. 00279 // 00280 00281 ULONG IrqlTable[8]; 00282 00283 #define SFW_IMT_ENTRIES 4 00284 #define HDW_IMT_ENTRIES 128 00285 00286 struct _IRQLMASK { 00287 USHORT IrqlTableIndex; // synchronization irql level 00288 USHORT IDTIndex; // vector in IDT 00289 } IrqlMask[SFW_IMT_ENTRIES + HDW_IMT_ENTRIES]; 00290 00291 // 00292 // Interrupt Dispatch Table (IDT). 00293 // 00294 00295 PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR]; 00296 00297 // 00298 // Reserved vectors mask, these vectors cannot be attached to via 00299 // standard interrupt objects. 00300 // 00301 00302 ULONG ReservedVectors; 00303 00304 // 00305 // Complement of processor affinity mask. 00306 // 00307 00308 KAFFINITY NotMember; 00309 00310 ULONG InterruptInProgress; 00311 ULONG DpcRequested; 00312 00313 // 00314 // Pointer to machine check handler 00315 // 00316 00317 PKBUS_ERROR_ROUTINE MachineCheckError; 00318 00319 // 00320 // DPC Stack. 00321 // 00322 00323 PVOID DpcStack; 00324 00325 // 00326 // End of the architecturally defined section of the PCR. This section 00327 // may be directly addressed by vendor/platform specific HAL code and will 00328 // not change from version to version of NT. Some of these values are 00329 // reserved for chip-specific palcode. 00330 // end_ntddk end_nthal 00331 // 00332 00333 // 00334 // Start of the operating system release dependent section of the PCR. 00335 // This section may change from release to release and should not be 00336 // addressed by vendor/platform specific HAL code. 00337 00338 ULONG Spare1; 00339 00340 // 00341 // Current process id. 00342 // 00343 00344 ULONG CurrentPid; 00345 00346 // 00347 // Spare field. 00348 // 00349 00350 ULONG Spare2; 00351 00352 // 00353 // System service dispatch start and end address used by get/set context. 00354 // 00355 00356 ULONG_PTR SystemServiceDispatchStart; 00357 ULONG_PTR SystemServiceDispatchEnd; 00358 00359 // 00360 // Pointer to Idle thread. 00361 // 00362 00363 struct _KTHREAD *IdleThread; 00364 00365 00366 } KPCR, *PKPCR; // ntddk nthal 00367 00368 // 00369 // Define Processor Status Register structure 00370 // 00371 00372 typedef struct _PSR { 00373 ULONG MODE: 1; 00374 ULONG INTERRUPT_ENABLE: 1; 00375 ULONG IRQL: 3; 00376 } PSR, *PPSR; 00377 00378 // 00379 // Define Interrupt Enable Register structure 00380 // 00381 00382 typedef struct _IE { 00383 ULONG SoftwareInterruptEnables: 2; 00384 ULONG HardwareInterruptEnables: 6; 00385 } IE, *PIE; 00386 00387 #define HARDWARE_PTE_DIRTY_MASK 0x4 00388 00389 00390 #if defined(_AXP64_) 00391 00392 #define _HARDWARE_PTE_WORKING_SET_BITS 14 00393 00394 typedef struct _HARDWARE_PTE { 00395 ULONGLONG Valid : 1; 00396 ULONGLONG Reserved1 : 1; 00397 ULONGLONG FaultOnWrite : 1; 00398 ULONGLONG Reserved2 : 1; 00399 ULONGLONG Global : 1; 00400 ULONGLONG GranularityHint : 2; 00401 ULONGLONG Reserved3 : 1; 00402 ULONGLONG KernelReadAccess : 1; 00403 ULONGLONG UserReadAccess : 1; 00404 ULONGLONG Reserved4 : 2; 00405 ULONGLONG KernelWriteAccess : 1; 00406 ULONGLONG UserWriteAccess : 1; 00407 ULONGLONG Reserved5 : 2; 00408 ULONGLONG Write : 1; 00409 ULONGLONG CopyOnWrite: 1; 00410 ULONGLONG SoftwareWsIndex : _HARDWARE_PTE_WORKING_SET_BITS; 00411 ULONGLONG PageFrameNumber : 32; 00412 } HARDWARE_PTE, *PHARDWARE_PTE; 00413 00414 // 00415 // Define initialize page directory base 00416 // 00417 00418 #define INITIALIZE_DIRECTORY_TABLE_BASE(dirbase, pfn) \ 00419 *((PULONGLONG)(dirbase)) = 0; \ 00420 ((PHARDWARE_PTE)(dirbase))->PageFrameNumber = pfn; \ 00421 ((PHARDWARE_PTE)(dirbase))->Write = 1; \ 00422 ((PHARDWARE_PTE)(dirbase))->KernelReadAccess = 1; \ 00423 ((PHARDWARE_PTE)(dirbase))->KernelWriteAccess = 1; \ 00424 ((PHARDWARE_PTE)(dirbase))->Global = 0; \ 00425 ((PHARDWARE_PTE)(dirbase))->FaultOnWrite = 0; \ 00426 ((PHARDWARE_PTE)(dirbase))->Valid = 1; 00427 00428 #else 00429 00430 typedef struct _HARDWARE_PTE { 00431 ULONG Valid: 1; 00432 ULONG Owner: 1; 00433 ULONG Dirty: 1; 00434 ULONG reserved: 1; 00435 ULONG Global: 1; 00436 ULONG GranularityHint: 2; 00437 ULONG Write: 1; 00438 ULONG CopyOnWrite: 1; 00439 ULONG PageFrameNumber: 23; 00440 } HARDWARE_PTE, *PHARDWARE_PTE; 00441 00442 // 00443 // Define initialize page directory base 00444 // 00445 00446 #define INITIALIZE_DIRECTORY_TABLE_BASE(dirbase, pfn) \ 00447 ((PHARDWARE_PTE)(dirbase))->PageFrameNumber = pfn; \ 00448 ((PHARDWARE_PTE)(dirbase))->Global = 0; \ 00449 ((PHARDWARE_PTE)(dirbase))->Dirty = 1; \ 00450 ((PHARDWARE_PTE)(dirbase))->Valid = 1; 00451 00452 #endif 00453 00454 00455 // begin_nthal 00456 // 00457 // Define some constants for bus type 00458 // 00459 00460 #define MACHINE_TYPE_ISA 0 00461 #define MACHINE_TYPE_EISA 2 00462 00463 // 00464 // Define pointer to Processor Control Registers 00465 // 00466 00467 #define PCR ((PKPCR)__rdpcr()) 00468 00469 // begin_ntddk 00470 00471 #if defined(_AXP64_) 00472 00473 #define KI_USER_SHARED_DATA 0xffffffffff000000UI64 00474 00475 #else 00476 00477 #define KI_USER_SHARED_DATA 0xff000000UL 00478 00479 #endif 00480 00481 #define SharedUserData ((KUSER_SHARED_DATA * const) KI_USER_SHARED_DATA) 00482 00483 // begin_wdm 00484 // 00485 // length of dispatch code in interrupt template 00486 // 00487 #define DISPATCH_LENGTH 4 00488 00489 // 00490 // Define IRQL levels across the architecture. 00491 // 00492 00493 #define PASSIVE_LEVEL 0 00494 #define LOW_LEVEL 0 00495 #define APC_LEVEL 1 00496 #define DISPATCH_LEVEL 2 00497 #define HIGH_LEVEL 7 00498 #define SYNCH_LEVEL (IPI_LEVEL-1) 00499 00500 // end_ntddk end_wdm end_nthal 00501 00502 #define KiProfileIrql PROFILE_LEVEL // enable portable code 00503 00504 // 00505 // Define interrupt levels that cannot be connected 00506 // 00507 00508 #define ILLEGAL_LEVEL ( (1<<0) | (1<<APC_LEVEL) | (1<<DISPATCH_LEVEL) | \ 00509 (1<<CLOCK_LEVEL) | (1<<IPI_LEVEL) ) 00510 // 00511 // Sanitize FPCR and PSR based on processor mode. 00512 // 00513 // ## tvb&jn - need to replace these with proper macros. 00514 // 00515 00516 #define SANITIZE_FPCR(fpcr, mode) (fpcr) 00517 00518 // 00519 // Define SANITIZE_PSR for Alpha. 00520 // 00521 // If kernel mode, then caller specifies psr 00522 // 00523 // If user mode, then 00524 // force mode bit to user (1) 00525 // force interrupt enable bit to true (1) 00526 // force irql to 0 00527 // 00528 // In both cases insure that extraneous bits are not set 00529 // 00530 00531 #define SANITIZE_PSR(psr, mode) \ 00532 ( ((mode) == KernelMode) ? \ 00533 (psr & 0x3f) : \ 00534 (0x3) ) 00535 00536 // begin_nthal 00537 // 00538 // Exception frame 00539 // 00540 // This frame is established when handling an exception. It provides a place 00541 // to save all nonvolatile registers. The volatile registers will already 00542 // have been saved in a trap frame. 00543 // 00544 // The layout of the record conforms to a standard call frame since it is 00545 // used as such. Thus it contains a place to save a return address and is 00546 // padded so that it is EXACTLY a multiple of 32 bytes in length. 00547 // 00548 // 00549 // N.B - the 32-byte alignment is more stringent than required by the 00550 // calling standard (which requires 16-byte alignment), the 32-byte alignment 00551 // is established for performance reasons in the interaction with the PAL. 00552 // 00553 00554 typedef struct _KEXCEPTION_FRAME { 00555 00556 ULONGLONG IntRa; // return address register, ra 00557 00558 ULONGLONG FltF2; // nonvolatile floating registers, f2 - f9 00559 ULONGLONG FltF3; 00560 ULONGLONG FltF4; 00561 ULONGLONG FltF5; 00562 ULONGLONG FltF6; 00563 ULONGLONG FltF7; 00564 ULONGLONG FltF8; 00565 ULONGLONG FltF9; 00566 00567 ULONGLONG IntS0; // nonvolatile integer registers, s0 - s5 00568 ULONGLONG IntS1; 00569 ULONGLONG IntS2; 00570 ULONGLONG IntS3; 00571 ULONGLONG IntS4; 00572 ULONGLONG IntS5; 00573 ULONGLONG IntFp; // frame pointer register, fp/s6 00574 00575 ULONGLONG SwapReturn; 00576 ULONG Psr; // processor status 00577 ULONG Fill[5]; // padding for 32-byte stack frame alignment 00578 // N.B. - Ulongs from the filler section are used 00579 // in ctxsw.s - do not delete 00580 00581 } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME; 00582 00583 // 00584 // Trap Frame 00585 // 00586 // This frame is established when handling a trap. It provides a place to 00587 // save all volatile registers. The nonvolatile registers are saved in an 00588 // exception frame or through the normal C calling conventions for saved 00589 // registers. 00590 // 00591 // The layout of the record conforms to a standard call frame since it is 00592 // used as such. Thus it contains a place to save a return address and is 00593 // padded so that it is EXACTLY a multiple of 32 bytes in length. 00594 // 00595 // 00596 // N.B - the 32-byte alignment is more stringent than required by the 00597 // calling standard (which requires 16-byte alignment), the 32-byte alignment 00598 // is established for performance reasons in the interaction with the PAL. 00599 // 00600 00601 typedef struct _KTRAP_FRAME { 00602 00603 // 00604 // Fields saved in the PALcode. 00605 // 00606 00607 ULONGLONG IntSp; // $30: stack pointer register, sp 00608 ULONGLONG Fir; // (fault instruction) continuation address 00609 ULONG Psr; // processor status 00610 ULONG Fill1[1]; // unused 00611 ULONGLONG IntFp; // $15: frame pointer register, fp/s6 00612 00613 ULONGLONG IntA0; // $16: argument registers, a0 - a3 00614 ULONGLONG IntA1; // $17: 00615 ULONGLONG IntA2; // $18: 00616 ULONGLONG IntA3; // $19: 00617 00618 ULONGLONG IntRa; // $26: return address register, ra 00619 ULONGLONG IntGp; // $29: global pointer register, gp 00620 UCHAR ExceptionRecord[(sizeof(EXCEPTION_RECORD) + 15) & (~15)]; 00621 00622 // 00623 // Volatile integer registers, s0 - s5 are nonvolatile. 00624 // 00625 00626 ULONGLONG IntV0; // $0: return value register, v0 00627 ULONGLONG IntT0; // $1: temporary registers, t0 - t7 00628 ULONGLONG IntT1; // $2: 00629 ULONGLONG IntT2; // $3: 00630 ULONGLONG IntT3; // $4: 00631 ULONGLONG IntT4; // $5: 00632 ULONGLONG IntT5; // $6: 00633 ULONGLONG IntT6; // $7: 00634 ULONGLONG IntT7; // $8: 00635 00636 ULONGLONG IntT8; // $22: temporary registers, t8 - t11 00637 ULONGLONG IntT9; // $23: 00638 ULONGLONG IntT10; // $24: 00639 ULONGLONG IntT11; // $25: 00640 00641 ULONGLONG IntT12; // $27: temporary register, t12 00642 ULONGLONG IntAt; // $28: assembler temporary register, at 00643 00644 ULONGLONG IntA4; // $20: remaining argument registers a4 - a5 00645 ULONGLONG IntA5; // $21: 00646 00647 // 00648 // Volatile floating point registers, f2 - f9 are nonvolatile. 00649 // 00650 00651 ULONGLONG FltF0; // $f0: 00652 ULONGLONG Fpcr; // floating point control register 00653 ULONGLONG FltF1; // $f1: 00654 00655 ULONGLONG FltF10; // $f10: temporary registers, $f10 - $f30 00656 ULONGLONG FltF11; // $f11: 00657 ULONGLONG FltF12; // $f12: 00658 ULONGLONG FltF13; // $f13: 00659 ULONGLONG FltF14; // $f14: 00660 ULONGLONG FltF15; // $f15: 00661 ULONGLONG FltF16; // $f16: 00662 ULONGLONG FltF17; // $f17: 00663 ULONGLONG FltF18; // $f18: 00664 ULONGLONG FltF19; // $f19: 00665 ULONGLONG FltF20; // $f20: 00666 ULONGLONG FltF21; // $f21: 00667 ULONGLONG FltF22; // $f22: 00668 ULONGLONG FltF23; // $f23: 00669 ULONGLONG FltF24; // $f24: 00670 ULONGLONG FltF25; // $f25: 00671 ULONGLONG FltF26; // $f26: 00672 ULONGLONG FltF27; // $f27: 00673 ULONGLONG FltF28; // $f28: 00674 ULONGLONG FltF29; // $f29: 00675 ULONGLONG FltF30; // $f30: 00676 00677 ULONG OldIrql; // Previous Irql. 00678 ULONG PreviousMode; // Previous Mode. 00679 ULONG_PTR TrapFrame; // 00680 ULONG Fill2[3]; // padding for 32-byte stack frame alignment 00681 00682 } KTRAP_FRAME, *PKTRAP_FRAME; 00683 00684 #define KTRAP_FRAME_LENGTH ((sizeof(KTRAP_FRAME) + 15) & ~15) 00685 #define KTRAP_FRAME_ALIGN (16) 00686 #define KTRAP_FRAME_ROUND (KTRAP_FRAME_ALIGN - 1) 00687 00688 // 00689 // Firmware Frame 00690 // 00691 // The firmware frame is similar to the trap frame, but is built by the PAL 00692 // code that is active when the OS Loader is running. It does not contain an 00693 // exception record or NT style exception information. 00694 // 00695 // Type field defintions and parameters. 00696 // 00697 00698 #define FW_EXC_MCHK 0xdec0 // p1=icPerrStat, p2=dcPerrStat 00699 #define FW_EXC_ARITH 0xdec1 // p1=excSum, p2=excMask 00700 #define FW_EXC_INTERRUPT 0xdec2 // p1=isr, p2=ipl, p3=intid 00701 #define FW_EXC_DFAULT 0xdec3 // p1=sp 00702 #define FW_EXC_ITBMISS 0xdec4 // none 00703 #define FW_EXC_ITBACV 0xdec5 // none 00704 #define FW_EXC_NDTBMISS 0xdec6 // p1=sp 00705 #define FW_EXC_PDTBMISS 0xdec7 // p1=sp 00706 #define FW_EXC_UNALIGNED 0xdec8 // p1=sp 00707 #define FW_EXC_OPCDEC 0xdec9 // p1=sp 00708 #define FW_EXC_FEN 0xdeca // p1=icsr 00709 #define FW_EXC_HALT 0xdecb // not used 00710 #define FW_EXC_BPT 0xdecc // p1=0 - user, p1=1 - kernel, p1=type - call kdbg 00711 #define FW_EXC_GENTRAP 0xdecd // p1=gentrap code 00712 #define FW_EXC_HALT_INTERRUPT 0xdece // p1=isr, p2=ipl, p3=intid 00713 00714 typedef struct _FIRMWARE_FRAME { 00715 ULONGLONG Type; 00716 ULONGLONG Param1; 00717 ULONGLONG Param2; 00718 ULONGLONG Param3; 00719 ULONGLONG Param4; 00720 ULONGLONG Param5; 00721 ULONGLONG Psr; 00722 ULONGLONG Mmcsr; 00723 ULONGLONG Va; 00724 ULONGLONG Fir; 00725 ULONGLONG IntV0; 00726 ULONGLONG IntT0; 00727 ULONGLONG IntT1; 00728 ULONGLONG IntT2; 00729 ULONGLONG IntT3; 00730 ULONGLONG IntT4; 00731 ULONGLONG IntT5; 00732 ULONGLONG IntT6; 00733 ULONGLONG IntT7; 00734 ULONGLONG IntS0; 00735 ULONGLONG IntS1; 00736 ULONGLONG IntS2; 00737 ULONGLONG IntS3; 00738 ULONGLONG IntS4; 00739 ULONGLONG IntS5; 00740 ULONGLONG IntFp; 00741 ULONGLONG IntA0; 00742 ULONGLONG IntA1; 00743 ULONGLONG IntA2; 00744 ULONGLONG IntA3; 00745 ULONGLONG IntA4; 00746 ULONGLONG IntA5; 00747 ULONGLONG IntT8; 00748 ULONGLONG IntT9; 00749 ULONGLONG IntT10; 00750 ULONGLONG IntT11; 00751 ULONGLONG IntRa; 00752 ULONGLONG IntT12; 00753 ULONGLONG IntAt; 00754 ULONGLONG IntGp; 00755 ULONGLONG IntSp; 00756 ULONGLONG IntZero; 00757 ULONGLONG FltF0; 00758 ULONGLONG FltF1; 00759 ULONGLONG FltF2; 00760 ULONGLONG FltF3; 00761 ULONGLONG FltF4; 00762 ULONGLONG FltF5; 00763 ULONGLONG FltF6; 00764 ULONGLONG FltF7; 00765 ULONGLONG FltF8; 00766 ULONGLONG FltF9; 00767 ULONGLONG FltF10; 00768 ULONGLONG FltF11; 00769 ULONGLONG FltF12; 00770 ULONGLONG FltF13; 00771 ULONGLONG FltF14; 00772 ULONGLONG FltF15; 00773 ULONGLONG FltF16; 00774 ULONGLONG FltF17; 00775 ULONGLONG FltF18; 00776 ULONGLONG FltF19; 00777 ULONGLONG FltF20; 00778 ULONGLONG FltF21; 00779 ULONGLONG FltF22; 00780 ULONGLONG FltF23; 00781 ULONGLONG FltF24; 00782 ULONGLONG FltF25; 00783 ULONGLONG FltF26; 00784 ULONGLONG FltF27; 00785 ULONGLONG FltF28; 00786 ULONGLONG FltF29; 00787 ULONGLONG FltF30; 00788 ULONGLONG FltF31; 00789 } FIRMWARE_FRAME, *PFIRMWARE_FRAME; 00790 00791 #define FIRMWARE_FRAME_LENGTH sizeof(FIRMWARE_FRAME) 00792 00793 // 00794 // The frame saved by KiCallUserMode is defined here to allow 00795 // the kernel debugger to trace the entire kernel stack 00796 // when usermode callouts are pending. 00797 // 00798 00799 typedef struct _KCALLOUT_FRAME { 00800 ULONGLONG F2; // saved floating registers f2 - f9 00801 ULONGLONG F3; 00802 ULONGLONG F4; 00803 ULONGLONG F5; 00804 ULONGLONG F6; 00805 ULONGLONG F7; 00806 ULONGLONG F8; 00807 ULONGLONG F9; 00808 ULONGLONG S0; // saved integer registers s0 - s5 00809 ULONGLONG S1; 00810 ULONGLONG S2; 00811 ULONGLONG S3; 00812 ULONGLONG S4; 00813 ULONGLONG S5; 00814 ULONGLONG FP; 00815 ULONGLONG CbStk; // saved callback stack address 00816 ULONGLONG InStk; // saved initial stack address 00817 ULONGLONG TrFr; // saved callback trap frame address 00818 ULONGLONG TrFir; 00819 ULONGLONG Ra; // saved return address 00820 ULONGLONG A0; // saved argument registers a0-a2 00821 ULONGLONG A1; 00822 } KCALLOUT_FRAME, *PKCALLOUT_FRAME; 00823 00824 typedef struct _UCALLOUT_FRAME { 00825 PVOID Buffer; 00826 ULONG Length; 00827 ULONG ApiNumber; 00828 ULONG Pad; 00829 ULONGLONG Sp; 00830 ULONGLONG Ra; 00831 } UCALLOUT_FRAME, *PUCALLOUT_FRAME; 00832 00833 // 00834 // Define Machine Check Status code that is passed in the exception 00835 // record for a machine check exception. 00836 // 00837 00838 typedef struct _MCHK_STATUS { 00839 ULONG Correctable: 1; 00840 ULONG Retryable: 1; 00841 } MCHK_STATUS, *PMCHK_STATUS; 00842 00843 // 00844 // Define the MCES register (Machine Check Error Summary). 00845 // 00846 00847 typedef struct _MCES { 00848 ULONG MachineCheck: 1; 00849 ULONG SystemCorrectable: 1; 00850 ULONG ProcessorCorrectable: 1; 00851 ULONG DisableProcessorCorrectable: 1; 00852 ULONG DisableSystemCorrectable: 1; 00853 ULONG DisableMachineChecks: 1; 00854 } MCES, *PMCES; 00855 00856 // end_nthal 00857 00858 // begin_ntddk begin_wdm 00859 // 00860 // Non-volatile floating point state 00861 // 00862 00863 typedef struct _KFLOATING_SAVE { 00864 ULONGLONG Fpcr; 00865 ULONGLONG SoftFpcr; 00866 ULONG Reserved1; // These reserved words are here to make it 00867 ULONG Reserved2; // the same size as i386/WDM. 00868 ULONG Reserved3; 00869 ULONG Reserved4; 00870 } KFLOATING_SAVE, *PKFLOATING_SAVE; 00871 00872 // end_ntddk end_wdm 00873 // 00874 // Define Alpha status code aliases. These are internal to PALcode and 00875 // kernel trap handling. 00876 // 00877 00878 #define STATUS_ALPHA_FLOATING_NOT_IMPLEMENTED STATUS_ILLEGAL_FLOAT_CONTEXT 00879 #define STATUS_ALPHA_ARITHMETIC_EXCEPTION STATUS_FLOAT_STACK_CHECK 00880 #define STATUS_ALPHA_GENTRAP STATUS_INSTRUCTION_MISALIGNMENT 00881 00882 // 00883 // Define status code for bad virtual address. This status differs from 00884 // those above in that it will be forwarded to the offending code. In lieu 00885 // of defining a new status code, we wlll alias this to an access violation. 00886 // Code can distinguish this error from an access violation by checking 00887 // the number of parameters: a standard access violation has 2 parameters, 00888 // while a non-canonical virtual address access violation will have 3 00889 // parameters (the third parameter is the upper 32-bits of the non-canonical 00890 // virtual address. 00891 // 00892 00893 #define STATUS_ALPHA_BAD_VIRTUAL_ADDRESS STATUS_ACCESS_VIOLATION 00894 00895 // begin_nthal 00896 // 00897 // Define the halt reason codes. 00898 // 00899 00900 #define AXP_HALT_REASON_HALT 0 00901 #define AXP_HALT_REASON_REBOOT 1 00902 #define AXP_HALT_REASON_RESTART 2 00903 #define AXP_HALT_REASON_POWERFAIL 3 00904 #define AXP_HALT_REASON_POWEROFF 4 00905 #define AXP_HALT_REASON_PALMCHK 6 00906 #define AXP_HALT_REASON_DBLMCHK 7 00907 00908 // 00909 // Processor State frame: Before a processor freezes itself, it 00910 // dumps the processor state to the processor state frame for 00911 // debugger to examine. This is used by KeFreezeExecution and 00912 // KeUnfreezeExecution routines. 00913 // (from mips.h)BUGBUG shielint Need to fill in the actual structure. 00914 // 00915 00916 typedef struct _KPROCESSOR_STATE { 00917 struct _CONTEXT ContextFrame; 00918 } KPROCESSOR_STATE, *PKPROCESSOR_STATE; 00919 00920 // begin_ntddk 00921 // 00922 // Processor Control Block (PRCB) 00923 // 00924 00925 #define PRCB_MINOR_VERSION 1 00926 #define PRCB_MAJOR_VERSION 2 00927 #define PRCB_BUILD_DEBUG 0x0001 00928 #define PRCB_BUILD_UNIPROCESSOR 0x0002 00929 00930 typedef struct _KPRCB { 00931 00932 // 00933 // Major and minor version numbers of the PCR. 00934 // 00935 00936 USHORT MinorVersion; 00937 USHORT MajorVersion; 00938 00939 // 00940 // Start of the architecturally defined section of the PRCB. This section 00941 // may be directly addressed by vendor/platform specific HAL code and will 00942 // not change from version to version of NT. 00943 // 00944 00945 struct _KTHREAD *CurrentThread; 00946 struct _KTHREAD *NextThread; 00947 struct _KTHREAD *IdleThread; 00948 CCHAR Number; 00949 CCHAR Reserved; 00950 USHORT BuildType; 00951 KAFFINITY SetMember; 00952 struct _RESTART_BLOCK *RestartBlock; 00953 00954 // 00955 // End of the architecturally defined section of the PRCB. This section 00956 // may be directly addressed by vendor/platform specific HAL code and will 00957 // not change from version to version of NT. 00958 // 00959 // end_ntddk end_nthal 00960 00961 ULONG InterruptCount; 00962 ULONG DpcTime; 00963 ULONG InterruptTime; 00964 ULONG KernelTime; 00965 ULONG UserTime; 00966 KDPC QuantumEndDpc; 00967 00968 // 00969 // Address of PCR. 00970 // 00971 00972 PKPCR Pcr; 00973 00974 // 00975 // MP Information. 00976 // 00977 00978 PVOID Spare2; 00979 PVOID Spare3; 00980 volatile ULONG IpiFrozen; 00981 struct _KPROCESSOR_STATE ProcessorState; 00982 ULONG LastDpcCount; 00983 ULONG DpcBypassCount; 00984 ULONG SoftwareInterrupts; 00985 PKTRAP_FRAME InterruptTrapFrame; 00986 ULONG ApcBypassCount; 00987 ULONG DispatchInterruptCount; 00988 ULONG DebugDpcTime; 00989 PVOID Spares[6]; 00990 00991 // 00992 // Spares. 00993 // 00994 00995 PVOID MoreSpares[3]; 00996 PKIPI_COUNTS IpiCounts; 00997 00998 // 00999 // Per-processor data for various hot code which resides in the 01000 // kernel image. We give each processor it's own copy of the data 01001 // to lessen the caching impact of sharing the data between multiple 01002 // processors. 01003 // 01004 01005 // 01006 // Spares (formerly fsrtl filelock free lists) 01007 // 01008 01009 PVOID SpareHotData[2]; 01010 01011 // 01012 // Cache manager performance counters. 01013 // 01014 01015 ULONG CcFastReadNoWait; 01016 ULONG CcFastReadWait; 01017 ULONG CcFastReadNotPossible; 01018 ULONG CcCopyReadNoWait; 01019 ULONG CcCopyReadWait; 01020 ULONG CcCopyReadNoWaitMiss; 01021 01022 // 01023 // Kernel performance counters. 01024 // 01025 01026 ULONG KeAlignmentFixupCount; 01027 ULONG KeContextSwitches; 01028 ULONG KeDcacheFlushCount; 01029 ULONG KeExceptionDispatchCount; 01030 ULONG KeFirstLevelTbFills; 01031 ULONG KeFloatingEmulationCount; 01032 ULONG KeIcacheFlushCount; 01033 ULONG KeSecondLevelTbFills; 01034 ULONG KeSystemCalls; 01035 ULONG KeByteWordEmulationCount; 01036 01037 // 01038 // Reserved for future counters. 01039 // 01040 01041 ULONG ReservedCounter[1]; 01042 01043 // 01044 // I/O system per processor single entry lookaside lists. 01045 // 01046 01047 PVOID SmallIrpFreeEntry; 01048 PVOID LargeIrpFreeEntry; 01049 PVOID MdlFreeEntry; 01050 01051 // 01052 // Object manager per processor single entry lookaside lists. 01053 // 01054 01055 PVOID CreateInfoFreeEntry; 01056 PVOID NameBufferFreeEntry; 01057 01058 // 01059 // Cache manager per processor single entry lookaside lists. 01060 // 01061 01062 PVOID SharedCacheMapEntry; 01063 01064 // 01065 // Spares (formerly fsrtl filelock free lists) 01066 // 01067 01068 PVOID MoreSpareHotData[2]; 01069 01070 // 01071 // Nonpaged per processor lookaside lists. 01072 // 01073 01074 PP_LOOKASIDE_LIST PPLookasideList[16]; 01075 01076 // 01077 // Nonpaged per processor small pool lookaside lists. 01078 // 01079 01080 PP_LOOKASIDE_LIST PPNPagedLookasideList[POOL_SMALL_LISTS]; 01081 01082 // 01083 // Paged per processor small pool lookaside lists. 01084 // 01085 01086 PP_LOOKASIDE_LIST PPPagedLookasideList[POOL_SMALL_LISTS]; 01087 01088 // 01089 // Per processor lock queue entries. 01090 // 01091 01092 KSPIN_LOCK_QUEUE LockQueue[16]; 01093 01094 // 01095 // Reserved Pad. 01096 // 01097 01098 #if !defined(_AXP64_) 01099 01100 UCHAR ReservedPad[16 * 8]; 01101 01102 #endif 01103 01104 // 01105 // MP interprocessor request packet and summary. 01106 // 01107 // N.B. This is carefully aligned to be on a cache line boundary. 01108 // 01109 01110 volatile PVOID CurrentPacket[3]; 01111 volatile KAFFINITY TargetSet; 01112 volatile PKIPI_WORKER WorkerRoutine; 01113 ULONG CachePad1[11]; 01114 01115 // 01116 // N.B. These two longwords must be on a quadword boundary and adjacent. 01117 // 01118 01119 volatile ULONGLONG RequestSummary; 01120 01121 // 01122 // Spare counters. 01123 // 01124 01125 ULONG Spare4[14]; 01126 ULONG DpcInterruptRequested; 01127 ULONG Spare5[17]; 01128 ULONG CachePad2[2]; 01129 ULONG MaximumDpcQueueDepth; 01130 ULONG MinimumDpcRate; 01131 ULONG AdjustDpcThreshold; 01132 ULONG DpcRequestRate; 01133 LARGE_INTEGER StartCount; 01134 // 01135 // DPC list head, spinlock, and count. 01136 // 01137 01138 LIST_ENTRY DpcListHead; 01139 KSPIN_LOCK DpcLock; 01140 ULONG DpcCount; 01141 ULONG QuantumEnd; 01142 ULONG DpcRoutineActive; 01143 ULONG DpcQueueDepth; 01144 01145 BOOLEAN SkipTick; 01146 01147 // 01148 // Processor's power state 01149 // 01150 PROCESSOR_POWER_STATE PowerState; 01151 01152 } KPRCB, *PKPRCB, *RESTRICTED_POINTER PRKPRCB; // ntddk nthal 01153 01154 // begin_ntddk begin_wdm begin_nthal begin_ntndis 01155 // 01156 // I/O space read and write macros. 01157 // 01158 // These have to be actual functions on Alpha, because we need 01159 // to shift the VA and OR in the BYTE ENABLES. 01160 // 01161 // These can become INLINEs if we require that ALL Alpha systems shift 01162 // the same number of bits and have the SAME byte enables. 01163 // 01164 // The READ/WRITE_REGISTER_* calls manipulate I/O registers in MEMORY space? 01165 // 01166 // The READ/WRITE_PORT_* calls manipulate I/O registers in PORT space? 01167 // 01168 01169 NTHALAPI 01170 UCHAR 01171 READ_REGISTER_UCHAR( 01172 PUCHAR Register 01173 ); 01174 01175 NTHALAPI 01176 USHORT 01177 READ_REGISTER_USHORT( 01178 PUSHORT Register 01179 ); 01180 01181 NTHALAPI 01182 ULONG 01183 READ_REGISTER_ULONG( 01184 PULONG Register 01185 ); 01186 01187 NTHALAPI 01188 VOID 01189 READ_REGISTER_BUFFER_UCHAR( 01190 PUCHAR Register, 01191 PUCHAR Buffer, 01192 ULONG Count 01193 ); 01194 01195 NTHALAPI 01196 VOID 01197 READ_REGISTER_BUFFER_USHORT( 01198 PUSHORT Register, 01199 PUSHORT Buffer, 01200 ULONG Count 01201 ); 01202 01203 NTHALAPI 01204 VOID 01205 READ_REGISTER_BUFFER_ULONG( 01206 PULONG Register, 01207 PULONG Buffer, 01208 ULONG Count 01209 ); 01210 01211 01212 NTHALAPI 01213 VOID 01214 WRITE_REGISTER_UCHAR( 01215 PUCHAR Register, 01216 UCHAR Value 01217 ); 01218 01219 NTHALAPI 01220 VOID 01221 WRITE_REGISTER_USHORT( 01222 PUSHORT Register, 01223 USHORT Value 01224 ); 01225 01226 NTHALAPI 01227 VOID 01228 WRITE_REGISTER_ULONG( 01229 PULONG Register, 01230 ULONG Value 01231 ); 01232 01233 NTHALAPI 01234 VOID 01235 WRITE_REGISTER_BUFFER_UCHAR( 01236 PUCHAR Register, 01237 PUCHAR Buffer, 01238 ULONG Count 01239 ); 01240 01241 NTHALAPI 01242 VOID 01243 WRITE_REGISTER_BUFFER_USHORT( 01244 PUSHORT Register, 01245 PUSHORT Buffer, 01246 ULONG Count 01247 ); 01248 01249 NTHALAPI 01250 VOID 01251 WRITE_REGISTER_BUFFER_ULONG( 01252 PULONG Register, 01253 PULONG Buffer, 01254 ULONG Count 01255 ); 01256 01257 NTHALAPI 01258 UCHAR 01259 READ_PORT_UCHAR( 01260 PUCHAR Port 01261 ); 01262 01263 NTHALAPI 01264 USHORT 01265 READ_PORT_USHORT( 01266 PUSHORT Port 01267 ); 01268 01269 NTHALAPI 01270 ULONG 01271 READ_PORT_ULONG( 01272 PULONG Port 01273 ); 01274 01275 NTHALAPI 01276 VOID 01277 READ_PORT_BUFFER_UCHAR( 01278 PUCHAR Port, 01279 PUCHAR Buffer, 01280 ULONG Count 01281 ); 01282 01283 NTHALAPI 01284 VOID 01285 READ_PORT_BUFFER_USHORT( 01286 PUSHORT Port, 01287 PUSHORT Buffer, 01288 ULONG Count 01289 ); 01290 01291 NTHALAPI 01292 VOID 01293 READ_PORT_BUFFER_ULONG( 01294 PULONG Port, 01295 PULONG Buffer, 01296 ULONG Count 01297 ); 01298 01299 NTHALAPI 01300 VOID 01301 WRITE_PORT_UCHAR( 01302 PUCHAR Port, 01303 UCHAR Value 01304 ); 01305 01306 NTHALAPI 01307 VOID 01308 WRITE_PORT_USHORT( 01309 PUSHORT Port, 01310 USHORT Value 01311 ); 01312 01313 NTHALAPI 01314 VOID 01315 WRITE_PORT_ULONG( 01316 PULONG Port, 01317 ULONG Value 01318 ); 01319 01320 NTHALAPI 01321 VOID 01322 WRITE_PORT_BUFFER_UCHAR( 01323 PUCHAR Port, 01324 PUCHAR Buffer, 01325 ULONG Count 01326 ); 01327 01328 NTHALAPI 01329 VOID 01330 WRITE_PORT_BUFFER_USHORT( 01331 PUSHORT Port, 01332 PUSHORT Buffer, 01333 ULONG Count 01334 ); 01335 01336 NTHALAPI 01337 VOID 01338 WRITE_PORT_BUFFER_ULONG( 01339 PULONG Port, 01340 PULONG Buffer, 01341 ULONG Count 01342 ); 01343 01344 // end_ntndis end_wdm 01345 // 01346 // Define Interlocked operation result values. 01347 // 01348 01349 #define RESULT_ZERO 0 01350 #define RESULT_NEGATIVE 1 01351 #define RESULT_POSITIVE 2 01352 01353 // 01354 // Interlocked result type is portable, but its values are machine specific. 01355 // Constants for value are in i386.h, mips.h, etc. 01356 // 01357 01358 typedef enum _INTERLOCKED_RESULT { 01359 ResultNegative = RESULT_NEGATIVE, 01360 ResultZero = RESULT_ZERO, 01361 ResultPositive = RESULT_POSITIVE 01362 } INTERLOCKED_RESULT; 01363 01364 // 01365 // Convert portable interlock interfaces to architecture specific interfaces. 01366 // 01367 01368 #define ExInterlockedIncrementLong(Addend, Lock) \ 01369 ExAlphaInterlockedIncrementLong(Addend) 01370 01371 #define ExInterlockedDecrementLong(Addend, Lock) \ 01372 ExAlphaInterlockedDecrementLong(Addend) 01373 01374 #define ExInterlockedExchangeAddLargeInteger(Target, Value, Lock) \ 01375 ExpInterlockedExchangeAddLargeInteger(Target, Value) 01376 01377 #define ExInterlockedExchangeUlong(Target, Value, Lock) \ 01378 ExAlphaInterlockedExchangeUlong(Target, Value) 01379 01380 NTKERNELAPI 01381 INTERLOCKED_RESULT 01382 ExAlphaInterlockedIncrementLong ( 01383 IN PLONG Addend 01384 ); 01385 01386 NTKERNELAPI 01387 INTERLOCKED_RESULT 01388 ExAlphaInterlockedDecrementLong ( 01389 IN PLONG Addend 01390 ); 01391 01392 NTKERNELAPI 01393 LARGE_INTEGER 01394 ExpInterlockedExchangeAddLargeInteger ( 01395 IN PLARGE_INTEGER Addend, 01396 IN LARGE_INTEGER Increment 01397 ); 01398 01399 NTKERNELAPI 01400 ULONG 01401 ExAlphaInterlockedExchangeUlong ( 01402 IN PULONG Target, 01403 IN ULONG Value 01404 ); 01405 01406 // begin_wdm 01407 01408 #if defined(_M_ALPHA) && !defined(RC_INVOKED) 01409 01410 #define InterlockedIncrement _InterlockedIncrement 01411 #define InterlockedDecrement _InterlockedDecrement 01412 #define InterlockedExchange _InterlockedExchange 01413 #define InterlockedExchangeAdd _InterlockedExchangeAdd 01414 01415 LONG 01416 InterlockedIncrement ( 01417 IN OUT PLONG Addend 01418 ); 01419 01420 LONG 01421 InterlockedDecrement ( 01422 IN OUT PLONG Addend 01423 ); 01424 01425 LONG 01426 InterlockedExchange ( 01427 IN OUT PLONG Target, 01428 LONG Value 01429 ); 01430 01431 #if defined(_M_AXP64) 01432 01433 #define InterlockedCompareExchange _InterlockedCompareExchange 01434 #define InterlockedCompareExchange64 _InterlockedCompareExchange64 01435 #define InterlockedExchangePointer _InterlockedExchangePointer 01436 #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer 01437 #define InterlockedExchange64 _InterlockedExchange64 01438 01439 LONG 01440 InterlockedCompareExchange ( 01441 IN OUT PLONG Destination, 01442 IN LONG ExChange, 01443 IN LONG Comperand 01444 ); 01445 01446 LONGLONG 01447 InterlockedCompareExchange64 ( 01448 IN OUT PLONGLONG Destination, 01449 IN LONGLONG ExChange, 01450 IN LONGLONG Comperand 01451 ); 01452 01453 PVOID 01454 InterlockedExchangePointer ( 01455 IN OUT PVOID *Target, 01456 IN PVOID Value 01457 ); 01458 01459 PVOID 01460 InterlockedCompareExchangePointer ( 01461 IN OUT PVOID *Destination, 01462 IN PVOID ExChange, 01463 IN PVOID Comperand 01464 ); 01465 01466 LONGLONG 01467 InterlockedExchange64( 01468 IN OUT PLONGLONG Target, 01469 IN LONGLONG Value 01470 ); 01471 01472 #pragma intrinsic(_InterlockedCompareExchange64) 01473 #pragma intrinsic(_InterlockedExchangePointer) 01474 #pragma intrinsic(_InterlockedCompareExchangePointer) 01475 #pragma intrinsic(_InterlockedExchange64) 01476 01477 #else 01478 01479 #define InterlockedExchangePointer(Target, Value) \ 01480 (PVOID)InterlockedExchange((PLONG)(Target), (LONG)(Value)) 01481 01482 #define InterlockedCompareExchange(Destination, ExChange, Comperand) \ 01483 (LONG)_InterlockedCompareExchange((PVOID *)(Destination), (PVOID)(ExChange), (PVOID)(Comperand)) 01484 01485 #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \ 01486 _InterlockedCompareExchange(Destination, ExChange, Comperand) 01487 01488 PVOID 01489 _InterlockedCompareExchange ( 01490 IN OUT PVOID *Destination, 01491 IN PVOID ExChange, 01492 IN PVOID Comperand 01493 ); 01494 01495 NTKERNELAPI 01496 LONGLONG 01497 ExpInterlockedCompareExchange64 ( 01498 IN OUT PLONGLONG Destination, 01499 IN PLONGLONG Exchange, 01500 IN PLONGLONG Comperand 01501 ); 01502 01503 #endif 01504 01505 LONG 01506 InterlockedExchangeAdd( 01507 IN OUT PLONG Addend, 01508 IN LONG Value 01509 ); 01510 01511 #pragma intrinsic(_InterlockedIncrement) 01512 #pragma intrinsic(_InterlockedDecrement) 01513 #pragma intrinsic(_InterlockedExchange) 01514 #pragma intrinsic(_InterlockedExchangeAdd) 01515 #pragma intrinsic(_InterlockedCompareExchange) 01516 01517 #endif 01518 01519 // there is a lot of other stuff that could go in here 01520 // probe macros 01521 // others 01522 // end_ntddk end_wdm end_nthal 01523 // 01524 // Intrinsic interlocked functions. 01525 // 01526 01527 01528 // begin_ntddk begin_wdm begin_nthal begin_ntndis 01529 01530 // 01531 // Define the page size for the Alpha ev4 and lca as 8k. 01532 // 01533 01534 #define PAGE_SIZE 0x2000 01535 01536 // 01537 // Define the number of trailing zeroes in a page aligned virtual address. 01538 // This is used as the shift count when shifting virtual addresses to 01539 // virtual page numbers. 01540 // 01541 01542 #define PAGE_SHIFT 13L 01543 01544 // end_ntddk end_wdm end_nthal end_ntndis 01545 01546 // 01547 // Define the number of bits to shift to right justify the Page Directory Index 01548 // field of a PTE. 01549 // 01550 01551 #if defined(_AXP64_) 01552 01553 #define PDI_SHIFT 23 01554 #define PDI1_SHIFT 33 01555 #define PDI2_SHIFT 23 01556 #define PDI_MASK 0x3ff 01557 01558 #else 01559 01560 #define PDI_SHIFT 24 01561 01562 #endif 01563 01564 // 01565 // Define the number of bits to shift to right justify the Page Table Index 01566 // field of a PTE. 01567 // 01568 01569 #define PTI_SHIFT 13 01570 01571 // 01572 // Define the maximum address space number allowable for the architecture. 01573 // 01574 01575 #define ALPHA_AXP_MAXIMUM_ASN 0xffffffff 01576 01577 // begin_ntddk begin_nthal 01578 01579 // 01580 // The highest user address reserves 64K bytes for a guard page. This is so 01581 // the probing of addresses from kernel mode only have to check the 01582 // starting address for structures of 64K bytes or less. 01583 // 01584 01585 #if defined(_AXP64_) 01586 01587 #define MM_HIGHEST_USER_ADDRESS (PVOID)0x3FFFFFEFFFF // highest user address 01588 #define MM_USER_PROBE_ADDRESS 0x3FFFFFF0000UI64 // guard page address 01589 #define MM_SYSTEM_RANGE_START (PVOID)0xFFFFFC0000000000 // start of system space 01590 01591 #else 01592 01593 #define MM_HIGHEST_USER_ADDRESS (PVOID)0x7FFEFFFF // highest user address 01594 #define MM_USER_PROBE_ADDRESS 0x7FFF0000 // starting address of guard page 01595 #define MM_SYSTEM_RANGE_START (PVOID)KSEG0_BASE // start of system space 01596 01597 #endif 01598 01599 01600 // 01601 // The following definitions are required for the debugger data block. 01602 // 01603 01604 extern PVOID MmHighestUserAddress; 01605 extern PVOID MmSystemRangeStart; 01606 extern ULONG_PTR MmUserProbeAddress; 01607 01608 // 01609 // The lowest user address reserves the low 64k. 01610 // 01611 01612 #define MM_LOWEST_USER_ADDRESS (PVOID)0x00010000 01613 01614 // begin_wdm 01615 01616 #define MmGetProcedureAddress(Address) (Address) 01617 #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address) 01618 01619 // end_ntddk end_wdm end_nthal 01620 01621 // 01622 // Define the page table base and the page directory base for 01623 // the TB miss routines and memory management. 01624 // 01625 01626 #if defined(_AXP64_) 01627 01628 #define PDE_TBASE 0xFFFFFE0180600000UI64 // first level PDR address 01629 #define PDE_SELFMAP 0xFFFFFE0180601800UI64 // first level PDR self map address 01630 #define PDE_UBASE 0xFFFFFE0180000000UI64 // user second level PDR address 01631 #define PDE_KBASE 0xFFFFFE01807FE000UI64 // kernel second level PDR address 01632 #define PDE_BASE PDE_KBASE // kernel second level PDR address 01633 #define PTE_BASE 0xFFFFFE0000000000UI64 // page table address 01634 #define PDE64_BASE 0xFFFFFE0180600000UI64 // first level PDR address 01635 #define PTE64_BASE 0xFFFFFE0000000000UI64 // page table address 01636 #define VA_SHIFT (63 - 42) // address sign extend shift count 01637 01638 #else 01639 01640 #define PDE_BASE (ULONG)0xC0180000 // first level PDR address 01641 #define PDE_SELFMAP (ULONG)0xC0180300 // first level PDR self map address 01642 #define PTE_BASE (ULONG)0xC0000000 // page table address 01643 #define PDE64_BASE (ULONG)0xC0184000 // first level 64-bit PDR address 01644 #define PTE64_BASE (ULONG)0xC2000000 // 64-bit page table address 01645 01646 #endif 01647 01648 // 01649 // Generate kernel segment physical address. 01650 // 01651 01652 #if defined(_AXP64_) 01653 01654 #define KSEG_ADDRESS(FrameNumber) \ 01655 ((PVOID)(KSEG43_BASE | ((ULONG_PTR)(FrameNumber) << PAGE_SHIFT))) 01656 01657 #else 01658 01659 #define KSEG_ADDRESS(FrameNumber) \ 01660 ((PVOID)(KSEG0_BASE | ((ULONG)(FrameNumber) << PAGE_SHIFT))) 01661 01662 #endif 01663 01664 // begin_ntddk begin_wdm 01665 // 01666 // The lowest address for system space. 01667 // 01668 01669 #if defined(_AXP64_) 01670 01671 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFFFE0200000000 01672 01673 #else 01674 01675 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 01676 01677 #endif 01678 01679 // end_ntddk end_wdm 01680 01681 #if defined(_AXP64_) 01682 01683 #define SYSTEM_BASE 0xFFFFFE0200000000 // start of system space (no typecast) 01684 01685 #else 01686 01687 #define SYSTEM_BASE 0xc0800000 // start of system space (no typecast) 01688 01689 #endif 01690 01691 // begin_nthal begin_ntddk begin_wdm 01692 01693 // 01694 // Define prototypes to access PCR values 01695 // 01696 01697 NTKERNELAPI 01698 KIRQL 01699 KeGetCurrentIrql(); 01700 01701 // end_nthal end_ntddk end_wdm 01702 01703 #define KeGetCurrentThread() ((struct _KTHREAD *) __rdthread()) 01704 01705 // begin_ntddk begin_wdm 01706 01707 NTSTATUS 01708 KeSaveFloatingPointState ( 01709 OUT PKFLOATING_SAVE FloatSave 01710 ); 01711 01712 NTSTATUS 01713 KeRestoreFloatingPointState ( 01714 IN PKFLOATING_SAVE FloatSave 01715 ); 01716 01717 // end_ntddk end_wdm 01718 // begin_nthal 01719 01720 #define KeGetPreviousMode() (KeGetCurrentThread()->PreviousMode) 01721 01722 #define KeGetDcacheFillSize() PCR->FirstLevelDcacheFillSize 01723 01724 // 01725 // Test if executing DPC. 01726 // 01727 01728 BOOLEAN 01729 KeIsExecutingDpc ( 01730 VOID 01731 ); 01732 01733 // 01734 // Return interrupt trap frame 01735 // 01736 PKTRAP_FRAME 01737 KeGetInterruptTrapFrame( 01738 VOID 01739 ); 01740 01741 // begin_ntddk 01742 // 01743 // Get address of current PRCB. 01744 // 01745 01746 #define KeGetCurrentPrcb() (PCR->Prcb) 01747 01748 // 01749 // Get current processor number. 01750 // 01751 01752 #define KeGetCurrentProcessorNumber() KeGetCurrentPrcb()->Number 01753 01754 // end_ntddk 01755 01756 // 01757 // Define interface to get pcr address 01758 // 01759 01760 PKPCR KeGetPcr(VOID); 01761 01762 // end_nthal 01763 01764 // 01765 // Data cache, instruction cache, I/O buffer, and write buffer flush routine 01766 // prototypes. 01767 // 01768 01769 VOID 01770 KeSweepDcache ( 01771 IN BOOLEAN AllProcessors 01772 ); 01773 01774 #define KeSweepCurrentDcache() \ 01775 HalSweepDcache(); 01776 01777 VOID 01778 KeSweepIcache ( 01779 IN BOOLEAN AllProcessors 01780 ); 01781 01782 VOID 01783 KeSweepIcacheRange ( 01784 IN BOOLEAN AllProcessors, 01785 IN PVOID BaseAddress, 01786 IN ULONG_PTR Length 01787 ); 01788 01789 #define KeSweepCurrentIcache() \ 01790 HalSweepIcache(); 01791 01792 VOID 01793 KeFlushIcacheRange ( 01794 IN BOOLEAN AllProcessors, 01795 IN PVOID BaseAddress, 01796 IN ULONG_PTR Length 01797 ); 01798 01799 // begin_ntddk begin_wdm begin_ntndis begin_nthal 01800 // 01801 // Cache and write buffer flush functions. 01802 // 01803 01804 VOID 01805 KeFlushIoBuffers ( 01806 IN PMDL Mdl, 01807 IN BOOLEAN ReadOperation, 01808 IN BOOLEAN DmaOperation 01809 ); 01810 01811 // end_ntddk end_wdm end_ntndis 01812 01813 // 01814 // Clock, profile, and interprocessor interrupt functions. 01815 // 01816 01817 struct _KEXCEPTION_FRAME; 01818 struct _KTRAP_FRAME; 01819 01820 NTKERNELAPI 01821 VOID 01822 KeIpiInterrupt ( 01823 IN struct _KTRAP_FRAME *TrapFrame 01824 ); 01825 01826 #define KeYieldProcessor() 01827 01828 NTKERNELAPI 01829 VOID 01830 KeProfileInterrupt ( 01831 VOID 01832 ); 01833 01834 NTKERNELAPI 01835 VOID 01836 KeProfileInterruptWithSource ( 01837 IN KPROFILE_SOURCE ProfileSource 01838 ); 01839 01840 NTKERNELAPI 01841 VOID 01842 KeUpdateRunTime ( 01843 VOID 01844 ); 01845 01846 NTKERNELAPI 01847 VOID 01848 KeUpdateSystemTime ( 01849 IN ULONG TimeIncrement 01850 ); 01851 01852 // 01853 // The following function prototypes are exported for use in MP HALs. 01854 // 01855 01856 01857 #if defined(NT_UP) 01858 01859 #define KiAcquireSpinLock(SpinLock) 01860 01861 #else 01862 01863 VOID 01864 KiAcquireSpinLock ( 01865 IN PKSPIN_LOCK SpinLock 01866 ); 01867 01868 #endif 01869 01870 #if defined(NT_UP) 01871 01872 #define KiReleaseSpinLock(SpinLock) 01873 01874 #else 01875 01876 VOID 01877 KiReleaseSpinLock ( 01878 IN PKSPIN_LOCK SpinLock 01879 ); 01880 01881 #endif 01882 01883 // end_nthal 01884 01885 // 01886 // KeTestSpinLock may be used to spin at low IRQL until the lock is 01887 // available. The IRQL must then be raised and the lock acquired with 01888 // KeTryToAcquireSpinLock. If that fails, lower the IRQL and start again. 01889 // 01890 01891 #if defined(NT_UP) 01892 01893 #define KeTestSpinLock(SpinLock) (TRUE) 01894 01895 #else 01896 01897 BOOLEAN 01898 KeTestSpinLock ( 01899 IN PKSPIN_LOCK SpinLock 01900 ); 01901 01902 #endif 01903 01904 01905 // 01906 // Fill TB entry. 01907 // 01908 01909 #define KeFillEntryTb(Pte, Virtual, Invalid) \ 01910 if (Invalid != FALSE) { \ 01911 KeFlushSingleTb(Virtual, FALSE, FALSE, Pte, *Pte); \ 01912 } 01913 01914 // 01915 // Define machine-specific external references. 01916 // 01917 01918 extern ULONG KiInterruptTemplate[]; 01919 01920 // 01921 // Define machine-dependent function prototypes. 01922 // 01923 01924 VOID 01925 KeFlushDcache ( 01926 IN BOOLEAN AllProcessors, 01927 IN PVOID BaseAddress OPTIONAL, 01928 IN ULONG Length 01929 ); 01930 01931 ULONG 01932 KiCopyInformation ( 01933 IN OUT PEXCEPTION_RECORD ExceptionRecord1, 01934 IN PEXCEPTION_RECORD ExceptionRecord2 01935 ); 01936 01937 BOOLEAN 01938 KiEmulateByteWord( 01939 IN OUT PEXCEPTION_RECORD ExceptionRecord, 01940 IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, 01941 IN OUT struct _KTRAP_FRAME *TrapFrame 01942 ); 01943 01944 BOOLEAN 01945 KiEmulateFloating ( 01946 IN OUT PEXCEPTION_RECORD ExceptionRecord, 01947 IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, 01948 IN OUT struct _KTRAP_FRAME *TrapFrame, 01949 IN OUT PSW_FPCR SoftwareFpcr 01950 ); 01951 01952 BOOLEAN 01953 KiEmulateReference ( 01954 IN OUT PEXCEPTION_RECORD ExceptionRecord, 01955 IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, 01956 IN OUT struct _KTRAP_FRAME *TrapFrame, 01957 IN BOOLEAN QuadwordOnly 01958 ); 01959 01960 BOOLEAN 01961 KiFloatingException ( 01962 IN OUT PEXCEPTION_RECORD ExceptionRecord, 01963 IN OUT struct _KEXCEPTION_FRAME *ExceptionFrame, 01964 IN OUT struct _KTRAP_FRAME *TrapFrame, 01965 IN BOOLEAN ImpreciseTrap, 01966 OUT PULONG SoftFpcrCopy 01967 ); 01968 01969 ULONGLONG 01970 KiGetRegisterValue ( 01971 IN ULONG Register, 01972 IN struct _KEXCEPTION_FRAME *ExceptionFrame, 01973 IN struct _KTRAP_FRAME *TrapFrame 01974 ); 01975 01976 VOID 01977 KiSetFloatingStatus ( 01978 IN OUT PEXCEPTION_RECORD ExceptionRecord 01979 ); 01980 01981 VOID 01982 KiSetRegisterValue ( 01983 IN ULONG Register, 01984 IN ULONGLONG Value, 01985 OUT struct _KEXCEPTION_FRAME *ExceptionFrame, 01986 OUT struct _KTRAP_FRAME *TrapFrame 01987 ); 01988 01989 VOID 01990 KiRequestSoftwareInterrupt ( 01991 KIRQL RequestIrql 01992 ); 01993 01994 // 01995 // Define query system time macro. 01996 // 01997 01998 #if _AXP64_ 01999 #define KiQuerySystemTime(CurrentTime) \ 02000 while (TRUE) { \ 02001 (CurrentTime)->HighPart = SharedUserData->SystemHigh1Time; \ 02002 (CurrentTime)->LowPart = SharedUserData->SystemLowTime; \ 02003 if ((CurrentTime)->HighPart == SharedUserData->SystemHigh2Time) break; \ 02004 } 02005 #else 02006 #define KiQuerySystemTime(CurrentTime) \ 02007 *(PULONGLONG)(CurrentTime) = SharedUserData->SystemTime 02008 #endif 02009 02010 // 02011 // Define query tick count macro. 02012 // 02013 02014 #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) 02015 02016 // begin_wdm begin_ntddk 02017 02018 #define KeQueryTickCount(CurrentCount ) \ 02019 *(PULONGLONG)(CurrentCount) = **((volatile ULONGLONG **)(&KeTickCount)); 02020 02021 // end_wdm end_ntddk 02022 02023 #else 02024 02025 // begin_nthal 02026 #define KiQueryTickCount(CurrentCount) \ 02027 *(PULONGLONG)(CurrentCount) = KeTickCount; 02028 02029 VOID 02030 KeQueryTickCount ( 02031 OUT PLARGE_INTEGER CurrentCount 02032 ); 02033 02034 // end_nthal 02035 #endif 02036 02037 #define KiQueryLowTickCount() (ULONG)KeTickCount 02038 02039 #define KiQueryInterruptTime(CurrentTime) \ 02040 *(PULONGLONG)(CurrentTime) = SharedUserData->InterruptTime 02041 02042 // 02043 // Define executive macros for acquiring and releasing executive spinlocks. 02044 // These macros can ONLY be used by executive components and NOT by drivers. 02045 // Drivers MUST use the kernel interfaces since they must be MP enabled on 02046 // all systems. 02047 // 02048 // KeRaiseIrql is one instruction shorter than KeAcquireSpinLock on Alpha UP. 02049 // KeLowerIrql is one instruction shorter than KeReleaseSpinLock. 02050 // 02051 02052 #if defined(NT_UP) && !defined(_NTDDK_) && !defined(_NTIFS_) 02053 #define ExAcquireSpinLock(Lock, OldIrql) KeRaiseIrql(DISPATCH_LEVEL, (OldIrql)) 02054 #define ExReleaseSpinLock(Lock, OldIrql) KeLowerIrql((OldIrql)) 02055 #define ExAcquireSpinLockAtDpcLevel(Lock) 02056 #define ExReleaseSpinLockFromDpcLevel(Lock) 02057 #else 02058 02059 // begin_wdm begin_ntddk 02060 02061 #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql)) 02062 #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql)) 02063 #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock) 02064 #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock) 02065 02066 // end_wdm end_ntddk 02067 02068 #endif 02069 02070 // 02071 // The acquire and release fast lock macros disable and enable interrupts 02072 // on UP nondebug systems. On MP or debug systems, the spinlock routines 02073 // are used. 02074 // 02075 // N.B. Extreme caution should be observed when using these routines. 02076 // 02077 02078 #if defined(_M_ALPHA) 02079 02080 #define _disable() __di() 02081 #define _enable() __ei() 02082 02083 #endif 02084 02085 #if defined(NT_UP) && !DBG 02086 #define ExAcquireFastLock(Lock, OldIrql) \ 02087 ExAcquireSpinLock(Lock, OldIrql) 02088 #else 02089 #define ExAcquireFastLock(Lock, OldIrql) \ 02090 ExAcquireSpinLock(Lock, OldIrql) 02091 #endif 02092 02093 #if defined(NT_UP) && !DBG 02094 #define ExReleaseFastLock(Lock, OldIrql) \ 02095 ExReleaseSpinLock(Lock, OldIrql) 02096 #else 02097 #define ExReleaseFastLock(Lock, OldIrql) \ 02098 ExReleaseSpinLock(Lock, OldIrql) 02099 #endif 02100 02101 02102 // 02103 // Alpha function definitions 02104 // 02105 02106 //++ 02107 // 02108 // BOOLEAN 02109 // KiIsThreadNumericStateSaved( 02110 // IN PKTHREAD Address 02111 // ) 02112 // 02113 // This call is used on a not running thread to see if it's numeric 02114 // state has been saved in its context information. On Alpha the 02115 // numeric state is always saved. 02116 // 02117 //-- 02118 02119 #define KiIsThreadNumericStateSaved(a) TRUE 02120 02121 //++ 02122 // 02123 // VOID 02124 // KiRundownThread( 02125 // IN PKTHREAD Address 02126 // ) 02127 // 02128 //-- 02129 02130 #define KiRundownThread(a) 02131 02132 // 02133 // Alpha Feature bit definitions 02134 // 02135 #define KF_BYTE 0x00000001 02136 02137 // 02138 // Define macro to test if x86 feature is present. 02139 // 02140 // N.B. All x86 features test TRUE on Alpha systems. 02141 // 02142 02143 #define Isx86FeaturePresent(_f_) TRUE 02144 02145 // begin_ntddk begin_wdm begin_nthal begin_ntndis 02146 #ifdef __cplusplus 02147 } // extern "C" 02148 #endif 02149 #endif // _ALPHA_ 02150 // end_ntddk end_wdm end_nthal end_ntndis 02151 02152 #endif // _ALPHAH_

Generated on Sat May 15 19:39:15 2004 for test by doxygen 1.3.7