xref: /illumos-gate/usr/src/man/man9f/bitx64.9f (revision 71815ce76261aa773c97600750fdce92334d1990)
1*71815ce7SRobert Mustacchi.\"
2*71815ce7SRobert Mustacchi.\" This file and its contents are supplied under the terms of the
3*71815ce7SRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0.
4*71815ce7SRobert Mustacchi.\" You may only use this file in accordance with the terms of version
5*71815ce7SRobert Mustacchi.\" 1.0 of the CDDL.
6*71815ce7SRobert Mustacchi.\"
7*71815ce7SRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this
8*71815ce7SRobert Mustacchi.\" source.  A copy of the CDDL is also available via the Internet at
9*71815ce7SRobert Mustacchi.\" http://www.illumos.org/license/CDDL.
10*71815ce7SRobert Mustacchi.\"
11*71815ce7SRobert Mustacchi.\"
12*71815ce7SRobert Mustacchi.\" Copyright 2022 Oxide Computer Company
13*71815ce7SRobert Mustacchi.\"
14*71815ce7SRobert Mustacchi.Dd April 12, 2022
15*71815ce7SRobert Mustacchi.Dt BITX64 9F
16*71815ce7SRobert Mustacchi.Os
17*71815ce7SRobert Mustacchi.Sh NAME
18*71815ce7SRobert Mustacchi.Nm bitx8 ,
19*71815ce7SRobert Mustacchi.Nm bitx16 ,
20*71815ce7SRobert Mustacchi.Nm bitx32 ,
21*71815ce7SRobert Mustacchi.Nm bitx64
22*71815ce7SRobert Mustacchi.Nd extract bits from an integer
23*71815ce7SRobert Mustacchi.Sh SYNOPSIS
24*71815ce7SRobert Mustacchi.In sys/bitext.h
25*71815ce7SRobert Mustacchi.Ft uint8_t
26*71815ce7SRobert Mustacchi.Fo bitx8
27*71815ce7SRobert Mustacchi.Fa "uint8_t value"
28*71815ce7SRobert Mustacchi.Fa "uint_t high"
29*71815ce7SRobert Mustacchi.Fa "uint_t low"
30*71815ce7SRobert Mustacchi.Fc
31*71815ce7SRobert Mustacchi.Ft uint16_t
32*71815ce7SRobert Mustacchi.Fo bitx16
33*71815ce7SRobert Mustacchi.Fa "uint16_t value"
34*71815ce7SRobert Mustacchi.Fa "uint_t high"
35*71815ce7SRobert Mustacchi.Fa "uint_t low"
36*71815ce7SRobert Mustacchi.Fc
37*71815ce7SRobert Mustacchi.Ft uint32_t
38*71815ce7SRobert Mustacchi.Fo bitx32
39*71815ce7SRobert Mustacchi.Fa "uint32_t value"
40*71815ce7SRobert Mustacchi.Fa "uint_t high"
41*71815ce7SRobert Mustacchi.Fa "uint_t low"
42*71815ce7SRobert Mustacchi.Fc
43*71815ce7SRobert Mustacchi.Ft uint64_t
44*71815ce7SRobert Mustacchi.Fo bitx64
45*71815ce7SRobert Mustacchi.Fa "uint64_t value"
46*71815ce7SRobert Mustacchi.Fa "uint_t high"
47*71815ce7SRobert Mustacchi.Fa "uint_t low"
48*71815ce7SRobert Mustacchi.Fc
49*71815ce7SRobert Mustacchi.Sh INTERFACE LEVEL
50*71815ce7SRobert Mustacchi.Sy Volatile -
51*71815ce7SRobert MustacchiThis interface is still evolving in illumos.
52*71815ce7SRobert MustacchiAPI and ABI stability is not guaranteed.
53*71815ce7SRobert Mustacchi.Sh PARAMETERS
54*71815ce7SRobert Mustacchi.Bl -tag -width Fa
55*71815ce7SRobert Mustacchi.It Fa value
56*71815ce7SRobert MustacchiAn integer to extract a value from.
57*71815ce7SRobert Mustacchi.It Fa high
58*71815ce7SRobert MustacchiThe high end, inclusive, of the bit range to extract from
59*71815ce7SRobert Mustacchi.Fa value .
60*71815ce7SRobert Mustacchi.It Fa low
61*71815ce7SRobert MustacchiThe low end, inclusive, of the bit range to extract from
62*71815ce7SRobert Mustacchi.Fa value .
63*71815ce7SRobert Mustacchi.El
64*71815ce7SRobert Mustacchi.Sh DESCRIPTION
65*71815ce7SRobert MustacchiThe
66*71815ce7SRobert Mustacchi.Fn bitx8 ,
67*71815ce7SRobert Mustacchi.Fn bitx16 ,
68*71815ce7SRobert Mustacchi.Fn bitx32 ,
69*71815ce7SRobert Mustacchiand
70*71815ce7SRobert Mustacchi.Fn bitx64
71*71815ce7SRobert Mustacchifunctions are used to extract a range of bits from on an 8, 16, 32, and
72*71815ce7SRobert Mustacchi64-bit value respectively.
73*71815ce7SRobert MustacchiThese functions are all implementations of a classical application of a
74*71815ce7SRobert Mustacchibitwise-AND of a mask and a logical right shift.
75*71815ce7SRobert MustacchiMore specifically, the arguments
76*71815ce7SRobert Mustacchi.Fa high
77*71815ce7SRobert Mustacchiand
78*71815ce7SRobert Mustacchi.Fa low
79*71815ce7SRobert Mustacchidescribe an inclusive range of bits
80*71815ce7SRobert Mustacchi.Po
81*71815ce7SRobert Mustacchi.Pf [ Fa low ,
82*71815ce7SRobert Mustacchi.Fa high ]
83*71815ce7SRobert Mustacchi.Pc
84*71815ce7SRobert Mustacchito extract from
85*71815ce7SRobert Mustacchi.Fa value .
86*71815ce7SRobert MustacchiThe extracted bits are all shifted right such that the resulting value
87*71815ce7SRobert Mustacchistarts at bit 0
88*71815ce7SRobert Mustacchi.Po that is, shifted over by
89*71815ce7SRobert Mustacchi.Fa low
90*71815ce7SRobert Mustacchi.Pc .
91*71815ce7SRobert Mustacchi.Pp
92*71815ce7SRobert MustacchiEach of the variants here operates on a specifically sized integer.
93*71815ce7SRobert Mustacchi.Fa high
94*71815ce7SRobert Mustacchiand
95*71815ce7SRobert Mustacchi.Fa low
96*71815ce7SRobert Mustacchimust fit within the bit range that the integer implies.
97*71815ce7SRobert MustacchiFor example, the valid range for
98*71815ce7SRobert Mustacchi.Fa bitx32
99*71815ce7SRobert Mustacchiis from 0 to 31.
100*71815ce7SRobert Mustacchi.Fa high
101*71815ce7SRobert Mustacchimust not be less than
102*71815ce7SRobert Mustacchi.Fa low .
103*71815ce7SRobert Mustacchi.Sh CONTEXT
104*71815ce7SRobert MustacchiThese functions may be called in all contexts,
105*71815ce7SRobert Mustacchi.Sy user ,
106*71815ce7SRobert Mustacchi.Sy kernel ,
107*71815ce7SRobert Mustacchiand
108*71815ce7SRobert Mustacchi.Sy interrupt .
109*71815ce7SRobert Mustacchi.Sh RETURN VALUES
110*71815ce7SRobert MustacchiUpon successful completion, the
111*71815ce7SRobert Mustacchi.Fn bitx8 ,
112*71815ce7SRobert Mustacchi.Fn bitx16 ,
113*71815ce7SRobert Mustacchi.Fn bitx32 ,
114*71815ce7SRobert Mustacchiand
115*71815ce7SRobert Mustacchi.Fn bitx64
116*71815ce7SRobert Mustacchifunctions all return the indicated portion of
117*71815ce7SRobert Mustacchi.Fa val .
118*71815ce7SRobert Mustacchi.Sh SEE ALSO
119*71815ce7SRobert Mustacchi.Xr bitdel64 9F ,
120*71815ce7SRobert Mustacchi.Xr bitset64 9F
121