You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
3.3 KiB
C++
155 lines
3.3 KiB
C++
#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;
|
|
|
|
#define APP_NUM 7
|
|
|
|
uint8_t app_stack[1024][APP_NUM];
|
|
Application application[APP_NUM];
|
|
|
|
application[0] = Application(&app_stack[sizeof(app_stack[0])-1]);
|
|
|
|
|
|
// 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);
|
|
}
|
|
|
|
LAPIC::Timer::setup(1000000);
|
|
|
|
ApplicationProcessor::boot();
|
|
|
|
PS2Controller::init();
|
|
|
|
IOAPIC::init();
|
|
IOAPIC::config(1, Core::Interrupt::KEYBOARD);
|
|
IOAPIC::allow(1);
|
|
|
|
Core::Interrupt::enable();
|
|
|
|
LAPIC::Timer::activate();
|
|
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;
|
|
}
|