Browse Source

Renumber harvey system call numbers

Create a new struct member, SyscallBase, in sysconf.

This is a base from which to offset Harvey system calls.

In mksys.go, add sysconf.SyscallBase to the harvey system call numbers.

This allows us to easily define a base from which to offset Harvey
system calls.

The next step is to add a Plan9SystemCall element to sysconf.json,
then generate those system calls, then add the handler in the
kernel, which should be a pretty simple shim. It's been done
before for NxM, in the opposite direction, when we did Linux
system call emulation, so the code to switch out on system
call number and so on exists.

I'd suggest adding back Plan 9 binary support by, first, translating
plan 9 a.out format to ELF, then running it; that's likely easier than
putting plan 9 a.out format support back in the kernel (Plan 9 a.out
for amd64 was a terrible hack and no Plan 9 a.out was ever defined for
RISCV anyway).

As jmk used to say, "Plan 9 is a 32-bit system." That's true. Harvey
is much closer to being a 64-bit system then Plan 9 ever was, there's
not reason to bring back Plan 9 a.out format.

Signed-off-by: Ronald Minnich <rminnich@gmail.com>
Ronald Minnich 3 years ago
parent
commit
839f2c9424
2 changed files with 8 additions and 0 deletions
  1. 1 0
      sys/src/sysconf.json
  2. 7 0
      util/src/harvey/cmd/mksys/mksys.go

+ 1 - 0
sys/src/sysconf.json

@@ -19,6 +19,7 @@
 			"Name": "local"
 		}
 	],
+	"SyscallBase": 1024,
 	"Syscalls": [
 		{
 			"Id": 0,

+ 7 - 0
util/src/harvey/cmd/mksys/mksys.go

@@ -69,6 +69,7 @@ type Bootmethods struct {
 }
 
 type Sysconf struct {
+	SyscallBase uint32
 	Syscalls    []Syscall
 	Syserrors   []Syserror
 	Bootmethods []Bootmethods
@@ -116,6 +117,11 @@ func main() {
 	syscalls := sysconf.Syscalls
 	syserrors := sysconf.Syserrors
 	bootmethods := sysconf.Bootmethods
+	// Adjust the syscall # for Harvey system calls to 1024 + number
+	// The plan is that we can then bring in a plan 9 system call interface
+	// and easily run native Plan 9 binaries, including Plan 9 Go binaries.
+	// This is a bit of a hack but OTOH it makes for a pretty easy change.
+	// Boot tested.
 	for i := range syscalls {
 		if syscalls[i].Define == "" {
 			syscalls[i].Define = strings.ToUpper(syscalls[i].Name)
@@ -126,6 +132,7 @@ func main() {
 		if syscalls[i].Libname == "" {
 			syscalls[i].Libname = syscalls[i].Name
 		}
+		syscalls[i].Id += sysconf.SyscallBase
 	}
 
 	switch *mode {