Add Syscall: Exit, PutChar, GetCar, PutString, GetString

This commit is contained in:
Yorick Barbanneau 2021-10-11 22:41:17 +02:00
parent 6f405265a5
commit 80fc250109
15 changed files with 359 additions and 17 deletions

View file

@ -10,6 +10,7 @@
#include "copyright.h"
#include "system.h"
#include "consoledriver.h"
#include "console.h"
#include "addrspace.h"
#include "synch.h"
@ -84,7 +85,7 @@ void
ConsoleTest (const char *in, const char *out)
{
char ch;
printf("test console\n<");
readAvail = new Semaphore ("read avail", 0);
writeDone = new Semaphore ("write done", 0);
console = new Console (in, out, ReadAvailHandler, WriteDoneHandler, NULL);
@ -93,14 +94,44 @@ ConsoleTest (const char *in, const char *out)
{
readAvail->P (); // wait for character to arrive
ch = console->RX ();
#ifdef CHANGED
// My modifications...
// Check input before display it...
if (ch == 'q' || ch == -1 ) {
printf ("au revoir!\n");
break; // if q, quit
}
console->TX ('<');
writeDone->P ();
console->TX (ch); // echo it!
writeDone->P (); // wait for write to finish
console->TX ('>');
writeDone->P ();
#else
console->TX (ch); // echo it!
writeDone->P (); // wait for write to finish
if (ch == 'q') {
printf ("Nothing more, bye!\n");
break; // if q, quit
}
#endif
}
delete console;
delete readAvail;
delete writeDone;
}
#ifdef CHANGED
void
ConsoleDriverTest (const char *in, const char *out)
{
printf("test consoledriver\n");
char ch;
ConsoleDriver *test_consoledriver = new ConsoleDriver(in, out);
while ((ch = test_consoledriver->GetChar()) != EOF)
test_consoledriver->PutChar(ch);
fprintf(stderr, "EOF detected in ConsoleDriver!\n");
delete test_consoledriver;
}
#endif //CHANGED