summaryrefslogtreecommitdiff
path: root/elksemu
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1997-02-25 20:42:19 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:38:07 +0200
commit4c36e9a0c125ccfff37aa440dab2cf58c4152fff (patch)
treea5d9c84ba2661029ddb2223dacd50529a361c3d5 /elksemu
parentf8de35da65c5d93bb733073cf40da154bc1c0748 (diff)
parent9696d7b0e1f3a1b0f5fd4a0428eb75afe8ad4ed6 (diff)
downloaddev86-4c36e9a0c125ccfff37aa440dab2cf58c4152fff.tar.gz
Import Dev86src-0.0.11.tar.gzv0.0.11
Diffstat (limited to 'elksemu')
-rw-r--r--elksemu/Makefile6
-rw-r--r--elksemu/elks.c5
-rw-r--r--elksemu/minix.c72
3 files changed, 79 insertions, 4 deletions
diff --git a/elksemu/Makefile b/elksemu/Makefile
index b2b34e8..5964353 100644
--- a/elksemu/Makefile
+++ b/elksemu/Makefile
@@ -4,7 +4,7 @@
ifeq ($(CC),bcc)
# Use BCC to make a tiny static a.out version.
-CFLAGS=-O -3 -N -ansi
+CFLAGS=-O -3 -N -ansi -s
else
# For gcc with the default compiler
CFLAGS=-O2 -fno-strength-reduce -Wall -idirafter . $(DEFS)
@@ -13,7 +13,7 @@ endif
# For gcc making a.out with a basically ELF compiler
# CFLAGS=-O2 -fno-strength-reduce -b i486-linuxaout -N -s -static
-OBJ=elks.o elks_sys.o elks_signal.o
+OBJ=elks.o elks_sys.o elks_signal.o minix.o
elksemu: $(OBJ)
$(CC) $(CFLAGS) -o elksemu $(OBJ)
@@ -32,7 +32,7 @@ install: elksemu
install -d $(DIST)/lib
install -s -o root -g root -m 4555 elksemu $(DIST)/lib/elksemu
-clean:
+clean realclean:
rm -f $(OBJ) elksemu call_tab.v defn_tab.v
module: binfmt_elks.o
diff --git a/elksemu/elks.c b/elksemu/elks.c
index 8cdcb14..2c58f8e 100644
--- a/elksemu/elks.c
+++ b/elksemu/elks.c
@@ -40,6 +40,9 @@ static void elks_init()
static void elks_take_interrupt(int arg)
{
+#if 1
+ if(arg==0x20) { minix_syscall(); return; }
+#endif
if(arg!=0x80)
{
dbprintf(("Took an int %d\n", arg));
@@ -48,7 +51,7 @@ static void elks_take_interrupt(int arg)
return;
}
- dbprintf(("syscall AX=%X BX=%X CX=%X DX=%x\n",
+ dbprintf(("syscall AX=%x BX=%x CX=%x DX=%x\n",
(unsigned short)elks_cpu.regs.eax,
(unsigned short)elks_cpu.regs.ebx,
(unsigned short)elks_cpu.regs.ecx,
diff --git a/elksemu/minix.c b/elksemu/minix.c
new file mode 100644
index 0000000..0c0ad67
--- /dev/null
+++ b/elksemu/minix.c
@@ -0,0 +1,72 @@
+
+/*
+ * System calls are mostly pretty easy as the emulator is tightly bound to
+ * the minix task.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/vm86.h>
+#include <sys/times.h>
+#include <utime.h>
+#include <termios.h>
+#include <time.h>
+#include <signal.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <dirent.h>
+#include "elks.h"
+
+#ifdef DEBUG
+#define dbprintf(x) db_printf x
+#else
+#define dbprintf(x)
+#endif
+
+static char * minix_names[] = {
+ "0", "EXIT", "FORK", "READ", "WRITE", "OPEN", "CLOSE", "WAIT",
+ "CREAT", "LINK", "UNLINK", "WAITPID", "CHDIR", "TIME", "MKNOD",
+ "CHMOD", "CHOWN", "BRK", "STAT", "LSEEK", "GETPID", "MOUNT",
+ "UMOUNT", "SETUID", "GETUID", "STIME", "PTRACE", "ALARM", "FSTAT",
+ "PAUSE", "UTIME", "31", "32", "ACCESS", "34", "35", "SYNC", "KILL",
+ "RENAME", "MKDIR", "RMDIR", "DUP", "PIPE", "TIMES", "44", "45",
+ "SETGID", "GETGID", "SIGNAL", "49", "50", "51", "52", "53", "IOCTL",
+ "FCNTL", "56", "57", "58", "EXEC", "UMASK", "CHROOT", "SETSID",
+ "GETPGRP", "KSIG", "UNPAUSE", "66", "REVIVE", "TASK_REPLY", "69",
+ "70", "SIGACTION", "SIGSUSPEND", "SIGPENDING", "SIGPROCMASK",
+ "SIGRETURN", "REBOOT", "77"
+
+ };
+
+void
+minix_syscall()
+{
+ static char *nm[4] = {"?", "send", "receive", "sendrec"};
+ char tsks[10], syss[10];
+
+ int sr = (unsigned short) elks_cpu.regs.ecx;
+ int tsk = (unsigned short) elks_cpu.regs.eax;
+ int sys = ELKS_PEEK(short, (unsigned short) elks_cpu.regs.ebx + 2);
+
+ if (sr < 0 || sr > 3) sr = 0;
+ switch(tsk)
+ {
+ case 0: strcpy(tsks, "MM"); break;
+ case 1: strcpy(tsks, "FS"); break;
+ default: sprintf(tsks, "task(%d)", tsk);
+ }
+ if( sys > 0 && sys < 77 )
+ strcpy(syss, minix_names[sys]);
+ else
+ sprintf(syss, "%d", sys);
+
+ fprintf(stderr, "Minix syscall %s(%s,&{%d,%s,...})\n", nm[sr], tsks, getpid(), syss);
+ exit(99);
+}