summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/plan9/amd64/u.h14
-rw-r--r--src/cmd/6l/pass.c6
-rw-r--r--src/pkg/runtime/asm_amd64.s4
-rw-r--r--src/pkg/runtime/defs_plan9_386.h1
-rw-r--r--src/pkg/runtime/defs_plan9_amd64.h3
-rw-r--r--src/pkg/runtime/mem_plan9.c5
-rw-r--r--src/pkg/runtime/os_plan9.h2
-rw-r--r--src/pkg/runtime/rt0_plan9_amd64.s13
-rw-r--r--src/pkg/runtime/signal_plan9_amd64.c19
-rw-r--r--src/pkg/runtime/sys_plan9_amd64.s124
-rw-r--r--src/pkg/syscall/asm_plan9_amd64.s166
-rw-r--r--src/pkg/syscall/syscall_plan9.go2
-rw-r--r--src/pkg/syscall/syscall_plan9_386.go2
-rw-r--r--src/pkg/syscall/syscall_plan9_amd64.go7
-rw-r--r--src/pkg/syscall/zerrors_plan9_amd64.go39
-rw-r--r--src/pkg/syscall/zsyscall_plan9_amd64.go239
-rw-r--r--src/pkg/syscall/zsysnum_plan9_amd64.go47
-rw-r--r--src/pkg/syscall/ztypes_plan9_amd64.go75
18 files changed, 761 insertions, 7 deletions
diff --git a/include/plan9/amd64/u.h b/include/plan9/amd64/u.h
new file mode 100644
index 000000000..f2430b535
--- /dev/null
+++ b/include/plan9/amd64/u.h
@@ -0,0 +1,14 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "/amd64/include/u.h"
+
+typedef char int8;
+typedef uchar uint8;
+typedef short int16;
+typedef ushort uint16;
+typedef int int32;
+typedef uint uint32;
+typedef vlong int64;
+typedef uvlong uint64;
diff --git a/src/cmd/6l/pass.c b/src/cmd/6l/pass.c
index fc89fd8fc..c2d5dc106 100644
--- a/src/cmd/6l/pass.c
+++ b/src/cmd/6l/pass.c
@@ -310,7 +310,8 @@ patch(void)
}
}
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
- || HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd) {
+ || HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd
+ || HEADTYPE == Hplan9x64) {
// ELF uses FS instead of GS.
if(p->from.type == D_INDIR+D_GS)
p->from.type = D_INDIR+D_FS;
@@ -444,7 +445,8 @@ dostkoff(void)
p = appendp(p); // load g into CX
p->as = AMOVQ;
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
- || HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd) // ELF uses FS
+ || HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd
+ || HEADTYPE == Hplan9x64) // ELF uses FS
p->from.type = D_INDIR+D_FS;
else
p->from.type = D_INDIR+D_GS;
diff --git a/src/pkg/runtime/asm_amd64.s b/src/pkg/runtime/asm_amd64.s
index 160c7cc41..08133f02d 100644
--- a/src/pkg/runtime/asm_amd64.s
+++ b/src/pkg/runtime/asm_amd64.s
@@ -31,6 +31,10 @@ TEXT _rt0_amd64(SB),7,$-8
JEQ ok
needtls:
+ // skip TLS setup on Plan 9
+ CMPL runtime·isplan9(SB), $1
+ JEQ ok
+
LEAQ runtime·tls0(SB), DI
CALL runtime·settls(SB)
diff --git a/src/pkg/runtime/defs_plan9_386.h b/src/pkg/runtime/defs_plan9_386.h
index 58fd9d94d..3874ad256 100644
--- a/src/pkg/runtime/defs_plan9_386.h
+++ b/src/pkg/runtime/defs_plan9_386.h
@@ -1,2 +1,3 @@
// nothing to see here
#define tos_pid 48
+#define PAGESIZE 0x1000
diff --git a/src/pkg/runtime/defs_plan9_amd64.h b/src/pkg/runtime/defs_plan9_amd64.h
new file mode 100644
index 000000000..8c324ea58
--- /dev/null
+++ b/src/pkg/runtime/defs_plan9_amd64.h
@@ -0,0 +1,3 @@
+// nothing to see here
+#define tos_pid 64
+#define PAGESIZE 0x200000ULL
diff --git a/src/pkg/runtime/mem_plan9.c b/src/pkg/runtime/mem_plan9.c
index 15cbc176b..26ca367f1 100644
--- a/src/pkg/runtime/mem_plan9.c
+++ b/src/pkg/runtime/mem_plan9.c
@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
#include "runtime.h"
+#include "defs_GOOS_GOARCH.h"
#include "arch_GOARCH.h"
#include "malloc.h"
#include "os_GOOS.h"
@@ -13,14 +14,14 @@ static Lock memlock;
enum
{
- Round = 4095
+ Round = PAGESIZE-1
};
void*
runtime·SysAlloc(uintptr nbytes)
{
uintptr bl;
-
+
runtime·lock(&memlock);
mstats.sys += nbytes;
// Plan 9 sbrk from /sys/src/libc/9sys/sbrk.c
diff --git a/src/pkg/runtime/os_plan9.h b/src/pkg/runtime/os_plan9.h
index 6f1f0bb8e..ce746b3f3 100644
--- a/src/pkg/runtime/os_plan9.h
+++ b/src/pkg/runtime/os_plan9.h
@@ -9,7 +9,7 @@ int32 runtime·pwrite(int32 fd, void *buf, int32 nbytes, int64 offset);
int32 runtime·read(int32 fd, void *buf, int32 nbytes);
int32 runtime·close(int32 fd);
void runtime·exits(int8* msg);
-int32 runtime·brk_(void*);
+intptr runtime·brk_(void*);
int32 runtime·sleep(int32 ms);
int32 runtime·rfork(int32 flags, void *stk, M *m, G *g, void (*fn)(void));
int32 runtime·plan9_semacquire(uint32 *addr, int32 block);
diff --git a/src/pkg/runtime/rt0_plan9_amd64.s b/src/pkg/runtime/rt0_plan9_amd64.s
new file mode 100644
index 000000000..499413a83
--- /dev/null
+++ b/src/pkg/runtime/rt0_plan9_amd64.s
@@ -0,0 +1,13 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+TEXT _rt0_amd64_plan9(SB),7, $0
+ MOVQ AX, _tos(SB)
+ MOVQ $_rt0_amd64(SB), AX
+ MOVQ SP, DI
+ JMP AX
+
+DATA runtime·isplan9(SB)/4, $1
+GLOBL runtime·isplan9(SB), $4
+GLOBL _tos(SB), $8
diff --git a/src/pkg/runtime/signal_plan9_amd64.c b/src/pkg/runtime/signal_plan9_amd64.c
new file mode 100644
index 000000000..d26688516
--- /dev/null
+++ b/src/pkg/runtime/signal_plan9_amd64.c
@@ -0,0 +1,19 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "runtime.h"
+
+void
+runtime·sigenable(uint32 sig)
+{
+ USED(sig);
+}
+
+void
+runtime·resetcpuprofiler(int32 hz)
+{
+ // TODO: Enable profiling interrupts.
+
+ m->profilehz = hz;
+}
diff --git a/src/pkg/runtime/sys_plan9_amd64.s b/src/pkg/runtime/sys_plan9_amd64.s
new file mode 100644
index 000000000..cc343d170
--- /dev/null
+++ b/src/pkg/runtime/sys_plan9_amd64.s
@@ -0,0 +1,124 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "defs_GOOS_GOARCH.h"
+#include "zasm_GOOS_GOARCH.h"
+
+// setldt(int entry, int address, int limit)
+TEXT runtime·setldt(SB),7,$0
+ RET
+
+TEXT runtime·open(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $14, BP
+ SYSCALL
+ RET
+
+TEXT runtime·pread(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $50, BP
+ SYSCALL
+ RET
+
+TEXT runtime·pwrite(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $51, BP
+ SYSCALL
+ RET
+
+TEXT runtime·close(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $4, BP
+ SYSCALL
+ RET
+
+TEXT runtime·exits(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $8, BP
+ SYSCALL
+ RET
+
+TEXT runtime·brk_(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $24, BP
+ SYSCALL
+ RET
+
+TEXT runtime·sleep(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $17, BP
+ SYSCALL
+ RET
+
+TEXT runtime·plan9_semacquire(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $37, BP
+ SYSCALL
+ RET
+
+TEXT runtime·plan9_tsemacquire(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $52, BP
+ SYSCALL
+ RET
+
+TEXT runtime·notify(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $28, BP
+ SYSCALL
+ RET
+
+TEXT runtime·noted(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $29, BP
+ SYSCALL
+ RET
+
+TEXT runtime·plan9_semrelease(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $38, BP
+ SYSCALL
+ RET
+
+TEXT runtime·rfork(SB),7,$0
+ MOVQ $0x8000, AX
+ MOVQ $19, BP // rfork
+ SYSCALL
+
+ // In parent, return.
+ CMPQ AX, $0
+ JEQ 2(PC)
+ RET
+
+ // In child on forked stack.
+ MOVQ mm+24(SP), BX // m
+ MOVQ gg+32(SP), DX // g
+ MOVQ fn+40(SP), SI // fn
+
+ // set SP to be on the new child stack
+ MOVQ stack+16(SP), CX
+ MOVQ CX, SP
+
+ // Initialize m, g.
+ get_tls(AX)
+ MOVQ DX, g(AX)
+ MOVQ BX, m(AX)
+
+ // Initialize AX from _tos->pid
+ MOVQ _tos(SB), AX
+ MOVQ tos_pid(AX), AX
+ MOVQ AX, m_procid(BX) // save pid as m->procid
+
+ CALL runtime·stackcheck(SB) // smashes AX, CX
+
+ MOVQ 0(DX), DX // paranoia; check they are not nil
+ MOVQ 0(BX), BX
+
+ CALL SI // fn()
+ CALL runtime·exit(SB)
+ RET
+
+// This is needed by asm_amd64.s
+TEXT runtime·settls(SB),7,$0
+ RET
diff --git a/src/pkg/syscall/asm_plan9_amd64.s b/src/pkg/syscall/asm_plan9_amd64.s
new file mode 100644
index 000000000..c0469760d
--- /dev/null
+++ b/src/pkg/syscall/asm_plan9_amd64.s
@@ -0,0 +1,166 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//
+// System call support for Plan 9
+//
+
+//func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err string)
+//func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err string)
+//func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
+//func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
+
+// Trap # in BP, args on stack above caller pc.
+// NxM requires that Plan 9 system calls be
+// marked with $0x8000 in AX.
+TEXT ·Syscall(SB),7,$0
+ CALL runtime·entersyscall(SB)
+ MOVQ $0x8000, AX // for NxM
+ MOVQ 8(SP), BP // syscall entry
+ // slide args down on top of system call number
+ LEAQ 16(SP), SI
+ LEAQ 8(SP), DI
+ CLD
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ SYSCALL
+ MOVQ AX, r1+40(SP)
+ MOVQ $0, r2+48(SP)
+ CMPQ AX, $-1
+ JNE ok3
+
+ SUBQ $16, SP
+ CALL syscall·errstr(SB)
+ MOVQ SP, SI
+ ADDQ $16, SP
+ JMP copyresult3
+
+ok3:
+ LEAQ runtime·emptystring(SB), SI
+
+copyresult3:
+ LEAQ err+56(SP), DI
+
+ CLD
+ MOVSQ
+ MOVSQ
+
+ CALL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·Syscall6(SB),7,$0
+ CALL runtime·entersyscall(SB)
+ MOVQ $0x8000, AX // for NxM
+ MOVQ 8(SP), BP // syscall entry
+ // slide args down on top of system call number
+ LEAQ 16(SP), SI
+ LEAQ 8(SP), DI
+ CLD
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ SYSCALL
+ MOVQ AX, r1+64(SP)
+ MOVQ $0, r2+72(SP)
+ CMPQ AX, $-1
+ JNE ok4
+
+ SUBQ $16, SP
+ CALL syscall·errstr(SB)
+ MOVQ SP, SI
+ ADDQ $16, SP
+ JMP copyresult4
+
+ok4:
+ LEAQ runtime·emptystring(SB), SI
+
+copyresult4:
+ LEAQ err+80(SP), DI
+
+ CLD
+ MOVSL
+ MOVSL
+
+ CALL runtime·exitsyscall(SB)
+ RET
+
+TEXT ·RawSyscall(SB),7,$0
+ MOVQ $0x8000, AX // for NxM
+ MOVQ 8(SP), BP // syscall entry
+ // slide args down on top of system call number
+ LEAQ 16(SP), SI
+ LEAQ 8(SP), DI
+ CLD
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ SYSCALL
+ MOVQ AX, r1+40(SP)
+ MOVQ AX, r2+48(SP)
+ MOVQ AX, err+56(SP)
+ RET
+
+TEXT ·RawSyscall6(SB),7,$0
+ MOVQ $0x8000, AX // for NxM
+ MOVQ 8(SP), BP // syscall entry
+ // slide args down on top of system call number
+ LEAQ 16(SP), SI
+ LEAQ 8(SP), DI
+ CLD
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ MOVSQ
+ SYSCALL
+ MOVQ AX, r1+64(SP)
+ MOVQ AX, r2+72(SP)
+ MOVQ AX, err+80(SP)
+ RET
+
+#define SYS_SEEK 39 /* from zsysnum_plan9_amd64.go */
+
+//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
+TEXT ·seek(SB),7,$0
+ LEAQ newoffset+48(SP), AX
+ MOVQ AX, placeholder+8(SP)
+
+ MOVQ $0x8000, AX // for NxM
+ MOVQ $SYS_SEEK, BP // syscall entry
+ SYSCALL
+
+ CMPQ AX, $-1
+ JNE ok6
+ MOVQ AX, 48(SP) // newoffset low
+ MOVQ AX, 56(SP) // newoffset high
+
+ SUBQ $16, SP
+ CALL syscall·errstr(SB)
+ MOVQ SP, SI
+ ADDQ $16, SP
+ JMP copyresult6
+
+ok6:
+ LEAQ runtime·emptystring(SB), SI
+
+copyresult6:
+ LEAQ err+64(SP), DI
+
+ CLD
+ MOVSQ
+ MOVSQ
+ RET
+
+//func exit(code int)
+// Import runtime·exit for cleanly exiting.
+TEXT ·exit(SB),7,$8
+ MOVQ code+0(FP), AX
+ MOVQ AX, 0(SP)
+ CALL runtime·exit(SB)
+ RET
diff --git a/src/pkg/syscall/syscall_plan9.go b/src/pkg/syscall/syscall_plan9.go
index d81f9302d..3657f7c15 100644
--- a/src/pkg/syscall/syscall_plan9.go
+++ b/src/pkg/syscall/syscall_plan9.go
@@ -77,8 +77,6 @@ func errstr() string {
return cstring(buf[:])
}
-func Getpagesize() int { return 4096 }
-
// Implemented in assembly to import from runtime.
func exit(int)
diff --git a/src/pkg/syscall/syscall_plan9_386.go b/src/pkg/syscall/syscall_plan9_386.go
index e82b540b4..4e4c7511e 100644
--- a/src/pkg/syscall/syscall_plan9_386.go
+++ b/src/pkg/syscall/syscall_plan9_386.go
@@ -3,3 +3,5 @@
// license that can be found in the LICENSE file.
package syscall
+
+func Getpagesize() int { return 0x1000 }
diff --git a/src/pkg/syscall/syscall_plan9_amd64.go b/src/pkg/syscall/syscall_plan9_amd64.go
new file mode 100644
index 000000000..6f752f213
--- /dev/null
+++ b/src/pkg/syscall/syscall_plan9_amd64.go
@@ -0,0 +1,7 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func Getpagesize() int { return 0x200000 }
diff --git a/src/pkg/syscall/zerrors_plan9_amd64.go b/src/pkg/syscall/zerrors_plan9_amd64.go
new file mode 100644
index 000000000..3d62508d3
--- /dev/null
+++ b/src/pkg/syscall/zerrors_plan9_amd64.go
@@ -0,0 +1,39 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+import "errors"
+
+// Constants
+const (
+ // Invented values to support what package os expects.
+ O_CREAT = 0x02000
+ O_APPEND = 0x00400
+ O_NOCTTY = 0x00000
+ O_NONBLOCK = 0x00000
+ O_SYNC = 0x00000
+ O_ASYNC = 0x00000
+
+ S_IFMT = 0x1f000
+ S_IFIFO = 0x1000
+ S_IFCHR = 0x2000
+ S_IFDIR = 0x4000
+ S_IFBLK = 0x6000
+ S_IFREG = 0x8000
+ S_IFLNK = 0xa000
+ S_IFSOCK = 0xc000
+)
+
+// Errors
+var (
+ EINVAL = errors.New("bad arg in system call")
+ ENOTDIR = errors.New("not a directory")
+ ENOENT = errors.New("file does not exist")
+ EEXIST = errors.New("file already exists")
+ EIO = errors.New("i/o error")
+ ENAMETOOLONG = errors.New("file name too long")
+ EPERM = errors.New("permission denied")
+ EPLAN9 = errors.New("not supported by plan 9")
+)
diff --git a/src/pkg/syscall/zsyscall_plan9_amd64.go b/src/pkg/syscall/zsyscall_plan9_amd64.go
new file mode 100644
index 000000000..913c28fa2
--- /dev/null
+++ b/src/pkg/syscall/zsyscall_plan9_amd64.go
@@ -0,0 +1,239 @@
+// mksyscall.pl -l32 -plan9 syscall_plan9.go syscall_plan9_386.go
+// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
+
+package syscall
+
+import "unsafe"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func exits(msg *byte) {
+ Syscall(SYS_EXITS, uintptr(unsafe.Pointer(msg)), 0, 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fd2path(fd int, buf []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_FD2PATH, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func pipe(p *[2]_C_int) (err error) {
+ r0, _, e1 := Syscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func await(s []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(s) > 0 {
+ _p0 = unsafe.Pointer(&s[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_AWAIT, uintptr(_p0), uintptr(len(s)), 0)
+ n = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup(oldfd int, newfd int) (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), uintptr(newfd), 0)
+ fd = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Open(path string, mode int) (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), 0)
+ fd = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Create(path string, mode int, perm uint32) (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_CREATE, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(mode), uintptr(perm))
+ fd = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Remove(path string) (err error) {
+ r0, _, e1 := Syscall(SYS_REMOVE, uintptr(unsafe.Pointer(StringBytePtr(path))), 0, 0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ n = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ n = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Close(fd int) (err error) {
+ r0, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chdir(path string) (err error) {
+ r0, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(StringBytePtr(path))), 0, 0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Bind(name string, old string, flag int) (err error) {
+ r0, _, e1 := Syscall(SYS_BIND, uintptr(unsafe.Pointer(StringBytePtr(name))), uintptr(unsafe.Pointer(StringBytePtr(old))), uintptr(flag))
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mount(fd int, afd int, old string, flag int, aname string) (err error) {
+ r0, _, e1 := Syscall6(SYS_MOUNT, uintptr(fd), uintptr(afd), uintptr(unsafe.Pointer(StringBytePtr(old))), uintptr(flag), uintptr(unsafe.Pointer(StringBytePtr(aname))), 0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, edir []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(edir) > 0 {
+ _p0 = unsafe.Pointer(&edir[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(_p0), uintptr(len(edir)))
+ n = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, edir []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(edir) > 0 {
+ _p0 = unsafe.Pointer(&edir[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
+ n = int(r0)
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Wstat(path string, edir []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(edir) > 0 {
+ _p0 = unsafe.Pointer(&edir[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_WSTAT, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(_p0), uintptr(len(edir)))
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fwstat(fd int, edir []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(edir) > 0 {
+ _p0 = unsafe.Pointer(&edir[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_FWSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
+ if int(r0) == -1 {
+ err = e1
+ }
+ return
+}
diff --git a/src/pkg/syscall/zsysnum_plan9_amd64.go b/src/pkg/syscall/zsysnum_plan9_amd64.go
new file mode 100644
index 000000000..4135b8d81
--- /dev/null
+++ b/src/pkg/syscall/zsysnum_plan9_amd64.go
@@ -0,0 +1,47 @@
+// mksysnum_plan9.sh /media/sys/src/libc/9syscall/sys.h
+// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
+
+package syscall
+
+const (
+ SYS_SYSR1 = 0
+ SYS_BIND = 2
+ SYS_CHDIR = 3
+ SYS_CLOSE = 4
+ SYS_DUP = 5
+ SYS_ALARM = 6
+ SYS_EXEC = 7
+ SYS_EXITS = 8
+ SYS_FAUTH = 10
+ SYS_SEGBRK = 12
+ SYS_OPEN = 14
+ SYS_OSEEK = 16
+ SYS_SLEEP = 17
+ SYS_RFORK = 19
+ SYS_PIPE = 21
+ SYS_CREATE = 22
+ SYS_FD2PATH = 23
+ SYS_BRK_ = 24
+ SYS_REMOVE = 25
+ SYS_NOTIFY = 28
+ SYS_NOTED = 29
+ SYS_SEGATTACH = 30
+ SYS_SEGDETACH = 31
+ SYS_SEGFREE = 32
+ SYS_SEGFLUSH = 33
+ SYS_RENDEZVOUS = 34
+ SYS_UNMOUNT = 35
+ SYS_SEMACQUIRE = 37
+ SYS_SEMRELEASE = 38
+ SYS_SEEK = 39
+ SYS_FVERSION = 40
+ SYS_ERRSTR = 41
+ SYS_STAT = 42
+ SYS_FSTAT = 43
+ SYS_WSTAT = 44
+ SYS_FWSTAT = 45
+ SYS_MOUNT = 46
+ SYS_AWAIT = 47
+ SYS_PREAD = 50
+ SYS_PWRITE = 51
+)
diff --git a/src/pkg/syscall/ztypes_plan9_amd64.go b/src/pkg/syscall/ztypes_plan9_amd64.go
new file mode 100644
index 000000000..3e3a8d1f3
--- /dev/null
+++ b/src/pkg/syscall/ztypes_plan9_amd64.go
@@ -0,0 +1,75 @@
+// godefs -gsyscall -f -m32 types_plan9.c
+
+// MACHINE GENERATED - DO NOT EDIT.
+
+package syscall
+
+// Constants
+const (
+ O_RDONLY = 0
+ O_WRONLY = 0x1
+ O_RDWR = 0x2
+ O_TRUNC = 0x10
+ O_CLOEXEC = 0x20
+ O_EXCL = 0x1000
+ STATMAX = 0xffff
+ ERRMAX = 0x80
+ MORDER = 0x3
+ MREPL = 0
+ MBEFORE = 0x1
+ MAFTER = 0x2
+ MCREATE = 0x4
+ MCACHE = 0x10
+ MMASK = 0x17
+ RFNAMEG = 0x1
+ RFENVG = 0x2
+ RFFDG = 0x4
+ RFNOTEG = 0x8
+ RFPROC = 0x10
+ RFMEM = 0x20
+ RFNOWAIT = 0x40
+ RFCNAMEG = 0x400
+ RFCENVG = 0x800
+ RFCFDG = 0x1000
+ RFREND = 0x2000
+ RFNOMNT = 0x4000
+ QTDIR = 0x80
+ QTAPPEND = 0x40
+ QTEXCL = 0x20
+ QTMOUNT = 0x10
+ QTAUTH = 0x8
+ QTTMP = 0x4
+ QTFILE = 0
+ DMDIR = 0x80000000
+ DMAPPEND = 0x40000000
+ DMEXCL = 0x20000000
+ DMMOUNT = 0x10000000
+ DMAUTH = 0x8000000
+ DMTMP = 0x4000000
+ DMREAD = 0x4
+ DMWRITE = 0x2
+ DMEXEC = 0x1
+ STATFIXLEN = 0x31
+)
+
+// Types
+
+type _C_int int32
+
+type Prof struct {
+ Pp *[0]byte /* sPlink */
+ Next *[0]byte /* sPlink */
+ Last *[0]byte /* sPlink */
+ First *[0]byte /* sPlink */
+ Pid uint32
+ What uint32
+}
+
+type Tos struct {
+ Prof Prof
+ Cyclefreq uint64
+ Kcycles int64
+ Pcycles int64
+ Pid uint32
+ Clock uint32
+}