Browse Source

Tweak _test.o to use the putch() syscall.

It's still running in kernel space. Once I make it possible for ELFLoader
to set up a ring 3 task, we'll really be cooking!
Andreas Kling 6 years ago
parent
commit
e4afa2a041
7 changed files with 13 additions and 3 deletions
  1. 2 2
      Kernel/Syscall.cpp
  2. 1 0
      Kernel/Syscall.h
  3. 5 0
      Kernel/Userspace.cpp
  4. 1 0
      Kernel/Userspace.h
  5. BIN
      Kernel/_fs_contents
  6. 3 0
      Kernel/_test.cpp
  7. 1 1
      Kernel/init.cpp

+ 2 - 2
Kernel/Syscall.cpp

@@ -51,8 +51,8 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3)
     case Syscall::Yield:
         yield();
         break;
-    case 0x1235: // putch
-        kprintf( "%c", arg1 & 0xFF );
+    case Syscall::PutCharacter:
+        kprintf("%c", arg1 & 0xff);
         break;
     case Syscall::Sleep:
         //kprintf("syscall: sleep(%d)\n", arg1);

+ 1 - 0
Kernel/Syscall.h

@@ -10,6 +10,7 @@ namespace Syscall {
 enum Function {
     Sleep = 0x1982,
     Yield = 0x1983,
+    PutCharacter = 1984,
     PosixOpen = 0x1985,
     PosixClose = 0x1986,
     PosixRead = 0x1987,

+ 5 - 0
Kernel/Userspace.cpp

@@ -52,4 +52,9 @@ void yield()
     DO_SYSCALL_A0(Syscall::Yield);
 }
 
+void putch(char ch)
+{
+    DO_SYSCALL_A1(Syscall::PutCharacter, ch);
+}
+
 }

+ 1 - 0
Kernel/Userspace.h

@@ -12,5 +12,6 @@ int kill(pid_t pid, int sig);
 uid_t getuid();
 void sleep(DWORD ticks);
 void yield();
+void putch(char);
 
 }

BIN
Kernel/_fs_contents


+ 3 - 0
Kernel/_test.cpp

@@ -8,5 +8,8 @@ extern "C" int elf_entry()
     char buf[2048];
     int nread = read(fd, buf, sizeof(buf));
     buf[nread] = '\0';
+    for (int i = 0; i < nread; ++i) {
+        putch(buf[i]);
+    }
     return 0;
 }

+ 1 - 1
Kernel/init.cpp

@@ -170,7 +170,7 @@ static void init_stage2()
 
 #ifdef TEST_ELF_LOADER
     {
-        auto testExecutable = vfs->open("/_hello.o");
+        auto testExecutable = vfs->open("/_test.o");
         ASSERT(testExecutable);
         auto testExecutableData = testExecutable->readEntireFile();
         ASSERT(testExecutableData);