unix: add linux constants and types for PPS devices ioctl's
After trying to implement Pulse Per Second devices
in go, I found that the ioctl values and structs
where not in the unix package yet:
~# strace ppstest /dev/pps0 |& grep ioctl
ioctl(3, PPS_GETPARAMS, 0xbee63b18) = 0
ioctl(3, PPS_GETCAP, 0xbee63b84) = 0
ioctl(3, PPS_GETPARAMS, 0xbee63b18) = 0
ioctl(3, PPS_SETPARAMS, 0xbee63b18) = 0
ioctl(3, PPS_FETCH, 0xbee63b00) = 0
ioctl(3, PPS_FETCH, 0xbee63b00) = 0
ioctl(3, PPS_FETCH, 0xbee63b00) = 0
ioctl(3, PPS_FETCH, 0xbee63b00) = 0
ioctl(3, PPS_FETCH, 0xbee63b00) = 0
This commit should add them.
Change-Id: If1225ab7c4c38aad5d8ae841d1fdebfa45055549
GitHub-Last-Rev: c1469112b8d73d711d3038a2a0fec19e83690486
GitHub-Pull-Request: golang/sys#90
Reviewed-on: https://go-review.googlesource.com/c/sys/+/265217
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Ben Cartwright-Cox authored 3 years ago
Tobias Klauser committed 3 years ago
112 | 112 |
#include <linux/nexthop.h>
|
113 | 113 |
#include <linux/openat2.h>
|
114 | 114 |
#include <linux/perf_event.h>
|
|
115 |
#include <linux/pps.h>
|
115 | 116 |
#include <linux/random.h>
|
116 | 117 |
#include <linux/rtc.h>
|
117 | 118 |
#include <linux/rtnetlink.h>
|
|
2575 | 2576 |
// Watchdog API
|
2576 | 2577 |
|
2577 | 2578 |
type WatchdogInfo C.struct_watchdog_info
|
|
2579 |
|
|
2580 |
// PPS API
|
|
2581 |
|
|
2582 |
type PPSFData C.struct_pps_fdata
|
|
2583 |
|
|
2584 |
type PPSKParams C.struct_pps_kparams
|
|
2585 |
|
|
2586 |
type PPSKInfo C.struct_pps_kinfo
|
|
2587 |
|
|
2588 |
type PPSKTime C.struct_pps_ktime
|
|
2589 |
|
|
2590 |
const (
|
|
2591 |
PPS_GETPARAMS = C.PPS_GETPARAMS
|
|
2592 |
PPS_SETPARAMS = C.PPS_SETPARAMS
|
|
2593 |
PPS_GETCAP = C.PPS_GETCAP
|
|
2594 |
PPS_FETCH = C.PPS_FETCH
|
|
2595 |
)
|
232 | 232 |
#include <linux/net_namespace.h>
|
233 | 233 |
#include <linux/nsfs.h>
|
234 | 234 |
#include <linux/perf_event.h>
|
|
235 |
#include <linux/pps.h>
|
235 | 236 |
#include <linux/ptrace.h>
|
236 | 237 |
#include <linux/random.h>
|
237 | 238 |
#include <linux/reboot.h>
|
601 | 601 |
Peer uint32
|
602 | 602 |
Id [16]int8
|
603 | 603 |
}
|
|
604 |
|
|
605 |
type PPSKInfo struct {
|
|
606 |
Assert_sequence uint32
|
|
607 |
Clear_sequence uint32
|
|
608 |
Assert_tu PPSKTime
|
|
609 |
Clear_tu PPSKTime
|
|
610 |
Current_mode int32
|
|
611 |
}
|
|
612 |
|
|
613 |
const (
|
|
614 |
PPS_GETPARAMS = 0x800470a1
|
|
615 |
PPS_SETPARAMS = 0x400470a2
|
|
616 |
PPS_GETCAP = 0x800470a3
|
|
617 |
PPS_FETCH = 0xc00470a4
|
|
618 |
)
|
618 | 618 |
Peer uint32
|
619 | 619 |
Id [16]int8
|
620 | 620 |
}
|
|
621 |
|
|
622 |
type PPSKInfo struct {
|
|
623 |
Assert_sequence uint32
|
|
624 |
Clear_sequence uint32
|
|
625 |
Assert_tu PPSKTime
|
|
626 |
Clear_tu PPSKTime
|
|
627 |
Current_mode int32
|
|
628 |
_ [4]byte
|
|
629 |
}
|
|
630 |
|
|
631 |
const (
|
|
632 |
PPS_GETPARAMS = 0x800870a1
|
|
633 |
PPS_SETPARAMS = 0x400870a2
|
|
634 |
PPS_GETCAP = 0x800870a3
|
|
635 |
PPS_FETCH = 0xc00870a4
|
|
636 |
)
|
595 | 595 |
Peer uint32
|
596 | 596 |
Id [16]uint8
|
597 | 597 |
}
|
|
598 |
|
|
599 |
type PPSKInfo struct {
|
|
600 |
Assert_sequence uint32
|
|
601 |
Clear_sequence uint32
|
|
602 |
Assert_tu PPSKTime
|
|
603 |
Clear_tu PPSKTime
|
|
604 |
Current_mode int32
|
|
605 |
_ [4]byte
|
|
606 |
}
|
|
607 |
|
|
608 |
const (
|
|
609 |
PPS_GETPARAMS = 0x800470a1
|
|
610 |
PPS_SETPARAMS = 0x400470a2
|
|
611 |
PPS_GETCAP = 0x800470a3
|
|
612 |
PPS_FETCH = 0xc00470a4
|
|
613 |
)
|
597 | 597 |
Peer uint32
|
598 | 598 |
Id [16]int8
|
599 | 599 |
}
|
|
600 |
|
|
601 |
type PPSKInfo struct {
|
|
602 |
Assert_sequence uint32
|
|
603 |
Clear_sequence uint32
|
|
604 |
Assert_tu PPSKTime
|
|
605 |
Clear_tu PPSKTime
|
|
606 |
Current_mode int32
|
|
607 |
_ [4]byte
|
|
608 |
}
|
|
609 |
|
|
610 |
const (
|
|
611 |
PPS_GETPARAMS = 0x800870a1
|
|
612 |
PPS_SETPARAMS = 0x400870a2
|
|
613 |
PPS_GETCAP = 0x800870a3
|
|
614 |
PPS_FETCH = 0xc00870a4
|
|
615 |
)
|
601 | 601 |
Peer uint32
|
602 | 602 |
Id [16]int8
|
603 | 603 |
}
|
|
604 |
|
|
605 |
type PPSKInfo struct {
|
|
606 |
Assert_sequence uint32
|
|
607 |
Clear_sequence uint32
|
|
608 |
Assert_tu PPSKTime
|
|
609 |
Clear_tu PPSKTime
|
|
610 |
Current_mode int32
|
|
611 |
_ [4]byte
|
|
612 |
}
|
|
613 |
|
|
614 |
const (
|
|
615 |
PPS_GETPARAMS = 0x400470a1
|
|
616 |
PPS_SETPARAMS = 0x800470a2
|
|
617 |
PPS_GETCAP = 0x400470a3
|
|
618 |
PPS_FETCH = 0xc00470a4
|
|
619 |
)
|
600 | 600 |
Peer uint32
|
601 | 601 |
Id [16]int8
|
602 | 602 |
}
|
|
603 |
|
|
604 |
type PPSKInfo struct {
|
|
605 |
Assert_sequence uint32
|
|
606 |
Clear_sequence uint32
|
|
607 |
Assert_tu PPSKTime
|
|
608 |
Clear_tu PPSKTime
|
|
609 |
Current_mode int32
|
|
610 |
_ [4]byte
|
|
611 |
}
|
|
612 |
|
|
613 |
const (
|
|
614 |
PPS_GETPARAMS = 0x400870a1
|
|
615 |
PPS_SETPARAMS = 0x800870a2
|
|
616 |
PPS_GETCAP = 0x400870a3
|
|
617 |
PPS_FETCH = 0xc00870a4
|
|
618 |
)
|
600 | 600 |
Peer uint32
|
601 | 601 |
Id [16]int8
|
602 | 602 |
}
|
|
603 |
|
|
604 |
type PPSKInfo struct {
|
|
605 |
Assert_sequence uint32
|
|
606 |
Clear_sequence uint32
|
|
607 |
Assert_tu PPSKTime
|
|
608 |
Clear_tu PPSKTime
|
|
609 |
Current_mode int32
|
|
610 |
_ [4]byte
|
|
611 |
}
|
|
612 |
|
|
613 |
const (
|
|
614 |
PPS_GETPARAMS = 0x400870a1
|
|
615 |
PPS_SETPARAMS = 0x800870a2
|
|
616 |
PPS_GETCAP = 0x400870a3
|
|
617 |
PPS_FETCH = 0xc00870a4
|
|
618 |
)
|
601 | 601 |
Peer uint32
|
602 | 602 |
Id [16]int8
|
603 | 603 |
}
|
|
604 |
|
|
605 |
type PPSKInfo struct {
|
|
606 |
Assert_sequence uint32
|
|
607 |
Clear_sequence uint32
|
|
608 |
Assert_tu PPSKTime
|
|
609 |
Clear_tu PPSKTime
|
|
610 |
Current_mode int32
|
|
611 |
_ [4]byte
|
|
612 |
}
|
|
613 |
|
|
614 |
const (
|
|
615 |
PPS_GETPARAMS = 0x400470a1
|
|
616 |
PPS_SETPARAMS = 0x800470a2
|
|
617 |
PPS_GETCAP = 0x400470a3
|
|
618 |
PPS_FETCH = 0xc00470a4
|
|
619 |
)
|
607 | 607 |
Peer uint32
|
608 | 608 |
Id [16]uint8
|
609 | 609 |
}
|
|
610 |
|
|
611 |
type PPSKInfo struct {
|
|
612 |
Assert_sequence uint32
|
|
613 |
Clear_sequence uint32
|
|
614 |
Assert_tu PPSKTime
|
|
615 |
Clear_tu PPSKTime
|
|
616 |
Current_mode int32
|
|
617 |
_ [4]byte
|
|
618 |
}
|
|
619 |
|
|
620 |
const (
|
|
621 |
PPS_GETPARAMS = 0x400870a1
|
|
622 |
PPS_SETPARAMS = 0x800870a2
|
|
623 |
PPS_GETCAP = 0x400870a3
|
|
624 |
PPS_FETCH = 0xc00870a4
|
|
625 |
)
|
607 | 607 |
Peer uint32
|
608 | 608 |
Id [16]uint8
|
609 | 609 |
}
|
|
610 |
|
|
611 |
type PPSKInfo struct {
|
|
612 |
Assert_sequence uint32
|
|
613 |
Clear_sequence uint32
|
|
614 |
Assert_tu PPSKTime
|
|
615 |
Clear_tu PPSKTime
|
|
616 |
Current_mode int32
|
|
617 |
_ [4]byte
|
|
618 |
}
|
|
619 |
|
|
620 |
const (
|
|
621 |
PPS_GETPARAMS = 0x400870a1
|
|
622 |
PPS_SETPARAMS = 0x800870a2
|
|
623 |
PPS_GETCAP = 0x400870a3
|
|
624 |
PPS_FETCH = 0xc00870a4
|
|
625 |
)
|
625 | 625 |
Peer uint32
|
626 | 626 |
Id [16]uint8
|
627 | 627 |
}
|
|
628 |
|
|
629 |
type PPSKInfo struct {
|
|
630 |
Assert_sequence uint32
|
|
631 |
Clear_sequence uint32
|
|
632 |
Assert_tu PPSKTime
|
|
633 |
Clear_tu PPSKTime
|
|
634 |
Current_mode int32
|
|
635 |
_ [4]byte
|
|
636 |
}
|
|
637 |
|
|
638 |
const (
|
|
639 |
PPS_GETPARAMS = 0x800870a1
|
|
640 |
PPS_SETPARAMS = 0x400870a2
|
|
641 |
PPS_GETCAP = 0x800870a3
|
|
642 |
PPS_FETCH = 0xc00870a4
|
|
643 |
)
|
621 | 621 |
Peer uint32
|
622 | 622 |
Id [16]int8
|
623 | 623 |
}
|
|
624 |
|
|
625 |
type PPSKInfo struct {
|
|
626 |
Assert_sequence uint32
|
|
627 |
Clear_sequence uint32
|
|
628 |
Assert_tu PPSKTime
|
|
629 |
Clear_tu PPSKTime
|
|
630 |
Current_mode int32
|
|
631 |
_ [4]byte
|
|
632 |
}
|
|
633 |
|
|
634 |
const (
|
|
635 |
PPS_GETPARAMS = 0x800870a1
|
|
636 |
PPS_SETPARAMS = 0x400870a2
|
|
637 |
PPS_GETCAP = 0x800870a3
|
|
638 |
PPS_FETCH = 0xc00870a4
|
|
639 |
)
|
602 | 602 |
Peer uint32
|
603 | 603 |
Id [16]int8
|
604 | 604 |
}
|
|
605 |
|
|
606 |
type PPSKInfo struct {
|
|
607 |
Assert_sequence uint32
|
|
608 |
Clear_sequence uint32
|
|
609 |
Assert_tu PPSKTime
|
|
610 |
Clear_tu PPSKTime
|
|
611 |
Current_mode int32
|
|
612 |
_ [4]byte
|
|
613 |
}
|
|
614 |
|
|
615 |
const (
|
|
616 |
PPS_GETPARAMS = 0x400870a1
|
|
617 |
PPS_SETPARAMS = 0x800870a2
|
|
618 |
PPS_GETCAP = 0x400870a3
|
|
619 |
PPS_FETCH = 0xc00870a4
|
|
620 |
)
|