Leaked source code of windows server 2003
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.

93 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. pat.c
  5. Abstract:
  6. This module initializes the page attributes table.
  7. Author:
  8. David N. Cutler (davec) 2-May-2001
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #include "ki.h"
  14. #pragma alloc_text(PAGELK, KiSetPageAttributesTable)
  15. VOID
  16. KiSetPageAttributesTable (
  17. VOID
  18. )
  19. /*++
  20. Routine Description:
  21. This function initializes the page attribute table for the current
  22. processor. The page attribute table is set up to provide write back,
  23. write combining, uncacheable/stronly order, and uncacheable/weakly
  24. ordered.
  25. PAT_Entry PAT Index PCD PWT Memory Type
  26. 0 0 0 0 WB
  27. 1 0 0 1 WC *
  28. 2 0 1 0 WEAK_UC
  29. 3 0 1 1 STRONG_UC
  30. 4 1 0 0 WB
  31. 5 1 0 1 WC *
  32. 6 1 1 0 WEAK_UC
  33. 7 1 1 1 STRONG_UC
  34. N.B. The caller must have the PAGELK code locked before calling this
  35. function.
  36. Arguments:
  37. None.
  38. Return Value:
  39. None.
  40. --*/
  41. {
  42. PAT_ATTRIBUTES Attributes;
  43. //
  44. // Initialize the page attribute table.
  45. //
  46. Attributes.hw.Pat[0] = PAT_TYPE_WB;
  47. Attributes.hw.Pat[1] = PAT_TYPE_USWC;
  48. Attributes.hw.Pat[2] = PAT_TYPE_WEAK_UC;
  49. Attributes.hw.Pat[3] = PAT_TYPE_STRONG_UC;
  50. Attributes.hw.Pat[4] = PAT_TYPE_WB;
  51. Attributes.hw.Pat[5] = PAT_TYPE_USWC;
  52. Attributes.hw.Pat[6] = PAT_TYPE_WEAK_UC;
  53. Attributes.hw.Pat[7] = PAT_TYPE_STRONG_UC;
  54. //
  55. // Invalidate the cache on the current proccesor, write the page attributes
  56. // table, and invalidate the cache a second time.
  57. //
  58. WritebackInvalidate();
  59. WriteMSR(MSR_PAT, Attributes.QuadPart);
  60. WritebackInvalidate();
  61. return;
  62. }