<a name="l7"></a>In ZealOS, the lowest 2Gig of memory is called the </span><span class=cF2>code heap</span><span class=cF0>. ZealOS's compiler always uses 32-bit signed relative JMP & CALL
<a name="l8"></a>insts because 64-bit CALLs take two insts. With signed +/- 32-bit values, code can only call a function within 2Gig distance.
<a name="l9"></a>Therefore, ZealOS keeps all code in the lowest 2Gig memory addresses including what would normally be called "the kernel". Two
<a name="l10"></a>Gig is plenty for code, don't worry.
<a name="l12"></a>You can create new, independent heaps using </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/HeapCtrl.html#l1"><span class=cF4>HeapCtrlInit</span></a><span class=cF0>(). Then, use the </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l3527"><span class=cF4>CHeapCtrl</span></a><span class=cF0> as the 2nd arg to </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l391"><span class=cF4>MAlloc</span></a><span class=cF0>(). See </span><a href="https://tomawezome.github.io/ZealOS/System/Utils/HeapLog.html#l83"><span class=cF4>HeapLog</span></a><span class=cF0>()
<a name="l15"></a>Memory alloced by a task will be freed when the task is killed. The </span><a href="https://tomawezome.github.io/ZealOS/Doc/Glossary.html#l154"><span class=cF4>System Task</span></a><span class=cF0> is a task that never dies. His memory is like
<a name="l16"></a>kernel memory in other operating systems. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l408"><span class=cF4>ZCAlloc</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l394"><span class=cF4>ZMAlloc</span></a><span class=cF0>(), </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l427"><span class=cF4>ZMAllocIdent</span></a><span class=cF0>() and </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l503"><span class=cF4>ZStrNew</span></a><span class=cF0>().
<a name="l19"></a>lowest 4Gig addresses have an alias to access hardware located toward the top of mapped space, </span><span class=cF2>0x0140000000</span><span class=cF0>. See </span><span class=cF4>
<a name="l31"></a> Kernel module, placed here by the boot-loader, </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l4439"><span class=cF4>BOOT_RAM_BASE</span></a><span class=cF0>.
<a name="l34"></a> Boot block relocated here before loading the Kernel module, </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootDVD.html#l1"><span class=cF4>BootDVD</span></a><span class=cF0> & </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootHD.html#l1"><span class=cF4>BootHD</span></a><span class=cF0>.
<a name="l38"></a></span><span class=cF2> 0x00000A0000- 0x00000BFFFF</span><span class=cF0> VGA graphics mem with alias at </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KGlobals.html#l30"><span class=cF4>text</span></a><span class=cF0>.vga_alias.
<a name="l44"></a> 0xF0000000. PCI devices are supported, so </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MemPhysical.html#l64"><span class=cF4>Mem32DevAlloc</span></a><span class=cF0>() flaws could become an issue.
<a name="l59"></a>contiguous requests. You can </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l391"><span class=cF4>MAlloc</span></a><span class=cF0>() an 8Gig chunk on a 12Gig machine. You can </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l391"><span class=cF4>MAlloc</span></a><span class=cF0>() a 32Gig chunk on a 64Gig machine.
<a name="l62"></a>the code heap is 1/4 of the total. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/BlkPool.html#l31"><span class=cF4>BlkPoolsInit</span></a><span class=cF0>().
<a name="l81"></a>the lowest 2Meg area directly was cached but the alias he created up at the top of address space was uncached. See </span><span class=cF4>
<a name="l82"></a></span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MemPhysical.html#l157"><span class=cF4>UncachedAliasAlloc</span></a><span class=cF0>(). Unfortunately, he could no longer boast of the simplicity of identity mapping everything. Since many of
<a name="l84"></a>numbers of A0000-BFFFF, but must access the relocated alias location. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMain.html#l121"><span class=cF4>text.vga_alias</span></a><span class=cF0>. We also no longer cause a fault
<a name="l87"></a>Then, Terry switched to 1Gig page sizes. For the lowest 4Gig, he set-up an alias up at the top of address space. See </span><span class=cF4>
<a name="l88"></a></span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MemPhysical.html#l157"><span class=cF4>UncachedAliasAlloc</span></a><span class=cF0>(). Not all computers support 1Gig page tables, however, so he also supported 2Meg.
<a name="l92"></a>all of the first 4Gig can be accessed without caching at the </span><a href="https://tomawezome.github.io/ZealOS/Kernel/MultiProc.html#l147"><span class=cF4>dev.uncached_alias</span></a><span class=cF0>.