home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / ibm / pc / hardware / 22189 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  5.7 KB

  1. Path: sparky!uunet!ogicse!hp-cv!sdd.hp.com!hplabs!ucbvax!BTVLABVM.VNET.IBM.COM!JULIUS
  2. From: JULIUS@BTVLABVM.VNET.IBM.COM ("Julius C. Chang")
  3. Newsgroups: comp.sys.ibm.pc.hardware
  4. Subject: A20 handler
  5. Message-ID: <9208191350.AA07094@ucbvax.Berkeley.EDU>
  6. Date: 19 Aug 92 13:39:57 GMT
  7. Article-I.D.: ucbvax.9208191350.AA07094
  8. Sender: usenet@ucbvax.BERKELEY.EDU
  9. Lines: 102
  10.  
  11.  
  12.     This is from my files and is an excerpt from a README file
  13. written by Bob Smith of Qualitas.  Note that the excerpt explains
  14. the origin of the A20 Gate, but not why there are different A20
  15. handlers for HIMEM.SYS.  Basically, the A20 Gate is implementation
  16. dependent and controlling the A20 line can (and usually does) vary
  17. from manufacturer to manufacturer.
  18.  
  19. Julius
  20. ------------------------------------------------------------------------
  21.  
  22. Compatibility with 8086/8088 Programs
  23. -------------------------------------
  24.  
  25. Now for a bit of history on how the IBM AT and later systems maintain
  26. a certain degree of compatibility with the 8086/8088 processors.  When
  27. these early CPUs encountered a segment and offset which together
  28. exceed the limit of its 20-bit address space (such as FFFF:0010 =
  29. 00100000), they automatically wrap at one megabyte back down to zero.
  30. Thus FFFF:0010 is identical to 0:0, or more accurately, memory
  31. references to the former location are satisfied from the latter
  32. location.  When the IBM AT was designed to use a 80286 CPU, its
  33. architects faced a problem.  The newer processor was oriented more
  34. toward PM operation.  Consequently, it didn't automatically wrap
  35. addresses at 1MB, as that would defeat the purpose of having a
  36. continuous stream of RAM at 1MB and beyond.  Nonetheless, the AT's
  37. designers decided to emulate this odd behavior because they understood
  38. well the need for compatibility.  That is, there were (and still are)
  39. many programs which rely upon the 1MB wrap as it is called.
  40.  
  41. Because the 8086/8088 processors have a 20-bit address space, they
  42. need address bits A0 to A19 only.  The maximum address which can be
  43. generated in RM (FFFF:FFFF) has 21 significant bits, that is, of the
  44. bits beyond A19 only A20 is non-zero.  The AT's designers realized
  45. that they could emulate the 1MB wrap by artificially forcing A20 to
  46. zero.  Thus the mechanism used to emulate this behavior and obtain
  47. compatibility is called the A20 gate.  Typically, it is controlled by
  48. a single bit in the output port byte (a kitchen sink catchall) of the
  49. 8042 PPI (Programmable Peripheral Interface) chip on the system board.
  50. The two values of this bit correspond to the two states of the A20
  51. gate.  The value zero means that A20 is forced to zero regardless of
  52. what address the CPU generates; a value of one means that A20 is
  53. untouched, that is, controlled by the CPU to have whatever value the
  54. CPU calculates.  In this way, with A20 disabled (forced to zero)
  55. although the CPU may generate an address of 00100000 when presented
  56. with FFFF:0010, the actual address the bus sees is 00000000.
  57.  
  58. As a side note, the A20 gate has caused fits for several system
  59. designers.  When memory cache controllers were introduced into PC
  60. systems, some designers forgot about the A20 gate.  That is, they
  61. designed their systems such that (from a logical perspective) the
  62. sequence of control was from the CPU to the memory cache to the A20
  63. gate circuitry to the bus.  A problem occurs in the following sequence
  64. with (say) A20 enabled:  read from FFFF:0010 (thus putting the value
  65. at physical address 1MB into the cache), disable the A20 gate, and
  66. read again from FFFF:0010.  The program expects to get the second
  67. value from physical address zero (because A20 is now disabled), but if
  68. the memory cache controller doesn't know that the A20 gate has changed
  69. it will provide the CPU with the (incorrect) value from its memory
  70. cache for physical address 1MB.
  71.  
  72. Moreover, consider what happens with the 486 CPU which has an onboard
  73. memory cache.  Without really having any choice, Intel decided to
  74. immortalize this behavior in silicon by defining an input pin (A20M#)
  75. on the 486 to allow external circuitry to control the state of the A20
  76. address line which the cache sees so that it would work correctly.
  77.  
  78. One more digression about the A20 gate:  why is it so important to
  79. emulate the 1MB wrap?  Isn't this a problem that could be solved
  80. simply by more careful programming?  Yes, but it's too late.  Quite
  81. likely, your hard disk is infested with numerous programs which under
  82. certain circumstances will fail if the 1MB wrap weren't emulated.  The
  83. major perpetrator of this feature is the EXEPACK program as well as
  84. the corresponding option to the linker.  In particular, the code which
  85. EXEPACK prefixes onto your packed .EXE files is dependent upon the 1MB
  86. wrap.  In particular, if such a program is loaded with its code
  87. segment at 0FF0 or lower (essentially anywhere within the first 64KB)
  88. and the A20 gate is enabled (thus not emulating the 1MB wrap), the
  89. unpacking code fails with the message "Packed file is corrupt!".
  90.  
  91.  
  92.  
  93. ------------------------------- Referenced Note ---------------------------
  94. Subject: A20 handler
  95. From: j_manning@csc32.enet.dec.com (John Manning)
  96. Message-ID: <1992Aug18.133745.24530@nntpd2.cxo.dec.com>
  97. Date: 18 Aug 92 14:34:56 GMT
  98.  
  99. Can some explain the difference in the various A20 handler numbers?
  100.  
  101. My machine says "A20 handler number 1 installed" when I load himem.sys.  I
  102. noticed a Packard Bell computer at a store yesterday that said "A20 handler
  103. number 3 installed" when it loads himem.sys.  What is the difference?
  104.  
  105. Thanks,
  106.  
  107. John
  108.  
  109. -------------------------------------------------------------------------------
  110. |    John Manning                       |  Opinions expressed are my own.     |
  111. |    j_manning@csc32.enet.dec.com       |  I do not represent Digital Equip.  |
  112. -------------------------------------------------------------------------------
  113.