Memory initialization
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.
After AMC-OS Loader execution, the first megabyte of memory is divided like this :
00000-003FF
|
Real-mode interrupt table (for V86) |
00400-00500
|
BIOS static data (for V86) |
00501-007FF
|
Partially allocated memory by AMCOSLDR_DefinitiveAlloc
|
00800-[__A]
|
Kernel static data |
[__A]-077FF
|
Partially allocated memory by AMCOSLDR_DefinitiveAlloc
|
077FF-07BFF
|
AMC-OS Loader stack (no longer used- reclaimable) |
07C00-07DFF
|
Boot loader code (no longer used - reclaimable) |
07E00-07FFF
|
Free (unused - reclaimable) |
08000-9[_D]
|
Partially allocated memory by AMCOSLDR_DefinitiveAlloc , including Kernel
|
9[_D]-9FFFF
|
Extended BIOS data area (EBDA - optional) |
All reclaimable memory is added to the SMALLOC structures of AMC-OS Loader, than will be analyzed by Kernel.
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
.