mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
363 lines
48 KiB
HolyC
Executable file
363 lines
48 KiB
HolyC
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=cF2>/*On each core, tasks are linked in a</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF2>circular doubly-linked list queue with</span><span class=cF0>
|
|
<a name="l3"></a></span><span class=cF2>the Executive task as the head. On Core0,</span><span class=cF0>
|
|
<a name="l4"></a></span><span class=cF2>the queue order represents the front-to-back</span><span class=cF0>
|
|
<a name="l5"></a></span><span class=cF2>window stack order with the window mgr</span><span class=cF0>
|
|
<a name="l6"></a></span><span class=cF2>as the wallpaper.</span><span class=cF0>
|
|
<a name="l7"></a>
|
|
<a name="l8"></a></span><span class=cF2>The scheduler is round-robin. It checks</span><span class=cF0>
|
|
<a name="l9"></a></span><span class=cF2>if a task is ready and runs it or skips it.</span><span class=cF0>
|
|
<a name="l10"></a></span><span class=cF2>Swapping tasks just involves storing and</span><span class=cF0>
|
|
<a name="l11"></a></span><span class=cF2>restoring regs (no disk I/O for virtual</span><span class=cF0>
|
|
<a name="l12"></a></span><span class=cF2>memory and no addr map changes). It is</span><span class=cF0>
|
|
<a name="l13"></a></span><span class=cF2>always fully identity-mapped on all cores.</span><span class=cF0>
|
|
<a name="l14"></a></span><span class=cF2>Tasks can be switched in half a microsecond.</span><span class=cF0>
|
|
<a name="l15"></a>
|
|
<a name="l16"></a></span><span class=cF2>The scheduler checks if a task is</span><span class=cF0>
|
|
<a name="l17"></a></span><span class=cF2>waiting for a certain time or waiting</span><span class=cF0>
|
|
<a name="l18"></a></span><span class=cF2>on a message and skips if not ready.</span><span class=cF0>
|
|
<a name="l19"></a></span><span class=cF2>A task runs until it voluntarily yields ctrl</span><span class=cF0>
|
|
<a name="l20"></a></span><span class=cF2>with a call to </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Sched.html#l289"><span class=cF4>Yield</span></a><span class=cF2>(). Tasks waiting on I/O</span><span class=cF0>
|
|
<a name="l21"></a></span><span class=cF2>often loop, checking for a status and</span><span class=cF4>
|
|
<a name="l22"></a></span><a href="https://tomawezome.github.io/ZealOS/Kernel/Sched.html#l289"><span class=cF4>Yield</span></a><span class=cF2>ing. This does not really degrade</span><span class=cF0>
|
|
<a name="l23"></a></span><span class=cF2>performance, but pegs the CPU Load.</span><span class=cF0>
|
|
<a name="l24"></a>
|
|
<a name="l25"></a></span><span class=cF2>The scheduler checks for a few keys:</span><span class=cF0>
|
|
<a name="l26"></a>
|
|
<a name="l27"></a></span><span class=cF2><CTRL-ALT-x> kill a task.</span><span class=cF0>
|
|
<a name="l28"></a></span><span class=cF2><CTRL-ALT-DEL> reboots.</span><span class=cF0>
|
|
<a name="l29"></a></span><span class=cF2><CTRL-ALT-n> Next task.</span><span class=cF0>
|
|
<a name="l30"></a></span><span class=cF2><CTRL-ALT-c> breaks execution of a program.</span><span class=cF0>
|
|
<a name="l31"></a>
|
|
<a name="l32"></a></span><span class=cF2>Each core has its own circular task queue.</span><span class=cF0>
|
|
<a name="l33"></a></span><span class=cF2>For AP processors, they have an "Executive" task</span><span class=cF0>
|
|
<a name="l34"></a></span><span class=cF2>which stays in a loop waiting for jobs or</span><span class=cF0>
|
|
<a name="l35"></a></span><span class=cF2>requests to spawn tasks. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/MultiProc.html#l200"><span class=cF4>CoreAPExecutiveTask</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l36"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l37"></a>
|
|
<a name="l38"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>TaskFocusNext</span><span class=cF0>()
|
|
<a name="l39"></a>{
|
|
<a name="l40"></a> </span><span class=cF9>CTask</span><span class=cF0> *task, *_task = </span><span class=cFB>sys_focus_task</span><span class=cF0>;
|
|
<a name="l41"></a>
|
|
<a name="l42"></a> </span><span class=cFB>sys_focus_task</span><span class=cF0> = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l43"></a> </span><span class=cF1>if</span><span class=cF0> (!_task)
|
|
<a name="l44"></a> _task = </span><span class=cFB>sys_task</span><span class=cF0>;
|
|
<a name="l45"></a> task = _task->next_task;
|
|
<a name="l46"></a> </span><span class=cF1>do</span><span class=cF0>
|
|
<a name="l47"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&task->win_inhibit, </span><span class=cF3>WIf_SELF_FOCUS</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l49"></a> {
|
|
<a name="l50"></a> </span><span class=cFB>sys_focus_task</span><span class=cF0> = task;
|
|
<a name="l51"></a> </span><span class=cF5>CallExtNum</span><span class=cF0>(</span><span class=cF3>EXT_WIN_TO_TOP</span><span class=cF0>, task, </span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l52"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l53"></a> }
|
|
<a name="l54"></a> task = task->next_task;
|
|
<a name="l55"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l56"></a> </span><span class=cF1>while</span><span class=cF0> (task != _task);
|
|
<a name="l57"></a>}
|
|
<a name="l58"></a>
|
|
<a name="l59"></a></span><span class=cF1>asm</span><span class=cF0> {
|
|
<a name="l60"></a></span><span class=cFD>TASK_CONTEXT_SAVE</span><span class=cF0>::
|
|
<a name="l61"></a></span><span class=cF2>//OUT:</span><span class=cF0> </span><span class=cF2>RSI=FS</span><span class=cF0>
|
|
<a name="l62"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l63"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l64"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l65"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>FS</span><span class=cF0>:</span><span class=cF9>CTask</span><span class=cF0>.addr[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l66"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rflags[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l67"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rsi[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l68"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rax[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l69"></a>
|
|
<a name="l70"></a></span><span class=cF2>/*Divert the stack to the Task memory</span><span class=cF0>
|
|
<a name="l71"></a></span><span class=cF2>and push onto it and divert it back.</span><span class=cF0>
|
|
<a name="l72"></a></span><span class=cF2>It's a little faster.</span><span class=cF0>
|
|
<a name="l73"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l74"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RSP</span><span class=cF0>
|
|
<a name="l75"></a> </span><span class=cF1>LEA</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.r15+</span><span class=cFE>8</span><span class=cF0>[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l76"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R15</span><span class=cF0>
|
|
<a name="l77"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R14</span><span class=cF0>
|
|
<a name="l78"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R13</span><span class=cF0>
|
|
<a name="l79"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R12</span><span class=cF0>
|
|
<a name="l80"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R11</span><span class=cF0>
|
|
<a name="l81"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R10</span><span class=cF0>
|
|
<a name="l82"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R9</span><span class=cF0>
|
|
<a name="l83"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>R8</span><span class=cF0>
|
|
<a name="l84"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RDI</span><span class=cF0>
|
|
<a name="l85"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RBP</span><span class=cF0>
|
|
<a name="l86"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0>
|
|
<a name="l87"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>
|
|
<a name="l88"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RCX</span><span class=cF0>
|
|
<a name="l89"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l90"></a>
|
|
<a name="l91"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.fpu_mmx[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l92"></a> </span><span class=cF1>FXSAVE</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>]
|
|
<a name="l93"></a>
|
|
<a name="l94"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.bpt_list[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l95"></a>@@05: </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>, </span><span class=cFC>RDX</span><span class=cF0>
|
|
<a name="l96"></a> </span><span class=cF1>JZ</span><span class=cF0> @@10
|
|
<a name="l97"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RDI</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CBpt</span><span class=cF0>.addr[</span><span class=cFC>RDX</span><span class=cF0>]
|
|
<a name="l98"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> </span><span class=cF9>CBpt</span><span class=cF0>.val[</span><span class=cFC>RDX</span><span class=cF0>]
|
|
<a name="l99"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> [</span><span class=cFC>RDI</span><span class=cF0>], </span><span class=cFC>AL</span><span class=cF0>
|
|
<a name="l100"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CBpt</span><span class=cF0>.next[</span><span class=cFC>RDX</span><span class=cF0>]
|
|
<a name="l101"></a> </span><span class=cF1>JMP</span><span class=cF0> @@05
|
|
<a name="l102"></a>@@10: </span><span class=cF1>RET</span><span class=cF0>
|
|
<a name="l103"></a>
|
|
<a name="l104"></a></span><span class=cF2>//************************************</span><span class=cF0>
|
|
<a name="l105"></a></span><span class=cFD>_TASK_CONTEXT_RESTORE</span><span class=cF0>::
|
|
<a name="l106"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l107"></a> </span><span class=cF1>INC</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.swap_counter[</span><span class=cFC>RAX</span><span class=cF0>]
|
|
<a name="l108"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>FS</span><span class=cF0>:</span><span class=cF9>CTask</span><span class=cF0>.addr[</span><span class=cFC>RAX</span><span class=cF0>]
|
|
<a name="l109"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rflags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>RFLAGf_INT</span><span class=cF0>
|
|
<a name="l110"></a> </span><span class=cF1>JNC</span><span class=cF0> @@05
|
|
<a name="l111"></a> </span><span class=cF1>BTS</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.cpu_flags[</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cF3>CPUf_RAN_A_TASK</span><span class=cF0>
|
|
<a name="l112"></a>@@05: </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.task_flags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>TASKf_DISABLE_BPTS</span><span class=cF0>
|
|
<a name="l113"></a> </span><span class=cF1>JC</span><span class=cF0> @@15
|
|
<a name="l114"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.bpt_list[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l115"></a>@@10: </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>, </span><span class=cFC>RDX</span><span class=cF0>
|
|
<a name="l116"></a> </span><span class=cF1>JZ</span><span class=cF0> @@15
|
|
<a name="l117"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RDI</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CBpt</span><span class=cF0>.addr[</span><span class=cFC>RDX</span><span class=cF0>]
|
|
<a name="l118"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> [</span><span class=cFC>RDI</span><span class=cF0>], </span><span class=cF3>OC_BPT</span><span class=cF0>
|
|
<a name="l119"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CBpt</span><span class=cF0>.next[</span><span class=cFC>RDX</span><span class=cF0>]
|
|
<a name="l120"></a> </span><span class=cF1>JMP</span><span class=cF0> @@10
|
|
<a name="l121"></a>
|
|
<a name="l122"></a>@@15: </span><span class=cF1>INC</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.swap_counter[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l123"></a>
|
|
<a name="l124"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.fpu_mmx[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l125"></a> </span><span class=cF1>FXRSTOR</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>]
|
|
<a name="l126"></a>
|
|
<a name="l127"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RSP</span><span class=cF0>
|
|
<a name="l128"></a> </span><span class=cF1>LEA</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rcx[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l129"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RCX</span><span class=cF0>
|
|
<a name="l130"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RDX</span><span class=cF0>
|
|
<a name="l131"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0>
|
|
<a name="l132"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RBP</span><span class=cF0>
|
|
<a name="l133"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RDI</span><span class=cF0>
|
|
<a name="l134"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R8</span><span class=cF0>
|
|
<a name="l135"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R9</span><span class=cF0>
|
|
<a name="l136"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R10</span><span class=cF0>
|
|
<a name="l137"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R11</span><span class=cF0>
|
|
<a name="l138"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R12</span><span class=cF0>
|
|
<a name="l139"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R13</span><span class=cF0>
|
|
<a name="l140"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R14</span><span class=cF0>
|
|
<a name="l141"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>R15</span><span class=cF0>
|
|
<a name="l142"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l143"></a>
|
|
<a name="l144"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rax[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l145"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>CGDT</span><span class=cF0>.ds
|
|
<a name="l146"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rsp[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l147"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rflags[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l148"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>CGDT</span><span class=cF0>.cs64
|
|
<a name="l149"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rip[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l150"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rsi[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l151"></a> </span><span class=cF1>IRET</span><span class=cF0>
|
|
<a name="l152"></a>
|
|
<a name="l153"></a></span><span class=cF2>//************************************</span><span class=cF0>
|
|
<a name="l154"></a>END_RSI_TASK:
|
|
<a name="l155"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l156"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_FS_BASE</span><span class=cF0>
|
|
<a name="l157"></a></span><span class=cFD>_TASK_END_NOW</span><span class=cF0>::
|
|
<a name="l158"></a> </span><span class=cF1>CALL</span><span class=cF0> &</span><span class=cFD>TaskEnd</span><span class=cF0>
|
|
<a name="l159"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l160"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_FS_BASE</span><span class=cF0>
|
|
<a name="l161"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF1>I8</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l162"></a>
|
|
<a name="l163"></a></span><span class=cFD>_YIELD</span><span class=cF0>::
|
|
<a name="l164"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l165"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> [</span><span class=cFD>SYS_SEMAS</span><span class=cF0> + </span><span class=cF3>SEMA_SINGLE_USER</span><span class=cF0> * </span><span class=cF3>DEFAULT_CACHE_LINE_WIDTH</span><span class=cF0>], </span><span class=cFE>1</span><span class=cF0>
|
|
<a name="l166"></a> </span><span class=cF1>JZ</span><span class=cF0> @@05
|
|
<a name="l167"></a> </span><span class=cF1>POPFD</span><span class=cF0> </span><span class=cF2>//If single user, don't change task.</span><span class=cF0>
|
|
<a name="l168"></a> </span><span class=cF1>RET</span><span class=cF0>
|
|
<a name="l169"></a>
|
|
<a name="l170"></a>@@05: </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l171"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>TASK_CONTEXT_SAVE</span><span class=cF0>
|
|
<a name="l172"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFD>_RET</span><span class=cF0>
|
|
<a name="l173"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rip[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cFC>RBX</span><span class=cF0>
|
|
<a name="l174"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rflags[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l175"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rsp[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cFC>RSP</span><span class=cF0>
|
|
<a name="l176"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.next_task[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l177"></a>
|
|
<a name="l178"></a>RESTORE_RSI_TASK:
|
|
<a name="l179"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFD>SYS_CTRL_ALT_FLAGS</span><span class=cF0>], </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>CTRL_ALT_DEL</span><span class=cF0>|</span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>CTRL_ALT_TAB</span><span class=cF0>|</span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>CTRL_ALT_X</span><span class=cF0>|</span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>CTRL_ALT_C</span><span class=cF0>
|
|
<a name="l180"></a> </span><span class=cF1>JNZ</span><span class=cF0> HANDLE_SYSF_KEY_EVENT
|
|
<a name="l181"></a>
|
|
<a name="l182"></a>RESTORE_RSI_TASK2:
|
|
<a name="l183"></a>@@20: </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.task_flags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>
|
|
<a name="l184"></a> </span><span class=cF1>JC</span><span class=cF0> END_RSI_TASK
|
|
<a name="l185"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.task_flags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>TASKf_AWAITING_MESSAGE</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>TASKf_SUSPENDED</span><span class=cF0>
|
|
<a name="l186"></a> </span><span class=cF1>JNZ</span><span class=cF0> @@25
|
|
<a name="l187"></a>
|
|
<a name="l188"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> [&</span><span class=cFB>counts</span><span class=cF0>.jiffies]
|
|
<a name="l189"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.wake_jiffy[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l190"></a> </span><span class=cF1>JG</span><span class=cF0> @@25 </span><span class=cF2>//Jmp if not ready, yet.</span><span class=cF0>
|
|
<a name="l191"></a>
|
|
<a name="l192"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l193"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_FS_BASE</span><span class=cF0>
|
|
<a name="l194"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> </span><span class=cFD>_TASK_CONTEXT_RESTORE</span><span class=cF0>
|
|
<a name="l195"></a>
|
|
<a name="l196"></a>@@25: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.next_task[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l197"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l198"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.executive_task[</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l199"></a> </span><span class=cF1>JNE</span><span class=cF0> @@20 </span><span class=cF2>//Jmp if not Executive</span><span class=cF0>
|
|
<a name="l200"></a> </span><span class=cF1>BTR</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.cpu_flags[</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cF3>CPUf_RAN_A_TASK</span><span class=cF0>
|
|
<a name="l201"></a> </span><span class=cF1>JC</span><span class=cF0> @@20 </span><span class=cF2>//Jmp if had chance for IRQ already</span><span class=cF0>
|
|
<a name="l202"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.idle_task[</span><span class=cFC>RAX</span><span class=cF0>]
|
|
<a name="l203"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.stack[</span><span class=cFC>RAX</span><span class=cF0>]
|
|
<a name="l204"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cF3>MEM_DEFAULT_STACK</span><span class=cF0> + </span><span class=cF9>CTaskStack</span><span class=cF0>.stack_base </span><span class=cF2>//Reset to top</span><span class=cF0>
|
|
<a name="l205"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_FS_BASE</span><span class=cF0>
|
|
<a name="l206"></a> </span><span class=cF1>STI</span><span class=cF0> </span><span class=cF2>//Restore idle task so we can unmask IRQs.</span><span class=cF0>
|
|
<a name="l207"></a> </span><span class=cF1>HLT</span><span class=cF0>
|
|
<a name="l208"></a></span><span class=cFD>SYS_IDLE_PT</span><span class=cF0>::
|
|
<a name="l209"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l210"></a>
|
|
<a name="l211"></a>RESTORE_EXECUTIVE_TASK_IF_READY:
|
|
<a name="l212"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l213"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.executive_task[</span><span class=cFC>RAX</span><span class=cF0>]
|
|
<a name="l214"></a> </span><span class=cF1>JMP</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l215"></a>
|
|
<a name="l216"></a>HANDLE_SYSF_KEY_EVENT:
|
|
<a name="l217"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l218"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_FS_BASE</span><span class=cF0>
|
|
<a name="l219"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RBX</span><span class=cF0>, </span><span class=cFC>RBX</span><span class=cF0>
|
|
<a name="l220"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.num[</span><span class=cFC>RBX</span><span class=cF0>]
|
|
<a name="l221"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l222"></a> </span><span class=cF1>JNZ</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK2
|
|
<a name="l223"></a>
|
|
<a name="l224"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFD>SYS_CTRL_ALT_FLAGS</span><span class=cF0>
|
|
<a name="l225"></a> </span><span class=cF1>LOCK</span><span class=cF0>
|
|
<a name="l226"></a> </span><span class=cF1>BTR</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cF3>CTRL_ALT_DEL</span><span class=cF0>
|
|
<a name="l227"></a> </span><span class=cF1>JC</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> &</span><span class=cF5>Reboot</span><span class=cF0>
|
|
<a name="l228"></a>
|
|
<a name="l229"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.idle_task[</span><span class=cFC>RBX</span><span class=cF0>], </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l230"></a> </span><span class=cF1>JE</span><span class=cF0> RESTORE_EXECUTIVE_TASK_IF_READY
|
|
<a name="l231"></a>
|
|
<a name="l232"></a> </span><span class=cF1>LOCK</span><span class=cF0>
|
|
<a name="l233"></a> </span><span class=cF1>BTR</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cF3>CTRL_ALT_TAB</span><span class=cF0>
|
|
<a name="l234"></a> </span><span class=cF1>JNC</span><span class=cF0> @@05
|
|
<a name="l235"></a> </span><span class=cF1>CALL</span><span class=cF0> &</span><span class=cFD>TaskFocusNext</span><span class=cF0>
|
|
<a name="l236"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_FS_TASK
|
|
<a name="l237"></a>
|
|
<a name="l238"></a>@@05: </span><span class=cF1>LOCK</span><span class=cF0>
|
|
<a name="l239"></a> </span><span class=cF1>BTR</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cF3>CTRL_ALT_X</span><span class=cF0>
|
|
<a name="l240"></a> </span><span class=cF1>JC</span><span class=cF0> END_FOCUS_USER
|
|
<a name="l241"></a> </span><span class=cF1>LOCK</span><span class=cF0>
|
|
<a name="l242"></a> </span><span class=cF1>BTR</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>RAX</span><span class=cF0>], </span><span class=cF3>CTRL_ALT_C</span><span class=cF0>
|
|
<a name="l243"></a> </span><span class=cF1>JNC</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l244"></a>
|
|
<a name="l245"></a>BREAK_FOCUS_USER:
|
|
<a name="l246"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFD>SYS_FOCUS_TASK</span><span class=cF0>]
|
|
<a name="l247"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l248"></a> </span><span class=cF1>JZ</span><span class=cF0> RESTORE_EXECUTIVE_TASK_IF_READY
|
|
<a name="l249"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.win_inhibit[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>WIf_SELF_FOCUS</span><span class=cF0>
|
|
<a name="l250"></a> </span><span class=cF1>JC</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l251"></a> </span><span class=cF1>LOCK</span><span class=cF0>
|
|
<a name="l252"></a> </span><span class=cF1>BTR</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.task_flags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>TASKf_BREAK_LOCKED</span><span class=cF0>
|
|
<a name="l253"></a> </span><span class=cF1>JNC</span><span class=cF0> @@10
|
|
<a name="l254"></a> </span><span class=cF1>LOCK</span><span class=cF0>
|
|
<a name="l255"></a> </span><span class=cF1>BTS</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.task_flags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>TASKf_PENDING_BREAK</span><span class=cF0>
|
|
<a name="l256"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l257"></a>
|
|
<a name="l258"></a>@@10: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, &</span><span class=cF5>Break</span><span class=cF0>
|
|
<a name="l259"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.rip[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cFC>RAX</span><span class=cF0>
|
|
<a name="l260"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.task_flags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>TASKf_BREAK_TO_SHIFT_ESC</span><span class=cF0>
|
|
<a name="l261"></a> </span><span class=cF1>JC</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l262"></a>
|
|
<a name="l263"></a></span><span class=cF2>//Do these now, in case interrupt happens.</span><span class=cF0>
|
|
<a name="l264"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.wake_jiffy[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
|
|
<a name="l265"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l266"></a> </span><span class=cF1>CALL</span><span class=cF0> &</span><span class=cF5>TaskResetAwaitingMessage</span><span class=cF0>
|
|
<a name="l267"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l268"></a>
|
|
<a name="l269"></a>END_FOCUS_USER:
|
|
<a name="l270"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFD>SYS_FOCUS_TASK</span><span class=cF0>]
|
|
<a name="l271"></a> </span><span class=cF1>CALL</span><span class=cF0> &</span><span class=cFD>TaskFocusNext</span><span class=cF0>
|
|
<a name="l272"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l273"></a> </span><span class=cF1>JZ</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_EXECUTIVE_TASK_IF_READY
|
|
<a name="l274"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l275"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_FS_BASE</span><span class=cF0>
|
|
<a name="l276"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.win_inhibit[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>WIf_SELF_FOCUS</span><span class=cF0>
|
|
<a name="l277"></a> </span><span class=cF1>JC</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l278"></a> </span><span class=cF1>LOCK</span><span class=cF0>
|
|
<a name="l279"></a> </span><span class=cF1>BTS</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF9>CTask</span><span class=cF0>.task_flags[</span><span class=cFC>RSI</span><span class=cF0>], </span><span class=cF3>TASKf_KILL_TASK</span><span class=cF0>
|
|
<a name="l280"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> END_RSI_TASK
|
|
<a name="l281"></a>
|
|
<a name="l282"></a>RESTORE_FS_TASK:
|
|
<a name="l283"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>RSI</span><span class=cF0>
|
|
<a name="l284"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSI</span><span class=cF0>, </span><span class=cFC>FS</span><span class=cF0>:</span><span class=cF9>CTask</span><span class=cF0>.addr[</span><span class=cFC>RSI</span><span class=cF0>]
|
|
<a name="l285"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF9>I32</span><span class=cF0> RESTORE_RSI_TASK
|
|
<a name="l286"></a>}
|
|
<a name="l287"></a>
|
|
<a name="l288"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>_TASK_CONTEXT_RESTORE</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskContextRestore</span><span class=cF0>(); </span><span class=cF2>//Restore a task context.</span><span class=cF0>
|
|
<a name="l289"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>_YIELD</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Yield</span><span class=cF0>(); </span><span class=cF2>//Yield cpu to next task.</span><span class=cF0>
|
|
<a name="l290"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>_TASK_END_NOW</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskEndNow</span><span class=cF0>(); </span><span class=cF2>//Terminate current task.</span><span class=cF0>
|
|
<a name="l291"></a>
|
|
<a name="l292"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskQueueIns</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task, </span><span class=cF9>CTask</span><span class=cF0> *pred=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l293"></a>{</span><span class=cF2>//Insert a task in the scheduler running task queue.</span><span class=cF0>
|
|
<a name="l294"></a></span><span class=cF2>//You have no business with this, probably.</span><span class=cF0>
|
|
<a name="l295"></a> </span><span class=cF9>CTask</span><span class=cF0> *last;
|
|
<a name="l296"></a>
|
|
<a name="l297"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l298"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l299"></a> </span><span class=cF1>if</span><span class=cF0> (!pred)
|
|
<a name="l300"></a> pred = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l301"></a> last = pred->last_task;
|
|
<a name="l302"></a> last->next_task = pred->last_task = task;
|
|
<a name="l303"></a> task->last_task = last;
|
|
<a name="l304"></a> task->next_task = pred;
|
|
<a name="l305"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l306"></a>}
|
|
<a name="l307"></a>
|
|
<a name="l308"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>TaskQueueRemove</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task)
|
|
<a name="l309"></a>{</span><span class=cF2>//Remove a task from the scheduler running task queue.</span><span class=cF0>
|
|
<a name="l310"></a></span><span class=cF2>//Use </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KTask.html#l88"><span class=cF4>Suspend</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l311"></a> </span><span class=cF9>CTask</span><span class=cF0> *next, *last;
|
|
<a name="l312"></a>
|
|
<a name="l313"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l314"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l315"></a> next = task->next_task;
|
|
<a name="l316"></a> last = task->last_task;
|
|
<a name="l317"></a> last->next_task = next;
|
|
<a name="l318"></a> next->last_task = last;
|
|
<a name="l319"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l320"></a>}
|
|
<a name="l321"></a>
|
|
<a name="l322"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>TaskQueueInsChild</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task)
|
|
<a name="l323"></a>{
|
|
<a name="l324"></a> </span><span class=cF9>CTask</span><span class=cF0> *last, *pred;
|
|
<a name="l325"></a>
|
|
<a name="l326"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l327"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l328"></a> pred = task->parent_task->last_child_task;
|
|
<a name="l329"></a> last = pred->last_sibling_task;
|
|
<a name="l330"></a> last->next_sibling_task = pred->last_sibling_task = task;
|
|
<a name="l331"></a> task->last_sibling_task = last;
|
|
<a name="l332"></a> task->next_sibling_task = pred;
|
|
<a name="l333"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l334"></a>}
|
|
</span></pre></body>
|
|
</html>
|