2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=US-ASCII" >
2021-10-27 08:28:16 +01:00
< meta name = "generator" content = "ZealOS V1.04" >
2021-07-03 05:07:57 +01:00
< style type = "text/css" >
2021-10-08 07:06:11 +01:00
body {background-color:#1f1f1f;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
2021-07-03 05:07:57 +01:00
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = "font-family:monospace;font-size:12pt" >
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< 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 > );
2021-07-03 05:07:57 +01:00
< a name = "l5" > < / a >
2021-07-04 23:11:34 +01:00
< 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 >
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< 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;
2021-07-03 05:07:57 +01:00
< a name = "l23" > < / a >
2021-07-04 23:11:34 +01:00
< 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);
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< a name = "l36" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l37" > < / a > total = < / span > < span class = cF5 > MemBIOSTotal< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l38" > < / a >
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< a name = "l45" > < / a >
2021-07-26 20:29:49 +01:00
< 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://zeal-operating-system.github.io/ZealOS/Kernel/Memory/PageTables.CC.html#l195" > < span class = cF4 > RLf_16MEG_SYS_CODE_BP< / span > < / a > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< 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 > ;
2021-07-03 05:07:57 +01:00
< a name = "l49" > < / a >
2021-07-04 23:11:34 +01:00
< 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 > );
2021-07-03 05:07:57 +01:00
< a name = "l82" > < / a > }
< / span > < / pre > < / body >
< / html >