github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/Doc/e820.txt (about)

     1  
     2  BIOS-provided physical RAM e820 map:                                            
     3  0000000000000000 - 000000000009f000 000000000009f000 (usable)                   
     4  000000000009f000 - 0000000000001000 00000000000a0000 (reserved)                 
     5  00000000000e8000 - 0000000000018000 0000000000100000 (reserved)                 
     6  0000000000100000 - 0000000007ef0000 0000000007ff0000 (usable)                   
     7  0000000007ff0000 - 0000000000010000 0000000008000000 (ACPI reclaim)             
     8  00000000fffbc000 - 0000000000004000 00000000fffc0000 (reserved)                 
     9  00000000fffc0000 - 0000000000040000 0000000100000000 (reserved)   
    10  
    11  
    12  INT 15h, AX=E820h - Query System Address Map
    13  
    14  Real mode only.
    15  This call returns a memory map of all the installed RAM, and of physical 
    16  memory ranges reserved by the BIOS. The address map is returned by making 
    17  successive calls to this API, each returning one "run" of physical address 
    18  information. Each run has a type which dictates how this run of physical 
    19  address range should be treated by the operating system.
    20  
    21  If the information returned from INT 15h, AX=E820h in some way differs 
    22  from INT 15h, AX=E801h or INT 15h AH=88h, then the information returned 
    23  from E820h supersedes what is returned from these older interfaces. This 
    24  allows the BIOS to return whatever information it wishes to for 
    25  compatibility reasons.
    26  
    27  Input:
    28  	EAX	Function Code	E820h
    29  	EBX	Continuation	Contains the "continuation value" to get the
    30  				next run of physical memory.  This is the
    31  				value returned by a previous call to this
    32  				routine.  If this is the first call, EBX
    33  				must contain zero.
    34  	ES:DI	Buffer Pointer	Pointer to an  Address Range Descriptor
    35  				structure which the BIOS is to fill in.
    36  	ECX	Buffer Size	The length in bytes of the structure passed
    37  				to the BIOS.  The BIOS will fill in at most
    38  				ECX bytes of the structure or however much
    39  				of the structure the BIOS implements.  The
    40  				minimum size which must be supported by both
    41  				the BIOS and the caller is 20 bytes.  Future
    42  				implementations may extend this structure.
    43  	EDX	Signature	'SMAP' -  Used by the BIOS to verify the
    44  				caller is requesting the system map
    45  				information to be returned in ES:DI.
    46  Output:
    47  	CF	Carry Flag	Non-Carry - indicates no error
    48  	EAX	Signature	'SMAP' - Signature to verify correct BIOS
    49  				revision.
    50  	ES:DI	Buffer Pointer	Returned Address Range Descriptor pointer.
    51  				Same value as on input.
    52  	ECX	Buffer Size	Number of bytes returned by the BIOS in the
    53  				address range descriptor.  The minimum size
    54  				structure returned by the BIOS is 20 bytes.
    55  	EBX	Continuation	Contains the continuation value to get the
    56  				next address descriptor.  The actual
    57  				significance of the continuation value is up
    58  				to the discretion of the BIOS.  The caller
    59  				must pass the continuation value unchanged
    60  				as input to the next iteration of the E820
    61  				call in order to get the next Address Range
    62  				Descriptor.  A return value of zero means that
    63  				this is the last descriptor.  Note that the
    64  				BIOS indicate that the last valid descriptor
    65  				has been returned by either returning a zero
    66  				as the continuation value, or by returning
    67  				carry.
    68  Address Range Descriptor Structure
    69  
    70  Offset in Bytes		Name		Description
    71  	0	    BaseAddrLow		Low 32 Bits of Base Address
    72  	4	    BaseAddrHigh	High 32 Bits of Base Address
    73  	8	    LengthLow		Low 32 Bits of Length in Bytes
    74  	12	    LengthHigh		High 32 Bits of Length in Bytes
    75  	16	    Type		Address type of  this range.
    76  The BaseAddrLow and BaseAddrHigh together are the 64 bit BaseAddress of this 
    77  range. The BaseAddress is the physical address of the start of the range 
    78  being specified.
    79  The LengthLow and LengthHigh together are the 64 bit Length of this range. 
    80  The Length is the physical contiguous length in bytes of a range being specified.
    81  
    82  The Type field describes the usage of the described address range as 
    83  defined in the table below.
    84  
    85  Value	Pneumonic		Description
    86  1	AddressRangeMemory	This run is available RAM usable by the
    87  				operating system.
    88  2	AddressRangeReserved	This run of addresses is in use or reserved
    89  				by the system, and must not be used by the
    90  				operating system.
    91  Other	Undefined		Undefined - Reserved for future use.  Any
    92  				range of this type must be treated by the
    93  				OS as if the type returned was
    94  				AddressRangeReserved.
    95  The BIOS can use the AddressRangeReserved address range type to block out 
    96  various addresses as "not suitable" for use by a programmable device.
    97  Some of the reasons a BIOS would do this are:
    98  
    99  The address range contains system ROM.
   100  The address range contains RAM in use by the ROM.
   101  The address range is in use by a memory mapped system device.
   102  The address range is for whatever reason are unsuitable for a standard 
   103  device to use as a device memory space.
   104  
   105  Assumptions and Limitations
   106  
   107  1. The BIOS will return address ranges describing base board memory and 
   108  ISA or PCI memory that is contiguous with that baseboard memory.
   109  2. The BIOS WILL NOT return a range description for the memory mapping 
   110  of PCI devices, ISA Option ROM's, and ISA plug & play cards. This is 
   111  because the OS has mechanisms available to detect them.
   112  3. The BIOS will return chipset defined address holes that are not being 
   113  used by devices as reserved.
   114  4. Address ranges defined for base board memory mapped I/O devices 
   115  (for example APICs) will be returned as reserved.
   116  5. All occurrences of the system BIOS will be mapped as reserved. 
   117  This includes the area below 1 MB, at 16 MB (if present) and at end of 
   118  the address space (4 gig).
   119  6. Standard PC address ranges will not be reported. Example video memory 
   120  at A0000 to BFFFF physical will not be described by this function. 
   121  The range from E0000 to EFFFF is base board specific and will be reported 
   122  as suits the bas board.
   123  7. All of lower memory is reported as normal memory. It is OS's 
   124  responsibility to handle standard RAM locations reserved for specific 
   125  uses, for example: the interrupt vector table(0:0) and the BIOS data 
   126  area(40:0).
   127  Example address map
   128  
   129  This sample address map describes a machine which has 128 MB RAM, 640K of 
   130  base memory and 127 MB extended. The base memory has 639K available for 
   131  the user and 1K for an extended BIOS data area. There is a 4 MB Linear 
   132  Frame Buffer (LFB) based at 12 MB. The memory hole created by the chipset 
   133  is from 8 M to 16 M. There are memory mapped APIC devices in the system. 
   134  The IO Unit is at FEC00000 and the Local Unit is at FEE00000. The system 
   135  BIOS is remapped to 4G - 64K.
   136  Note that the 639K endpoint of the first memory range is also the base memory 
   137  size reported in the BIOS data segment at 40:13.
   138  
   139  Key to types: "ARM" is AddressRangeMemory, "ARR" is AddressRangeReserved.
   140  
   141  Base (Hex)	Length	Type	Description
   142  0000 0000	639K	ARM	Available Base memory - typically the same
   143  				value as is returned via the INT 12 function.
   144  0009 FC00	1K	ARR	Memory reserved for use by the BIOS(s).
   145  				This area typically includes the Extended
   146  				BIOS data area.
   147  000F 0000	64K	ARR	System BIOS
   148  0010 0000	7M	ARM	Extended memory, this is not limited to
   149  				the 64 MB address range.
   150  0080 0000	8M	ARR	Chipset memory hole required to support the
   151  				LFB mapping at 12 MB.
   152  0100 0000	120M	ARM	Base board RAM relocated above a chipset
   153  				memory hole.
   154  FEC0 0000	4K	ARR	IO APIC memory mapped I/O at FEC00000.  Note
   155  				the range of addresses required for an APIC
   156  				device may vary from base OEM to OEM.
   157  FEE0 0000	4K	ARR	Local APIC memory mapped I/O at FEE00000.
   158  FFFF 0000	64K	ARR	Remapped System BIOS at end of address space.
   159  Sample operating system usage
   160  
   161  The following code segment is intended to describe the algorithm needed 
   162  when calling the Query System Address Map function. It is an implementation 
   163  example and uses non standard mechanisms.
   164      E820Present = FALSE;
   165      Regs.ebx = 0;
   166      do {
   167          Regs.eax = 0xE820;
   168          Regs.es  = SEGMENT (&Descriptor);
   169          Regs.di  = OFFSET  (&Descriptor);
   170          Regs.ecx = sizeof  (Descriptor);
   171  	Regs.edx = 'SMAP';
   172  
   173          _int( 0x15, Regs );
   174  
   175          if ((Regs.eflags & EFLAG_CARRY)  ||  Regs.eax != 'SMAP') {
   176              break;
   177          }
   178  
   179          if (Regs.ecx < 20  ||  Regs.ecx > sizeof (Descriptor) ) {
   180              // bug in bios - all returned descriptors must be
   181              // at least 20 bytes long, and can not be larger then
   182              // the input buffer.
   183  
   184              break;
   185          }
   186  
   187  	E820Present = TRUE;
   188  	.
   189          .
   190          .
   191          Add address range Descriptor.BaseAddress through
   192          Descriptor.BaseAddress + Descriptor.Length
   193          as type Descriptor.Type
   194  	.
   195          .
   196          .
   197  
   198      } while (Regs.ebx != 0);
   199  
   200      if (!E820Present) {
   201  	.
   202          .
   203          .
   204  	call INT 15h, AX=E801h and/or INT 15h, AH=88h to obtain old style
   205  	memory information
   206  	.
   207          .
   208          .
   209      }
   210  INT 15h, AX=E801h - Get Memory Size for Large Configurations
   211  
   212  Real mode only (as far as I know).
   213  Originally defined for EISA servers, this interface is capable of reporting 
   214  up to 4 GB of RAM. While not nearly as flexible as E820h, it is present 
   215  in many more systems.
   216  
   217  Input:
   218  
   219  	AX	Function Code	E801h
   220  Output:
   221  	CF	Carry Flag	Non-Carry - indicates no error
   222  	AX	Extended 1	Number of contiguous KB between 1 and 16 MB,
   223  				maximum 0x3C00 = 15 MB.
   224  	BX	Extended 2	Number of contiguous 64 KB blocks between
   225  				16 MB and 4 GB.
   226  	CX	Configured 1	Number of contiguous KB between 1 and 16 MB,
   227  				maximum 0x3C00 = 15 MB.
   228  	DX	Configured 2	Number of contiguous 64 KB blocks between
   229  				16 MB and 4 GB.
   230  Not sure what this difference between the "Extended" and "Configured" numbers 
   231  are, but they appear to be identical, as reported from the BIOS.
   232  NOTE: It is possible for a machine using this interface to report a 
   233  memory hole just under 16 MB (Count 1 is less than 15 MB, but Count 2 is non-zero).
   234  
   235  INT 15h, AH=88h - Get Extended Memory Size
   236  
   237  Real mode only.
   238  This interface is quite primitive. It returns a single value for 
   239  contiguous memory above 1 MB. The biggest limitation is that the value 
   240  returned is a 16-bit value, in KB, so it has a maximum saturation of just 
   241  under 64 MB even presuming it returns as much as it can. On some systems, 
   242  it won't return anything above the 16 MB boundary.
   243  
   244  The one useful point is that it works on every PC available.
   245  
   246  Input:
   247  
   248  	AH	Function Code	88h
   249  Output:
   250  	CF	Carry Flag	Non-Carry - indicates no error
   251  	AX	Memory Count	Number of contiguous KB above 1 MB.
   252