Memory initialization

From AMC-OS Developers
Revision as of 18:47, 18 April 2020 by Kindman (talk | contribs)
Jump to navigation Jump to search

During AMC-OS Loader

To get size and map of memory, AMC-OS Loader now relies mainly on BIOS instead of probing, which was the preferred way in AMC-OS <2.10.

AMC-OS Loader proceed this way :

  • Try INT 15H, function E820 to get memory map.
  • Try INT 15H, function E801 to get size of memory below 16MB and above 16MB
  • Try INT 15H, function 88 to get effective size of extended memory
  • Get configured size of extended memory in CMOS

Depending on functions supported by BIOS, map will be more or less precise, and memory might be lost if ISA Hole in the 15-16M area is configured.

Kernel start

When Kernel starts, AMC-OS uses information discovered by the loader to build memory structures.

First megabyte

Kernel starts by calling INIT_MemoryUsableIn1stMeg. The function determines the first address of free memory in the first megabyte, just after kernel relocation code and below EBDA.

The function fills :

  • MEMORY_FreePageAddrIn1stMeg
  • MEMORY_FreePagesIn1stMeg

A20 Gate

Kernel unlocks A20 gate by calling INIT_A20Gate.

A20 gate was controlled by keyboard controller on AT+. To allow compatibility with 8086/8088, the A20 address line was forced to 0 on AT computers, blocking access to memory above 1MB. A20 gate must be enabled to allow A20 address line to be used normally.

Physical memory initialization

Physical memory is initialized by calling INIT_GlobalMemory.

Memory map

The function first builds a map of physical memory :

  • If available, it relies first on type-1 (available) entries of E820 BIOS records. In current release, memory above 4GB is ignored.
  • If available, it relies on E801 BIOS call results to determine a block of memory below 16MB and a block of memory above 16MB.
  • In other cases, kernel do a manual probing of available memory, using function INIT_MemoryCheckSegment.