Add Syscall: Exit, PutChar, GetCar, PutString, GetString
This commit is contained in:
parent
6f405265a5
commit
80fc250109
15 changed files with 359 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue