templeos-info/public/Wb/Kernel/KCfg.HC.HTML

205 lines
18 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF2>//This is run in a </span><a href="/Wb/Kernel/Kernel.PRJ.HTML#l8"><span class=cF4>#exe</span></a><span class=cF2>{}.</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF1>U8</span><span class=cF0> *kernel_cfg_options=</span><span class=cF6>&quot;MemInit\0HeapInit\0VarInit\0StaffMode\0&quot;</span><span class=cF0>
<a name="l4"></a></span><span class=cF6>&quot;HomeDir\0NoMP\0TextMode\0DontProbe\0MountIDEAuto\0DbgDistro\0Help\0&quot;</span><span class=cF0>;
<a name="l5"></a>
<a name="l6"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_MEM_INIT 0
<a name="l7"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_HEAP_INIT 1
<a name="l8"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_VAR_INIT 2
<a name="l9"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_STAFF_MODE 3
<a name="l10"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_HOME_DIR 4
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_NO_MP 5
<a name="l12"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_TEXT_MODE 6
<a name="l13"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_DONT_PROBE 7
<a name="l14"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_MOUNT_IDE_AUTO 8
<a name="l15"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_DBG_DISTRO 9
<a name="l16"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_OPTIONS_NUM 10
<a name="l17"></a>
<a name="l18"></a>#</span><span class=cF1>define</span><span class=cF0> CFG_HELP 10
<a name="l19"></a>
<a name="l20"></a></span><span class=cF1>class</span><span class=cF0> CKCfg
<a name="l21"></a>{
<a name="l22"></a> </span><span class=cF1>U8</span><span class=cF0> *dsk_cache_size_exp;
<a name="l23"></a> </span><span class=cF9>CDoc</span><span class=cF0> *add_dev;
<a name="l24"></a> </span><span class=cF1>U8</span><span class=cF0> *dbg_distro_file,*dbg_distro_start;
<a name="l25"></a> </span><span class=cF1>U8</span><span class=cF0> *home_dir;
<a name="l26"></a> </span><span class=cF1>Bool</span><span class=cF0> opts[CFG_OPTIONS_NUM];
<a name="l27"></a> </span><span class=cF1>U8</span><span class=cF0> mem_init_val,heap_init_val,var_init_val,
<a name="l28"></a> boot_drv_let,mount_ide_auto_hd_let,mount_ide_auto_cd_let;
<a name="l29"></a>};
<a name="l30"></a>
<a name="l31"></a></span><span class=cF9>CDoc</span><span class=cF0> *KCfgAddDev(CKCfg *c)
<a name="l32"></a>{
<a name="l33"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
<a name="l34"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocNew</span><span class=cF0>;
<a name="l35"></a> </span><span class=cF6>&quot;\n\nIn anticipation of the drives you will\n&quot;</span><span class=cF0>
<a name="l36"></a> </span><span class=cF6>&quot;define shortly, enter the drive letter\n&quot;</span><span class=cF0>
<a name="l37"></a> </span><span class=cF6>&quot;of the drive with the account directory.\n&quot;</span><span class=cF0>
<a name="l38"></a> </span><span class=cF6>&quot;\n($PURPLE$&lt;ENTER&gt;$FG$ for cur drv) Boot Drv:&quot;</span><span class=cF0>;
<a name="l39"></a> ch=</span><span class=cF5>Let2Let</span><span class=cF0>(</span><span class=cF5>GetChar</span><span class=cF0>);
<a name="l40"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'A'</span><span class=cF0>&lt;=ch&lt;=</span><span class=cF6>'Z'</span><span class=cF0>)
<a name="l41"></a> c-&gt;boot_drv_let=ch;
<a name="l42"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l43"></a> c-&gt;boot_drv_let=</span><span class=cF5>Drv2Let</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dv);
<a name="l44"></a> </span><span class=cF6>&quot;\n\n$BK,1$$PURPLE$Mount drives so they will be present when &quot;</span><span class=cF0>
<a name="l45"></a> </span><span class=cF6>&quot;you boot.$FG$$BK,0$\n&quot;</span><span class=cF0>;
<a name="l46"></a> </span><span class=cF5>Mount2</span><span class=cF0>(c-&gt;boot_drv_let,doc,</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l47"></a> </span><span class=cF1>return</span><span class=cF0> doc;
<a name="l48"></a>}
<a name="l49"></a>
<a name="l50"></a></span><span class=cF1>U0</span><span class=cF0> KCfgOptions(CKCfg *c)
<a name="l51"></a>{
<a name="l52"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l53"></a> </span><span class=cF1>U8</span><span class=cF0> *st=</span><span class=cF3>NULL</span><span class=cF0>,*st2,*st3;
<a name="l54"></a> </span><span class=cF1>Bool</span><span class=cF0> state;
<a name="l55"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l56"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l57"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;CFG_OPTIONS_NUM;i++)
<a name="l58"></a> </span><span class=cF1>if</span><span class=cF0> (i==CFG_HOME_DIR)
<a name="l59"></a> </span><span class=cF6>&quot;$PURPLE$%13tz$FG$:\&quot;%s\&quot;\n&quot;</span><span class=cF0>,i,kernel_cfg_options,c-&gt;home_dir;
<a name="l60"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l61"></a> </span><span class=cF6>&quot;$PURPLE$%13tz$FG$:%Z\n&quot;</span><span class=cF0>,i,kernel_cfg_options,c-&gt;opts[i],</span><span class=cF6>&quot;ST_OFF_ON&quot;</span><span class=cF0>;
<a name="l62"></a> </span><span class=cF6>&quot;\nType '$PURPLE$Help$FG$' for help.\n&quot;</span><span class=cF0>;
<a name="l63"></a> st=</span><span class=cF5>GetStr</span><span class=cF0>(</span><span class=cF6>&quot;Option ($PURPLE$&lt;ENTER&gt;$FG$ when done):&quot;</span><span class=cF0>,</span><span class=cF6>&quot;&quot;</span><span class=cF0>);
<a name="l64"></a> i=</span><span class=cF5>LstMatch</span><span class=cF0>(st,kernel_cfg_options,</span><span class=cF3>LMF_IGNORE_CASE</span><span class=cF0>);
<a name="l65"></a> </span><span class=cF1>if</span><span class=cF0> (i==CFG_HELP)
<a name="l66"></a> </span><span class=cF6>&quot;\n&quot;</span><span class=cF0>
<a name="l67"></a> </span><span class=cF6>&quot;$PURPLE$MemInit$FG$ Initializes memory above 0x100000 &quot;</span><span class=cF0>
<a name="l68"></a> </span><span class=cF6>&quot;to a val at boot.\n&quot;</span><span class=cF0>
<a name="l69"></a> </span><span class=cF6>&quot;$PURPLE$HeapInit$FG$ Initializes MAlloc() memory to a val.\n&quot;</span><span class=cF0>
<a name="l70"></a> </span><span class=cF6>&quot;$PURPLE$VarInit$FG$ Initializes glbl var memory to a val.\n&quot;</span><span class=cF0>
<a name="l71"></a> </span><span class=cF6>&quot;$PURPLE$HomeDir$FG$ Set home dir.\n&quot;</span><span class=cF0>
<a name="l72"></a> </span><span class=cF6>&quot;$PURPLE$NoMP$FG$ No multicore.\n&quot;</span><span class=cF0>
<a name="l73"></a> </span><span class=cF6>&quot;$PURPLE$TextMode$FG$ Text Mode (requires hard reboot).\n&quot;</span><span class=cF0>
<a name="l74"></a> </span><span class=cF6>&quot;$PURPLE$DontProbe$FG$ Just prompt CD/DVD ports, don't probe.\n&quot;</span><span class=cF0>
<a name="l75"></a> </span><span class=cF6>&quot;$PURPLE$MountIDEAuto$FG$ Auto Mount IDE drives to 'C' and 'T'.\n&quot;</span><span class=cF0>
<a name="l76"></a> </span><span class=cF6>&quot;$PURPLE$DbgDistro$FG$ Include RAM Drv in Kernel.BIN.\n&quot;</span><span class=cF0>
<a name="l77"></a> </span><span class=cF6>&quot;\n&quot;</span><span class=cF0>;
<a name="l78"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l79"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=i&lt;CFG_OPTIONS_NUM) {
<a name="l80"></a> state=c-&gt;opts[i]=!c-&gt;opts[i];
<a name="l81"></a> </span><span class=cF1>switch</span><span class=cF0> (i) </span><span class=cF7>{</span><span class=cF0>
<a name="l82"></a> </span><span class=cF1>case</span><span class=cF0> CFG_MEM_INIT:
<a name="l83"></a> </span><span class=cF1>if</span><span class=cF0> (state)
<a name="l84"></a> c-&gt;mem_init_val=</span><span class=cF5>GetI64</span><span class=cF0>(</span><span class=cF6>&quot;Val (0-255):&quot;</span><span class=cF0>,255,0,255);
<a name="l85"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l86"></a> </span><span class=cF1>case</span><span class=cF0> CFG_HEAP_INIT:
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (state)
<a name="l88"></a> c-&gt;heap_init_val=</span><span class=cF5>GetI64</span><span class=cF0>(</span><span class=cF6>&quot;Val (0-255):&quot;</span><span class=cF0>,255,0,255);
<a name="l89"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l90"></a> </span><span class=cF1>case</span><span class=cF0> CFG_VAR_INIT:
<a name="l91"></a> </span><span class=cF1>if</span><span class=cF0> (state)
<a name="l92"></a> c-&gt;var_init_val=</span><span class=cF5>GetI64</span><span class=cF0>(</span><span class=cF6>&quot;Val (0-255):&quot;</span><span class=cF0>,255,0,255);
<a name="l93"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l94"></a> </span><span class=cF1>case</span><span class=cF0> CFG_HOME_DIR:
<a name="l95"></a> st2=</span><span class=cF5>GetStr</span><span class=cF0>(</span><span class=cF6>&quot;Home Dir(\&quot;%s\&quot;):&quot;</span><span class=cF0>,c-&gt;home_dir);
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (!*st2)
<a name="l97"></a> st2=</span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;::/Home&quot;</span><span class=cF0>);
<a name="l98"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (st2[1]!=</span><span class=cF6>':'</span><span class=cF0>) {
<a name="l99"></a> st3=</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;::%s&quot;</span><span class=cF0>,st2);
<a name="l100"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l101"></a> st2=st3;
<a name="l102"></a> }
<a name="l103"></a> </span><span class=cF5>Free</span><span class=cF0>(c-&gt;home_dir);
<a name="l104"></a> c-&gt;home_dir=st2;
<a name="l105"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>c-&gt;home_dir,</span><span class=cF6>&quot;::/Home&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l106"></a> c-&gt;opts[i]=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l107"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l108"></a> c-&gt;opts[i]=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l109"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l110"></a> </span><span class=cF1>case</span><span class=cF0> CFG_MOUNT_IDE_AUTO:
<a name="l111"></a> </span><span class=cF1>if</span><span class=cF0> (state) {
<a name="l112"></a> </span><span class=cF6>&quot;First HD Drive Let:&quot;</span><span class=cF0>;
<a name="l113"></a> c-&gt;mount_ide_auto_hd_let=</span><span class=cF5>Let2Let</span><span class=cF0>(</span><span class=cF5>GetChar</span><span class=cF0>);
<a name="l114"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF6>'A'</span><span class=cF0>&lt;=c-&gt;mount_ide_auto_hd_let&lt;=</span><span class=cF6>'Z'</span><span class=cF7>)</span><span class=cF0>)
<a name="l115"></a> c-&gt;mount_ide_auto_hd_let=0;
<a name="l116"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l117"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;mount_ide_auto_hd_let)
<a name="l118"></a> </span><span class=cF6>&quot;First HD Drive:%C\n&quot;</span><span class=cF0>,c-&gt;mount_ide_auto_hd_let;
<a name="l119"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l120"></a> </span><span class=cF6>&quot;First HD Drive:%C\n&quot;</span><span class=cF0>,</span><span class=cF6>'C'</span><span class=cF0>;
<a name="l121"></a>
<a name="l122"></a> </span><span class=cF6>&quot;First CD Drive Let:&quot;</span><span class=cF0>;
<a name="l123"></a> c-&gt;mount_ide_auto_cd_let=</span><span class=cF5>Let2Let</span><span class=cF0>(</span><span class=cF5>GetChar</span><span class=cF0>);
<a name="l124"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF6>'A'</span><span class=cF0>&lt;=c-&gt;mount_ide_auto_cd_let&lt;=</span><span class=cF6>'Z'</span><span class=cF7>)</span><span class=cF0>)
<a name="l125"></a> c-&gt;mount_ide_auto_cd_let=0;
<a name="l126"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;mount_ide_auto_cd_let)
<a name="l128"></a> </span><span class=cF6>&quot;First CD Drive:%C\n&quot;</span><span class=cF0>,c-&gt;mount_ide_auto_cd_let;
<a name="l129"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l130"></a> </span><span class=cF6>&quot;First CD Drive:%C\n&quot;</span><span class=cF0>,</span><span class=cF6>'T'</span><span class=cF0>;
<a name="l131"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l132"></a> c-&gt;mount_ide_auto_hd_let=0;
<a name="l133"></a> c-&gt;mount_ide_auto_cd_let=0;
<a name="l134"></a> }
<a name="l135"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l136"></a> </span><span class=cF1>case</span><span class=cF0> CFG_DBG_DISTRO:
<a name="l137"></a> </span><span class=cF5>Free</span><span class=cF0>(c-&gt;dbg_distro_file);
<a name="l138"></a> c-&gt;dbg_distro_file=0;
<a name="l139"></a> c-&gt;dbg_distro_start=0;
<a name="l140"></a> </span><span class=cF1>if</span><span class=cF0> (state) {
<a name="l141"></a> c-&gt;dbg_distro_file=</span><span class=cF5>GetStr</span><span class=cF0>(</span><span class=cF6>&quot;Dbg Distro File:&quot;</span><span class=cF0>);
<a name="l142"></a> c-&gt;dbg_distro_start=</span><span class=cF5>GetI64</span><span class=cF0>(</span><span class=cF6>&quot;Dbg Distro Start:&quot;</span><span class=cF0>);
<a name="l143"></a> }
<a name="l144"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l145"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l146"></a> }
<a name="l147"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (*st);
<a name="l148"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l149"></a>}
<a name="l150"></a>
<a name="l151"></a>CKCfg *KCfgNew()
<a name="l152"></a>{
<a name="l153"></a> CKCfg *c=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CKCfg</span><span class=cF7>)</span><span class=cF0>);
<a name="l154"></a>
<a name="l155"></a> c-&gt;add_dev=KCfgAddDev(c);
<a name="l156"></a> c-&gt;home_dir=</span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;::/Home&quot;</span><span class=cF0>);
<a name="l157"></a> c-&gt;dsk_cache_size_exp=</span><span class=cF5>GetStr</span><span class=cF0>(
<a name="l158"></a> </span><span class=cF6>&quot;Disk Cache Size in Bytes,\n&quot;</span><span class=cF0>
<a name="l159"></a> </span><span class=cF6>&quot;gets rounded-up funny,\n&quot;</span><span class=cF0>
<a name="l160"></a> </span><span class=cF6>&quot;($PURPLE$&lt;ENTER&gt;$FG$ will use default.):&quot;</span><span class=cF0>,
<a name="l161"></a> </span><span class=cF6>&quot;Scale2Mem(0x80000,0x8000000)&quot;</span><span class=cF0>);
<a name="l162"></a> KCfgOptions(c);
<a name="l163"></a> </span><span class=cF1>return</span><span class=cF0> c;
<a name="l164"></a>}
<a name="l165"></a>
<a name="l166"></a></span><span class=cF1>U0</span><span class=cF0> KCfgDel(CKCfg *c)
<a name="l167"></a>{
<a name="l168"></a> </span><span class=cF5>DocDel</span><span class=cF0>(c-&gt;add_dev);
<a name="l169"></a> </span><span class=cF5>Free</span><span class=cF0>(c-&gt;dbg_distro_file);
<a name="l170"></a> </span><span class=cF5>Free</span><span class=cF0>(c-&gt;home_dir);
<a name="l171"></a> </span><span class=cF5>Free</span><span class=cF0>(c-&gt;dsk_cache_size_exp);
<a name="l172"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
<a name="l173"></a>}
</span></pre></body>
</html>