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

pat.c File Reference

#include "ki.h"
#include "pat.h"

Go to the source code of this file.

Classes

struct  _NEW_PAT

Defines

#define DBGMSG(a)

Typedefs

typedef _NEW_PAT NEW_PAT
typedef _NEW_PATPNEW_PAT

Functions

VOID KeRestorePAT (VOID)
VOID KiInitializePAT (VOID)
VOID KiLoadPAT (IN PNEW_PAT Context)
VOID KiLoadPATTarget (IN PKIPI_CONTEXT SignalDone, IN PVOID Context, IN PVOID Parameter2, IN PVOID Parameter3)
VOID KiSynchronizePATLoad (IN PNEW_PAT Context)


Define Documentation

#define DBGMSG  ) 
 

Definition at line 31 of file pat.c.


Typedef Documentation

typedef struct _NEW_PAT NEW_PAT
 

typedef struct _NEW_PAT * PNEW_PAT
 

Referenced by KiLoadPATTarget().


Function Documentation

VOID KeRestorePAT VOID   ) 
 

Definition at line 94 of file pat.c.

References KeFeatureBits, KF_PAT, and KiInitializePAT().

00098 : 00099 00100 Reinitialize the Page Attribute Table (PAT) on all processors. 00101 00102 N.B. The caller must have the PAGELK code locked 00103 00104 Arguments: 00105 00106 None. 00107 00108 Return Value: 00109 00110 None. 00111 --*/ 00112 { 00113 if (KeFeatureBits & KF_PAT) { 00114 KiInitializePAT(); 00115 } 00116 }

VOID KiInitializePAT VOID   ) 
 

Referenced by KeRestorePAT(), and KiInitMachineDependent().

VOID KiLoadPAT IN PNEW_PAT  Context  ) 
 

Definition at line 289 of file pat.c.

References Index, KiDisableInterrupts(), KiRestoreInterrupts(), KiSynchronizePATLoad(), PAT_MSR, and WRMSR().

Referenced by KiInitializePAT(), and KiLoadPATTarget().

00294 : 00295 00296 This function loads the PAT to all processors. 00297 00298 Arguments: 00299 00300 Context - Context which includes new PAT to load 00301 00302 Return Value: 00303 00304 PAT on all processors programmed to new values 00305 00306 --*/ 00307 { 00308 BOOLEAN Enable; 00309 ULONG HldCr0, HldCr4, Index; 00310 00311 // 00312 // Disable interrupts 00313 // 00314 00315 Enable = KiDisableInterrupts(); 00316 00317 // 00318 // Synchronize all processors 00319 // 00320 00321 KiSynchronizePATLoad (Context); 00322 00323 _asm { 00324 ; 00325 ; Get current CR0 00326 ; 00327 00328 mov eax, cr0 00329 mov HldCr0, eax 00330 00331 ; 00332 ; Disable caching & line fill 00333 ; 00334 00335 and eax, not CR0_NW 00336 or eax, CR0_CD 00337 mov cr0, eax 00338 00339 ; 00340 ; Flush caches 00341 ; 00342 00343 ; 00344 ; wbinvd 00345 ; 00346 00347 _emit 0Fh 00348 _emit 09h 00349 00350 ; 00351 ; Get current cr4 00352 ; 00353 00354 _emit 0Fh 00355 _emit 20h 00356 _emit 0E0h ; mov eax, cr4 00357 mov HldCr4, eax 00358 00359 ; 00360 ; Disable global page 00361 ; 00362 00363 and eax, not CR4_PGE 00364 _emit 0Fh 00365 _emit 22h 00366 _emit 0E0h ; mov cr4, eax 00367 00368 ; 00369 ; Flush TLB 00370 ; 00371 00372 mov eax, cr3 00373 mov cr3, eax 00374 } 00375 00376 // 00377 // Synchronize all processors 00378 // 00379 00380 KiSynchronizePATLoad (Context); 00381 00382 // 00383 // Load new PAT 00384 // 00385 00386 WRMSR (PAT_MSR, Context->Attributes.QuadPart); 00387 00388 // 00389 // Synchronize all processors 00390 // 00391 00392 KiSynchronizePATLoad (Context); 00393 00394 _asm { 00395 00396 ; 00397 ; Flush caches. 00398 ; 00399 00400 ; 00401 ; wbinvd 00402 ; 00403 00404 _emit 0Fh 00405 _emit 09h 00406 00407 ; 00408 ; Flush TLBs 00409 ; 00410 00411 mov eax, cr3 00412 mov cr3, eax 00413 } 00414 00415 // 00416 // Synchronize all processors 00417 // 00418 00419 KiSynchronizePATLoad (Context); 00420 00421 _asm { 00422 ; 00423 ; Restore CR4 (global page enable) 00424 ; 00425 00426 mov eax, HldCr4 00427 _emit 0Fh 00428 _emit 22h 00429 _emit 0E0h ; mov cr4, eax 00430 00431 ; 00432 ; Restore CR0 (cache enable) 00433 ; 00434 00435 mov eax, HldCr0 00436 mov cr0, eax 00437 } 00438 00439 // 00440 // Restore interrupts and return 00441 // 00442 00443 KiRestoreInterrupts (Enable); 00444 }

VOID KiLoadPATTarget IN PKIPI_CONTEXT  SignalDone,
IN PVOID  Context,
IN PVOID  Parameter2,
IN PVOID  Parameter3
 

Definition at line 249 of file pat.c.

References KiLoadPAT(), PNEW_PAT, and _NEW_PAT::TargetPhase.

Referenced by KiInitializePAT().

00257 : 00258 00259 Synchronize with target processors prior to PAT modification. 00260 00261 Arguments: 00262 00263 Context - Context which includes the PAT to load 00264 00265 Return Value: 00266 00267 None 00268 00269 --*/ 00270 { 00271 PNEW_PAT Context; 00272 00273 Context = (PNEW_PAT) NewPAT; 00274 00275 // 00276 // Wait for all processors to be ready 00277 // 00278 00279 KiIpiSignalPacketDoneAndStall (SignalDone, Context->TargetPhase); 00280 00281 // 00282 // Update PAT 00283 // 00284 00285 KiLoadPAT (Context); 00286 }

VOID KiSynchronizePATLoad IN PNEW_PAT  Context  ) 
 

Definition at line 447 of file pat.c.

References KeGetCurrentPrcb, and KeNumberProcessors.

Referenced by KiLoadPAT().

00452 : 00453 00454 This function synchronizes all processors during the various phases 00455 of modifying the PAT. 00456 00457 Arguments: 00458 00459 Context - Context which includes the barrier synchronization counter. 00460 00461 Return Value: 00462 00463 PAT on all processors programmed to new values 00464 00465 --*/ 00466 { 00467 ULONG CurrentPhase; 00468 volatile ULONG *TargetPhase; 00469 PKPRCB Prcb; 00470 00471 TargetPhase = Context->TargetPhase; 00472 Prcb = KeGetCurrentPrcb(); 00473 00474 if (Prcb->Number == (CCHAR) Context->Processor) { 00475 00476 // 00477 // Wait for all processors to signal 00478 // 00479 00480 while (Context->TargetCount != (ULONG) KeNumberProcessors - 1) ; 00481 00482 // 00483 // Reset count for next time 00484 // 00485 00486 Context->TargetCount = 0; 00487 00488 // 00489 // Let waiting processor go to next synchronization point 00490 // 00491 00492 InterlockedIncrement ((PULONG) TargetPhase); 00493 00494 00495 } else { 00496 00497 // 00498 // Get current phase 00499 // 00500 00501 CurrentPhase = *TargetPhase; 00502 00503 // 00504 // Signal that we have completed the current phase 00505 // 00506 00507 InterlockedIncrement ((PULONG) &Context->TargetCount); 00508 00509 // 00510 // Wait for new phase to begin 00511 // 00512 00513 while (*TargetPhase == CurrentPhase) ; 00514 } 00515 } }


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