http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/spf13/pflag/uint64.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/spf13/pflag/uint64.go b/newtmgr/vendor/github.com/spf13/pflag/uint64.go new file mode 100644 index 0000000..c681885 --- /dev/null +++ b/newtmgr/vendor/github.com/spf13/pflag/uint64.go @@ -0,0 +1,91 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- uint64 Value +type uint64Value uint64 + +func newUint64Value(val uint64, p *uint64) *uint64Value { + *p = val + return (*uint64Value)(p) +} + +func (i *uint64Value) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 64) + *i = uint64Value(v) + return err +} + +func (i *uint64Value) Type() string { + return "uint64" +} + +func (i *uint64Value) String() string { return fmt.Sprintf("%v", *i) } + +func uint64Conv(sval string) (interface{}, error) { + v, err := strconv.ParseUint(sval, 0, 64) + if err != nil { + return 0, err + } + return uint64(v), nil +} + +// GetUint64 return the uint64 value of a flag with the given name +func (f *FlagSet) GetUint64(name string) (uint64, error) { + val, err := f.getFlagType(name, "uint64", uint64Conv) + if err != nil { + return 0, err + } + return val.(uint64), nil +} + +// Uint64Var defines a uint64 flag with specified name, default value, and usage string. +// The argument p points to a uint64 variable in which to store the value of the flag. +func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) { + f.VarP(newUint64Value(value, p), name, "", usage) +} + +// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { + f.VarP(newUint64Value(value, p), name, shorthand, usage) +} + +// Uint64Var defines a uint64 flag with specified name, default value, and usage string. +// The argument p points to a uint64 variable in which to store the value of the flag. +func Uint64Var(p *uint64, name string, value uint64, usage string) { + CommandLine.VarP(newUint64Value(value, p), name, "", usage) +} + +// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash. +func Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { + CommandLine.VarP(newUint64Value(value, p), name, shorthand, usage) +} + +// Uint64 defines a uint64 flag with specified name, default value, and usage string. +// The return value is the address of a uint64 variable that stores the value of the flag. +func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 { + p := new(uint64) + f.Uint64VarP(p, name, "", value, usage) + return p +} + +// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64 { + p := new(uint64) + f.Uint64VarP(p, name, shorthand, value, usage) + return p +} + +// Uint64 defines a uint64 flag with specified name, default value, and usage string. +// The return value is the address of a uint64 variable that stores the value of the flag. +func Uint64(name string, value uint64, usage string) *uint64 { + return CommandLine.Uint64P(name, "", value, usage) +} + +// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash. +func Uint64P(name, shorthand string, value uint64, usage string) *uint64 { + return CommandLine.Uint64P(name, shorthand, value, usage) +}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/spf13/pflag/uint8.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/spf13/pflag/uint8.go b/newtmgr/vendor/github.com/spf13/pflag/uint8.go new file mode 100644 index 0000000..26db418 --- /dev/null +++ b/newtmgr/vendor/github.com/spf13/pflag/uint8.go @@ -0,0 +1,91 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- uint8 Value +type uint8Value uint8 + +func newUint8Value(val uint8, p *uint8) *uint8Value { + *p = val + return (*uint8Value)(p) +} + +func (i *uint8Value) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 8) + *i = uint8Value(v) + return err +} + +func (i *uint8Value) Type() string { + return "uint8" +} + +func (i *uint8Value) String() string { return fmt.Sprintf("%v", *i) } + +func uint8Conv(sval string) (interface{}, error) { + v, err := strconv.ParseUint(sval, 0, 8) + if err != nil { + return 0, err + } + return uint8(v), nil +} + +// GetUint8 return the uint8 value of a flag with the given name +func (f *FlagSet) GetUint8(name string) (uint8, error) { + val, err := f.getFlagType(name, "uint8", uint8Conv) + if err != nil { + return 0, err + } + return val.(uint8), nil +} + +// Uint8Var defines a uint8 flag with specified name, default value, and usage string. +// The argument p points to a uint8 variable in which to store the value of the flag. +func (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string) { + f.VarP(newUint8Value(value, p), name, "", usage) +} + +// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { + f.VarP(newUint8Value(value, p), name, shorthand, usage) +} + +// Uint8Var defines a uint8 flag with specified name, default value, and usage string. +// The argument p points to a uint8 variable in which to store the value of the flag. +func Uint8Var(p *uint8, name string, value uint8, usage string) { + CommandLine.VarP(newUint8Value(value, p), name, "", usage) +} + +// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. +func Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { + CommandLine.VarP(newUint8Value(value, p), name, shorthand, usage) +} + +// Uint8 defines a uint8 flag with specified name, default value, and usage string. +// The return value is the address of a uint8 variable that stores the value of the flag. +func (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8 { + p := new(uint8) + f.Uint8VarP(p, name, "", value, usage) + return p +} + +// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8 { + p := new(uint8) + f.Uint8VarP(p, name, shorthand, value, usage) + return p +} + +// Uint8 defines a uint8 flag with specified name, default value, and usage string. +// The return value is the address of a uint8 variable that stores the value of the flag. +func Uint8(name string, value uint8, usage string) *uint8 { + return CommandLine.Uint8P(name, "", value, usage) +} + +// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. +func Uint8P(name, shorthand string, value uint8, usage string) *uint8 { + return CommandLine.Uint8P(name, shorthand, value, usage) +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/tarm/serial/.travis.yml ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/tarm/serial/.travis.yml b/newtmgr/vendor/github.com/tarm/serial/.travis.yml new file mode 100644 index 0000000..01dad03 --- /dev/null +++ b/newtmgr/vendor/github.com/tarm/serial/.travis.yml @@ -0,0 +1,9 @@ +language: go +go: + - 1.4 + - 1.6 + - tip +env: + - GOOS=linux CGO=1 + - GOOS=linux CGO=0 + - GOOS=windows GOARCH=386 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/tarm/serial/LICENSE ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/tarm/serial/LICENSE b/newtmgr/vendor/github.com/tarm/serial/LICENSE new file mode 100644 index 0000000..6a66aea --- /dev/null +++ b/newtmgr/vendor/github.com/tarm/serial/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/tarm/serial/README.md ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/tarm/serial/README.md b/newtmgr/vendor/github.com/tarm/serial/README.md new file mode 100644 index 0000000..d2fa899 --- /dev/null +++ b/newtmgr/vendor/github.com/tarm/serial/README.md @@ -0,0 +1,82 @@ +[](http://godoc.org/github.com/tarm/serial) +[](https://travis-ci.org/tarm/serial) + +Serial +======== +A Go package to allow you to read and write from the +serial port as a stream of bytes. + +Details +------- +It aims to have the same API on all platforms, including windows. As +an added bonus, the windows package does not use cgo, so you can cross +compile for windows from another platform. + +You can cross compile with + GOOS=windows GOARCH=386 go install github.com/tarm/serial + +Currently there is very little in the way of configurability. You can +set the baud rate. Then you can Read(), Write(), or Close() the +connection. By default Read() will block until at least one byte is +returned. Write is the same. + +Currently all ports are opened with 8 data bits, 1 stop bit, no +parity, no hardware flow control, and no software flow control. This +works fine for many real devices and many faux serial devices +including usb-to-serial converters and bluetooth serial ports. + +You may Read() and Write() simulantiously on the same connection (from +different goroutines). + +Usage +----- +```go +package main + +import ( + "log" + + "github.com/tarm/serial" +) + +func main() { + c := &serial.Config{Name: "COM45", Baud: 115200} + s, err := serial.OpenPort(c) + if err != nil { + log.Fatal(err) + } + + n, err := s.Write([]byte("test")) + if err != nil { + log.Fatal(err) + } + + buf := make([]byte, 128) + n, err = s.Read(buf) + if err != nil { + log.Fatal(err) + } + log.Printf("%q", buf[:n]) +} +``` + +NonBlocking Mode +---------------- +By default the returned Port reads in blocking mode. Which means +`Read()` will block until at least one byte is returned. If that's not +what you want, specify a positive ReadTimeout and the Read() will +timeout returning 0 bytes if no bytes are read. Please note that this +is the total timeout the read operation will wait and not the interval +timeout between two bytes. + +```go + c := &serial.Config{Name: "COM45", Baud: 115200, ReadTimeout: time.Second * 5} + + // In this mode, you will want to suppress error for read + // as 0 bytes return EOF error on Linux / POSIX + n, _ = s.Read(buf) +``` + +Possible Future Work +-------------------- +- better tests (loopback etc) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/tarm/serial/serial.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/tarm/serial/serial.go b/newtmgr/vendor/github.com/tarm/serial/serial.go new file mode 100644 index 0000000..f61ea28 --- /dev/null +++ b/newtmgr/vendor/github.com/tarm/serial/serial.go @@ -0,0 +1,167 @@ +/* +Goserial is a simple go package to allow you to read and write from +the serial port as a stream of bytes. + +It aims to have the same API on all platforms, including windows. As +an added bonus, the windows package does not use cgo, so you can cross +compile for windows from another platform. Unfortunately goinstall +does not currently let you cross compile so you will have to do it +manually: + + GOOS=windows make clean install + +Currently there is very little in the way of configurability. You can +set the baud rate. Then you can Read(), Write(), or Close() the +connection. Read() will block until at least one byte is returned. +Write is the same. There is currently no exposed way to set the +timeouts, though patches are welcome. + +Currently all ports are opened with 8 data bits, 1 stop bit, no +parity, no hardware flow control, and no software flow control. This +works fine for many real devices and many faux serial devices +including usb-to-serial converters and bluetooth serial ports. + +You may Read() and Write() simulantiously on the same connection (from +different goroutines). + +Example usage: + + package main + + import ( + "github.com/tarm/serial" + "log" + ) + + func main() { + c := &serial.Config{Name: "COM5", Baud: 115200} + s, err := serial.OpenPort(c) + if err != nil { + log.Fatal(err) + } + + n, err := s.Write([]byte("test")) + if err != nil { + log.Fatal(err) + } + + buf := make([]byte, 128) + n, err = s.Read(buf) + if err != nil { + log.Fatal(err) + } + log.Print("%q", buf[:n]) + } +*/ +package serial + +import ( + "errors" + "time" +) + +const DefaultSize = 8 // Default value for Config.Size + +type StopBits byte +type Parity byte + +const ( + Stop1 StopBits = 1 + Stop1Half StopBits = 15 + Stop2 StopBits = 2 +) + +const ( + ParityNone Parity = 'N' + ParityOdd Parity = 'O' + ParityEven Parity = 'E' + ParityMark Parity = 'M' // parity bit is always 1 + ParitySpace Parity = 'S' // parity bit is always 0 +) + +// Config contains the information needed to open a serial port. +// +// Currently few options are implemented, but more may be added in the +// future (patches welcome), so it is recommended that you create a +// new config addressing the fields by name rather than by order. +// +// For example: +// +// c0 := &serial.Config{Name: "COM45", Baud: 115200, ReadTimeout: time.Millisecond * 500} +// or +// c1 := new(serial.Config) +// c1.Name = "/dev/tty.usbserial" +// c1.Baud = 115200 +// c1.ReadTimeout = time.Millisecond * 500 +// +type Config struct { + Name string + Baud int + ReadTimeout time.Duration // Total timeout + + // Size is the number of data bits. If 0, DefaultSize is used. + Size byte + + // Parity is the bit to use and defaults to ParityNone (no parity bit). + Parity Parity + + // Number of stop bits to use. Default is 1 (1 stop bit). + StopBits StopBits + + // RTSFlowControl bool + // DTRFlowControl bool + // XONFlowControl bool + + // CRLFTranslate bool +} + +// ErrBadSize is returned if Size is not supported. +var ErrBadSize error = errors.New("unsupported serial data size") + +// ErrBadStopBits is returned if the specified StopBits setting not supported. +var ErrBadStopBits error = errors.New("unsupported stop bit setting") + +// ErrBadParity is returned if the parity is not supported. +var ErrBadParity error = errors.New("unsupported parity setting") + +// OpenPort opens a serial port with the specified configuration +func OpenPort(c *Config) (*Port, error) { + size, par, stop := c.Size, c.Parity, c.StopBits + if size == 0 { + size = DefaultSize + } + if par == 0 { + par = ParityNone + } + if stop == 0 { + stop = Stop1 + } + return openPort(c.Name, c.Baud, size, par, stop, c.ReadTimeout) +} + +// Converts the timeout values for Linux / POSIX systems +func posixTimeoutValues(readTimeout time.Duration) (vmin uint8, vtime uint8) { + const MAXUINT8 = 1<<8 - 1 // 255 + // set blocking / non-blocking read + var minBytesToRead uint8 = 1 + var readTimeoutInDeci int64 + if readTimeout > 0 { + // EOF on zero read + minBytesToRead = 0 + // convert timeout to deciseconds as expected by VTIME + readTimeoutInDeci = (readTimeout.Nanoseconds() / 1e6 / 100) + // capping the timeout + if readTimeoutInDeci < 1 { + // min possible timeout 1 Deciseconds (0.1s) + readTimeoutInDeci = 1 + } else if readTimeoutInDeci > MAXUINT8 { + // max possible timeout is 255 deciseconds (25.5s) + readTimeoutInDeci = MAXUINT8 + } + } + return minBytesToRead, uint8(readTimeoutInDeci) +} + +// func SendBreak() + +// func RegisterBreakHandler(func()) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/tarm/serial/serial_linux.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/tarm/serial/serial_linux.go b/newtmgr/vendor/github.com/tarm/serial/serial_linux.go new file mode 100644 index 0000000..adf18c6 --- /dev/null +++ b/newtmgr/vendor/github.com/tarm/serial/serial_linux.go @@ -0,0 +1,157 @@ +// +build linux,!cgo + +package serial + +import ( + "os" + "syscall" + "time" + "unsafe" +) + +func openPort(name string, baud int, databits byte, parity Parity, stopbits StopBits, readTimeout time.Duration) (p *Port, err error) { + var bauds = map[int]uint32{ + 50: syscall.B50, + 75: syscall.B75, + 110: syscall.B110, + 134: syscall.B134, + 150: syscall.B150, + 200: syscall.B200, + 300: syscall.B300, + 600: syscall.B600, + 1200: syscall.B1200, + 1800: syscall.B1800, + 2400: syscall.B2400, + 4800: syscall.B4800, + 9600: syscall.B9600, + 19200: syscall.B19200, + 38400: syscall.B38400, + 57600: syscall.B57600, + 115200: syscall.B115200, + 230400: syscall.B230400, + 460800: syscall.B460800, + 500000: syscall.B500000, + 576000: syscall.B576000, + 921600: syscall.B921600, + 1000000: syscall.B1000000, + 1152000: syscall.B1152000, + 1500000: syscall.B1500000, + 2000000: syscall.B2000000, + 2500000: syscall.B2500000, + 3000000: syscall.B3000000, + 3500000: syscall.B3500000, + 4000000: syscall.B4000000, + } + + rate := bauds[baud] + + if rate == 0 { + return + } + + f, err := os.OpenFile(name, syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_NONBLOCK, 0666) + if err != nil { + return nil, err + } + + defer func() { + if err != nil && f != nil { + f.Close() + } + }() + + // Base settings + cflagToUse := syscall.CREAD | syscall.CLOCAL | rate + switch databits { + case 5: + cflagToUse |= syscall.CS5 + case 6: + cflagToUse |= syscall.CS6 + case 7: + cflagToUse |= syscall.CS7 + case 8: + cflagToUse |= syscall.CS8 + default: + return nil, ErrBadSize + } + // Stop bits settings + switch stopbits { + case Stop1: + // default is 1 stop bit + case Stop2: + cflagToUse |= syscall.CSTOPB + default: + // Don't know how to set 1.5 + return nil, ErrBadStopBits + } + // Parity settings + switch parity { + case ParityNone: + // default is no parity + case ParityOdd: + cflagToUse |= syscall.PARENB + cflagToUse |= syscall.PARODD + case ParityEven: + cflagToUse |= syscall.PARENB + default: + return nil, ErrBadParity + } + fd := f.Fd() + vmin, vtime := posixTimeoutValues(readTimeout) + t := syscall.Termios{ + Iflag: syscall.IGNPAR, + Cflag: cflagToUse, + Cc: [32]uint8{syscall.VMIN: vmin, syscall.VTIME: vtime}, + Ispeed: rate, + Ospeed: rate, + } + + if _, _, errno := syscall.Syscall6( + syscall.SYS_IOCTL, + uintptr(fd), + uintptr(syscall.TCSETS), + uintptr(unsafe.Pointer(&t)), + 0, + 0, + 0, + ); errno != 0 { + return nil, errno + } + + if err = syscall.SetNonblock(int(fd), false); err != nil { + return + } + + return &Port{f: f}, nil +} + +type Port struct { + // We intentionly do not use an "embedded" struct so that we + // don't export File + f *os.File +} + +func (p *Port) Read(b []byte) (n int, err error) { + return p.f.Read(b) +} + +func (p *Port) Write(b []byte) (n int, err error) { + return p.f.Write(b) +} + +// Discards data written to the port but not transmitted, +// or data received but not read +func (p *Port) Flush() error { + const TCFLSH = 0x540B + _, _, err := syscall.Syscall( + syscall.SYS_IOCTL, + uintptr(p.f.Fd()), + uintptr(TCFLSH), + uintptr(syscall.TCIOFLUSH), + ) + return err +} + +func (p *Port) Close() (err error) { + return p.f.Close() +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/tarm/serial/serial_posix.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/tarm/serial/serial_posix.go b/newtmgr/vendor/github.com/tarm/serial/serial_posix.go new file mode 100644 index 0000000..3e8bc7c --- /dev/null +++ b/newtmgr/vendor/github.com/tarm/serial/serial_posix.go @@ -0,0 +1,196 @@ +// +build !windows,cgo + +package serial + +// #include <termios.h> +// #include <unistd.h> +import "C" + +// TODO: Maybe change to using syscall package + ioctl instead of cgo + +import ( + "errors" + "fmt" + "os" + "syscall" + "time" + //"unsafe" +) + +func openPort(name string, baud int, databits byte, parity Parity, stopbits StopBits, readTimeout time.Duration) (p *Port, err error) { + f, err := os.OpenFile(name, syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_NONBLOCK, 0666) + if err != nil { + return + } + + fd := C.int(f.Fd()) + if C.isatty(fd) != 1 { + f.Close() + return nil, errors.New("File is not a tty") + } + + var st C.struct_termios + _, err = C.tcgetattr(fd, &st) + if err != nil { + f.Close() + return nil, err + } + var speed C.speed_t + switch baud { + case 115200: + speed = C.B115200 + case 57600: + speed = C.B57600 + case 38400: + speed = C.B38400 + case 19200: + speed = C.B19200 + case 9600: + speed = C.B9600 + case 4800: + speed = C.B4800 + case 2400: + speed = C.B2400 + case 1200: + speed = C.B1200 + case 600: + speed = C.B600 + case 300: + speed = C.B300 + case 200: + speed = C.B200 + case 150: + speed = C.B150 + case 134: + speed = C.B134 + case 110: + speed = C.B110 + case 75: + speed = C.B75 + case 50: + speed = C.B50 + default: + f.Close() + return nil, fmt.Errorf("Unknown baud rate %v", baud) + } + + _, err = C.cfsetispeed(&st, speed) + if err != nil { + f.Close() + return nil, err + } + _, err = C.cfsetospeed(&st, speed) + if err != nil { + f.Close() + return nil, err + } + + // Turn off break interrupts, CR->NL, Parity checks, strip, and IXON + st.c_iflag &= ^C.tcflag_t(C.BRKINT | C.ICRNL | C.INPCK | C.ISTRIP | C.IXOFF | C.IXON | C.PARMRK) + + // Select local mode, turn off parity, set to 8 bits + st.c_cflag &= ^C.tcflag_t(C.CSIZE | C.PARENB) + st.c_cflag |= (C.CLOCAL | C.CREAD) + // databits + switch databits { + case 5: + st.c_cflag |= C.CS5 + case 6: + st.c_cflag |= C.CS6 + case 7: + st.c_cflag |= C.CS7 + case 8: + st.c_cflag |= C.CS8 + default: + return nil, ErrBadSize + } + // Parity settings + switch parity { + case ParityNone: + // default is no parity + case ParityOdd: + st.c_cflag |= C.PARENB + st.c_cflag |= C.PARODD + case ParityEven: + st.c_cflag |= C.PARENB + default: + return nil, ErrBadParity + } + // Stop bits settings + switch stopbits { + case Stop1: + // as is, default is 1 bit + case Stop2: + st.c_cflag |= C.CSTOPB + default: + return nil, ErrBadStopBits + } + // Select raw mode + st.c_lflag &= ^C.tcflag_t(C.ICANON | C.ECHO | C.ECHOE | C.ISIG) + st.c_oflag &= ^C.tcflag_t(C.OPOST) + + // set blocking / non-blocking read + /* + * http://man7.org/linux/man-pages/man3/termios.3.html + * - Supports blocking read and read with timeout operations + */ + vmin, vtime := posixTimeoutValues(readTimeout) + st.c_cc[C.VMIN] = C.cc_t(vmin) + st.c_cc[C.VTIME] = C.cc_t(vtime) + + _, err = C.tcsetattr(fd, C.TCSANOW, &st) + if err != nil { + f.Close() + return nil, err + } + + //fmt.Println("Tweaking", name) + r1, _, e := syscall.Syscall(syscall.SYS_FCNTL, + uintptr(f.Fd()), + uintptr(syscall.F_SETFL), + uintptr(0)) + if e != 0 || r1 != 0 { + s := fmt.Sprint("Clearing NONBLOCK syscall error:", e, r1) + f.Close() + return nil, errors.New(s) + } + + /* + r1, _, e = syscall.Syscall(syscall.SYS_IOCTL, + uintptr(f.Fd()), + uintptr(0x80045402), // IOSSIOSPEED + uintptr(unsafe.Pointer(&baud))); + if e != 0 || r1 != 0 { + s := fmt.Sprint("Baudrate syscall error:", e, r1) + f.Close() + return nil, os.NewError(s) + } + */ + + return &Port{f: f}, nil +} + +type Port struct { + // We intentionly do not use an "embedded" struct so that we + // don't export File + f *os.File +} + +func (p *Port) Read(b []byte) (n int, err error) { + return p.f.Read(b) +} + +func (p *Port) Write(b []byte) (n int, err error) { + return p.f.Write(b) +} + +// Discards data written to the port but not transmitted, +// or data received but not read +func (p *Port) Flush() error { + _, err := C.tcflush(C.int(p.f.Fd()), C.TCIOFLUSH) + return err +} + +func (p *Port) Close() (err error) { + return p.f.Close() +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/github.com/tarm/serial/serial_windows.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/github.com/tarm/serial/serial_windows.go b/newtmgr/vendor/github.com/tarm/serial/serial_windows.go new file mode 100644 index 0000000..a41bf4f --- /dev/null +++ b/newtmgr/vendor/github.com/tarm/serial/serial_windows.go @@ -0,0 +1,327 @@ +// +build windows + +package serial + +import ( + "fmt" + "os" + "sync" + "syscall" + "time" + "unsafe" +) + +type Port struct { + f *os.File + fd syscall.Handle + rl sync.Mutex + wl sync.Mutex + ro *syscall.Overlapped + wo *syscall.Overlapped +} + +type structDCB struct { + DCBlength, BaudRate uint32 + flags [4]byte + wReserved, XonLim, XoffLim uint16 + ByteSize, Parity, StopBits byte + XonChar, XoffChar, ErrorChar, EofChar, EvtChar byte + wReserved1 uint16 +} + +type structTimeouts struct { + ReadIntervalTimeout uint32 + ReadTotalTimeoutMultiplier uint32 + ReadTotalTimeoutConstant uint32 + WriteTotalTimeoutMultiplier uint32 + WriteTotalTimeoutConstant uint32 +} + +func openPort(name string, baud int, databits byte, parity Parity, stopbits StopBits, readTimeout time.Duration) (p *Port, err error) { + if len(name) > 0 && name[0] != '\\' { + name = "\\\\.\\" + name + } + + h, err := syscall.CreateFile(syscall.StringToUTF16Ptr(name), + syscall.GENERIC_READ|syscall.GENERIC_WRITE, + 0, + nil, + syscall.OPEN_EXISTING, + syscall.FILE_ATTRIBUTE_NORMAL|syscall.FILE_FLAG_OVERLAPPED, + 0) + if err != nil { + return nil, err + } + f := os.NewFile(uintptr(h), name) + defer func() { + if err != nil { + f.Close() + } + }() + + if err = setCommState(h, baud, databits, parity, stopbits); err != nil { + return nil, err + } + if err = setupComm(h, 64, 64); err != nil { + return nil, err + } + if err = setCommTimeouts(h, readTimeout); err != nil { + return nil, err + } + if err = setCommMask(h); err != nil { + return nil, err + } + + ro, err := newOverlapped() + if err != nil { + return nil, err + } + wo, err := newOverlapped() + if err != nil { + return nil, err + } + port := new(Port) + port.f = f + port.fd = h + port.ro = ro + port.wo = wo + + return port, nil +} + +func (p *Port) Close() error { + return p.f.Close() +} + +func (p *Port) Write(buf []byte) (int, error) { + p.wl.Lock() + defer p.wl.Unlock() + + if err := resetEvent(p.wo.HEvent); err != nil { + return 0, err + } + var n uint32 + err := syscall.WriteFile(p.fd, buf, &n, p.wo) + if err != nil && err != syscall.ERROR_IO_PENDING { + return int(n), err + } + return getOverlappedResult(p.fd, p.wo) +} + +func (p *Port) Read(buf []byte) (int, error) { + if p == nil || p.f == nil { + return 0, fmt.Errorf("Invalid port on read %v %v", p, p.f) + } + + p.rl.Lock() + defer p.rl.Unlock() + + if err := resetEvent(p.ro.HEvent); err != nil { + return 0, err + } + var done uint32 + err := syscall.ReadFile(p.fd, buf, &done, p.ro) + if err != nil && err != syscall.ERROR_IO_PENDING { + return int(done), err + } + return getOverlappedResult(p.fd, p.ro) +} + +// Discards data written to the port but not transmitted, +// or data received but not read +func (p *Port) Flush() error { + return purgeComm(p.fd) +} + +var ( + nSetCommState, + nSetCommTimeouts, + nSetCommMask, + nSetupComm, + nGetOverlappedResult, + nCreateEvent, + nResetEvent, + nPurgeComm, + nFlushFileBuffers uintptr +) + +func init() { + k32, err := syscall.LoadLibrary("kernel32.dll") + if err != nil { + panic("LoadLibrary " + err.Error()) + } + defer syscall.FreeLibrary(k32) + + nSetCommState = getProcAddr(k32, "SetCommState") + nSetCommTimeouts = getProcAddr(k32, "SetCommTimeouts") + nSetCommMask = getProcAddr(k32, "SetCommMask") + nSetupComm = getProcAddr(k32, "SetupComm") + nGetOverlappedResult = getProcAddr(k32, "GetOverlappedResult") + nCreateEvent = getProcAddr(k32, "CreateEventW") + nResetEvent = getProcAddr(k32, "ResetEvent") + nPurgeComm = getProcAddr(k32, "PurgeComm") + nFlushFileBuffers = getProcAddr(k32, "FlushFileBuffers") +} + +func getProcAddr(lib syscall.Handle, name string) uintptr { + addr, err := syscall.GetProcAddress(lib, name) + if err != nil { + panic(name + " " + err.Error()) + } + return addr +} + +func setCommState(h syscall.Handle, baud int, databits byte, parity Parity, stopbits StopBits) error { + var params structDCB + params.DCBlength = uint32(unsafe.Sizeof(params)) + + params.flags[0] = 0x01 // fBinary + params.flags[0] |= 0x10 // Assert DSR + + params.BaudRate = uint32(baud) + + params.ByteSize = databits + + switch parity { + case ParityNone: + params.Parity = 0 + case ParityOdd: + params.Parity = 1 + case ParityEven: + params.Parity = 2 + case ParityMark: + params.Parity = 3 + case ParitySpace: + params.Parity = 4 + default: + return ErrBadParity + } + + switch stopbits { + case Stop1: + params.StopBits = 0 + case Stop1Half: + params.StopBits = 1 + case Stop2: + params.StopBits = 2 + default: + return ErrBadStopBits + } + + r, _, err := syscall.Syscall(nSetCommState, 2, uintptr(h), uintptr(unsafe.Pointer(¶ms)), 0) + if r == 0 { + return err + } + return nil +} + +func setCommTimeouts(h syscall.Handle, readTimeout time.Duration) error { + var timeouts structTimeouts + const MAXDWORD = 1<<32 - 1 + + // blocking read by default + var timeoutMs int64 = MAXDWORD - 1 + + if readTimeout > 0 { + // non-blocking read + timeoutMs = readTimeout.Nanoseconds() / 1e6 + if timeoutMs < 1 { + timeoutMs = 1 + } else if timeoutMs > MAXDWORD-1 { + timeoutMs = MAXDWORD - 1 + } + } + + /* From http://msdn.microsoft.com/en-us/library/aa363190(v=VS.85).aspx + + For blocking I/O see below: + + Remarks: + + If an application sets ReadIntervalTimeout and + ReadTotalTimeoutMultiplier to MAXDWORD and sets + ReadTotalTimeoutConstant to a value greater than zero and + less than MAXDWORD, one of the following occurs when the + ReadFile function is called: + + If there are any bytes in the input buffer, ReadFile returns + immediately with the bytes in the buffer. + + If there are no bytes in the input buffer, ReadFile waits + until a byte arrives and then returns immediately. + + If no bytes arrive within the time specified by + ReadTotalTimeoutConstant, ReadFile times out. + */ + + timeouts.ReadIntervalTimeout = MAXDWORD + timeouts.ReadTotalTimeoutMultiplier = MAXDWORD + timeouts.ReadTotalTimeoutConstant = uint32(timeoutMs) + + r, _, err := syscall.Syscall(nSetCommTimeouts, 2, uintptr(h), uintptr(unsafe.Pointer(&timeouts)), 0) + if r == 0 { + return err + } + return nil +} + +func setupComm(h syscall.Handle, in, out int) error { + r, _, err := syscall.Syscall(nSetupComm, 3, uintptr(h), uintptr(in), uintptr(out)) + if r == 0 { + return err + } + return nil +} + +func setCommMask(h syscall.Handle) error { + const EV_RXCHAR = 0x0001 + r, _, err := syscall.Syscall(nSetCommMask, 2, uintptr(h), EV_RXCHAR, 0) + if r == 0 { + return err + } + return nil +} + +func resetEvent(h syscall.Handle) error { + r, _, err := syscall.Syscall(nResetEvent, 1, uintptr(h), 0, 0) + if r == 0 { + return err + } + return nil +} + +func purgeComm(h syscall.Handle) error { + const PURGE_TXABORT = 0x0001 + const PURGE_RXABORT = 0x0002 + const PURGE_TXCLEAR = 0x0004 + const PURGE_RXCLEAR = 0x0008 + r, _, err := syscall.Syscall(nPurgeComm, 2, uintptr(h), + PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR, 0) + if r == 0 { + return err + } + return nil +} + +func newOverlapped() (*syscall.Overlapped, error) { + var overlapped syscall.Overlapped + r, _, err := syscall.Syscall6(nCreateEvent, 4, 0, 1, 0, 0, 0, 0) + if r == 0 { + return nil, err + } + overlapped.HEvent = syscall.Handle(r) + return &overlapped, nil +} + +func getOverlappedResult(h syscall.Handle, overlapped *syscall.Overlapped) (int, error) { + var n int + r, _, err := syscall.Syscall6(nGetOverlappedResult, 4, + uintptr(h), + uintptr(unsafe.Pointer(overlapped)), + uintptr(unsafe.Pointer(&n)), 1, 0, 0) + if r == 0 { + return n, err + } + + return n, nil +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/LICENSE ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/LICENSE b/newtmgr/vendor/golang.org/x/sys/LICENSE new file mode 100644 index 0000000..6a66aea --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/PATENTS ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/PATENTS b/newtmgr/vendor/golang.org/x/sys/PATENTS new file mode 100644 index 0000000..7330990 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/.gitignore ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/.gitignore b/newtmgr/vendor/golang.org/x/sys/unix/.gitignore new file mode 100644 index 0000000..e482715 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/.gitignore @@ -0,0 +1 @@ +_obj/ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm.s b/newtmgr/vendor/golang.org/x/sys/unix/asm.s new file mode 100644 index 0000000..8ed2fdb --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm.s @@ -0,0 +1,10 @@ +// Copyright 2014 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. + +// +build !gccgo + +#include "textflag.h" + +TEXT ·use(SB),NOSPLIT,$0 + RET http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_386.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_386.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_386.s new file mode 100644 index 0000000..8a72783 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_386.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for 386, Darwin +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s new file mode 100644 index 0000000..6321421 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for AMD64, Darwin +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-104 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm.s new file mode 100644 index 0000000..333242d --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm.s @@ -0,0 +1,30 @@ +// Copyright 2015 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. + +// +build !gccgo +// +build arm,darwin + +#include "textflag.h" + +// +// System call support for ARM, Darwin +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + B syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + B syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + B syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + B syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + B syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s new file mode 100644 index 0000000..97e0174 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s @@ -0,0 +1,30 @@ +// Copyright 2015 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. + +// +build !gccgo +// +build arm64,darwin + +#include "textflag.h" + +// +// System call support for AMD64, Darwin +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + B syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + B syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-104 + B syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + B syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + B syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s new file mode 100644 index 0000000..d5ed672 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for AMD64, DragonFly +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-64 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-88 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-112 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-64 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_386.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_386.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_386.s new file mode 100644 index 0000000..c9a0a26 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_386.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for 386, FreeBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s new file mode 100644 index 0000000..3517247 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for AMD64, FreeBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-104 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s new file mode 100644 index 0000000..9227c87 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for ARM, FreeBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + B syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + B syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + B syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + B syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + B syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_386.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_386.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_386.s new file mode 100644 index 0000000..4db2909 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_386.s @@ -0,0 +1,35 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System calls for 386, Linux +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + JMP syscall·Syscall6(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + JMP syscall·RawSyscall6(SB) + +TEXT ·socketcall(SB),NOSPLIT,$0-36 + JMP syscall·socketcall(SB) + +TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 + JMP syscall·rawsocketcall(SB) + +TEXT ·seek(SB),NOSPLIT,$0-28 + JMP syscall·seek(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_amd64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_amd64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_amd64.s new file mode 100644 index 0000000..44e25c6 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_amd64.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System calls for AMD64, Linux +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) + +TEXT ·gettimeofday(SB),NOSPLIT,$0-16 + JMP syscall·gettimeofday(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm.s new file mode 100644 index 0000000..cf0b574 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System calls for arm, Linux +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + B syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + B syscall·Syscall6(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + B syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + B syscall·RawSyscall6(SB) + +TEXT ·seek(SB),NOSPLIT,$0-32 + B syscall·seek(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm64.s new file mode 100644 index 0000000..4be9bfe --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_arm64.s @@ -0,0 +1,24 @@ +// Copyright 2015 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. + +// +build linux +// +build arm64 +// +build !gccgo + +#include "textflag.h" + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + B syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + B syscall·Syscall6(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + B syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + B syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s new file mode 100644 index 0000000..724e580 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s @@ -0,0 +1,28 @@ +// Copyright 2015 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. + +// +build linux +// +build mips64 mips64le +// +build !gccgo + +#include "textflag.h" + +// +// System calls for mips64, Linux +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s new file mode 100644 index 0000000..8d231fe --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s @@ -0,0 +1,28 @@ +// Copyright 2014 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. + +// +build linux +// +build ppc64 ppc64le +// +build !gccgo + +#include "textflag.h" + +// +// System calls for ppc64, Linux +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + BR syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + BR syscall·Syscall6(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + BR syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + BR syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_s390x.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_s390x.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_s390x.s new file mode 100644 index 0000000..1188985 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_linux_s390x.s @@ -0,0 +1,28 @@ +// Copyright 2016 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. + +// +build s390x +// +build linux +// +build !gccgo + +#include "textflag.h" + +// +// System calls for s390x, Linux +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + BR syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + BR syscall·Syscall6(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + BR syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + BR syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_386.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_386.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_386.s new file mode 100644 index 0000000..48bdcd7 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_386.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for 386, NetBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s new file mode 100644 index 0000000..2ede05c --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for AMD64, NetBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-104 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s new file mode 100644 index 0000000..e892857 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s @@ -0,0 +1,29 @@ +// Copyright 2013 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for ARM, NetBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + B syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + B syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + B syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + B syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + B syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_386.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_386.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_386.s new file mode 100644 index 0000000..00576f3 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_386.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for 386, OpenBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-28 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-40 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-52 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-28 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s new file mode 100644 index 0000000..790ef77 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s @@ -0,0 +1,29 @@ +// 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System call support for AMD64, OpenBSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-104 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/newtmgr/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s new file mode 100644 index 0000000..43ed17a --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s @@ -0,0 +1,17 @@ +// Copyright 2014 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. + +// +build !gccgo + +#include "textflag.h" + +// +// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go +// + +TEXT ·sysvicall6(SB),NOSPLIT,$0-64 + JMP syscall·sysvicall6(SB) + +TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 + JMP syscall·rawSysvicall6(SB) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/bluetooth_linux.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/bluetooth_linux.go b/newtmgr/vendor/golang.org/x/sys/unix/bluetooth_linux.go new file mode 100644 index 0000000..6e32296 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/bluetooth_linux.go @@ -0,0 +1,35 @@ +// Copyright 2016 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. + +// Bluetooth sockets and messages + +package unix + +// Bluetooth Protocols +const ( + BTPROTO_L2CAP = 0 + BTPROTO_HCI = 1 + BTPROTO_SCO = 2 + BTPROTO_RFCOMM = 3 + BTPROTO_BNEP = 4 + BTPROTO_CMTP = 5 + BTPROTO_HIDP = 6 + BTPROTO_AVDTP = 7 +) + +const ( + HCI_CHANNEL_RAW = 0 + HCI_CHANNEL_USER = 1 + HCI_CHANNEL_MONITOR = 2 + HCI_CHANNEL_CONTROL = 3 +) + +// Socketoption Level +const ( + SOL_BLUETOOTH = 0x112 + SOL_HCI = 0x0 + SOL_L2CAP = 0x6 + SOL_RFCOMM = 0x12 + SOL_SCO = 0x11 +) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/constants.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/constants.go b/newtmgr/vendor/golang.org/x/sys/unix/constants.go new file mode 100644 index 0000000..a96f0eb --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/constants.go @@ -0,0 +1,13 @@ +// Copyright 2015 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. + +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package unix + +const ( + R_OK = 0x4 + W_OK = 0x2 + X_OK = 0x1 +) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/env_unix.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/env_unix.go b/newtmgr/vendor/golang.org/x/sys/unix/env_unix.go new file mode 100644 index 0000000..45e281a --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/env_unix.go @@ -0,0 +1,27 @@ +// 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. + +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +// Unix environment variables. + +package unix + +import "syscall" + +func Getenv(key string) (value string, found bool) { + return syscall.Getenv(key) +} + +func Setenv(key, value string) error { + return syscall.Setenv(key, value) +} + +func Clearenv() { + syscall.Clearenv() +} + +func Environ() []string { + return syscall.Environ() +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/env_unset.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/env_unset.go b/newtmgr/vendor/golang.org/x/sys/unix/env_unset.go new file mode 100644 index 0000000..9222262 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/env_unset.go @@ -0,0 +1,14 @@ +// Copyright 2014 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. + +// +build go1.4 + +package unix + +import "syscall" + +func Unsetenv(key string) error { + // This was added in Go 1.4. + return syscall.Unsetenv(key) +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/flock.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/flock.go b/newtmgr/vendor/golang.org/x/sys/unix/flock.go new file mode 100644 index 0000000..ce67a59 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/flock.go @@ -0,0 +1,24 @@ +// +build linux darwin freebsd openbsd netbsd dragonfly + +// Copyright 2014 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. + +// +build darwin dragonfly freebsd linux netbsd openbsd + +package unix + +import "unsafe" + +// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux +// systems by flock_linux_32bit.go to be SYS_FCNTL64. +var fcntl64Syscall uintptr = SYS_FCNTL + +// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. +func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { + _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) + if errno == 0 { + return nil + } + return errno +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/flock_linux_32bit.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/flock_linux_32bit.go b/newtmgr/vendor/golang.org/x/sys/unix/flock_linux_32bit.go new file mode 100644 index 0000000..362831c --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/flock_linux_32bit.go @@ -0,0 +1,13 @@ +// +build linux,386 linux,arm + +// Copyright 2014 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 unix + +func init() { + // On 32-bit Linux systems, the fcntl syscall that matches Go's + // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. + fcntl64Syscall = SYS_FCNTL64 +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/gccgo.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/gccgo.go b/newtmgr/vendor/golang.org/x/sys/unix/gccgo.go new file mode 100644 index 0000000..94c8232 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/gccgo.go @@ -0,0 +1,46 @@ +// Copyright 2015 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. + +// +build gccgo + +package unix + +import "syscall" + +// We can't use the gc-syntax .s files for gccgo. On the plus side +// much of the functionality can be written directly in Go. + +//extern gccgoRealSyscall +func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) + +func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { + syscall.Entersyscall() + r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) + syscall.Exitsyscall() + return r, 0, syscall.Errno(errno) +} + +func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { + syscall.Entersyscall() + r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) + syscall.Exitsyscall() + return r, 0, syscall.Errno(errno) +} + +func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { + syscall.Entersyscall() + r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) + syscall.Exitsyscall() + return r, 0, syscall.Errno(errno) +} + +func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { + r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) + return r, 0, syscall.Errno(errno) +} + +func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { + r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) + return r, 0, syscall.Errno(errno) +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/gccgo_c.c ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/gccgo_c.c b/newtmgr/vendor/golang.org/x/sys/unix/gccgo_c.c new file mode 100644 index 0000000..07f6be0 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/gccgo_c.c @@ -0,0 +1,41 @@ +// Copyright 2015 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. + +// +build gccgo + +#include <errno.h> +#include <stdint.h> +#include <unistd.h> + +#define _STRINGIFY2_(x) #x +#define _STRINGIFY_(x) _STRINGIFY2_(x) +#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) + +// Call syscall from C code because the gccgo support for calling from +// Go to C does not support varargs functions. + +struct ret { + uintptr_t r; + uintptr_t err; +}; + +struct ret +gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) +{ + struct ret r; + + errno = 0; + r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); + r.err = errno; + return r; +} + +// Define the use function in C so that it is not inlined. + +extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); + +void +use(void *p __attribute__ ((unused))) +{ +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go b/newtmgr/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go new file mode 100644 index 0000000..bffe1a7 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go @@ -0,0 +1,20 @@ +// Copyright 2015 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. + +// +build gccgo,linux,amd64 + +package unix + +import "syscall" + +//extern gettimeofday +func realGettimeofday(*Timeval, *byte) int32 + +func gettimeofday(tv *Timeval) (err syscall.Errno) { + r := realGettimeofday(tv, nil) + if r < 0 { + return syscall.GetErrno() + } + return 0 +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5528d6fc/newtmgr/vendor/golang.org/x/sys/unix/mkall.sh ---------------------------------------------------------------------- diff --git a/newtmgr/vendor/golang.org/x/sys/unix/mkall.sh b/newtmgr/vendor/golang.org/x/sys/unix/mkall.sh new file mode 100755 index 0000000..3e224c5 --- /dev/null +++ b/newtmgr/vendor/golang.org/x/sys/unix/mkall.sh @@ -0,0 +1,285 @@ +#!/usr/bin/env bash +# 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. + +# The unix package provides access to the raw system call +# interface of the underlying operating system. Porting Go to +# a new architecture/operating system combination requires +# some manual effort, though there are tools that automate +# much of the process. The auto-generated files have names +# beginning with z. +# +# This script runs or (given -n) prints suggested commands to generate z files +# for the current system. Running those commands is not automatic. +# This script is documentation more than anything else. +# +# * asm_${GOOS}_${GOARCH}.s +# +# This hand-written assembly file implements system call dispatch. +# There are three entry points: +# +# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr); +# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr); +# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr); +# +# The first and second are the standard ones; they differ only in +# how many arguments can be passed to the kernel. +# The third is for low-level use by the ForkExec wrapper; +# unlike the first two, it does not call into the scheduler to +# let it know that a system call is running. +# +# * syscall_${GOOS}.go +# +# This hand-written Go file implements system calls that need +# special handling and lists "//sys" comments giving prototypes +# for ones that can be auto-generated. Mksyscall reads those +# comments to generate the stubs. +# +# * syscall_${GOOS}_${GOARCH}.go +# +# Same as syscall_${GOOS}.go except that it contains code specific +# to ${GOOS} on one particular architecture. +# +# * types_${GOOS}.c +# +# This hand-written C file includes standard C headers and then +# creates typedef or enum names beginning with a dollar sign +# (use of $ in variable names is a gcc extension). The hardest +# part about preparing this file is figuring out which headers to +# include and which symbols need to be #defined to get the +# actual data structures that pass through to the kernel system calls. +# Some C libraries present alternate versions for binary compatibility +# and translate them on the way in and out of system calls, but +# there is almost always a #define that can get the real ones. +# See types_darwin.c and types_linux.c for examples. +# +# * zerror_${GOOS}_${GOARCH}.go +# +# This machine-generated file defines the system's error numbers, +# error strings, and signal numbers. The generator is "mkerrors.sh". +# Usually no arguments are needed, but mkerrors.sh will pass its +# arguments on to godefs. +# +# * zsyscall_${GOOS}_${GOARCH}.go +# +# Generated by mksyscall.pl; see syscall_${GOOS}.go above. +# +# * zsysnum_${GOOS}_${GOARCH}.go +# +# Generated by mksysnum_${GOOS}. +# +# * ztypes_${GOOS}_${GOARCH}.go +# +# Generated by godefs; see types_${GOOS}.c above. + +GOOSARCH="${GOOS}_${GOARCH}" + +# defaults +mksyscall="./mksyscall.pl" +mkerrors="./mkerrors.sh" +zerrors="zerrors_$GOOSARCH.go" +mksysctl="" +zsysctl="zsysctl_$GOOSARCH.go" +mksysnum= +mktypes= +run="sh" + +case "$1" in +-syscalls) + for i in zsyscall*go + do + sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i + rm _$i + done + exit 0 + ;; +-n) + run="cat" + shift +esac + +case "$#" in +0) + ;; +*) + echo 'usage: mkall.sh [-n]' 1>&2 + exit 2 +esac + +GOOSARCH_in=syscall_$GOOSARCH.go +case "$GOOSARCH" in +_* | *_ | _) + echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 + exit 1 + ;; +darwin_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32" + mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +darwin_amd64) + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +darwin_arm) + mkerrors="$mkerrors" + mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +darwin_arm64) + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +dragonfly_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32 -dragonfly" + mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +dragonfly_amd64) + mkerrors="$mkerrors -m64" + mksyscall="./mksyscall.pl -dragonfly" + mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32" + mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_amd64) + mkerrors="$mkerrors -m64" + mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +freebsd_arm) + mkerrors="$mkerrors" + mksyscall="./mksyscall.pl -l32 -arm" + mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl" + # Let the type of C char be signed for making the bare syscall + # API consistent across over platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +linux_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32" + mksysnum="./mksysnum_linux.pl /usr/include/asm/unistd_32.h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_amd64) + unistd_h=$(ls -1 /usr/include/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h 2>/dev/null | head -1) + if [ "$unistd_h" = "" ]; then + echo >&2 cannot find unistd_64.h + exit 1 + fi + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_arm) + mkerrors="$mkerrors" + mksyscall="./mksyscall.pl -l32 -arm" + mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl -" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_arm64) + unistd_h=$(ls -1 /usr/include/asm/unistd.h /usr/include/asm-generic/unistd.h 2>/dev/null | head -1) + if [ "$unistd_h" = "" ]; then + echo >&2 cannot find unistd_64.h + exit 1 + fi + mksysnum="./mksysnum_linux.pl $unistd_h" + # Let the type of C char be signed for making the bare syscall + # API consistent across over platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +linux_ppc64) + GOOSARCH_in=syscall_linux_ppc64x.go + unistd_h=/usr/include/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_ppc64le) + GOOSARCH_in=syscall_linux_ppc64x.go + unistd_h=/usr/include/powerpc64le-linux-gnu/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_s390x) + GOOSARCH_in=syscall_linux_s390x.go + unistd_h=/usr/include/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + # Let the type of C char be signed to make the bare sys + # API more consistent between platforms. + # This is a deliberate departure from the way the syscall + # package generates its version of the types file. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +netbsd_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32 -netbsd" + mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +netbsd_amd64) + mkerrors="$mkerrors -m64" + mksyscall="./mksyscall.pl -netbsd" + mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +openbsd_386) + mkerrors="$mkerrors -m32" + mksyscall="./mksyscall.pl -l32 -openbsd" + mksysctl="./mksysctl_openbsd.pl" + zsysctl="zsysctl_openbsd.go" + mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +openbsd_amd64) + mkerrors="$mkerrors -m64" + mksyscall="./mksyscall.pl -openbsd" + mksysctl="./mksysctl_openbsd.pl" + zsysctl="zsysctl_openbsd.go" + mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +solaris_amd64) + mksyscall="./mksyscall_solaris.pl" + mkerrors="$mkerrors -m64" + mksysnum= + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +*) + echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2 + exit 1 + ;; +esac + +( + if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi + case "$GOOS" in + *) + syscall_goos="syscall_$GOOS.go" + case "$GOOS" in + darwin | dragonfly | freebsd | netbsd | openbsd) + syscall_goos="syscall_bsd.go $syscall_goos" + ;; + esac + if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi + ;; + esac + if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi + if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi + if [ -n "$mktypes" ]; then + echo "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go"; + echo "$mktypes types_$GOOS.go | go run mkpost.go >>ztypes_$GOOSARCH.go"; + fi +) | $run
