浏览代码

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 年之前
父节点
当前提交
e4afa2a041
共有 7 个文件被更改,包括 13 次插入3 次删除
  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. 二进制
      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:
     case Syscall::Yield:
         yield();
         yield();
         break;
         break;
-    case 0x1235: // putch
-        kprintf( "%c", arg1 & 0xFF );
+    case Syscall::PutCharacter:
+        kprintf("%c", arg1 & 0xff);
         break;
         break;
     case Syscall::Sleep:
     case Syscall::Sleep:
         //kprintf("syscall: sleep(%d)\n", arg1);
         //kprintf("syscall: sleep(%d)\n", arg1);

+ 1 - 0
Kernel/Syscall.h

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

+ 5 - 0
Kernel/Userspace.cpp

@@ -52,4 +52,9 @@ void yield()
     DO_SYSCALL_A0(Syscall::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();
 uid_t getuid();
 void sleep(DWORD ticks);
 void sleep(DWORD ticks);
 void yield();
 void yield();
+void putch(char);
 
 
 }
 }

二进制
Kernel/_fs_contents


+ 3 - 0
Kernel/_test.cpp

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

+ 1 - 1
Kernel/init.cpp

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