<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.amc-os.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kindman</id>
	<title>AMC-OS Developers - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.amc-os.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kindman"/>
	<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php/Special:Contributions/Kindman"/>
	<updated>2026-06-02T14:37:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=112</id>
		<title>Memory initialization</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=112"/>
		<updated>2022-09-10T23:13:52Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* First megabyte */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=During AMC-OS Loader=&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;2.10.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader proceed this way :&lt;br /&gt;
* Try INT 15H, function E820 to get memory map.&lt;br /&gt;
* Try INT 15H, function E801 to get size of memory below 16MB and above 16MB&lt;br /&gt;
* Try INT 15H, function 88 to get effective size of extended memory&lt;br /&gt;
* Get configured size of extended memory in CMOS&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
After AMC-OS Loader execution, the first megabyte of memory is divided like this :&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table (for V86)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data (for V86)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack (&#039;&#039;no longer used-  reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (&#039;&#039;no longer used - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (&#039;&#039;unused - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;, including Kernel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-9FFFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
All reclaimable memory is added to the SMALLOC structures of AMC-OS Loader, than will be analyzed by Kernel.&lt;br /&gt;
&lt;br /&gt;
End of 1st megabyte, segment-like, [_D] or A000H is stored in &amp;lt;code&amp;gt;MEMORY_BaseMaxSegment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Kernel start=&lt;br /&gt;
&lt;br /&gt;
Process of memory initialization by Kernel is the following :&lt;br /&gt;
&lt;br /&gt;
* Initialization of 1st MB of memory : AMC-OS uses information discovered by the loader to build initial memory structures.&lt;br /&gt;
* A20 gate unlocking to access memory above 1MB&lt;br /&gt;
* Initialization of all physical memory&lt;br /&gt;
&lt;br /&gt;
==Initialization of first megabyte==&lt;br /&gt;
Kernel starts by calling &amp;lt;code&amp;gt;INIT_MemoryUsableIn1stMeg()&amp;lt;/code&amp;gt;. The function determines the first address of free memory in the first megabyte, just after kernel relocation code and below EBDA. It checks that it matches with AMC-OS Loader MALLOC structure, as its last allocatable block should start just after kernel relocation code. &lt;br /&gt;
&lt;br /&gt;
The function fills :&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePageAddrIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePagesIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
which allow the call to &amp;lt;code&amp;gt;INIT_AllocatePagesBelow()&amp;lt;/code&amp;gt; for allocation of contiguous pages of memory during initialization.&lt;br /&gt;
&lt;br /&gt;
It also calls &amp;lt;code&amp;gt;INIT_MemorySmallocInit&amp;lt;/code&amp;gt;, which rebuilds AMC-OS Loader SMALLOC structures with 32-byte direct offsets to have a quick function for small memory allocation during memory initialization : &amp;lt;code&amp;gt;INIT_MemoryDefinitiveAlloc()&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
At this point, all unused memory by AMC-OS Loader is reclaimed by kernel, and 1st megabyte of memory is fully analyzed.&lt;br /&gt;
&lt;br /&gt;
==A20 Gate==&lt;br /&gt;
Kernel unlocks A20 gate by calling &amp;lt;code&amp;gt;INIT_A20Gate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Physical memory initialization==&lt;br /&gt;
Physical memory is initialized by calling &amp;lt;code&amp;gt;INIT_GlobalMemory&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Memory map===&lt;br /&gt;
The function first builds a map of physical memory :&lt;br /&gt;
* If available, it relies first on type-1 (available) entries of E820 BIOS records. &#039;&#039;In current release, memory above 4GB is ignored&#039;&#039;.&lt;br /&gt;
* If available, it relies on E801 BIOS call results to determine a block of memory below 16MB and a block of memory above 16MB.&lt;br /&gt;
* In other cases, kernel do a manual probing of available memory, using function &amp;lt;code&amp;gt;INIT_MemoryCheckSegment&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=111</id>
		<title>Memory initialization</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=111"/>
		<updated>2022-09-10T22:59:26Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* During AMC-OS Loader */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=During AMC-OS Loader=&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;2.10.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader proceed this way :&lt;br /&gt;
* Try INT 15H, function E820 to get memory map.&lt;br /&gt;
* Try INT 15H, function E801 to get size of memory below 16MB and above 16MB&lt;br /&gt;
* Try INT 15H, function 88 to get effective size of extended memory&lt;br /&gt;
* Get configured size of extended memory in CMOS&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
After AMC-OS Loader execution, the first megabyte of memory is divided like this :&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table (for V86)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data (for V86)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack (&#039;&#039;no longer used-  reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (&#039;&#039;no longer used - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (&#039;&#039;unused - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;, including Kernel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-9FFFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
All reclaimable memory is added to the SMALLOC structures of AMC-OS Loader, than will be analyzed by Kernel.&lt;br /&gt;
&lt;br /&gt;
=Kernel start=&lt;br /&gt;
&lt;br /&gt;
When Kernel starts, AMC-OS uses information discovered by the loader to build memory structures.&lt;br /&gt;
&lt;br /&gt;
==First megabyte==&lt;br /&gt;
Kernel starts by calling &amp;lt;code&amp;gt;INIT_MemoryUsableIn1stMeg&amp;lt;/code&amp;gt;. The function determines the first address of free memory in the first megabyte, just after kernel relocation code and below EBDA.&lt;br /&gt;
&lt;br /&gt;
The function fills :&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePageAddrIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePagesIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A20 Gate==&lt;br /&gt;
Kernel unlocks A20 gate by calling &amp;lt;code&amp;gt;INIT_A20Gate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Physical memory initialization==&lt;br /&gt;
Physical memory is initialized by calling &amp;lt;code&amp;gt;INIT_GlobalMemory&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Memory map===&lt;br /&gt;
The function first builds a map of physical memory :&lt;br /&gt;
* If available, it relies first on type-1 (available) entries of E820 BIOS records. &#039;&#039;In current release, memory above 4GB is ignored&#039;&#039;.&lt;br /&gt;
* If available, it relies on E801 BIOS call results to determine a block of memory below 16MB and a block of memory above 16MB.&lt;br /&gt;
* In other cases, kernel do a manual probing of available memory, using function &amp;lt;code&amp;gt;INIT_MemoryCheckSegment&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=110</id>
		<title>Memory initialization</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=110"/>
		<updated>2022-09-10T22:57:57Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Added memory map after execution of AMC-OS Loader&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=During AMC-OS Loader=&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;2.10.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader proceed this way :&lt;br /&gt;
* Try INT 15H, function E820 to get memory map.&lt;br /&gt;
* Try INT 15H, function E801 to get size of memory below 16MB and above 16MB&lt;br /&gt;
* Try INT 15H, function 88 to get effective size of extended memory&lt;br /&gt;
* Get configured size of extended memory in CMOS&lt;br /&gt;
&lt;br /&gt;
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. &lt;br /&gt;
&lt;br /&gt;
After AMC-OS Loader execution, the first megabyte of memory is divided like this :&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table (for V86)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data (for V86)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record (no longer used - reclaimable)&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code (&#039;&#039;no longer used - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture (&#039;&#039;no longer used - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack (&#039;&#039;no longer used-  reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (&#039;&#039;no longer used - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (&#039;&#039;unused - reclaimable&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Partially allocated memory by &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt;, including Kernel&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-9FFFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
All reclaimable memory is added to the SMALLOC structures of AMC-OS Loader, than will be analyzed by Kernel.&lt;br /&gt;
&lt;br /&gt;
=Kernel start=&lt;br /&gt;
&lt;br /&gt;
When Kernel starts, AMC-OS uses information discovered by the loader to build memory structures.&lt;br /&gt;
&lt;br /&gt;
==First megabyte==&lt;br /&gt;
Kernel starts by calling &amp;lt;code&amp;gt;INIT_MemoryUsableIn1stMeg&amp;lt;/code&amp;gt;. The function determines the first address of free memory in the first megabyte, just after kernel relocation code and below EBDA.&lt;br /&gt;
&lt;br /&gt;
The function fills :&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePageAddrIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePagesIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A20 Gate==&lt;br /&gt;
Kernel unlocks A20 gate by calling &amp;lt;code&amp;gt;INIT_A20Gate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Physical memory initialization==&lt;br /&gt;
Physical memory is initialized by calling &amp;lt;code&amp;gt;INIT_GlobalMemory&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Memory map===&lt;br /&gt;
The function first builds a map of physical memory :&lt;br /&gt;
* If available, it relies first on type-1 (available) entries of E820 BIOS records. &#039;&#039;In current release, memory above 4GB is ignored&#039;&#039;.&lt;br /&gt;
* If available, it relies on E801 BIOS call results to determine a block of memory below 16MB and a block of memory above 16MB.&lt;br /&gt;
* In other cases, kernel do a manual probing of available memory, using function &amp;lt;code&amp;gt;INIT_MemoryCheckSegment&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=109</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=109"/>
		<updated>2022-09-03T11:26:57Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* Initialization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
{|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data (initialized by boot loader)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__C] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (&amp;lt;code&amp;gt;AMCOSLDR_Malloc_Entry&amp;lt;/code&amp;gt;)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation of 512 bytes or more==&lt;br /&gt;
Three main functions are available to AMC-OS Loader for memory allocation. They wait 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. &lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : Used to allocate memory that will be freed at the end of AMC-OS Loader. Memory will be taken from top of free memory.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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. It typically do the same as &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; but do not consider the memory to be really used, so only the two other functions maintain the linked list of available blocks of memory.&lt;br /&gt;
Temporary allocations are reclaimed by kernel later during &amp;lt;code&amp;gt;INIT_MemoryUsableIn1stMeg&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Allocation of less than 512 bytes, &amp;quot;Small allocation&amp;quot; ==&lt;br /&gt;
For definitive allocation of less than 512 bytes, an other function is available. It also waits for the requested size in segment size (16-bytes unit), and returns a 16-byte aligned memory segment.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveSmallAlloc&amp;lt;/code&amp;gt; : 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. Small allocation is maintained with a linked list of structures { free_size_in_segment ; ptr_next_segment } stored directly in free memory, and starting by pointer stored in &amp;lt;code&amp;gt;AMCOSLDR_SmallAllocSegPtr&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
After AMC-OS Loader has finished, kernel reclaims the available memory later during &amp;lt;code&amp;gt;INIT_MemorySmallocInit&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=108</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=108"/>
		<updated>2022-09-03T11:25:41Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
{|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data (initialized by boot loader)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__A] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (&amp;lt;code&amp;gt;AMCOSLDR_Malloc_Entry&amp;lt;/code&amp;gt;)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation of 512 bytes or more==&lt;br /&gt;
Three main functions are available to AMC-OS Loader for memory allocation. They wait 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. &lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : Used to allocate memory that will be freed at the end of AMC-OS Loader. Memory will be taken from top of free memory.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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. It typically do the same as &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; but do not consider the memory to be really used, so only the two other functions maintain the linked list of available blocks of memory.&lt;br /&gt;
Temporary allocations are reclaimed by kernel later during &amp;lt;code&amp;gt;INIT_MemoryUsableIn1stMeg&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Allocation of less than 512 bytes, &amp;quot;Small allocation&amp;quot; ==&lt;br /&gt;
For definitive allocation of less than 512 bytes, an other function is available. It also waits for the requested size in segment size (16-bytes unit), and returns a 16-byte aligned memory segment.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveSmallAlloc&amp;lt;/code&amp;gt; : 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. Small allocation is maintained with a linked list of structures { free_size_in_segment ; ptr_next_segment } stored directly in free memory, and starting by pointer stored in &amp;lt;code&amp;gt;AMCOSLDR_SmallAllocSegPtr&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
After AMC-OS Loader has finished, kernel reclaims the available memory later during &amp;lt;code&amp;gt;INIT_MemorySmallocInit&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=107</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=107"/>
		<updated>2022-09-03T09:52:50Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Physical memory management =&lt;br /&gt;
For more information on physical memory initialization, refer to &#039;&#039;[[Memory initialization]]&#039;&#039; article.&lt;br /&gt;
&lt;br /&gt;
== Memory areas ==&lt;br /&gt;
&lt;br /&gt;
After scanning the linear address space for available physical memory, AMC-OS split the physical memory in two areas :&lt;br /&gt;
* The &#039;&#039;&#039;low memory area&#039;&#039;&#039; must be at least 4Mbytes large, and its size is proportional to the total amount of physical memory available. This area is also referred as &#039;&#039;kernel memory&#039;&#039; as the physical memory is available from all page directories at kernel privilege.&lt;br /&gt;
* The &#039;&#039;&#039;high memory area&#039;&#039;&#039; contains all the remaining memory and is used for user memory.&lt;br /&gt;
&lt;br /&gt;
Each memory area is divided in blocks of 256Kbytes, and is specified in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structure containing :&lt;br /&gt;
* the number and pointers to the used blocks they contain;&lt;br /&gt;
* the number and pointers to the free blocks they contain;&lt;br /&gt;
* the number and pointers to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory can be taken from low memory if high memory is exhausted.&lt;br /&gt;
&lt;br /&gt;
== Blocks management ==&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
By default, each memory area is divided in blocks of 256 Kbytes. A new block is &#039;&#039;activated&#039;&#039; and divided in free pages, if there are no more free pages available in the area. Free blocks are stored in the &#039;&#039;free blocks list&#039;&#039;, a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains :&lt;br /&gt;
* the pointer to the free block;&lt;br /&gt;
* the number of contiguous free blocks;&lt;br /&gt;
* the pointer to the next structure.&lt;br /&gt;
During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;br /&gt;
&lt;br /&gt;
== Kernel memory allocation procedures ==&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Threads&amp;diff=103</id>
		<title>Threads</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Threads&amp;diff=103"/>
		<updated>2020-07-29T15:57:00Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Thread definition in AMC-OS ==&lt;br /&gt;
&lt;br /&gt;
A thread is an execution unit running in the context of a specific [[Processes|process]]. It is consequently limited to the address space, code, data and execution rights of its [[Processes|parent process]]. If we refer to x86 architecture, a thread is the same as a task.&lt;br /&gt;
&lt;br /&gt;
A thread is characterized by :&lt;br /&gt;
* an internal thread ID (ITID) and global thread id (GTID)&lt;br /&gt;
* a task state segment (TSS) containing CPU state (registers, stack, ...)&lt;br /&gt;
* scheduling data (priority flag, counter of total and remaining active time...)&lt;br /&gt;
* a list of events related to the thread&lt;br /&gt;
&lt;br /&gt;
Threads are managed by the TSI module &#039;&#039;(Threads System Interface)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Threads System Interface (TSI) ==&lt;br /&gt;
&lt;br /&gt;
Each process is defined by a &amp;lt;code&amp;gt;TSI_ENTRY&amp;lt;/code&amp;gt; containing all thread information.&lt;br /&gt;
&lt;br /&gt;
=== Thread ID (iTID and TID) ===&lt;br /&gt;
&lt;br /&gt;
An internal thread ID (iTID) is a 16-bit unsigned integer, uniquely assigned to each thread in the whole system, with a maximum of &amp;lt;code&amp;gt;TSI_MAX_THREADS&amp;lt;/code&amp;gt;. The global thread ID (TID) is a 32-bit unsigned integer composed of the PID in the 16 upper bits, and of the ITID in the 16 lower bits.&lt;br /&gt;
&lt;br /&gt;
TSI maintains a linked list of unsorted used and free iTIDs, allowing allocation and release of iTIDs in &#039;&#039;O(1)&#039;&#039;, by respectively removing or adding the iTID at the beginning of the list.&lt;br /&gt;
Both list share the same global table called &amp;lt;code&amp;gt;StatusTable&amp;lt;/code&amp;gt; with two initial pointers, one for the linked list of free entries (&amp;lt;code&amp;gt;firstFreeEntry&amp;lt;/code&amp;gt;), one for the linked list of used entries (&amp;lt;code&amp;gt;firstUsedEntry&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Internal functions for iTID management are : &lt;br /&gt;
* iTID TSI_AllocateTID(TSI_ENTRY *)&lt;br /&gt;
* void TSI_ReleaseTID(iTID)&lt;br /&gt;
&lt;br /&gt;
To get the TSI_ENTRY for a specific iTID, an index table called &amp;lt;code&amp;gt;TSI_QuickTable&amp;lt;/code&amp;gt; is maintained.&lt;br /&gt;
&lt;br /&gt;
== Task scheduling and management ==&lt;br /&gt;
&lt;br /&gt;
=== Thread status ===&lt;br /&gt;
&lt;br /&gt;
A thread can mainly be considered as :&lt;br /&gt;
* inactive (stopped, waiting for external event, dying)&lt;br /&gt;
* active (waiting for execution)&lt;br /&gt;
* running (currently executed on a CPU)&lt;br /&gt;
&lt;br /&gt;
The status of the thread can change in these situations :&lt;br /&gt;
* suspension by timer (end of allowed execution time), from running to active. Handled by interrupt task &amp;lt;code&amp;gt;KERNEL_PeriodicTimer&amp;lt;/code&amp;gt;.&lt;br /&gt;
* suspension request (waiting for an external event, dying), or exception from running to inactive. Handled (finally) by task manager &amp;lt;code&amp;gt;TASKMGR_SwitchTask&amp;lt;/code&amp;gt;&lt;br /&gt;
* activation request (external event occured, new thread), from inactive to active. Handled by &amp;lt;code&amp;gt;TSI&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Active threads list ===&lt;br /&gt;
&lt;br /&gt;
Active threads are maintained in a circulary doubly linked list. A pointer refers to the next eligible thread for execution.&lt;br /&gt;
The list and pointers are modified by the task manager when removing a thread from the list (suspension request), or by TSI when adding a thread to the list (activation request). &lt;br /&gt;
&lt;br /&gt;
=== Running threads ===&lt;br /&gt;
&lt;br /&gt;
The currently running thread is directly stored in a table indexed by CPU.&lt;br /&gt;
&lt;br /&gt;
=== Allowed execution time and priority ===&lt;br /&gt;
&lt;br /&gt;
The priority defines the amount of allowed contiguous execution time on a CPU. At each timer interrupt, the counter is decremented and when it reaches 0 a new thread is dispatched for execution (except if there is no other thread waiting for execution).&lt;br /&gt;
&lt;br /&gt;
=== Periodic Timer interrupt ===&lt;br /&gt;
&lt;br /&gt;
The periodic timer interrupt task :&lt;br /&gt;
* decrements threads waiting for timeout&lt;br /&gt;
* decrements running threads remaining execution time&lt;br /&gt;
* for each CPU that reaches end of execution time, send an IPI to request task change and dispatching of a new thread.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Threads&amp;diff=102</id>
		<title>Threads</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Threads&amp;diff=102"/>
		<updated>2020-07-29T15:28:28Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Thread definition in AMC-OS ==&lt;br /&gt;
&lt;br /&gt;
A thread is an execution unit running in the context of a specific [[Processes|process]]. It is consequently limited to the address space, code, data and execution rights of its [[Processes|parent process]].&lt;br /&gt;
&lt;br /&gt;
A thread is characterized by :&lt;br /&gt;
* an internal thread ID (ITID) and global thread id (GTID)&lt;br /&gt;
* a task state segment (TSS) containing CPU state (registers, stack, ...)&lt;br /&gt;
* scheduling data (priority flag, counter of total and remaining active time...)&lt;br /&gt;
* a list of events related to the thread&lt;br /&gt;
&lt;br /&gt;
Threads are managed by the TSI module &#039;&#039;(Threads System Interface)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Threads System Interface (TSI) ==&lt;br /&gt;
&lt;br /&gt;
Each process is defined by a &amp;lt;code&amp;gt;TSI_ENTRY&amp;lt;/code&amp;gt; containing all thread information.&lt;br /&gt;
&lt;br /&gt;
=== Thread ID (iTID and TID) ===&lt;br /&gt;
&lt;br /&gt;
An internal thread ID (iTID) is a 16-bit unsigned integer, uniquely assigned to each thread in the whole system, with a maximum of &amp;lt;code&amp;gt;TSI_MAX_THREADS&amp;lt;/code&amp;gt;. The global thread ID (TID) is a 32-bit unsigned integer composed of the PID in the 16 upper bits, and of the ITID in the 16 lower bits.&lt;br /&gt;
&lt;br /&gt;
TSI maintains a linked list of unsorted used and free iTIDs, allowing allocation and release of iTIDs in &#039;&#039;O(1)&#039;&#039;, by respectively removing or adding the iTID at the beginning of the list.&lt;br /&gt;
Both list share the same global table called &amp;lt;code&amp;gt;StatusTable&amp;lt;/code&amp;gt; with two initial pointers, one for the linked list of free entries (&amp;lt;code&amp;gt;firstFreeEntry&amp;lt;/code&amp;gt;), one for the linked list of used entries (&amp;lt;code&amp;gt;firstUsedEntry&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Internal functions for iTID management are : &lt;br /&gt;
* iTID TSI_AllocateTID(TSI_ENTRY *)&lt;br /&gt;
* void TSI_ReleaseTID(iTID)&lt;br /&gt;
&lt;br /&gt;
To get the TSI_ENTRY for a specific iTID, an index table called &amp;lt;code&amp;gt;TSI_QuickTable&amp;lt;/code&amp;gt; is maintained.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Threads&amp;diff=101</id>
		<title>Threads</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Threads&amp;diff=101"/>
		<updated>2020-07-29T15:24:44Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Thread definition in AMC-OS ==&lt;br /&gt;
&lt;br /&gt;
A thread is an execution unit running in the context of a specific [[Processes|process]]. It is consequently limited to the address space, code, data and execution rights of its [[Processes|parent process]].&lt;br /&gt;
&lt;br /&gt;
A thread is characterized by :&lt;br /&gt;
* an internal thread ID (ITID) and global thread id (GTID)&lt;br /&gt;
* a task state segment (TSS) containing CPU state (registers, stack, ...)&lt;br /&gt;
* scheduling data (priority flag, counter of total and remaining active time...)&lt;br /&gt;
* a list of events related to the thread&lt;br /&gt;
&lt;br /&gt;
Threads are managed by the TSI module &#039;&#039;(Threads System Interface)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Threads System Interface (TSI) ==&lt;br /&gt;
&lt;br /&gt;
Each process is defined by a &amp;lt;code&amp;gt;TSI_ENTRY&amp;lt;/code&amp;gt; containing all thread information.&lt;br /&gt;
&lt;br /&gt;
=== Thread ID (ITID and GTID) ===&lt;br /&gt;
&lt;br /&gt;
An internal thread ID (ITID) is a 16-bit unsigned integer, uniquely assigned to each thread in the whole system, with a maximum of &amp;lt;code&amp;gt;TSI_MAX_THREADS&amp;lt;/code&amp;gt;. The global thread ID (GTID) is a 32-bit unsigned integer composed of the PID in the 16 upper bits, and of the ITID in the 16 lower bits.&lt;br /&gt;
&lt;br /&gt;
TSI maintains a linked list of unsorted used and free TIDs, allowing allocation and release of TIDs in &#039;&#039;O(1)&#039;&#039;, by respectively removing or adding the TID at the beginning of the list.&lt;br /&gt;
Both list share the same global table called &amp;lt;code&amp;gt;StatusTable&amp;lt;/code&amp;gt; with two initial pointers, one for the linked list of free entries (&amp;lt;code&amp;gt;firstFreeEntry&amp;lt;/code&amp;gt;), one for the linked list of used entries (&amp;lt;code&amp;gt;firstUsedEntry&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Internal functions for TID management are : &lt;br /&gt;
* ITID TSI_AllocateTID(TSI_ENTRY *)&lt;br /&gt;
* void TSI_ReleaseTID(ITID)&lt;br /&gt;
&lt;br /&gt;
To get the TSI_ENTRY for a specific ITID, an index table called &amp;lt;code&amp;gt;TSI_QuickTable&amp;lt;/code&amp;gt; is maintained.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Threads&amp;diff=100</id>
		<title>Threads</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Threads&amp;diff=100"/>
		<updated>2020-07-29T15:19:36Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Created page with &amp;quot;A thread is an execution unit running in the context of a specific process. It is consequently limited to the address space, code, data and execution rights of i...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A thread is an execution unit running in the context of a specific [[Processes|process]]. It is consequently limited to the address space, code, data and execution rights of its [[Processes|parent process]].&lt;br /&gt;
&lt;br /&gt;
A thread is characterized by :&lt;br /&gt;
* a task state segment (TSS) containing CPU state (registers, stack, ...)&lt;br /&gt;
* scheduling data (priority flag, counter of total and remaining active time...)&lt;br /&gt;
* a list of events related to the thread&lt;br /&gt;
&lt;br /&gt;
Threads are managed by the TSI module &#039;&#039;(Threads System Interface)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Threads System Interface (TSI) ==&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Processes&amp;diff=99</id>
		<title>Processes</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Processes&amp;diff=99"/>
		<updated>2020-07-29T14:50:53Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Process definition in AMC-OS ==&lt;br /&gt;
&lt;br /&gt;
A process is an instance of an [[Applications|application]].&lt;br /&gt;
Processes are managed in AMC-OS by the PSI &#039;&#039;(Processes System Interface)&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
It is characterized by :&lt;br /&gt;
* a process ID &#039;&#039;(PID)&#039;&#039; and its parent process ID&lt;br /&gt;
* an owner &#039;&#039;(User ID)&#039;&#039;&lt;br /&gt;
* a list of execution [[Threads|threads]]&lt;br /&gt;
* a page directory defining the address space used by all execution threads&lt;br /&gt;
* all resource handles shared by all threads in the process.&lt;br /&gt;
&lt;br /&gt;
== PSI (Processes System Interface) ==&lt;br /&gt;
&lt;br /&gt;
Each process is defined by a &amp;lt;code&amp;gt;PSI_ENTRY&amp;lt;/code&amp;gt; containing all process information.&lt;br /&gt;
&lt;br /&gt;
=== PID ===&lt;br /&gt;
&lt;br /&gt;
A PID is a 16-bit unsigned integer, uniquely assigned to each process, with a maximum of &amp;lt;code&amp;gt;PSI_MAX_PROCESSES&amp;lt;/code&amp;gt;.&lt;br /&gt;
PSI maintains a linked list of unsorted used and free PIDs, allowing allocation and release of PIDs in &#039;&#039;O(1)&#039;&#039;, by respectively removing or adding the PID at the beginning of the list.&lt;br /&gt;
Both list share the same global table called &amp;lt;code&amp;gt;StatusTable&amp;lt;/code&amp;gt; with two initial pointers, one for the linked list of free entries (&amp;lt;code&amp;gt;firstFreeEntry&amp;lt;/code&amp;gt;), one for the linked list of used entries (&amp;lt;code&amp;gt;firstUsedEntry&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Internal functions for PID management are : &lt;br /&gt;
* PID PSI_AllocatePID(PSI_ENTRY *)&lt;br /&gt;
* void PSI_ReleasePID(PID)&lt;br /&gt;
&lt;br /&gt;
To get the PSI_ENTRY for a specific PID, an index table called &amp;lt;code&amp;gt;PSI_QuickTable&amp;lt;/code&amp;gt; is maintained.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Processes&amp;diff=98</id>
		<title>Processes</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Processes&amp;diff=98"/>
		<updated>2020-07-29T14:49:41Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Created page with &amp;quot;== Process definition in AMC-OS ==  A process is an instance of an application. Processes are managed in AMC-OS by the PSI &amp;#039;&amp;#039;(Processes System Interface)&amp;#039;&amp;#039; mo...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Process definition in AMC-OS ==&lt;br /&gt;
&lt;br /&gt;
A process is an instance of an [[Applications|application]].&lt;br /&gt;
Processes are managed in AMC-OS by the PSI &#039;&#039;(Processes System Interface)&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
It is characterized by :&lt;br /&gt;
* a process ID &#039;&#039;(PID)&#039;&#039; and its parent process ID&lt;br /&gt;
* an owner &#039;&#039;(User ID)&#039;&#039;&lt;br /&gt;
* a list of execution [[Threads|threads]]&lt;br /&gt;
* a page directory defining the address space used by all execution threads&lt;br /&gt;
* all resource handles shared by all threads in the process.&lt;br /&gt;
&lt;br /&gt;
== PSI (Processes System Interface) ==&lt;br /&gt;
&lt;br /&gt;
Each process is defined by a &amp;lt;code&amp;gt;PSI_ENTRY&amp;lt;/code&amp;gt; containing all process information.&lt;br /&gt;
&lt;br /&gt;
=== PID ===&lt;br /&gt;
&lt;br /&gt;
A PID is a 16-bit unsigned integer, uniquely assigned to each process, with a maximum of &amp;lt;code&amp;gt;PSI_MAX_PROCESSES&amp;lt;/code&amp;gt;.&lt;br /&gt;
PSI maintains a linked list of unsorted used and free PIDs, allowing allocation and release of PIDs in &#039;&#039;O(1)&#039;&#039;, by respectively removing or adding the PID at the beginning of the list.&lt;br /&gt;
Both list share the same global table called &amp;lt;code&amp;gt;StatusTable&amp;lt;/code&amp;gt; with two initial pointers, one for the linked list of free entries (&amp;lt;code&amp;gt;firstFreeEntry&amp;lt;/code&amp;gt;), one for the linked list of used entries (&amp;lt;code&amp;gt;firstUsedEntry&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Internal functions for PID management are : &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
PID PSI_AllocatePID(PSI_ENTRY *)&lt;br /&gt;
void PSI_ReleasePID(PID)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the PSI_ENTRY for a specific PID, an index table called &amp;lt;code&amp;gt;PSI_QuickTable&amp;lt;/code&amp;gt; is maintained.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Applications,_processes_and_threads&amp;diff=97</id>
		<title>Applications, processes and threads</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Applications,_processes_and_threads&amp;diff=97"/>
		<updated>2020-07-29T14:09:26Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Execution tasks in AMC-OS are divided in [[Applications|applications]], [[Processes|processes]] and [[Threads|threads]] : &lt;br /&gt;
&lt;br /&gt;
* [[Applications|An application]] is a static combination of executable code and data, in AMCX format.&lt;br /&gt;
* [[Processes|A process]] is an independant instance of an application.&lt;br /&gt;
* [[Threads|A thread]] is an instance of an execution flow in the restricted context of a process.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Applications,_processes_and_threads&amp;diff=96</id>
		<title>Applications, processes and threads</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Applications,_processes_and_threads&amp;diff=96"/>
		<updated>2020-07-29T14:09:17Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Execution tasks in AMC-OS are divided in [[Applications|applications]], [[Processes|processes] and [[Threads|threads]] : &lt;br /&gt;
&lt;br /&gt;
* [[Applications|An application]] is a static combination of executable code and data, in AMCX format.&lt;br /&gt;
* [[Processes|A process]] is an independant instance of an application.&lt;br /&gt;
* [[Threads|A thread]] is an instance of an execution flow in the restricted context of a process.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Applications,_processes_and_threads&amp;diff=95</id>
		<title>Applications, processes and threads</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Applications,_processes_and_threads&amp;diff=95"/>
		<updated>2020-07-29T14:07:46Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Created page with &amp;quot;Execution tasks in AMC-OS are divided in applications, processes and threads :   * An application is a static combination of executable code and data, in AMCX format. * A proc...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Execution tasks in AMC-OS are divided in applications, processes and threads : &lt;br /&gt;
&lt;br /&gt;
* An application is a static combination of executable code and data, in AMCX format.&lt;br /&gt;
* A process is an independant instance of an application.&lt;br /&gt;
* A thread is an instance of an execution flow in the restricted context of the process.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Main_Page&amp;diff=94</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Main_Page&amp;diff=94"/>
		<updated>2020-07-29T13:50:16Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Amc-os_ant_final.png|top|right|frame|AMC-OS Logo]]&lt;br /&gt;
&lt;br /&gt;
==Welcome to AMC-OS Developers Website==&lt;br /&gt;
&lt;br /&gt;
The AMC-OS Developers Website provides resources and information for people who :&lt;br /&gt;
* want to support AMC-OS development&lt;br /&gt;
* want to understand better how computers and OS work&lt;br /&gt;
* look for documentation and tools to build their own system&lt;br /&gt;
The website is divided into several sections depending on the information you are looking for.&lt;br /&gt;
&lt;br /&gt;
To get general information on AMC-OS, please visit the [http://www.amc-os.com/ main website].&lt;br /&gt;
&lt;br /&gt;
All AMC-OS code and documentation is released under the [[AMC-OS Developers:General disclaimer|AMC-OS License]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;5&amp;quot; width=&amp;quot;60%&amp;quot;&lt;br /&gt;
|+ AMC-OS Developers Website sections&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | OS Design&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Hardware&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Running AMC-OS&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* [[Processor management]]&lt;br /&gt;
* [[Boot process]]&lt;br /&gt;
* [[AMCX file format]]&lt;br /&gt;
* [[Memory and paging]]&lt;br /&gt;
* [[Applications, processes and threads]]&lt;br /&gt;
* [[Device drivers]]&lt;br /&gt;
|&lt;br /&gt;
* CPU&lt;br /&gt;
** [[Intel x86 Architecture]]&lt;br /&gt;
** [[Identifying CPU]]&lt;br /&gt;
* [[Interrupts]] (PIC, APIC)&lt;br /&gt;
* Devices identification&lt;br /&gt;
** [[BIOS]]&lt;br /&gt;
** [[Plug &amp;amp; Play]]&lt;br /&gt;
** [[PCI]]&lt;br /&gt;
* I/O&lt;br /&gt;
** [[Floppy disk controller]]&lt;br /&gt;
** [[IDE (ATA/ATAPI) controller]]&lt;br /&gt;
|&lt;br /&gt;
* [[Compiling and Linking]]&lt;br /&gt;
* [[Installing and running]]&lt;br /&gt;
* [[Debugging]]&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Building software&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Tools and resources&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; |&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* [[AMC-OS Kernel API]]&lt;br /&gt;
* [[AMC-OS C Library]]&lt;br /&gt;
* [[Compiling and Linking]]&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=93</id>
		<title>Memory initialization</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=93"/>
		<updated>2020-04-18T16:47:37Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=During AMC-OS Loader=&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;2.10.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader proceed this way :&lt;br /&gt;
* Try INT 15H, function E820 to get memory map.&lt;br /&gt;
* Try INT 15H, function E801 to get size of memory below 16MB and above 16MB&lt;br /&gt;
* Try INT 15H, function 88 to get effective size of extended memory&lt;br /&gt;
* Get configured size of extended memory in CMOS&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=Kernel start=&lt;br /&gt;
&lt;br /&gt;
When Kernel starts, AMC-OS uses information discovered by the loader to build memory structures.&lt;br /&gt;
&lt;br /&gt;
==First megabyte==&lt;br /&gt;
Kernel starts by calling &amp;lt;code&amp;gt;INIT_MemoryUsableIn1stMeg&amp;lt;/code&amp;gt;. The function determines the first address of free memory in the first megabyte, just after kernel relocation code and below EBDA.&lt;br /&gt;
&lt;br /&gt;
The function fills :&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePageAddrIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePagesIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A20 Gate==&lt;br /&gt;
Kernel unlocks A20 gate by calling &amp;lt;code&amp;gt;INIT_A20Gate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Physical memory initialization==&lt;br /&gt;
Physical memory is initialized by calling &amp;lt;code&amp;gt;INIT_GlobalMemory&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Memory map===&lt;br /&gt;
The function first builds a map of physical memory :&lt;br /&gt;
* If available, it relies first on type-1 (available) entries of E820 BIOS records. &#039;&#039;In current release, memory above 4GB is ignored&#039;&#039;.&lt;br /&gt;
* If available, it relies on E801 BIOS call results to determine a block of memory below 16MB and a block of memory above 16MB.&lt;br /&gt;
* In other cases, kernel do a manual probing of available memory, using function &amp;lt;code&amp;gt;INIT_MemoryCheckSegment&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=92</id>
		<title>Memory initialization</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=92"/>
		<updated>2020-04-18T16:39:49Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=During AMC-OS Loader=&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;2.10.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader proceed this way :&lt;br /&gt;
* Try INT 15H, function E820 to get memory map.&lt;br /&gt;
* Try INT 15H, function E801 to get size of memory below 16MB and above 16MB&lt;br /&gt;
* Try INT 15H, function 88 to get effective size of extended memory&lt;br /&gt;
* Get configured size of extended memory in CMOS&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=Kernel start=&lt;br /&gt;
&lt;br /&gt;
When Kernel starts, AMC-OS uses information discovered by the loader to build memory structures.&lt;br /&gt;
&lt;br /&gt;
==First megabyte==&lt;br /&gt;
Kernel starts by calling &amp;lt;code&amp;gt;INIT_MemoryUsableIn1stMeg&amp;lt;/code&amp;gt;. The function determines the first address of free memory in the first megabyte, just after kernel relocation code and below EBDA.&lt;br /&gt;
&lt;br /&gt;
The function fills :&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePageAddrIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;MEMORY_FreePagesIn1stMeg&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A20 Gate==&lt;br /&gt;
Kernel unlocks A20 gate by calling &amp;lt;code&amp;gt;INIT_A20Gate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=91</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=91"/>
		<updated>2020-04-18T16:04:37Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Physical memory management =&lt;br /&gt;
For more information on physical memory initialization, refer to &#039;&#039;[[Memory initialization]]&#039;&#039; article.&lt;br /&gt;
&lt;br /&gt;
== Memory areas ==&lt;br /&gt;
&lt;br /&gt;
After scanning the linear address space for available physical memory, AMC-OS split the physical memory in two areas :&lt;br /&gt;
* The &#039;&#039;&#039;low memory area&#039;&#039;&#039; must be at least 4Mbytes large, and its size is proportional to the total amount of physical memory available. This area is also referred as &#039;&#039;kernel memory&#039;&#039; as the physical memory is available from all page directories at kernel privilege.&lt;br /&gt;
* The &#039;&#039;&#039;high memory area&#039;&#039;&#039; contains all the remaining memory and is used for user memory.&lt;br /&gt;
&lt;br /&gt;
Each memory area is divided in blocks of 256Kbytes, and is specified in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structure containing :&lt;br /&gt;
* the number and pointers to the used blocks they contain;&lt;br /&gt;
* the number and pointers to the free blocks they contain;&lt;br /&gt;
* the number and pointers to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory can be taken from low memory if high memory is exhausted.&lt;br /&gt;
&lt;br /&gt;
== Blocks management ==&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
By default, each memory area is divided in blocks of 256 Kbytes. A new block is &#039;&#039;activated&#039;&#039; and divided in free pages, if there are no more free pages available in the area. Free blocks are stored in the &#039;&#039;free blocks list&#039;&#039;, a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains :&lt;br /&gt;
* the pointer to the free block;&lt;br /&gt;
* the number of contiguous free blocks;&lt;br /&gt;
* the pointer to the next structure.&lt;br /&gt;
During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=90</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=90"/>
		<updated>2020-04-18T15:59:07Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Physical memory management ==&lt;br /&gt;
For more information on physical memory initialization, refer to &#039;&#039;[[Memory initialization]]&#039;&#039; article.&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
After scanning the linear address space for available physical memory, AMC-OS split the physical memory in two areas :&lt;br /&gt;
* The &#039;&#039;&#039;low memory area&#039;&#039;&#039; must be at least 4Mbytes large, and its size is proportional to the total amount of physical memory available. This area is also referred as &#039;&#039;kernel memory&#039;&#039; as the physical memory is available from all page directories at kernel privilege.&lt;br /&gt;
* The &#039;&#039;&#039;high memory area&#039;&#039;&#039; contains all the remaining memory and is used for user memory.&lt;br /&gt;
&lt;br /&gt;
Each area is specified in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structure. It contains :&lt;br /&gt;
* the number and pointers to the used blocks they contain;&lt;br /&gt;
* the number and pointers to the free blocks they contain;&lt;br /&gt;
* the number and pointers to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory can be taken from low memory if high memory is exhausted.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
By default, each memory area is divided in blocks of 256 Kbytes. A new block is &#039;&#039;activated&#039;&#039; and divided in free pages, if there are no more free pages available in the area. Free blocks are stored in the &#039;&#039;free blocks list&#039;&#039;, a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains :&lt;br /&gt;
* the pointer to the free block;&lt;br /&gt;
* the number of contiguous free blocks;&lt;br /&gt;
* the pointer to the next structure.&lt;br /&gt;
During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=89</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=89"/>
		<updated>2020-04-18T15:58:43Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Memory model ==&lt;br /&gt;
&lt;br /&gt;
=== Physical memory ===&lt;br /&gt;
&lt;br /&gt;
Physical memory is divided in several segments that can be used by the system.&lt;br /&gt;
During initialization phase, the system scan the linear address space for the available segments. In a standard PC, there are typically two segments : the first megabyte of memory (generally only the first 640Kbytes  as BIOS, ROMs and video memory are mapped in the last 384Kbytes) and the memory above 1MB. In some cases, there also can be a hole in the 15-16M adressing space, or memory reserved for PCI addressing space. During the scan, the system counts the number of available blocks in each segment.&lt;br /&gt;
&lt;br /&gt;
AMC-OS split the physical memory in two areas :&lt;br /&gt;
* low memory reserved for kernel usage (&#039;&#039;will also be referred as &#039;&#039;&#039;kernel memory&#039;&#039;&#039;)&#039;&#039;;&lt;br /&gt;
* high memory for processes &#039;&#039;(will also be referred as &#039;&#039;&#039;user memory&#039;&#039;&#039;)&#039;&#039;. &lt;br /&gt;
These two areas are divided in contiguous blocks of 256Kbytes by default, themselves being divided in 4Kbytes pages. To reduce the amount of memory used by the system, the blocks are activated on demand, and only then divided in pages.&lt;br /&gt;
&lt;br /&gt;
=== Virtual memory ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Physical memory management ==&lt;br /&gt;
For more information on physical memory initialization, refer to &#039;&#039;[[Memory initialization]]&#039;&#039; article.&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
After scanning the linear address space for available physical memory, AMC-OS split the physical memory in two areas :&lt;br /&gt;
* The &#039;&#039;&#039;low memory area&#039;&#039;&#039; must be at least 4Mbytes large, and its size is proportional to the total amount of physical memory available. This area is also referred as &#039;&#039;kernel memory&#039;&#039; as the physical memory is available from all page directories at kernel privilege.&lt;br /&gt;
* The &#039;&#039;&#039;high memory area&#039;&#039;&#039; contains all the remaining memory and is used for user memory.&lt;br /&gt;
&lt;br /&gt;
Each area is specified in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structure. It contains :&lt;br /&gt;
* the number and pointers to the used blocks they contain;&lt;br /&gt;
* the number and pointers to the free blocks they contain;&lt;br /&gt;
* the number and pointers to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory can be taken from low memory if high memory is exhausted.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
By default, each memory area is divided in blocks of 256 Kbytes. A new block is &#039;&#039;activated&#039;&#039; and divided in free pages, if there are no more free pages available in the area. Free blocks are stored in the &#039;&#039;free blocks list&#039;&#039;, a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains :&lt;br /&gt;
* the pointer to the free block;&lt;br /&gt;
* the number of contiguous free blocks;&lt;br /&gt;
* the pointer to the next structure.&lt;br /&gt;
During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=88</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=88"/>
		<updated>2020-04-18T15:29:45Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Memory model ==&lt;br /&gt;
&lt;br /&gt;
=== Physical memory ===&lt;br /&gt;
&lt;br /&gt;
Physical memory is divided in several segments that can be used by the system.&lt;br /&gt;
During initialization phase, the system scan the linear address space for the available segments. In a standard PC, there are typically two segments : the first megabyte of memory (generally only the first 640Kbytes  as BIOS, ROMs and video memory are mapped in the last 384Kbytes) and the memory above 1MB. In some cases, there also can be a hole in the 15-16M adressing space, or memory reserved for PCI addressing space. During the scan, the system counts the number of available blocks in each segment.&lt;br /&gt;
&lt;br /&gt;
AMC-OS split the physical memory in two areas :&lt;br /&gt;
* low memory reserved for kernel usage (&#039;&#039;will also be referred as &#039;&#039;&#039;kernel memory&#039;&#039;&#039;)&#039;&#039;;&lt;br /&gt;
* high memory for processes &#039;&#039;(will also be referred as &#039;&#039;&#039;user memory&#039;&#039;&#039;)&#039;&#039;. &lt;br /&gt;
These two areas are divided in contiguous blocks of 256Kbytes by default, themselves being divided in 4Kbytes pages. To reduce the amount of memory used by the system, the blocks are activated on demand, and only then divided in pages.&lt;br /&gt;
&lt;br /&gt;
=== Virtual memory ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Physical memory management ==&lt;br /&gt;
For more information on physical memory initialization, refer to [[Memory Initialization]] article.&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
After scanning the linear address space for available physical memory, AMC-OS split the physical memory in two areas :&lt;br /&gt;
* The &#039;&#039;&#039;low memory area&#039;&#039;&#039; must be at least 4Mbytes large, and its size is proportional to the total amount of physical memory available. This area is also referred as &#039;&#039;kernel memory&#039;&#039; as the physical memory is available from all page directories at kernel privilege.&lt;br /&gt;
* The &#039;&#039;&#039;high memory area&#039;&#039;&#039; contains all the remaining memory and is used for user memory.&lt;br /&gt;
&lt;br /&gt;
Each area is specified in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structure. It contains :&lt;br /&gt;
* the number and pointers to the used blocks they contain;&lt;br /&gt;
* the number and pointers to the free blocks they contain;&lt;br /&gt;
* the number and pointers to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory can be taken from low memory if high memory is exhausted.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
By default, each memory area is divided in blocks of 256 Kbytes. A new block is &#039;&#039;activated&#039;&#039; and divided in free pages, if there are no more free pages available in the area. Free blocks are stored in the &#039;&#039;free blocks list&#039;&#039;, a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains :&lt;br /&gt;
* the pointer to the free block;&lt;br /&gt;
* the number of contiguous free blocks;&lt;br /&gt;
* the pointer to the next structure.&lt;br /&gt;
During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=87</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=87"/>
		<updated>2020-04-18T15:29:27Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* Physical memory management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Memory model ==&lt;br /&gt;
&lt;br /&gt;
=== Physical memory ===&lt;br /&gt;
&lt;br /&gt;
Physical memory is divided in several segments that can be used by the system.&lt;br /&gt;
During initialization phase, the system scan the linear address space for the available segments. In a standard PC, there are typically two segments : the first megabyte of memory (generally only the first 640Kbytes  as BIOS, ROMs and video memory are mapped in the last 384Kbytes) and the memory above 1MB. In some cases, there also can be a hole in the 15-16M adressing space, or memory reserved for PCI addressing space. During the scan, the system counts the number of available blocks in each segment.&lt;br /&gt;
&lt;br /&gt;
AMC-OS split the physical memory in two areas :&lt;br /&gt;
* low memory reserved for kernel usage (&#039;&#039;will also be referred as &#039;&#039;&#039;kernel memory&#039;&#039;&#039;)&#039;&#039;;&lt;br /&gt;
* high memory for processes &#039;&#039;(will also be referred as &#039;&#039;&#039;user memory&#039;&#039;&#039;)&#039;&#039;. &lt;br /&gt;
These two areas are divided in contiguous blocks of 256Kbytes by default, themselves being divided in 4Kbytes pages. To reduce the amount of memory used by the system, the blocks are activated on demand, and only then divided in pages.&lt;br /&gt;
&lt;br /&gt;
=== Virtual memory ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Physical memory management ==&lt;br /&gt;
For more information on physical memory initialization, refer to [[Memmory Initialization]] article.&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
After scanning the linear address space for available physical memory, AMC-OS split the physical memory in two areas :&lt;br /&gt;
* The &#039;&#039;&#039;low memory area&#039;&#039;&#039; must be at least 4Mbytes large, and its size is proportional to the total amount of physical memory available. This area is also referred as &#039;&#039;kernel memory&#039;&#039; as the physical memory is available from all page directories at kernel privilege.&lt;br /&gt;
* The &#039;&#039;&#039;high memory area&#039;&#039;&#039; contains all the remaining memory and is used for user memory.&lt;br /&gt;
&lt;br /&gt;
Each area is specified in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structure. It contains :&lt;br /&gt;
* the number and pointers to the used blocks they contain;&lt;br /&gt;
* the number and pointers to the free blocks they contain;&lt;br /&gt;
* the number and pointers to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory can be taken from low memory if high memory is exhausted.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
By default, each memory area is divided in blocks of 256 Kbytes. A new block is &#039;&#039;activated&#039;&#039; and divided in free pages, if there are no more free pages available in the area. Free blocks are stored in the &#039;&#039;free blocks list&#039;&#039;, a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains :&lt;br /&gt;
* the pointer to the free block;&lt;br /&gt;
* the number of contiguous free blocks;&lt;br /&gt;
* the pointer to the next structure.&lt;br /&gt;
During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=86</id>
		<title>Memory initialization</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_initialization&amp;diff=86"/>
		<updated>2020-04-18T15:28:51Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Created page with &amp;quot;==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 &amp;lt;2.10.  AMC-OS Loade...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==During AMC-OS Loader==&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;2.10.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader proceed this way :&lt;br /&gt;
* Try INT 15H, function E820 to get memory map.&lt;br /&gt;
* Try INT 15H, function E801 to get size of memory below 16MB and above 16MB&lt;br /&gt;
* Try INT 15H, function 88 to get effective size of extended memory&lt;br /&gt;
* Get configured size of extended memory in CMOS&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Kernel start==&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=85</id>
		<title>AMC-OS Loader</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=85"/>
		<updated>2020-04-18T15:28:37Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader is a module part of the [[Boot process|boot process]]. Its task is to locate the kernel in the booting volume, load it in memory and prepare all the necessary structures to start it.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader gives us much more flexibility in [[Boot process|boot process]], as we no longer have the limitation of 512 bytes of code. However, the CPU is still running in real mode, implying limitations in the size of structures and files we have to manipulate.&lt;br /&gt;
&lt;br /&gt;
==Process==&lt;br /&gt;
[[image:Amcos_loader.png|right|thumb|250px|AMC-OS Loader splash screen]]&lt;br /&gt;
AMC-OS Loader follow this procedure :&lt;br /&gt;
* Wait for options (typically F1 for debugging purposes if compiled with DEBUG support)&lt;br /&gt;
* System check : Check that we have a 386+ running in real-mode&lt;br /&gt;
* [[AMC-OS Loader Memory management|Check for EBDA and initialize first MB of memory to allow memory allocation]]&lt;br /&gt;
* [[Memory initialization|Ask BIOS information on the available RAM in the system]]&lt;br /&gt;
* Precisely [[Identifying CPU|identify the CPU]] using either the CPUID instruction or a CPU reset, and calculates its running frequency&lt;br /&gt;
* Check if we start from a MBR (removeable media) or a VBR and locate volume to boot&lt;br /&gt;
* Identify the volume type (FAT12, FAT16...) and initialize according filesystem driver.&lt;br /&gt;
* Locate and load the required kernel files&lt;br /&gt;
* Identify the video graphics card, check VESA support to get best text resolution during kernel initialization&lt;br /&gt;
* Prepare the CPU for protected mode (GDT and system descriptors)&lt;br /&gt;
* Do a first switch to protected mode to decode kernel AMCX file and relocate it in memory&lt;br /&gt;
* Do a second switch to protected mode to start kernel&lt;br /&gt;
&lt;br /&gt;
==Files==&lt;br /&gt;
AMC-OS Loader is composed of two files :&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; contains raw code of AMC-OS Loader (no header nor relocation).&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; is a picture of AMC-OS Logo displayed during AMC-OS Loader execution.&lt;br /&gt;
&lt;br /&gt;
Both files are loaded by the [[Boot process#The Boot Loader|boot sector]].&lt;br /&gt;
&lt;br /&gt;
==16-bit code and V86==&lt;br /&gt;
AMC-OS Loader stays in memory to allow 16-bit code to be executed from Kernel in V86 mode, typically to call INT 10H (video)&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_identification&amp;diff=84</id>
		<title>Memory identification</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_identification&amp;diff=84"/>
		<updated>2020-04-18T15:28:18Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=83</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=83"/>
		<updated>2020-04-13T15:51:09Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
{|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data (initialized by boot loader)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__A] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (AMCOSLDR_Malloc_Entry)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation==&lt;br /&gt;
Three functions are available to AMC-OS Loader for memory allocation :&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The two first functions maintains the linked list of available blocks of memory.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_identification&amp;diff=82</id>
		<title>Memory identification</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_identification&amp;diff=82"/>
		<updated>2020-04-13T15:24:19Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Created page with &amp;quot;==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 &amp;lt;2.10.  AMC-OS Loade...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==During AMC-OS Loader==&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;2.10.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader proceed this way :&lt;br /&gt;
* Try INT 15H, function E820 to get memory map.&lt;br /&gt;
* Try INT 15H, function E801 to get size of memory below 16MB and above 16MB&lt;br /&gt;
* Try INT 15H, function 88 to get effective size of extended memory&lt;br /&gt;
* Get configured size of extended memory in CMOS&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Kernel start==&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=81</id>
		<title>AMC-OS Loader</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=81"/>
		<updated>2020-04-13T15:19:17Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader is a module part of the [[Boot process|boot process]]. Its task is to locate the kernel in the booting volume, load it in memory and prepare all the necessary structures to start it.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader gives us much more flexibility in [[Boot process|boot process]], as we no longer have the limitation of 512 bytes of code. However, the CPU is still running in real mode, implying limitations in the size of structures and files we have to manipulate.&lt;br /&gt;
&lt;br /&gt;
==Process==&lt;br /&gt;
[[image:Amcos_loader.png|right|thumb|250px|AMC-OS Loader splash screen]]&lt;br /&gt;
AMC-OS Loader follow this procedure :&lt;br /&gt;
* Wait for options (typically F1 for debugging purposes if compiled with DEBUG support)&lt;br /&gt;
* System check : Check that we have a 386+ running in real-mode&lt;br /&gt;
* [[AMC-OS Loader Memory management|Check for EBDA and initialize first MB of memory to allow memory allocation]]&lt;br /&gt;
* [[Memory identification|Ask BIOS information on the available RAM in the system]]&lt;br /&gt;
* Precisely [[Identifying CPU|identify the CPU]] using either the CPUID instruction or a CPU reset, and calculates its running frequency&lt;br /&gt;
* Check if we start from a MBR (removeable media) or a VBR and locate volume to boot&lt;br /&gt;
* Identify the volume type (FAT12, FAT16...) and initialize according filesystem driver.&lt;br /&gt;
* Locate and load the required kernel files&lt;br /&gt;
* Identify the video graphics card, check VESA support to get best text resolution during kernel initialization&lt;br /&gt;
* Prepare the CPU for protected mode (GDT and system descriptors)&lt;br /&gt;
* Do a first switch to protected mode to decode kernel AMCX file and relocate it in memory&lt;br /&gt;
* Do a second switch to protected mode to start kernel&lt;br /&gt;
&lt;br /&gt;
==Files==&lt;br /&gt;
AMC-OS Loader is composed of two files :&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; contains raw code of AMC-OS Loader (no header nor relocation).&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; is a picture of AMC-OS Logo displayed during AMC-OS Loader execution.&lt;br /&gt;
&lt;br /&gt;
Both files are loaded by the [[Boot process#The Boot Loader|boot sector]].&lt;br /&gt;
&lt;br /&gt;
==16-bit code and V86==&lt;br /&gt;
AMC-OS Loader stays in memory to allow 16-bit code to be executed from Kernel in V86 mode, typically to call INT 10H (video)&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=80</id>
		<title>AMC-OS Loader</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=80"/>
		<updated>2020-04-13T15:17:59Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader is a module part of the [[Boot process|boot process]]. Its task is to locate the kernel in the booting volume, load it in memory and prepare all the necessary structures to start it.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader gives us much more flexibility in [[Boot process|boot process]], as we no longer have the limitation of 512 bytes of code. However, the CPU is still running in real mode, implying limitations in the size of structures and files we have to manipulate.&lt;br /&gt;
&lt;br /&gt;
==Process==&lt;br /&gt;
[[image:Amcos_loader.png|right|thumb|250px|AMC-OS Loader splash screen]]&lt;br /&gt;
AMC-OS Loader follow this procedure :&lt;br /&gt;
* Wait for options (typically F1 for debugging purposes if compiled with DEBUG support)&lt;br /&gt;
* System check : Check that we have a 386+ running in real-mode&lt;br /&gt;
* Check for EBDA and [[AMC-OS Loader Memory management|initialize first MB of memory to allow memory allocation]]&lt;br /&gt;
* Ask BIOS information on the available RAM in the system.&lt;br /&gt;
* Precisely [[Identifying CPU|identify the CPU]] using either the CPUID instruction or a CPU reset, and calculates its running frequency&lt;br /&gt;
* Check if we start from a MBR (removeable media) or a VBR and locate volume to boot&lt;br /&gt;
* Identify the volume type (FAT12, FAT16...) and initialize according filesystem driver.&lt;br /&gt;
* Locate and load the required kernel files&lt;br /&gt;
* Identify the video graphics card, check VESA support to get best text resolution during kernel initialization&lt;br /&gt;
* Prepare the CPU for protected mode (GDT and system descriptors)&lt;br /&gt;
* Do a first switch to protected mode to decode kernel AMCX file and relocate it in memory&lt;br /&gt;
* Do a second switch to protected mode to start kernel&lt;br /&gt;
&lt;br /&gt;
==Files==&lt;br /&gt;
AMC-OS Loader is composed of two files :&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; contains raw code of AMC-OS Loader (no header nor relocation).&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; is a picture of AMC-OS Logo displayed during AMC-OS Loader execution.&lt;br /&gt;
&lt;br /&gt;
Both files are loaded by the [[Boot process#The Boot Loader|boot sector]].&lt;br /&gt;
&lt;br /&gt;
==16-bit code and V86==&lt;br /&gt;
AMC-OS Loader stays in memory to allow 16-bit code to be executed from Kernel in V86 mode, typically to call INT 10H (video)&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=79</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=79"/>
		<updated>2020-04-13T15:15:52Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
{|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data (initialized by boot loader)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__A] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (AMCOSLDR_Malloc_Entry)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation==&lt;br /&gt;
Three functions are available to AMC-OS Loader for memory allocation :&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The two first functions maintains the linked list of available blocks of memory.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=78</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=78"/>
		<updated>2020-04-13T15:15:18Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
{|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data (initialized by boot loader)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__A] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (AMCOSLDR_Malloc_Entry)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation==&lt;br /&gt;
Three functions are available to AMC-OS Loader for memory allocation :&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
The two first functions maintains the linked list of available blocks of memory.&lt;br /&gt;
All function 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.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=77</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=77"/>
		<updated>2020-04-13T15:12:42Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
{|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data (initialized by boot loader)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__A] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (AMCOSLDR_Malloc_Entry)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation==&lt;br /&gt;
Three functions are available to AMC-OS Loader for memory allocation :&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
The two first functions maintains the linked list of available blocks of memory.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=76</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=76"/>
		<updated>2020-04-13T15:11:58Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
{|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Real-mode interrupt table&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt;&lt;br /&gt;
|BIOS static data&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt;&lt;br /&gt;
|Kernel static data (initialized by boot loader)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader code&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader picture&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|AMC-OS Loader stack&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Free (unused)&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt;&lt;br /&gt;
|&#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt;&lt;br /&gt;
|Extended BIOS data area (EBDA - optional)&lt;br /&gt;
}&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__A] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (AMCOSLDR_Malloc_Entry)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation==&lt;br /&gt;
Three functions are available to AMC-OS Loader for memory allocation :&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
The two first functions maintains the linked list of available blocks of memory.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=75</id>
		<title>AMC-OS Loader Memory management</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader_Memory_management&amp;diff=75"/>
		<updated>2020-04-13T15:08:53Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Created page with &amp;quot;=Memory used during AMC-OS Loader execution= AMC-OS Loader uses only the first megabyte of memory : *&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt; : Real-mode interrupt table *&amp;lt;code&amp;gt;00400-00500&amp;lt;/c...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Memory used during AMC-OS Loader execution=&lt;br /&gt;
AMC-OS Loader uses only the first megabyte of memory :&lt;br /&gt;
*&amp;lt;code&amp;gt;00000-003FF&amp;lt;/code&amp;gt; : Real-mode interrupt table&lt;br /&gt;
*&amp;lt;code&amp;gt;00400-00500&amp;lt;/code&amp;gt; : BIOS static data&lt;br /&gt;
*&amp;lt;code&amp;gt;00501-005FF&amp;lt;/code&amp;gt; : Free (unused)&lt;br /&gt;
*&amp;lt;code&amp;gt;00600-007FF&amp;lt;/code&amp;gt; : &#039;&#039;Master boot record&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;00800-[__A]&amp;lt;/code&amp;gt; : Kernel static data (initialized by boot loader)&lt;br /&gt;
*&amp;lt;code&amp;gt;[__A]-[__B]&amp;lt;/code&amp;gt; : AMC-OS Loader code&lt;br /&gt;
*&amp;lt;code&amp;gt;[__B]-[__C]&amp;lt;/code&amp;gt; : AMC-OS Loader picture&lt;br /&gt;
*&amp;lt;code&amp;gt;[__C]-077FF&amp;lt;/code&amp;gt; : &#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;077FF-07BFF&amp;lt;/code&amp;gt; : AMC-OS Loader stack&lt;br /&gt;
*&amp;lt;code&amp;gt;07C00-07DFF&amp;lt;/code&amp;gt; : Boot loader code (VBR or MBR for floppy disk)&lt;br /&gt;
*&amp;lt;code&amp;gt;07E00-07FFF&amp;lt;/code&amp;gt; : Free (unused)&lt;br /&gt;
*&amp;lt;code&amp;gt;08000-9[_D]&amp;lt;/code&amp;gt; : &#039;&#039;Free for allocation&#039;&#039;&lt;br /&gt;
*&amp;lt;code&amp;gt;9[_D]-09FFF&amp;lt;/code&amp;gt; : Extended BIOS data area (EBDA - optional)&lt;br /&gt;
&lt;br /&gt;
=Memory management=&lt;br /&gt;
==Initialization==&lt;br /&gt;
During memory initialization process (&amp;lt;code&amp;gt;AMCOSLDR_InitFirstMegabyte&amp;lt;/code&amp;gt;), AMC-OS Loader :&lt;br /&gt;
* looks for EBDA using interrupt 12H and value stored in 0040:000E to get highest pointer in memory [_D]&lt;br /&gt;
* calculates the values of [__A] to get lowest pointer in memory&lt;br /&gt;
* creates a linked list of available blocks of memory (AMCOSLDR_Malloc_Entry)&lt;br /&gt;
* initializes two blocks of available memory (marked &#039;&#039;Free for allocation&#039;&#039; in previous table)&lt;br /&gt;
&lt;br /&gt;
==Allocation==&lt;br /&gt;
Three functions are available to AMC-OS Loader for memory allocation :&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_DefinitiveAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_TempAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
* &amp;lt;code&amp;gt;AMCOSLDR_VolatileAlloc&amp;lt;/code&amp;gt; : 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.&lt;br /&gt;
The two first functions maintains the linked list of available blocks of memory.&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=74</id>
		<title>AMC-OS Loader</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=74"/>
		<updated>2020-04-13T14:46:32Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader is a module part of the [[Boot process|boot process]]. Its task is to locate the kernel in the booting volume, load it in memory and prepare all the necessary structures to start it.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader gives us much more flexibility in [[Boot process|boot process]], as we no longer have the limitation of 512 bytes of code. However, the CPU is still running in real mode, implying limitations in the size of structures and files we have to manipulate.&lt;br /&gt;
&lt;br /&gt;
==Process==&lt;br /&gt;
[[image:Amcos_loader.png|right|thumb|250px|AMC-OS Loader splash screen]]&lt;br /&gt;
AMC-OS Loader follow this procedure :&lt;br /&gt;
* Wait for options (typically F1 for debugging purposes if compiled with DEBUG support)&lt;br /&gt;
* System check : Check that we have a 386+ running in real-mode&lt;br /&gt;
* Check for EBDA and initialize first MB of memory to allow memory allocation : [[AMC-OS Loader Memory management]]&lt;br /&gt;
* Ask BIOS information on the available RAM in the system.&lt;br /&gt;
* Precisely [[Identifying CPU|identify the CPU]] using either the CPUID instruction or a CPU reset, and calculates its running frequency&lt;br /&gt;
* Check if we start from a MBR (removeable media) or a VBR and locate volume to boot&lt;br /&gt;
* Identify the volume type (FAT12, FAT16...) and initialize according filesystem driver.&lt;br /&gt;
* Locate and load the required kernel files&lt;br /&gt;
* Identify the video graphics card, check VESA support to get best text resolution during kernel initialization&lt;br /&gt;
* Prepare the CPU for protected mode (GDT and system descriptors)&lt;br /&gt;
* Do a first switch to protected mode to decode kernel AMCX file and relocate it in memory&lt;br /&gt;
* Do a second switch to protected mode to start kernel&lt;br /&gt;
&lt;br /&gt;
==Files==&lt;br /&gt;
AMC-OS Loader is composed of two files :&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; contains raw code of AMC-OS Loader (no header nor relocation).&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; is a picture of AMC-OS Logo displayed during AMC-OS Loader execution.&lt;br /&gt;
&lt;br /&gt;
Both files are loaded by the [[Boot process#The Boot Loader|boot sector]].&lt;br /&gt;
&lt;br /&gt;
==16-bit code and V86==&lt;br /&gt;
AMC-OS Loader stays in memory to allow 16-bit code to be executed from Kernel in V86 mode, typically to call INT 10H (video)&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=73</id>
		<title>AMC-OS Loader</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=73"/>
		<updated>2017-05-16T10:52:52Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* Process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader is a module part of the [[Boot process|boot process]]. Its task is to locate the kernel in the booting volume, load it in memory and prepare all the necessary structures to start it.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader gives us much more flexibility in [[Boot process|boot process]], as we no longer have the limitation of 512 bytes of code. However, the CPU is still running in real mode, implying limitations in the size of structures and files we have to manipulate.&lt;br /&gt;
&lt;br /&gt;
==Process==&lt;br /&gt;
[[image:Amcos_loader.png|right|thumb|250px|AMC-OS Loader splash screen]]&lt;br /&gt;
AMC-OS Loader follow this procedure :&lt;br /&gt;
* System check : Check that we have a 386+ running in real-mode&lt;br /&gt;
* Ask BIOS information on the available RAM in the system and initialize low memory (&amp;lt;640KB) for allocation.&lt;br /&gt;
* Precisely [[Identifying CPU|identify the CPU]] using either the CPUID instruction or a CPU reset, and calculates its running frequency&lt;br /&gt;
* Check if we start from a MBR (removeable media) or a VBR and locate volume to boot&lt;br /&gt;
* Identify the volume type (FAT12, FAT16...) and initialize according filesystem driver.&lt;br /&gt;
* Locate and load the required kernel files&lt;br /&gt;
* Identify the video graphics card, check VESA support to get best text resolution during kernel initialization&lt;br /&gt;
* Prepare the CPU for protected mode (GDT and system descriptors)&lt;br /&gt;
* Do a first switch to protected mode to decode kernel AMCX file and relocate it in memory&lt;br /&gt;
* Do a second switch to protected mode to start kernel&lt;br /&gt;
&lt;br /&gt;
==Files==&lt;br /&gt;
AMC-OS Loader is composed of two files :&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; contains raw code of AMC-OS Loader (no header nor relocation).&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; is a picture of AMC-OS Logo displayed during AMC-OS Loader execution.&lt;br /&gt;
&lt;br /&gt;
Both files are loaded by the [[Boot process#The Boot Loader|boot sector]].&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=72</id>
		<title>AMC-OS Loader</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=AMC-OS_Loader&amp;diff=72"/>
		<updated>2017-05-16T10:49:43Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader is a module part of the [[Boot process|boot process]]. Its task is to locate the kernel in the booting volume, load it in memory and prepare all the necessary structures to start it.&lt;br /&gt;
&lt;br /&gt;
AMC-OS Loader gives us much more flexibility in [[Boot process|boot process]], as we no longer have the limitation of 512 bytes of code. However, the CPU is still running in real mode, implying limitations in the size of structures and files we have to manipulate.&lt;br /&gt;
&lt;br /&gt;
==Process==&lt;br /&gt;
[[image:Amcos_loader.png|right|thumb|250px|AMC-OS Loader splash screen]]&lt;br /&gt;
AMC-OS Loader follow this procedure :&lt;br /&gt;
* System check : Check that we have a 386+ running in real-mode&lt;br /&gt;
* Load and compare the disk FATs, converts them to FAT16 for simpler management (for FAT12 floppy disks)&lt;br /&gt;
* Locate the &amp;lt;tt&amp;gt;MODULES&amp;lt;/tt&amp;gt; directory containing all kernel files required for boot&lt;br /&gt;
* Load all kernel files in memory using the contents of the &amp;lt;tt&amp;gt;[[AMCOS.MOD]]&amp;lt;/tt&amp;gt; file&lt;br /&gt;
* Precisely [[Identifying CPU|identify the CPU]] using either the CPUID instruction or a CPU reset, and calculates its running frequency&lt;br /&gt;
* Identify the video graphics card, check VESA support to get best text resolution during kernel initialization&lt;br /&gt;
* Prepare the CPU for protected mode (GDT and system descriptors)&lt;br /&gt;
* Do a first switch to protected mode to decode kernel AMCX file and relocate it in memory&lt;br /&gt;
* Do a second switch to protected mode to start kernel&lt;br /&gt;
&lt;br /&gt;
==Files==&lt;br /&gt;
AMC-OS Loader is composed of two files :&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; contains raw code of AMC-OS Loader (no header nor relocation).&lt;br /&gt;
* &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; is a picture of AMC-OS Logo displayed during AMC-OS Loader execution.&lt;br /&gt;
&lt;br /&gt;
Both files are loaded by the [[Boot process#The Boot Loader|boot sector]].&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Boot_process&amp;diff=71</id>
		<title>Boot process</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Boot_process&amp;diff=71"/>
		<updated>2017-05-16T10:46:16Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* The Boot Loader */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS booting process is done in three different phases :&lt;br /&gt;
* [[Boot process#The Boot Loader|The boot loader]] &#039;&#039;(also named volume boot record (VBR) or master boot record (MBR) for removeable media)&#039;&#039;&lt;br /&gt;
* [[AMC-OS Loader]] - Check system, CPU, memory, loads and relocates Kernel in memory&lt;br /&gt;
* &#039;&#039;&#039;Kernel initialization&#039;&#039;&#039; - Initializes all structures to start the AMC-OS kernel&lt;br /&gt;
&lt;br /&gt;
At power up, and after BIOS initialization, for historical/compatibility reasons, the processor runs in real adressing mode. In this mode, the CPU runs a 16-byte memory adressing scheme, meaning that we can only address 16 segments of 64KB of memory (ie 1MB), divided in &amp;quot;user&amp;quot; memory (640KB - the so-called &amp;quot;conventional memory&amp;quot; in MS-DOS) and Video RAM+System ROMS (384KB).&lt;br /&gt;
 &lt;br /&gt;
We have to switch the processor to 32-bit protected mode to run a 32-byte memory adressing scheme and adress 4GB of physical memory. It is even possible, starting with the Pentium Pro, to run a 36-byte memory addressing, called PAE (Physical Address Extension), allowing the adressing of 64GB of memory.&lt;br /&gt;
 &lt;br /&gt;
Switching to protected mode requires some preparation and resources, and most BIOS functions are no longer available (ie. disk read, changing video mode...), meaning that we must have loaded all kernel required files in memory before switching.&lt;br /&gt;
&lt;br /&gt;
==The Boot Loader==&lt;br /&gt;
The boot loader is the first sector (512 bytes) of the source media (typically the floppy disk). The BIOS automatically loads the first sector of the specified media during system boot process, at physical memory address &amp;lt;tt&amp;gt;00007C00&amp;lt;/tt&amp;gt;, checks that the last word value is &amp;lt;tt&amp;gt;55AA&amp;lt;/tt&amp;gt;, and if so, jump execution to first byte.&lt;br /&gt;
 &lt;br /&gt;
AMC-OS 1.44M Boot Floppy disks are in standard FAT12 format and contains the adequate header. There lasts only 451 bytes to :&lt;br /&gt;
* Load the FAT and Root directory (\) listing in memory&lt;br /&gt;
* Locate &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; files in the root directory&lt;br /&gt;
* Load the files in memory&lt;br /&gt;
* Switch execution to AMC-OS Loader&lt;br /&gt;
 &lt;br /&gt;
The boot loader uses BIOS support through &amp;lt;tt&amp;gt;INT 13H&amp;lt;/tt&amp;gt; for I/O functions.&lt;br /&gt;
In case of error during execution, the boot loader will display :&lt;br /&gt;
* &amp;lt;tt&amp;gt;FIL?&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;File not found&amp;lt;/tt&amp;gt; if one of the required files hasn&#039;t been found in the root directory&lt;br /&gt;
* &amp;lt;tt&amp;gt;DSK?&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Read error&amp;lt;/tt&amp;gt; if a read error occured (probably defective disk)&lt;br /&gt;
&lt;br /&gt;
==AMC-OS Loader==&lt;br /&gt;
&#039;&#039;See complete article : &#039;&#039; [[AMC-OS Loader]]&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Boot_process&amp;diff=70</id>
		<title>Boot process</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Boot_process&amp;diff=70"/>
		<updated>2017-05-16T10:45:14Z</updated>

		<summary type="html">&lt;p&gt;Kindman: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
AMC-OS booting process is done in three different phases :&lt;br /&gt;
* [[Boot process#The Boot Loader|The boot loader]] &#039;&#039;(also named volume boot record (VBR) or master boot record (MBR) for removeable media)&#039;&#039;&lt;br /&gt;
* [[AMC-OS Loader]] - Check system, CPU, memory, loads and relocates Kernel in memory&lt;br /&gt;
* &#039;&#039;&#039;Kernel initialization&#039;&#039;&#039; - Initializes all structures to start the AMC-OS kernel&lt;br /&gt;
&lt;br /&gt;
At power up, and after BIOS initialization, for historical/compatibility reasons, the processor runs in real adressing mode. In this mode, the CPU runs a 16-byte memory adressing scheme, meaning that we can only address 16 segments of 64KB of memory (ie 1MB), divided in &amp;quot;user&amp;quot; memory (640KB - the so-called &amp;quot;conventional memory&amp;quot; in MS-DOS) and Video RAM+System ROMS (384KB).&lt;br /&gt;
 &lt;br /&gt;
We have to switch the processor to 32-bit protected mode to run a 32-byte memory adressing scheme and adress 4GB of physical memory. It is even possible, starting with the Pentium Pro, to run a 36-byte memory addressing, called PAE (Physical Address Extension), allowing the adressing of 64GB of memory.&lt;br /&gt;
 &lt;br /&gt;
Switching to protected mode requires some preparation and resources, and most BIOS functions are no longer available (ie. disk read, changing video mode...), meaning that we must have loaded all kernel required files in memory before switching.&lt;br /&gt;
&lt;br /&gt;
==The Boot Loader==&lt;br /&gt;
The boot loader is the first sector (512 bytes) of the source media (typically the floppy disk). The BIOS automatically loads the first sector of the specified media during system boot process, at physical memory address &amp;lt;tt&amp;gt;00007C00&amp;lt;/tt&amp;gt;, checks that the last word value is &amp;lt;tt&amp;gt;55AA&amp;lt;/tt&amp;gt;, and if so, jump execution to first byte.&lt;br /&gt;
 &lt;br /&gt;
AMC-OS 1.44M Boot Floppy disks are in standard FAT12 format and contains the adequate header. There lasts only 451 bytes to :&lt;br /&gt;
* Load the FAT and Root directory (\) listing in memory&lt;br /&gt;
* Locate &amp;lt;tt&amp;gt;AMCOSLDR.IMG&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;AMCOSLDR.SYS&amp;lt;/tt&amp;gt; files in the root directory&lt;br /&gt;
* Load the files to fixed memory addresses&lt;br /&gt;
* Switch execution to AMC-OS Loader&lt;br /&gt;
 &lt;br /&gt;
The boot loader uses BIOS support through &amp;lt;tt&amp;gt;INT 13H&amp;lt;/tt&amp;gt; for I/O functions.&lt;br /&gt;
In case of error during execution, the boot loader will display :&lt;br /&gt;
* &amp;lt;tt&amp;gt;FIL?&amp;lt;/tt&amp;gt; if one of the required files hasn&#039;t been found in the root directory&lt;br /&gt;
* &amp;lt;tt&amp;gt;DSK?&amp;lt;/tt&amp;gt; if a read error occured (probably defective disk)&lt;br /&gt;
&lt;br /&gt;
==AMC-OS Loader==&lt;br /&gt;
&#039;&#039;See complete article : &#039;&#039; [[AMC-OS Loader]]&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=69</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=69"/>
		<updated>2015-07-19T22:01:47Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Memory model ==&lt;br /&gt;
&lt;br /&gt;
=== Physical memory ===&lt;br /&gt;
&lt;br /&gt;
Physical memory is divided in several segments that can be used by the system.&lt;br /&gt;
During initialization phase, the system scan the linear address space for the available segments. In a standard PC, there are typically two segments : the first megabyte of memory (generally only the first 640Kbytes  as BIOS, ROMs and video memory are mapped in the last 384Kbytes) and the memory above 1MB. In some cases, there also can be a hole in the 15-16M adressing space, or memory reserved for PCI addressing space. During the scan, the system counts the number of available blocks in each segment.&lt;br /&gt;
&lt;br /&gt;
AMC-OS split the physical memory in two areas :&lt;br /&gt;
* low memory reserved for kernel usage (&#039;&#039;will also be referred as &#039;&#039;&#039;kernel memory&#039;&#039;&#039;)&#039;&#039;;&lt;br /&gt;
* high memory for processes &#039;&#039;(will also be referred as &#039;&#039;&#039;user memory&#039;&#039;&#039;)&#039;&#039;. &lt;br /&gt;
These two areas are divided in contiguous blocks of 256Kbytes by default, themselves being divided in 4Kbytes pages. To reduce the amount of memory used by the system, the blocks are activated on demand, and only then divided in pages.&lt;br /&gt;
&lt;br /&gt;
=== Virtual memory ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Physical memory management ==&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
After scanning the linear address space for available physical memory, AMC-OS split the physical memory in two areas :&lt;br /&gt;
* The &#039;&#039;&#039;low memory area&#039;&#039;&#039; must be at least 4Mbytes large, and its size is proportional to the total amount of physical memory available. This area is also referred as &#039;&#039;kernel memory&#039;&#039; as the physical memory is available from all page directories at kernel privilege.&lt;br /&gt;
* The &#039;&#039;&#039;high memory area&#039;&#039;&#039; contains all the remaining memory and is used for user memory.&lt;br /&gt;
&lt;br /&gt;
Each area is specified in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structure. It contains :&lt;br /&gt;
* the number and pointers to the used blocks they contain;&lt;br /&gt;
* the number and pointers to the free blocks they contain;&lt;br /&gt;
* the number and pointers to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory can be taken from low memory if high memory is exhausted.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
By default, each memory area is divided in blocks of 256 Kbytes. A new block is &#039;&#039;activated&#039;&#039; and divided in free pages, if there are no more free pages available in the area. Free blocks are stored in the &#039;&#039;free blocks list&#039;&#039;, a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains :&lt;br /&gt;
* the pointer to the free block;&lt;br /&gt;
* the number of contiguous free blocks;&lt;br /&gt;
* the pointer to the next structure.&lt;br /&gt;
During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=68</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=68"/>
		<updated>2014-08-24T13:08:58Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Memory model ==&lt;br /&gt;
&lt;br /&gt;
=== Physical memory ===&lt;br /&gt;
&lt;br /&gt;
Physical memory is divided in several segments that can be used by the system.&lt;br /&gt;
During initialization phase, the system checks the different segments. There are typically two segments, the first megabyte of memory and the upper memory. In some cases, there also can be a hole in the 15-16M adressing space, or for PCI address space. In the same time, the system count the number of blocks (256K by default) in each segment.&lt;br /&gt;
&lt;br /&gt;
The physical memory is split by the system in two areas, low memory reserved for kernel usage (that will also be referred as &amp;quot;kernel memory&amp;quot;) and high memory for processes. These two areas are divided in contiguous blocks, themselves being divided in pages. To reduce the amount of memory used by the system, the blocks are activated on demand, and then divided in pages.&lt;br /&gt;
&lt;br /&gt;
=== Virtual memory ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Physical memory management ==&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
The low memory area must be at least 4MB large, and its size is proportional to the total amount of physical memory available.&lt;br /&gt;
Each area is characterized in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structures with the number and pointers to the used and free blocks they contain, and to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory is always taken first from high memory, then low memory if empty. Kernel memory is always taken only in low memory.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
The free blocks list is a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains the pointer to the free block, the number of contiguous free blocks and the pointer to the next structure. During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the block number, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=67</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=67"/>
		<updated>2014-08-24T13:08:04Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Memory model ==&lt;br /&gt;
&lt;br /&gt;
=== Physical memory ===&lt;br /&gt;
&lt;br /&gt;
Physical memory is divided in several segments that can be used by the system.&lt;br /&gt;
During initialization phase, the system checks the different segments. There are typically two segments, the first megabyte of memory and the upper memory. In some cases, there also can be a hole in the 15-16M adressing space, or for PCI address space. In the same time, the system count the number of blocks (256K by default) in each segment.&lt;br /&gt;
&lt;br /&gt;
The physical memory is split by the system in two areas, low memory reserved for kernel usage (that will also be referred as &amp;quot;kernel memory&amp;quot;) and high memory for processes. These two areas are divided in contiguous blocks, themselves being divided in pages. To reduce the amount of memory used by the system, the blocks are activated on demand, and then divided in pages.&lt;br /&gt;
&lt;br /&gt;
=== Virtual memory ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Physical memory management ==&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
The low memory area must be at least 4MB large, and its size is proportional to the total amount of physical memory available.&lt;br /&gt;
Each area is characterized in a &amp;lt;tt&amp;gt;MEMORY_AREA&amp;lt;/tt&amp;gt; structures with the number and pointers to the used and free blocks they contain, and to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory is always taken first from high memory, then low memory if empty. Kernel memory is always taken only in low memory.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
The free blocks list is a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains the pointer to the free block, the number of contiguous free blocks and the pointer to the next structure. During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in &amp;lt;tt&amp;gt;MEMORY_AREA.ptrFreeBlocks&amp;lt;/tt&amp;gt;, and count in &amp;lt;tt&amp;gt;MEMORY_AREA.nbFreeBlocks&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks structures list is stored in &amp;lt;tt&amp;gt;MEMORY_ptrInactiveFreeBlocksStruct, and count in &amp;lt;tt&amp;gt;MEMORY_nbInactiveFreeBlocksStruct&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the number of block, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=66</id>
		<title>Memory and paging</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Memory_and_paging&amp;diff=66"/>
		<updated>2014-08-24T13:05:18Z</updated>

		<summary type="html">&lt;p&gt;Kindman: Created page with &amp;quot; == Memory model ==  === Physical memory ===  Physical memory is divided in several segments that can be used by the system. During initialization phase, the system checks the...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Memory model ==&lt;br /&gt;
&lt;br /&gt;
=== Physical memory ===&lt;br /&gt;
&lt;br /&gt;
Physical memory is divided in several segments that can be used by the system.&lt;br /&gt;
During initialization phase, the system checks the different segments. There are typically two segments, the first megabyte of memory and the upper memory. In some cases, there also can be a hole in the 15-16M adressing space, or for PCI address space. In the same time, the system count the number of blocks (256K by default) in each segment.&lt;br /&gt;
&lt;br /&gt;
The physical memory is split by the system in two areas, low memory reserved for kernel usage (that will also be referred as &amp;quot;kernel memory&amp;quot;) and high memory for processes. These two areas are divided in contiguous blocks, themselves being divided in pages. To reduce the amount of memory used by the system, the blocks are activated on demand, and then divided in pages.&lt;br /&gt;
&lt;br /&gt;
=== Virtual memory ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Physical memory management ==&lt;br /&gt;
&lt;br /&gt;
=== Memory areas ===&lt;br /&gt;
&lt;br /&gt;
The low memory area must be at least 4MB large, and its size is proportional to the total amount of physical memory available.&lt;br /&gt;
Each area is characterized in a MEMORY_AREA structures with the number and pointers to the used and free blocks they contain, and to the free pages.&lt;br /&gt;
&lt;br /&gt;
User memory is always taken first from high memory, then low memory if empty. Kernel memory is always taken only in low memory.&lt;br /&gt;
&lt;br /&gt;
=== Free blocks list ===&lt;br /&gt;
&lt;br /&gt;
The free blocks list is a linked list of the &#039;&#039;&#039;InactiveMemory&#039;&#039;&#039; structure. It contains the pointer to the free block, the number of contiguous free blocks and the pointer to the next structure. During initialization phase, we pre-allocate the maximum of free blocks structures that can be necessary, ie half the number of blocks. This list of free blocks structures is also a linked list to accelerate allocating and freeing processes.&lt;br /&gt;
&lt;br /&gt;
The pointer to the free blocks list is stored in MEMORY_AREA.ptrFreeBlocks, and count in MEMORY_AREA.nbFreeBlocks.&lt;br /&gt;
The pointer to the free blocks structures list is stored in MEMORY_ptrInactiveFreeBlocksStruct, and count in MEMORY_nbInactiveFreeBlocksStruct.&lt;br /&gt;
&lt;br /&gt;
=== Number of free pages per block ===&lt;br /&gt;
&lt;br /&gt;
A free pages per block table is created to be able to put back in free blocks list a block that has all its pages free.&lt;br /&gt;
It is a simple table indexed by the number of block, containing for each entry an unsigned byte with the number of free pages. Obviously, there can&#039;t be more than 256 pages per block (64 by default).&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Interrupts&amp;diff=65</id>
		<title>Interrupts</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Interrupts&amp;diff=65"/>
		<updated>2013-07-18T14:43:04Z</updated>

		<summary type="html">&lt;p&gt;Kindman: minor checks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Processor===&lt;br /&gt;
====General considerations====&lt;br /&gt;
&lt;br /&gt;
The processor can interrupt the execution of the current process on 3 different event types :&lt;br /&gt;
* Exceptions/Faults : the running process made a fault, like the typical &amp;quot;General Protection Fault&amp;quot; when the process read or wrote memory in a forbidden place.&lt;br /&gt;
* Software interrupts : The process called an interrupt with the INT XX instruction.&lt;br /&gt;
* Hardware interrupts : Associated hardware raised the INT# line of the processor to inform it of any kind of event that just happened, like for a example &amp;quot;a key has been pressed&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The x86 family support 256 interrupts, and the first 32 are reserved for the exceptions and traps generated by the processor itself. All the others are available to software and external hardware. &lt;br /&gt;
&lt;br /&gt;
====Interrupt Descriptor Table (IDT)====&lt;br /&gt;
The OS maintains an &#039;&#039;interrupt descriptor table&#039;&#039; used by the processor to know what to do when a specific interrupt is triggered. In real mode, it is just a list of FAR jump addresses located at physical memory address 0. In protected mode, it is a table of descriptors (interrupt gate, task gate...). &lt;br /&gt;
&lt;br /&gt;
Once prepared, the interrupt descriptor table is set up using the LIDT instruction.&lt;br /&gt;
&lt;br /&gt;
===Hardware interrupts (IRQ)===&lt;br /&gt;
&lt;br /&gt;
Whenever the hardware wants to inform the system that something happened, like a new disc has been inserted or the user moved the mouse for example, it can deal with it in two ways :&lt;br /&gt;
* Update its internal status and wait for the operating system to check for it (this method is called &#039;&#039;polling&#039;&#039;).&lt;br /&gt;
* Request the interruption (IRQ) of the current process execution to immediately inform the operating system of a pending event.&lt;br /&gt;
&lt;br /&gt;
Both methods have their own interest, but the thing to keep in mind is that interrupts are used to treat the event as quickly as possible. Interrupts are more resource consuming due to task switching and they reduce the control on how CPU time division between processes, but if the OS doesn&#039;t check as quickly as necessary the hardware status, it can possibly lose data (like for a high rate network card, the buffer can be full and overrun if the OS doesn&#039;t read it before next packets arrive).&lt;br /&gt;
&lt;br /&gt;
====The Programmable Interrupt Controller====&lt;br /&gt;
&lt;br /&gt;
As on most microcomputers, the x86 CPU have two external interrupt lines : a software maskable (SMI) and a non-maskable interrupt line (NMI). The SMI is used by standard hardware to trigger an interrupt, and the NMI is used during critical condition (memory or I/O parity error) or to force the OS to an escape routine.&lt;br /&gt;
&lt;br /&gt;
To handle different interrupts, an programmable interrupt controller (PIC) is added. The PIC can handle multiple interrupt lines, priority between them, individual masking and so on. When an interrupt comes in, the INT# line is triggered and the interrupt number is sent to the CPU through data bus. &lt;br /&gt;
&lt;br /&gt;
On the x86 family, the [[#Programming the i8259 PIC|i8259 PIC]] was first used in the XT. It supported 8 differents IRQ. On the AT, an other i8259 was cascaded to the first one, leading up to 15 differents IRQs (16 minor the one used for cascading). It is only since some Pentium processors that it was replaced by an advanced PIC (APIC) supporting, amongst other things, 23 differents IRQ.&lt;br /&gt;
&lt;br /&gt;
==Programming the i8259 PIC==&lt;br /&gt;
&lt;br /&gt;
===Original specifications===&lt;br /&gt;
[http://www.amc-os.com/developers/specifications/intel_8259a.pdf Intel 8259A datasheet]&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Interrupts&amp;diff=64</id>
		<title>Interrupts</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Interrupts&amp;diff=64"/>
		<updated>2012-08-30T13:00:29Z</updated>

		<summary type="html">&lt;p&gt;Kindman: added i8259a spec&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Processor===&lt;br /&gt;
====General considerations====&lt;br /&gt;
&lt;br /&gt;
The processor can interrupt the execution of the current process due to 3 different types of interruptions :&lt;br /&gt;
* Exceptions/Faults : the running process made a fault, like for example the typical &amp;quot;General Protection Fault&amp;quot; if the process read or wrote memory in a wrong place.&lt;br /&gt;
* Software interrupts : The process called an interrupt with the INT XX instruction.&lt;br /&gt;
* Hardware interrupts : Associated hardware raised the INT# line of the processor to inform it of any kind of event that just happened, like for a example &amp;quot;a key has been pressed&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The x86 family support 256 interrupts, and the first 32 are reserved for the exceptions and traps generated by the processor itself. All the others are available to software and external hardware. &lt;br /&gt;
&lt;br /&gt;
====Interrupt Descriptor Table (IDT)====&lt;br /&gt;
The OS maintains an &#039;&#039;interrupt descriptor table&#039;&#039; used by the processor to know what to do when a specific interrupt is triggered. In real mode, it is just a list of FAR jump addresses located at physical memory address 0. In protected mode, it is a table of descriptors (interrupt gate, task gate...). &lt;br /&gt;
&lt;br /&gt;
Once prepared, the interrupt descriptor table is set up using the LIDT instruction.&lt;br /&gt;
&lt;br /&gt;
===Hardware interrupts (IRQ)===&lt;br /&gt;
&lt;br /&gt;
Whenever the hardware wants to inform the system that something happened, like a new disc has been inserted or the user moved the mouse for example, it can deal with it in two different ways :&lt;br /&gt;
* Update its internal status and wait for the operating system to check for it (this method is called &#039;&#039;polling&#039;&#039;).&lt;br /&gt;
* Request the interruption (IRQ) of the current process execution to immediately inform the operating system of an event to deal with.&lt;br /&gt;
&lt;br /&gt;
Both methods have their own interest, but the thing to keep in mind is that interrupts are used to treat the event as quickly as possible. Interrupts are more resource consuming due to task switching, and reduce control on how CPU time is divided between each process, but if the OS doesn&#039;t check as quickly as necessary the hardware status, it can possibly lose date (like for a high rate network card, the buffer can be full and overrun if the OS doesn&#039;t read it before next packets arrive).&lt;br /&gt;
&lt;br /&gt;
====The Programmable Interrupt Controller====&lt;br /&gt;
&lt;br /&gt;
As on most microcomputers, the x86 CPU have two external interrupt lines : a software maskable (SMI) and a non-maskable interrupt line (NMI). The SMI is used by standard hardware to trigger an interrupt, and the NMI is used during critical condition (memory or I/O parity error) or to force the OS to an escape routine.&lt;br /&gt;
&lt;br /&gt;
To handle different interrupts, an programmable interrupt controller (PIC) is added. The PIC can handle multiple interrupt lines, priority between them, individual masking and so on. When an interrupt comes in, the INT# line is triggered and the interrupt number is sent to the CPU through data bus. &lt;br /&gt;
&lt;br /&gt;
On the x86 family, the [[#Programming the i8259 PIC|i8259 PIC]] was first used in the XT. It supported 8 differents IRQ. On the AT, an other i8259 was cascaded to the first one, leading up to 15 differents IRQs (16 minor the one used for cascading). It is only since some Pentium processors that it was replaced by an advanced PIC (APIC) supporting, amongst other things, 23 differents IRQ.&lt;br /&gt;
&lt;br /&gt;
==Programming the i8259 PIC==&lt;br /&gt;
&lt;br /&gt;
===Original specifications===&lt;br /&gt;
[http://www.amc-os.com/developers/specifications/intel_8259a.pdf Intel 8259A datasheet]&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Floppy_disk_controller&amp;diff=63</id>
		<title>Floppy disk controller</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Floppy_disk_controller&amp;diff=63"/>
		<updated>2012-08-30T12:53:01Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The floppy disk controller is used to control up to 4 floppy disk drives.&lt;br /&gt;
&lt;br /&gt;
In the PC computer, it was originally based on a Nec uPD765 chip. On the PC/AT, a register was added to inform the OS that the media changed, and several other registers were added in the PS/2 and Model30 computers. Enhanced controllers were then implemented, with new functions and support of perpendicular mode, generally based on the Intel 82077AA chip.&lt;br /&gt;
&lt;br /&gt;
==Original specifications==&lt;br /&gt;
&lt;br /&gt;
* [http://www.amc-os.com/developers/specifications/intel_82072.pdf Intel 82072 datasheet]&lt;br /&gt;
* [http://www.amc-os.com/developers/specifications/nec_uPD765B.pdf Nec uPD765B datasheet]&lt;br /&gt;
* [http://www.amc-os.com/developers/specifications/intel_82077aa.pdf Intel 82077AA datasheet]&lt;br /&gt;
* [http://www.amc-os.com/developers/specifications/intel_82078.pdf Intel 82078 datasheet]&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Floppy_disk_controller&amp;diff=62</id>
		<title>Floppy disk controller</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Floppy_disk_controller&amp;diff=62"/>
		<updated>2012-08-30T12:38:40Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The floppy disk controller is used to control up to 4 floppy disk drives.&lt;br /&gt;
&lt;br /&gt;
In the PC computer, it was originally based on a Nec uPD765 chip. On the PC/AT, a register was added to inform the OS that the media changed, and several other registers were added in the PS/2 and Model30 computers. Enhanced controllers were then implemented, with new functions and support of perpendicular mode, generally based on the Intel 82077AA chip.&lt;br /&gt;
&lt;br /&gt;
==Original specifications==&lt;br /&gt;
&lt;br /&gt;
* [http://www.amc-os.com/developers/specifications/nec_uPD765B.pdf Nec uPD765B datasheet]&lt;br /&gt;
* [http://www.amc-os.com/developers/specifications/intel_82072.pdf Intel 82072 datasheet]&lt;br /&gt;
* [http://www.amc-os.com/developers/specifications/intel_82077aa.pdf Intel 82077AA datasheet]&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Floppy_disk_controller&amp;diff=61</id>
		<title>Floppy disk controller</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Floppy_disk_controller&amp;diff=61"/>
		<updated>2012-08-30T12:32:06Z</updated>

		<summary type="html">&lt;p&gt;Kindman: page creation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The floppy disk controller is used to control up to 4 floppy disk drives.&lt;br /&gt;
&lt;br /&gt;
In the PC computer, it was originally based on a Nec uPD765 chip. On the PC/AT, a register was added to inform the OS that the media changed, and several other registers were added in the PS/2 and Model30 computers. Enhanced controllers were then implemented, with new functions and support of perpendicular mode, generally based on the Intel 82077AA chip.&lt;br /&gt;
&lt;br /&gt;
==Original specifications==&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
	<entry>
		<id>http://wiki.amc-os.com/index.php?title=Main_Page&amp;diff=60</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://wiki.amc-os.com/index.php?title=Main_Page&amp;diff=60"/>
		<updated>2012-08-30T12:27:52Z</updated>

		<summary type="html">&lt;p&gt;Kindman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Amc-os_ant_final.png|top|right|frame|AMC-OS Logo]]&lt;br /&gt;
&lt;br /&gt;
==Welcome to AMC-OS Developers Website==&lt;br /&gt;
&lt;br /&gt;
The AMC-OS Developers Website provides resources and information for people who :&lt;br /&gt;
* want to support AMC-OS development&lt;br /&gt;
* want to understand better how computers and OS work&lt;br /&gt;
* look for documentation and tools to build their own system&lt;br /&gt;
The website is divided into several sections depending on the information you are looking for.&lt;br /&gt;
&lt;br /&gt;
To get general information on AMC-OS, please visit the [http://www.amc-os.com/ main website].&lt;br /&gt;
&lt;br /&gt;
All AMC-OS code and documentation is released under the [[AMC-OS Developers:General disclaimer|AMC-OS License]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;5&amp;quot; width=&amp;quot;60%&amp;quot;&lt;br /&gt;
|+ AMC-OS Developers Website sections&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | OS Design&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Hardware&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Running AMC-OS&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* [[Processor management]]&lt;br /&gt;
* [[Boot process]]&lt;br /&gt;
* [[AMCX file format]]&lt;br /&gt;
* [[Memory and paging]]&lt;br /&gt;
* [[Processes and threads]]&lt;br /&gt;
* [[Device drivers]]&lt;br /&gt;
|&lt;br /&gt;
* CPU&lt;br /&gt;
** [[Intel x86 Architecture]]&lt;br /&gt;
** [[Identifying CPU]]&lt;br /&gt;
* [[Interrupts]] (PIC, APIC)&lt;br /&gt;
* Devices identification&lt;br /&gt;
** [[BIOS]]&lt;br /&gt;
** [[Plug &amp;amp; Play]]&lt;br /&gt;
** [[PCI]]&lt;br /&gt;
* I/O&lt;br /&gt;
** [[Floppy disk controller]]&lt;br /&gt;
** [[IDE (ATA/ATAPI) controller]]&lt;br /&gt;
|&lt;br /&gt;
* [[Compiling and Linking]]&lt;br /&gt;
* [[Installing and running]]&lt;br /&gt;
* [[Debugging]]&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Building software&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Tools and resources&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; |&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
* [[AMC-OS Kernel API]]&lt;br /&gt;
* [[AMC-OS C Library]]&lt;br /&gt;
* [[Compiling and Linking]]&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Kindman</name></author>
	</entry>
</feed>