|  |  | @ -1,9 +1,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "arch/lapic.h" |  |  |  | #include "arch/lapic.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "boot/startup_ap.h" |  |  |  | #include "boot/startup_ap.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "arch/core_interrupt.h" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "debug/copystream.h" |  |  |  | #include "debug/copystream.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "debug/output.h" |  |  |  | #include "debug/output.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "debug/assert.h" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "arch/cga.h" |  |  |  | #include "arch/cga.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "arch/textwindow.h" |  |  |  | #include "arch/textwindow.h" | 
			
		
	
	
		
		
			
				
					|  |  | @ -11,13 +9,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "device/serialstream.h" |  |  |  | #include "device/serialstream.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "device/textstream.h" |  |  |  | #include "device/textstream.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "device/ps2controller.h" |  |  |  | #include "device/ps2controller.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "arch/ioapic.h" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "user/app1/appl.h" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "sync/ticketlock.h" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "interrupt/guard.h" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | TextStream kout = TextStream(0, 80, 0, 10, true); |  |  |  | TextStream kout = TextStream(0, 80, 0, 10, true); | 
			
		
	
		
		
			
				
					
					|  |  |  | Ticketlock koutlock; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //TextStream dout[8] = {
 |  |  |  | //TextStream dout[8] = {
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //    TextStream(0 ,20,12,25,false), 
 |  |  |  | //    TextStream(0 ,20,12,25,false), 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -29,7 +21,6 @@ Ticketlock koutlock; | 
			
		
	
		
		
			
				
					
					|  |  |  | //    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] = { |  |  |  | TextStream dout[Core::MAX] = { | 
			
		
	
		
		
			
				
					
					|  |  |  |     {0,  40, 10, 14}, |  |  |  |     {0,  40, 10, 14}, | 
			
		
	
		
		
			
				
					
					|  |  |  |     {40, 80, 10, 14}, |  |  |  |     {40, 80, 10, 14}, | 
			
		
	
	
		
		
			
				
					|  |  | @ -63,16 +54,39 @@ OutputStream* copyout[Core::MAX]{ | 
			
		
	
		
		
			
				
					
					|  |  |  |     &dout[7] |  |  |  |     &dout[7] | 
			
		
	
		
		
			
				
					
					|  |  |  | }; |  |  |  | }; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | unsigned int testx, testy; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | // Main function
 |  |  |  | // Main function
 | 
			
		
	
		
		
			
				
					
					|  |  |  | // (the bootstrap processor starts here)}
 |  |  |  | // (the bootstrap processor starts here)}
 | 
			
		
	
		
		
			
				
					
					|  |  |  | extern "C" int main() { |  |  |  | extern "C" int main() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   CGA::setCursor(0, 0); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   unsigned int numCPUs = Core::count(); |  |  |  |   unsigned int numCPUs = Core::count(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl; |  |  |  |   DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   ////test cga implemantation
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  // CGA::setCursor(1, 2);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  // unsigned x,y;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  // CGA::getCursor(x, y);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  // CGA::setCursor(x+1, y+1);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  // for(uint8_t i = 0; i < 10; i++)
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  //   CGA::show(i, i, i+0x30, CGA::Attribute());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   ////test textwindow implemantation
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //TextWindow tw_global = TextWindow(0, 80, 0, 25, true);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //tw_global.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::BLUE, false));
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |    | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //// test SerialStream
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //SerialStream ss = SerialStream();
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.print("test", 4);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.setAttribute(SerialStream::UNDERSCORE);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.print("test", 4);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.setAttribute(SerialStream::RESET);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.setForeground(SerialStream::MAGENTA);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.print("test", 4);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.setBackground(SerialStream::CYAN);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.print("test", 4);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.setPos(10, 10);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.print("test\n", 5);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //ss.setBackground(SerialStream::BLACK);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |    | 
			
		
	
		
		
			
				
					
					|  |  |  |   kout << "Test          <stream result> -> <expected>" << endl; |  |  |  |   kout << "Test          <stream result> -> <expected>" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |   kout << "bool:         " << true << " -> true" << endl; |  |  |  |   kout << "bool:         " << true << " -> true" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |   kout << "zero:         " << 0 << " -> 0" << endl; |  |  |  |   kout << "zero:         " << 0 << " -> 0" << endl; | 
			
		
	
	
		
		
			
				
					|  |  | @ -97,23 +111,12 @@ extern "C" int main() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   ApplicationProcessor::boot(); |  |  |  |   ApplicationProcessor::boot(); | 
			
		
	
		
		
			
				
					
					|  |  |  |    |  |  |  |    | 
			
		
	
		
		
			
				
					
					|  |  |  |   PS2Controller::init(); |  |  |  |   PS2Controller::init(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |   Key key = Key(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   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; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   Application{}.action(); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   while (true){ |  |  |  |   while (true){ | 
			
		
	
		
		
			
				
					
					|  |  |  |       DBG << "pos: " << testx << ", " << testy << endl << flush; |  |  |  |     if (PS2Controller::fetch(key)) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       Core::pause(); |  |  |  |       kout << key.ascii() << flush ; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return 0; |  |  |  |   return 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -121,12 +124,24 @@ extern "C" int main() { | 
			
		
	
		
		
			
				
					
					|  |  |  | extern "C" int main_ap() { |  |  |  | extern "C" int main_ap() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   DBG_VERBOSE << "CPU core " << static_cast<int>(Core::getID()) << " / LAPIC " |  |  |  |   DBG_VERBOSE << "CPU core " << static_cast<int>(Core::getID()) << " / LAPIC " | 
			
		
	
		
		
			
				
					
					|  |  |  |               << static_cast<int>(LAPIC::getID()) << " in main_ap()" << endl; |  |  |  |               << static_cast<int>(LAPIC::getID()) << " in main_ap()" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |   Core::Interrupt::enable(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   DBG << "App CPU " << static_cast<int>(Core::getID()) << endl << flush; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   //assert(Core::getID() != 1);
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   Application{}.action(); |  |  |  |   //TextWindow dout0 = TextWindow(0,20,13,19, false);
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //dout0.reset();
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //dout0.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::RED, false)); 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   ////test Serial
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //Serial s = Serial();
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //s.write('a');
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |    | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //uint8_t from = static_cast<int>(LAPIC::getID()) * 20;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //uint8_t to = from+20;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //dout[LAPIC::getID()] = TextStream(from, to, 0, 6, false);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   DBG << "test\n" << flush; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   DBG << static_cast<int>(LAPIC::getID()) << flush; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   return 0; |  |  |  |   return 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |