Compare commits
29 Commits
7c1f380184
...
e8135e9ff9
| Author | SHA1 | Date |
|---|---|---|
|
|
e8135e9ff9 | 4 months ago |
|
|
c38000e503 | 4 months ago |
|
|
9ffd22e941 | 4 months ago |
|
|
698d0c155b | 4 months ago |
|
|
68f0381c01 | 4 months ago |
|
|
bc0a94b705 | 4 months ago |
|
|
2a7d1bdedc | 4 months ago |
|
|
689c77f19e | 4 months ago |
|
|
38a10f2010 | 4 months ago |
|
|
f5c42a8e77 | 4 months ago |
|
|
638aa9b636 | 4 months ago |
|
|
7322a9ed70 | 4 months ago |
|
|
e6d6e7521c | 4 months ago |
|
|
da34f7cada | 4 months ago |
|
|
94249eda37 | 4 months ago |
|
|
d9978ddc37 | 4 months ago |
|
|
68e11c9793 | 4 months ago |
|
|
5b664840d8 | 4 months ago |
|
|
944d4991cb | 4 months ago |
|
|
76eb2420bd | 4 months ago |
|
|
b422ee176a | 4 months ago |
|
|
c1145d28f8 | 4 months ago |
|
|
ab76afa30a | 4 months ago |
|
|
3d659e0eab | 4 months ago |
|
|
e8ec76112b | 4 months ago |
|
|
a0e2a59f96 | 4 months ago |
|
|
24a0888760 | 4 months ago |
|
|
f90eaa3fcd | 4 months ago |
|
|
a38b6cbdb2 | 4 months ago |
@ -0,0 +1,195 @@
|
||||
#include "arch/lapic.h"
|
||||
#include "boot/startup_ap.h"
|
||||
#include "arch/core_interrupt.h"
|
||||
#include "debug/copystream.h"
|
||||
#include "debug/output.h"
|
||||
#include "debug/assert.h"
|
||||
|
||||
#include "arch/cga.h"
|
||||
#include "arch/textwindow.h"
|
||||
#include "arch/serial.h"
|
||||
#include "device/serialstream.h"
|
||||
#include "device/textstream.h"
|
||||
#include "device/ps2controller.h"
|
||||
#include "arch/ioapic.h"
|
||||
#include "thread/scheduler.h"
|
||||
#include "user/app1/appl.h"
|
||||
#include "sync/ticketlock.h"
|
||||
#include "interrupt/guard.h"
|
||||
|
||||
#include "arch/context.h"
|
||||
#include "thread/thread.h"
|
||||
|
||||
///TextStream kout = TextStream(0, 80, 0, 10, true);
|
||||
Ticketlock koutlock;
|
||||
Scheduler sch;
|
||||
|
||||
//TextStream dout[8] = {
|
||||
// TextStream(0 ,20,12,25,false),
|
||||
// TextStream(20,40,12,25,false),
|
||||
// TextStream(40,60,12,25,false),
|
||||
// TextStream(60,80,12,25,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
// TextStream(0 ,0 ,0, 0,false),
|
||||
//};
|
||||
|
||||
|
||||
TextStream dout[Core::MAX] = {
|
||||
{0, 40, 10, 14},
|
||||
{40, 80, 10, 14},
|
||||
{0, 40, 14, 18},
|
||||
{40, 80, 14, 18},
|
||||
{0, 40, 18, 22},
|
||||
{40, 80, 18, 22},
|
||||
{0, 40, 22, 25},
|
||||
{40, 80, 22, 25},
|
||||
};
|
||||
|
||||
CopyStream copystream[Core::MAX]{
|
||||
{&dout[0], &sout},
|
||||
{&dout[1], &sout},
|
||||
{&dout[2], &sout},
|
||||
{&dout[3], &sout},
|
||||
{&dout[4], &sout},
|
||||
{&dout[5], &sout},
|
||||
{&dout[6], &sout},
|
||||
{&dout[7], &sout},
|
||||
};
|
||||
|
||||
OutputStream* copyout[Core::MAX]{
|
||||
&dout[0],
|
||||
©stream[1],
|
||||
&dout[2],
|
||||
&dout[3],
|
||||
&dout[4],
|
||||
&dout[5],
|
||||
&dout[6],
|
||||
&dout[7]
|
||||
};
|
||||
|
||||
unsigned int testx, testy;
|
||||
|
||||
uint8_t test1_stack[1024];
|
||||
uint8_t test2_stack[1024];
|
||||
uint8_t test3_stack[1024];
|
||||
uint8_t test4_stack[1024];
|
||||
uint8_t test5_stack[1024];
|
||||
uint8_t test6_stack[1024];
|
||||
uint8_t test7_stack[1024];
|
||||
uint8_t test8_stack[1024];
|
||||
uint8_t test9_stack[1024];
|
||||
|
||||
|
||||
|
||||
//Thread test1_thread = Thread(&test1_stack[sizeof(test1_stack)-1]);
|
||||
Application application1 = Application(&test1_stack[sizeof(test1_stack)-1]);
|
||||
Application application2 = Application(&test2_stack[sizeof(test2_stack)-1]);
|
||||
Application application3 = Application(&test3_stack[sizeof(test3_stack)-1]);
|
||||
Application application4 = Application(&test4_stack[sizeof(test4_stack)-1]);
|
||||
Application application5 = Application(&test5_stack[sizeof(test5_stack)-1]);
|
||||
Application application6 = Application(&test6_stack[sizeof(test5_stack)-1]);
|
||||
Application application7 = Application(&test7_stack[sizeof(test5_stack)-1]);
|
||||
Application application8 = Application(&test8_stack[sizeof(test5_stack)-1]);
|
||||
Application application9 = Application(&test9_stack[sizeof(test5_stack)-1]);
|
||||
|
||||
//Context test2;
|
||||
//uint8_t test2_stack[256];
|
||||
//Thread test2_thread = Thread(&test2_stack[sizeof(test2_stack)-1]);
|
||||
|
||||
//void test_func1(){
|
||||
// while(1){
|
||||
// {
|
||||
// Guarded g = Guard::enter();
|
||||
// g.vault().kout << "test 1\n" << flush;
|
||||
// }
|
||||
// context_switch(&test2, &test1);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void test_func2(){
|
||||
// while(1){
|
||||
// {
|
||||
// Guarded g = Guard::enter();
|
||||
// g.vault().kout << "test 2\n" << flush;
|
||||
// }
|
||||
// context_switch(&test1, &test2);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
// Main function
|
||||
// (the bootstrap processor starts here)}
|
||||
extern "C" int main() {
|
||||
CGA::setCursor(0, 0);
|
||||
|
||||
unsigned int numCPUs = Core::count();
|
||||
/* Start application processors
|
||||
* To avoid unexpected behaviour, make sure that interrupts are not
|
||||
* enabled before the APs are booted. Otherwise it might interfere with the
|
||||
* Startup IPIs or even block devices like keyboard because of a missing EOI
|
||||
*/
|
||||
|
||||
{
|
||||
Guarded g = Guard::enter();
|
||||
sch.ready(&application1);
|
||||
sch.ready(&application2);
|
||||
sch.ready(&application3);
|
||||
sch.ready(&application4);
|
||||
sch.ready(&application5);
|
||||
sch.ready(&application6);
|
||||
sch.ready(&application7);
|
||||
sch.ready(&application8);
|
||||
sch.ready(&application9);
|
||||
}
|
||||
|
||||
ApplicationProcessor::boot();
|
||||
|
||||
PS2Controller::init();
|
||||
|
||||
IOAPIC::init();
|
||||
IOAPIC::config(1, Core::Interrupt::KEYBOARD);
|
||||
IOAPIC::allow(1);
|
||||
|
||||
Core::Interrupt::enable();
|
||||
|
||||
PS2Controller::drainBuffer();
|
||||
|
||||
DBG << "Main CPU " << static_cast<int>(LAPIC::getID()) << endl << flush;
|
||||
|
||||
|
||||
|
||||
{
|
||||
Guarded g = Guard::enter();
|
||||
sch.schedule();
|
||||
}
|
||||
|
||||
|
||||
//Application{}.action();
|
||||
while (true){
|
||||
//DBG << "pos: " << testx << ", " << testy << endl << flush;
|
||||
//Core::pause();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Main function for application processors
|
||||
extern "C" int main_ap() {
|
||||
DBG_VERBOSE << "CPU core " << static_cast<int>(Core::getID()) << " / LAPIC "
|
||||
<< static_cast<int>(LAPIC::getID()) << " in main_ap()" << endl;
|
||||
Core::Interrupt::enable();
|
||||
|
||||
DBG << "App CPU " << static_cast<int>(Core::getID()) << endl << flush;
|
||||
|
||||
{
|
||||
Guarded g = Guard::enter();
|
||||
sch.schedule();
|
||||
}
|
||||
|
||||
//assert(Core::getID() != 1);
|
||||
//Application{}.action();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,9 +1,21 @@
|
||||
#include "context.h"
|
||||
#include "../debug/output.h"
|
||||
|
||||
void panic(){
|
||||
DBG << "panic!\n" << flush;
|
||||
while(1);
|
||||
}
|
||||
|
||||
void prepareContext(void* tos, Context& context, void (*kickoff)(void*),
|
||||
void* param1) {
|
||||
(void)tos;
|
||||
(void)context;
|
||||
(void)kickoff;
|
||||
(void)param1;
|
||||
((uint64_t*)tos)[0] = (uint64_t)panic;
|
||||
((uint64_t*)tos)[-1] = (uint64_t)kickoff;
|
||||
((uint64_t*)tos)[-2] = (uint64_t)fake_systemv_abi;
|
||||
context.rsp = (void*)(((uint64_t) tos)-16);
|
||||
context.rbx = 0;
|
||||
context.rbp = 0;
|
||||
context.r12 = 0;
|
||||
context.r13 = 0;
|
||||
context.r14 = 0;
|
||||
context.r15 = (uint64_t)param1;
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
scheduler in vault
|
||||
next implementieren
|
||||
thread kill nicht in die liste enqueuen, scheduler.cc zeile 26
|
||||
setzen von epi flags interrupt vermutlich disablen.
|
||||
@ -1,16 +1,7 @@
|
||||
#include "./semaphore.h"
|
||||
|
||||
#include "../interrupt/guard.h"
|
||||
#include "../thread/thread.h"
|
||||
|
||||
Semaphore::Semaphore(unsigned c) { (void)c; }
|
||||
|
||||
Thread **Semaphore::thread_link(Thread &obj, unsigned link_index) {
|
||||
(void)obj;
|
||||
(void)link_index;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Semaphore::p(Vault &vault) { (void)vault; }
|
||||
|
||||
void Semaphore::v(Vault &vault) { (void)vault; }
|
||||
|
||||
@ -1,17 +1,32 @@
|
||||
// vim: set noet ts=4 sw=4:
|
||||
|
||||
#include "dispatcher.h"
|
||||
#include "../arch/core.h"
|
||||
|
||||
Dispatcher::Dispatcher() {}
|
||||
Dispatcher::Dispatcher() {
|
||||
}
|
||||
|
||||
Thread *Dispatcher::active() { return nullptr; }
|
||||
Thread *Dispatcher::active() {
|
||||
return lifePointer[Core::getID()];
|
||||
}
|
||||
|
||||
bool Dispatcher::isActive(const Thread *thread, unsigned *cpu) {
|
||||
(void)thread;
|
||||
(void)cpu;
|
||||
return false;
|
||||
for(uint8_t i=0; i<Core::MAX; i++){
|
||||
if(thread == lifePointer[i]){
|
||||
*cpu = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cpu = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Dispatcher::go(Thread *first) { (void)first; }
|
||||
void Dispatcher::go(Thread *first) {
|
||||
lifePointer[Core::getID()] = first;
|
||||
first->go();
|
||||
}
|
||||
|
||||
void Dispatcher::dispatch(Thread *next) { (void)next; }
|
||||
void Dispatcher::dispatch(Thread *next) {
|
||||
lifePointer[Core::getID()] = next;
|
||||
lifePointer[Core::getID()]->resume(next);
|
||||
}
|
||||
|
||||
@ -1,16 +1,43 @@
|
||||
// vim: set noet ts=4 sw=4:
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
#include "../debug/output.h"
|
||||
#include "../arch/context.h"
|
||||
#include "interrupt/guard.h"
|
||||
// Alias to simplify stuff
|
||||
typedef void (*kickoff_t)(void*);
|
||||
|
||||
void Thread::kickoff(Thread* object) { (void)object; }
|
||||
void Thread::kickoff(Thread* object) {
|
||||
Guard::leave();
|
||||
object->action();
|
||||
}
|
||||
|
||||
Thread::Thread(void* tos) {
|
||||
prepareContext(tos, context, (void(*)(void*)) &(kickoff), this);
|
||||
}
|
||||
|
||||
#include "../thread/scheduler.h"
|
||||
void Thread::resume(Thread* next) {
|
||||
Context *from;
|
||||
Context *to;
|
||||
|
||||
|
||||
|
||||
from = &this->context;
|
||||
to = &next->context;
|
||||
|
||||
Thread::Thread(void* tos) { (void)tos; }
|
||||
//dispatcher.lifePointer[Core::getID()] = next;
|
||||
DBG << "from: " << hex << from << endl;
|
||||
DBG << "to : " << hex << to << endl << flush;
|
||||
|
||||
context_switch(to, from);
|
||||
|
||||
void Thread::resume(Thread* next) { (void)next; }
|
||||
}
|
||||
|
||||
void Thread::go() {}
|
||||
void Thread::go() {
|
||||
context_launch(&context);
|
||||
}
|
||||
|
||||
void Thread::action() {}
|
||||
void Thread::action() {
|
||||
while(1);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue