minimal keyboard app
This commit is contained in:
@@ -76,7 +76,7 @@ extern "C" int main() {
|
|||||||
* Therefore activate the LAPIC timer in level 1/2 after initialization
|
* Therefore activate the LAPIC timer in level 1/2 after initialization
|
||||||
* (just before schedule())
|
* (just before schedule())
|
||||||
*/
|
*/
|
||||||
//LAPIC::Timer::activate();
|
LAPIC::Timer::activate();
|
||||||
|
|
||||||
DBG_VERBOSE << "Schedule..." << endl;
|
DBG_VERBOSE << "Schedule..." << endl;
|
||||||
// Schedule first app
|
// Schedule first app
|
||||||
|
|||||||
@@ -9,41 +9,47 @@ extern TextStream kout;
|
|||||||
extern Semaphore koutsem;
|
extern Semaphore koutsem;
|
||||||
|
|
||||||
void KeyboardApplication::action() { // NOLINT
|
void KeyboardApplication::action() { // NOLINT
|
||||||
const unsigned line = 10 + 2;
|
while(1){
|
||||||
for (unsigned column = 0;; ++column) {
|
char msg[11];
|
||||||
Key key;
|
if(read(0, msg, 10))
|
||||||
{
|
write(0, msg, 10);
|
||||||
Guarded g = Guard::enter();
|
|
||||||
g.vault().keys_sem.p(g.vault());
|
|
||||||
assert(g.vault().keys.consume(key) && "No key but sem returned!");
|
|
||||||
}
|
|
||||||
if (key.valid()) {
|
|
||||||
if (column >= CGA::COLUMNS - 1) {
|
|
||||||
column = 0;
|
|
||||||
koutsem.p(Guard::enter().vault());
|
|
||||||
for (unsigned offset = 0; offset < 3; offset++) {
|
|
||||||
for (unsigned column = 0; column < CGA::COLUMNS; ++column) {
|
|
||||||
CGA::show(column, line + offset, ' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
koutsem.v(Guard::enter().vault());
|
|
||||||
}
|
|
||||||
koutsem.p(Guard::enter().vault());
|
|
||||||
kout.setPos(column, line);
|
|
||||||
kout << static_cast<char>(key.ascii());
|
|
||||||
kout.flush();
|
|
||||||
koutsem.v(Guard::enter().vault());
|
|
||||||
}
|
|
||||||
for (unsigned offset = 0; offset < 3; offset++) {
|
|
||||||
{
|
|
||||||
Guarded g = Guard::enter();
|
|
||||||
g.vault().bellringer.sleep(g.vault(), 10);
|
|
||||||
koutsem.p(g.vault());
|
|
||||||
}
|
|
||||||
kout.setPos(column, line + offset);
|
|
||||||
kout << static_cast<char>(key.ascii());
|
|
||||||
kout.flush();
|
|
||||||
koutsem.v(Guard::enter().vault());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//const unsigned line = 10 + 2;
|
||||||
|
//for (unsigned column = 0;; ++column) {
|
||||||
|
// Key key;
|
||||||
|
// {
|
||||||
|
// Guarded g = Guard::enter();
|
||||||
|
// g.vault().keys_sem.p(g.vault());
|
||||||
|
// assert(g.vault().keys.consume(key) && "No key but sem returned!");
|
||||||
|
// }
|
||||||
|
// if (key.valid()) {
|
||||||
|
// if (column >= CGA::COLUMNS - 1) {
|
||||||
|
// column = 0;
|
||||||
|
// koutsem.p(Guard::enter().vault());
|
||||||
|
// for (unsigned offset = 0; offset < 3; offset++) {
|
||||||
|
// for (unsigned column = 0; column < CGA::COLUMNS; ++column) {
|
||||||
|
// CGA::show(column, line + offset, ' ');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// koutsem.v(Guard::enter().vault());
|
||||||
|
// }
|
||||||
|
// koutsem.p(Guard::enter().vault());
|
||||||
|
// kout.setPos(column, line);
|
||||||
|
// kout << static_cast<char>(key.ascii());
|
||||||
|
// kout.flush();
|
||||||
|
// koutsem.v(Guard::enter().vault());
|
||||||
|
// }
|
||||||
|
// for (unsigned offset = 0; offset < 3; offset++) {
|
||||||
|
// {
|
||||||
|
// Guarded g = Guard::enter();
|
||||||
|
// g.vault().bellringer.sleep(g.vault(), 10);
|
||||||
|
// koutsem.p(g.vault());
|
||||||
|
// }
|
||||||
|
// kout.setPos(column, line + offset);
|
||||||
|
// kout << static_cast<char>(key.ascii());
|
||||||
|
// kout.flush();
|
||||||
|
// koutsem.v(Guard::enter().vault());
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user