AMC-OS Loader Memory management

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

Memory used during AMC-OS Loader execution

AMC-OS Loader uses only the first megabyte of memory :

00000-003FF Real-mode interrupt table
00400-00500 BIOS static data
00501-005FF Free (unused)
00600-007FF Master boot record
00800-[__A] Kernel static data (initialized by boot loader)
[__A]-[__B] AMC-OS Loader code
[__B]-[__C] AMC-OS Loader picture
[__C]-077FF Free for allocation
077FF-07BFF AMC-OS Loader stack
07C00-07DFF Boot loader code (VBR or MBR for floppy disk)
07E00-07FFF Free (unused)
08000-9[_D] Free for allocation
9[_D]-09FFF Extended BIOS data area (EBDA - optional)

}

Memory management

Initialization

During memory initialization process (AMCOSLDR_InitFirstMegabyte), AMC-OS Loader :

  • looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]
  • calculates the values of [__A] to get lowest pointer in memory
  • creates a linked list of available blocks of memory (AMCOSLDR_Malloc_Entry)
  • initializes two blocks of available memory (marked Free for allocation in previous table)

Allocation

Three functions are available to AMC-OS Loader for memory allocation :

  • AMCOSLDR_DefinitiveAlloc : Used to allocate memory that shall stay at this place at the end of the process (used by kernel afterwards). Memory will be taken from bottom of free memory.
  • AMCOSLDR_TempAlloc : Used to allocate memory that will be freed at the end of the process (eraseable by kernel afterwards). Memory will be taken from top of free memory.
  • AMCOSLDR_VolatileAlloc : Used to allocate memory for immediate use (valid only until a new call to any memory function is made). Memory will be taken from top of free memory.

The two first functions maintains the linked list of available blocks of memory.