Source code of Windows XP (NT5)
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.

227 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1993 ACER America Corporation
  3. Module Name:
  4. acer.c
  5. Abstract:
  6. ACER Write-back Secondary Cache Control c code.
  7. This module implements the code which detects and enables the
  8. secondary write-back cache on ACER products (ICL also).
  9. Environment:
  10. Kernel mode only.
  11. --*/
  12. #include "halp.h"
  13. #include "spacer.h" // i/o addresses & bit definitions
  14. ULONG HalpGetCmosData (
  15. IN ULONG BusNumber,
  16. IN ULONG SlotNumber,
  17. IN PVOID Buffer,
  18. IN ULONG Length
  19. );
  20. VOID HalpAcerInitializeCache ( VOID ); // externally used
  21. BOOLEAN has_write_back_cache( VOID ); // local only
  22. // ************************ routines ****************************
  23. BOOLEAN has_write_back_cache( VOID )
  24. /*++
  25. Routine Description:
  26. This routine checks to see if this machine supports a secondary
  27. write-back cache.
  28. This routine checks if the machine is an ACER, ALTOS, or ICL product.
  29. eisa id: acr32xx - acer product
  30. eisa id: acs32xx - altos product
  31. eisa id: icl00xx - icl product
  32. The only thing that tells us whether or not the CPU has a secondary
  33. write-back cache is the least significant byte of the EISA id.
  34. xx = 61h for cpu0 indicates the presence of a write-back cache
  35. Arguments:
  36. None
  37. Return Value:
  38. TRUE machine supports a secondary write-back cache.
  39. FALSE machine is not known to support a write-back cache.
  40. --*/
  41. {
  42. UCHAR id0, id1, id2, id3;
  43. // grab cpu0's eisa id information
  44. id0 = READ_PORT_UCHAR( (PUCHAR) ACER_CPU0_EISA_ID0 );
  45. id1 = READ_PORT_UCHAR( (PUCHAR) ACER_CPU0_EISA_ID1 );
  46. id2 = READ_PORT_UCHAR( (PUCHAR) ACER_CPU0_EISA_ID2 );
  47. // are we a acer or altos machine?
  48. if ( (id0 == (UCHAR) ACER_ID0 &&
  49. id1 == (UCHAR) ACER_ID1 &&
  50. id2 == (UCHAR) ACER_ID2 ) ||
  51. (id0 == (UCHAR) ALTOS_ID0 &&
  52. id1 == (UCHAR) ALTOS_ID1 &&
  53. id2 == (UCHAR) ALTOS_ID2 ) ) {
  54. // check the lsw id cpu to see if it has a write back cache
  55. // All acer/altos/icl machines can only have 1 cpu type, so if the
  56. // first cpu supports a write-back cache then all of them do.
  57. id3 = READ_PORT_UCHAR( (PUCHAR) ACER_CPU0_EISA_ID3 );
  58. if ( id3 == (UCHAR) ACER_EISA_ID_WB_CPU0 )
  59. return TRUE; // gotcha
  60. }
  61. // are we an icl mx machine?
  62. if ( (id0 == (UCHAR) ICL_ID0 &&
  63. id1 == (UCHAR) ICL_ID1 &&
  64. id2 == (UCHAR) ICL_ID2 ) ) {
  65. // check the lsw id cpu to see if it has a write back cache
  66. // All acer/altos/icl machines can only have 1 cpu type, so if the
  67. // first cpu supports a write-back cache then all of them do.
  68. id3 = READ_PORT_UCHAR( (PUCHAR) ACER_CPU0_EISA_ID3 );
  69. if ( id3 == (UCHAR) ICL_EISA_ID_WB_CPU0 )
  70. return TRUE; // gotcha
  71. }
  72. return FALSE; // when in doubt be safe
  73. }
  74. VOID
  75. HalpAcerInitializeCache (
  76. VOID
  77. )
  78. /*++
  79. Routine Description:
  80. This routine enables the write-back cache available on certain
  81. ACER product. If the write-back cache is supported then it enables
  82. it.
  83. NOTE: 1) This routine assumes that the caller has provided any required
  84. synchronization to query the realtime clock information. Or that
  85. the HAL code which is calling this routine has serialized access.
  86. 2) For CSR bit definitions see the acer.h file
  87. You cannot call dbgprint to talk to the debugger since the port is not
  88. initialized yet.
  89. Arguments:
  90. None
  91. Return Value:
  92. None.
  93. SideEffects:
  94. NMI mask is enabled.
  95. --*/
  96. {
  97. UCHAR shadow_ram_setup; // tmp var for current shadow stat
  98. UCHAR high_ram_setup; // tmp var for current ram setup
  99. // say hello to the outside world
  100. //HalDisplayString(ACER_HAL_VERSION_NUMBER);
  101. //HalDisplayString("Acer HAL: Searching for secondary write-back cache\n");
  102. // check to see if this particular ACER model even has a
  103. // write-back cache
  104. if ( !has_write_back_cache() ) {
  105. //HalDisplayString("Acer HAL: No write-back cache found\n");
  106. return;
  107. }
  108. // retrieve BIOS setup shadow ram status
  109. // read in byte, mask off bit 0 - 1-RAM BIOS 0-ROM BIOS
  110. HalpGetCmosData((ULONG) 0, (ULONG) ACER_SHADOW_IDX,
  111. (PVOID) &shadow_ram_setup, (ULONG) 1 );
  112. // Set up shadow_ram_setup:
  113. // bit 0 - 1-BIOS Shadow 0=No Shadowing
  114. shadow_ram_setup &= RAM_ROM_MASK;
  115. if ( shadow_ram_setup == 0 ) {
  116. //HalDisplayString("Acer HAL: NO BIOS RAM Shadowing\n");
  117. } else {
  118. //HalDisplayString("Acer HAL: BIOS RAM Shadowing\n");
  119. }
  120. // retrieve BIOS setup 15MB-16MB ram status
  121. // mask off bit 1 -
  122. // 1-(15MB-16MB) RAM 0-(15MB-16MB) EISA
  123. HalpGetCmosData((ULONG) 0, (ULONG) ACER_15M_16M_IDX,
  124. (PVOID) &high_ram_setup, (ULONG) 1 );
  125. // 15MB-16MB memory setup (high_ram_setup):
  126. // bit 5 1=EISA 0=System RAM
  127. // note: the polarity is opposite from what getcmosdata read
  128. high_ram_setup &= DRAM_EISA_MASK; // just grab bit 1
  129. high_ram_setup ^= DRAM_EISA_MASK; // invert polarity
  130. high_ram_setup <<= 4; // place at bit<4>
  131. if ( high_ram_setup == 0) {
  132. //HalDisplayString("Acer HAL: 15Mb to 16Mb Allocated to System RAM\n");
  133. } else {
  134. //HalDisplayString("Acer HAL: 15Mb to 16Mb Allocated to I/O Space\n");
  135. }
  136. // Enable write-back secondary cache on cpus 0 & 1
  137. // by setting bit<2>
  138. WRITE_PORT_UCHAR( (PUCHAR) ACER_PORT_CPU01,
  139. (UCHAR) (WRITE_BALLOC_ON | shadow_ram_setup | high_ram_setup));
  140. // always set write-back secondary cache on cpus 2 & 3
  141. // even if system does not have cpus 2 & 3
  142. WRITE_PORT_UCHAR( (PUCHAR) ACER_PORT_CPU23,
  143. (UCHAR) (WRITE_BALLOC_ON | shadow_ram_setup | high_ram_setup));
  144. // flush the last pending i/o write by reading a safe io location
  145. READ_PORT_UCHAR( (PUCHAR) EISA_FLUSH_ADDR );
  146. // that's all folks
  147. //HalDisplayString("Acer HAL: Write-back cache enabled!\n");
  148. }