AMC-OS Loader Memory management: Difference between revisions

From AMC-OS Developers
Jump to navigation Jump to search
No edit summary
No edit summary
Line 55: Line 55:
* <code>AMCOSLDR_TempAlloc</code> : 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.
* <code>AMCOSLDR_TempAlloc</code> : 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.
* <code>AMCOSLDR_VolatileAlloc</code> : 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.
* <code>AMCOSLDR_VolatileAlloc</code> : 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.
All functions waits for the requested size in bytes (must be a multiple of 16), and returns a segment of memory aligned on 512 bytes boundaries to facilitate disk operations.
All functions waits for the requested size in segment size (16-bytes unit), and returns a segment of memory aligned on 512 bytes boundaries to facilitate disk operations.


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

Revision as of 17:51, 13 April 2020

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.

All functions waits for the requested size in segment size (16-bytes unit), and returns a segment of memory aligned on 512 bytes boundaries to facilitate disk operations.

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