diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -373,6 +373,7 @@ vgone.9 \ vhold.9 \ vinvalbuf.9 \ + virtio_endian.9 \ vm_fault_prefault.9 \ vm_map.9 \ vm_map_check_protection.9 \ @@ -2327,6 +2328,12 @@ usbdi.9 usb_fifo_softc.9 \ usbdi.9 usb_fifo_wakeup.9 .endif +MLINKS+=virtio_endian.9 htole16.9 \ + virtio_endian.9 htole32.9 \ + virtio_endian.9 htole64.9 \ + virtio_endian.9 letoh16.9 \ + virtio_endian.9 letoh32.9 \ + virtio_endian.9 letoh64.9 MLINKS+=vfsconf.9 vfs_modevent.9 \ vfsconf.9 vfs_register.9 \ vfsconf.9 vfs_unregister.9 diff --git a/share/man/man9/virtio_endian.9 b/share/man/man9/virtio_endian.9 new file mode 100644 --- /dev/null +++ b/share/man/man9/virtio_endian.9 @@ -0,0 +1,70 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2023 The FreeBSD Foundation +.\" +.\" This manual page was written by Mina Galić under +.\" sponsorship from the FreeBSD Foundation. +.\" +.Dd August 8, 2023 +.Dt VIRTIO_ENDIAN 9 +.Os +.Sh NAME +.Nm virtio_endian +.Nd "virtio helper functions for byteswapping" +.Sh SYNOPSIS +.In dev/virtio/virtio.h +.Ft uint16_t +.Fo virtio_htog16 +.Fa "bool modern" +.Fa "uint16_t val" +.Fc +.Ft uint32_t +.Fo virtio_htog32 +.Fa "bool modern" +.Fa "uint32_t val" +.Fc +.Ft uint64_t +.Fo virtio_htog64 +.Fa "bool modern" +.Fa "uint64_t val" +.Fc +.Ft uint16_t +.Fo virtio_gtoh16 +.Fa "bool modern" +.Fa "uint16_t val" +.Fc +.Ft uint32_t +.Fo virtio_gtoh32 +.Fa "bool modern" +.Fa "uint32_t val" +.Fc +.Ft uint64_t +.Fo virtio_gtoh64 +.Fa "bool modern" +.Fa "uint64_t val" +.Fc +.Sh DESCRIPTION +The virtio_htog functions correspond to the +.Xr htole16 9 , +.Xr htole32 9 , +.Xr htole64 9 +functions, while the virtio_gtoh functions correspond to the +.Xr le16toh 9 , +.Xr le32toh 9 , +.Xr le64toh 9 +functions. +Whether that is the case, or these functions act as passthrough of the +.Fa val +depends on the +.Fa modern +parameter. +.Sh EXAMPLES +.Bd -literal -offset indent +/* This example returns number byte-swapped, on Little Endian platforms */ +uint64_t cid = virtio_htog64(true, 0x2); +.Sh SEE ALSO +.Xr byteorder 9 . +.Sh AUTHORS +This manual page was written by +.An Mina Galić .