Skip to content

Commit

Permalink
syscall: add support for openbsd/ppc64
Browse files Browse the repository at this point in the history
Add syscall support for the openbsd/ppc64 port.

Updates #56001

Change-Id: I695c5c296e90645515de0c8f89f1bc57e976679d
Reviewed-on: https://go-review.googlesource.com/c/go/+/475636
Reviewed-by: Eric Grosse <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
4a6f656c committed Aug 22, 2023
1 parent c140105 commit e7e99a8
Show file tree
Hide file tree
Showing 10 changed files with 4,784 additions and 36 deletions.
32 changes: 32 additions & 0 deletions src/syscall/asm_openbsd_ppc64.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2023 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 "textflag.h"

//
// System call support for PPC64, OpenBSD
//

// Provide these function names via assembly so they are provided as ABI0,
// rather than ABIInternal.

// func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
TEXT ·Syscall(SB),NOSPLIT,$0-56
JMP ·syscallInternal(SB)

// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
TEXT ·Syscall6(SB),NOSPLIT,$0-80
JMP ·syscall6Internal(SB)

// func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
JMP ·rawSyscallInternal(SB)

// func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
JMP ·rawSyscall6Internal(SB)

// func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
TEXT ·Syscall9(SB),NOSPLIT,$0-104
JMP ·syscall9Internal(SB)
12 changes: 12 additions & 0 deletions src/syscall/mkall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ openbsd_mips64)
# API consistent between platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
;;
openbsd_ppc64)
GOOSARCH_in="syscall_openbsd_libc.go syscall_openbsd_$GOARCH.go"
mkerrors="$mkerrors -m64"
mksyscall="./mksyscall.pl -openbsd -libc"
mksysctl="./mksysctl_openbsd.pl"
zsysctl="zsysctl_openbsd.go"
mksysnum="curl -s 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
# Let the type of C char be signed to make the bare syscall
# API consistent between platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
mkasm="go run mkasm.go"
;;
plan9_386)
mkerrors=
mksyscall="./mksyscall.pl -l32 -plan9"
Expand Down
7 changes: 6 additions & 1 deletion src/syscall/mkasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ func main() {
if !trampolines[fn] {
trampolines[fn] = true
fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn)
fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
if goos == "openbsd" && arch == "ppc64" {
fmt.Fprintf(&out, "\tCALL\t%s(SB)\n", fn)
fmt.Fprintf(&out, "\tRET\n")
} else {
fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
}
}
}
err = os.WriteFile(fmt.Sprintf("zsyscall_%s_%s.s", goos, arch), out.Bytes(), 0644)
Expand Down
38 changes: 38 additions & 0 deletions src/syscall/syscall_openbsd_ppc64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2023 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 setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
}

func setTimeval(sec, usec int64) Timeval {
return Timeval{Sec: sec, Usec: usec}
}

func SetKevent(k *Kevent_t, fd, mode, flags int) {
k.Ident = uint64(fd)
k.Filter = int16(mode)
k.Flags = uint16(flags)
}

func (iov *Iovec) SetLen(length int) {
iov.Len = uint64(length)
}

func (msghdr *Msghdr) SetControllen(length int) {
msghdr.Controllen = uint32(length)
}

func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}

// RTM_LOCK only exists in OpenBSD 6.3 and earlier.
const RTM_LOCK = 0x8

// SYS___SYSCTL only exists in OpenBSD 5.8 and earlier, when it was
// was renamed to SYS_SYSCTL.
const SYS___SYSCTL = SYS_SYSCTL
Loading

0 comments on commit e7e99a8

Please sign in to comment.