3 Copyright (C) 2006-2009 Jörg Pfähler
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <kernel/thread.hpp>
21 #include <kernel/scheduler.hpp>
23 using namespace kernel
;
25 thread::thread( process
&Process
,
31 libkernel::thread_id_t id
)
32 : tid(id
), Process(Process
), threadStack(stack
), threadStackSize(stacksize
), State(run
), mFpuState(0), mFpuState2(0)
34 mCpuState
.eax
= param1
;
35 mCpuState
.ebx
= param2
;
41 mCpuState
.esp
= reinterpret_cast<uint32_t>(stack
);
42 mCpuState
.eflags
= 0x202;
43 mCpuState
.eip
= entryPoint
;
45 void thread::grantIOAccess()
47 mCpuState
.eflags
|= 0x3000;
49 void thread::unblock( libkernel::port_id_t port
,
50 libkernel::port_id_t source
,
57 mCpuState
.ebx
= source
;
58 mCpuState
.ecx
= param1
;
59 mCpuState
.edx
= param2
;
60 mCpuState
.esi
= param3
;
61 mCpuState
.edi
= param4
;
65 void thread::set_cpu_state(interrupt_stackframe
&frame
)
67 mCpuState
.eax
= frame
.eax
;
68 mCpuState
.ebx
= frame
.ebx
;
69 mCpuState
.ecx
= frame
.ecx
;
70 mCpuState
.edx
= frame
.edx
;
71 mCpuState
.edi
= frame
.edi
;
72 mCpuState
.esi
= frame
.esi
;
73 mCpuState
.ebp
= frame
.ebp
;
74 mCpuState
.esp
= frame
.esp
;
75 mCpuState
.eip
= frame
.eip
;
76 mCpuState
.eflags
= frame
.eflags
;