mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
111 lines
10 KiB
HTML
Executable file
111 lines
10 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.05">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>BlkPoolAdd</span><span class=cF0>(</span><span class=cF9>CBlkPool</span><span class=cF0> *bp, </span><span class=cF9>CMemBlk</span><span class=cF0> *m, </span><span class=cF9>I64</span><span class=cF0> pags)
|
|
<a name="l2"></a>{</span><span class=cF2>//Add mem to BlkPool.</span><span class=cF0>
|
|
<a name="l3"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_mem_init_flag</span><span class=cF0>)
|
|
<a name="l4"></a> </span><span class=cF5>MemSet</span><span class=cF0>(m, </span><span class=cFB>sys_mem_init_val</span><span class=cF0>, pags * </span><span class=cF3>MEM_PAG_SIZE</span><span class=cF0>);
|
|
<a name="l5"></a>
|
|
<a name="l6"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l8"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&bp->locked_flags, </span><span class=cF3>BPlf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l9"></a> </span><span class=cF1>PAUSE</span><span class=cF0>
|
|
<a name="l10"></a> m->next = bp->mem_free_list;
|
|
<a name="l11"></a> m->pags = pags;
|
|
<a name="l12"></a> m->mb_signature = </span><span class=cF3>MBS_UNUSED_SIGNATURE_VAL</span><span class=cF0>;
|
|
<a name="l13"></a> bp->alloced_u8s += pags << </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>;
|
|
<a name="l14"></a> bp->mem_free_list = m;
|
|
<a name="l15"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&bp->locked_flags, </span><span class=cF3>BPlf_LOCKED</span><span class=cF0>);
|
|
<a name="l16"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l17"></a>}
|
|
<a name="l18"></a>
|
|
<a name="l19"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>BlkPoolInit</span><span class=cF0>(</span><span class=cF9>CBlkPool</span><span class=cF0> *bp, </span><span class=cF9>I64</span><span class=cF0> pags)
|
|
<a name="l20"></a>{</span><span class=cF2>//Make mem chunk into a BlkPool.</span><span class=cF0>
|
|
<a name="l21"></a> </span><span class=cF9>I64</span><span class=cF0> num;
|
|
<a name="l22"></a> </span><span class=cF9>CMemBlk</span><span class=cF0> *m;
|
|
<a name="l23"></a>
|
|
<a name="l24"></a> </span><span class=cF5>MemSet</span><span class=cF0>(bp, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CBlkPool</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l25"></a> m = (bp</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CBlkPool</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF3>MEM_PAG_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>) & ~(</span><span class=cF3>MEM_PAG_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l26"></a> num = (bp</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0> + pags << </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0> - m</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>) >> </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>;
|
|
<a name="l27"></a> bp->alloced_u8s = (pags-num) << </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>; </span><span class=cF2>//Compensate before num added.</span><span class=cF0>
|
|
<a name="l28"></a> </span><span class=cF5>BlkPoolAdd</span><span class=cF0>(bp, m, num);
|
|
<a name="l29"></a>}
|
|
<a name="l30"></a>
|
|
<a name="l31"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>BlkPoolsInit</span><span class=cF0>()
|
|
<a name="l32"></a>{
|
|
<a name="l33"></a> </span><span class=cF9>I64</span><span class=cF0> i, total, lo, hi, code_heap_limit;
|
|
<a name="l34"></a> </span><span class=cF9>CMemE820</span><span class=cF0> *m20 = </span><span class=cFD>MEM_E820</span><span class=cF0>;
|
|
<a name="l35"></a> </span><span class=cF1>Bool</span><span class=cF0> first = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l36"></a>
|
|
<a name="l37"></a> total = </span><span class=cF5>MemBIOSTotal</span><span class=cF0>;
|
|
<a name="l38"></a>
|
|
<a name="l39"></a> </span><span class=cF1>if</span><span class=cF0> (total <= </span><span class=cFE>0x80000000</span><span class=cF0>)
|
|
<a name="l40"></a> code_heap_limit = total;
|
|
<a name="l41"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (total <= </span><span class=cFE>0x100000000</span><span class=cF0>)
|
|
<a name="l42"></a> code_heap_limit = total / </span><span class=cFE>4</span><span class=cF0>;
|
|
<a name="l43"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l44"></a> code_heap_limit = </span><span class=cFE>0x80000000</span><span class=cF0>;
|
|
<a name="l45"></a>
|
|
<a name="l46"></a> i = code_heap_limit - </span><span class=cF3>SYS_16MEG_AREA_LIMIT</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/PageTables.html#l195"><span class=cF4>RLf_16MEG_SYS_CODE_BP</span></a><span class=cF0>
|
|
<a name="l47"></a> </span><span class=cF5>BlkPoolAdd</span><span class=cF0>(</span><span class=cFB>sys_code_bp</span><span class=cF0>, </span><span class=cF3>SYS_16MEG_AREA_LIMIT</span><span class=cF0>, i >> </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>);
|
|
<a name="l48"></a> </span><span class=cFB>mem_heap_limit</span><span class=cF0> = i + </span><span class=cF3>SYS_16MEG_AREA_LIMIT</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l49"></a>
|
|
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (code_heap_limit<total)
|
|
<a name="l51"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l52"></a> </span><span class=cF1>while</span><span class=cF0> (m20->type)
|
|
<a name="l53"></a> {
|
|
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (m20->type == </span><span class=cF3>MEM_E820t_USABLE</span><span class=cF0>)
|
|
<a name="l55"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l56"></a> lo = m20->base;
|
|
<a name="l57"></a> hi = m20->base + m20->len;
|
|
<a name="l58"></a> </span><span class=cF1>if</span><span class=cF0> (lo<code_heap_limit)
|
|
<a name="l59"></a> {
|
|
<a name="l60"></a> </span><span class=cF1>if</span><span class=cF0> (hi > code_heap_limit)
|
|
<a name="l61"></a> lo = code_heap_limit;
|
|
<a name="l62"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l63"></a> hi = lo; </span><span class=cF2>//cancel</span><span class=cF0>
|
|
<a name="l64"></a> }
|
|
<a name="l65"></a> </span><span class=cF1>if</span><span class=cF0> (code_heap_limit <= lo < hi)
|
|
<a name="l66"></a> {
|
|
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (first)
|
|
<a name="l68"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l69"></a> </span><span class=cF5>BlkPoolInit</span><span class=cF0>(lo, </span><span class=cF7>(</span><span class=cF0>hi - lo</span><span class=cF7>)</span><span class=cF0> >> </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>);
|
|
<a name="l70"></a> </span><span class=cFB>sys_data_bp</span><span class=cF0> = lo;
|
|
<a name="l71"></a> </span><span class=cF5>Fs</span><span class=cF0>->data_heap = </span><span class=cF5>HeapCtrlInit</span><span class=cF0>(, </span><span class=cF5>Fs</span><span class=cF0>, </span><span class=cFB>sys_data_bp</span><span class=cF0>);
|
|
<a name="l72"></a> first = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l73"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l74"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l75"></a> </span><span class=cF5>BlkPoolAdd</span><span class=cF0>(</span><span class=cFB>sys_data_bp</span><span class=cF0>, lo, </span><span class=cF7>(</span><span class=cF0>hi - lo</span><span class=cF7>)</span><span class=cF0> >> </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>);
|
|
<a name="l76"></a> }
|
|
<a name="l77"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l78"></a> m20++;
|
|
<a name="l79"></a> }
|
|
<a name="l80"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l81"></a> </span><span class=cF5>LBts</span><span class=cF0>(&</span><span class=cFB>sys_run_level</span><span class=cF0>, </span><span class=cF3>RLf_FULL_HEAPS</span><span class=cF0>);
|
|
<a name="l82"></a>}
|
|
</span></pre></body>
|
|
</html>
|