• Home
  • Raw
  • Download

Lines Matching +full:1 +full:- +full:of +full:- +full:4

6 -----------------
8 When working with hardware, one has to choose between several approaches of
10 One can memory-map a pointer to a carefully crafted struct over the hardware
18 (sometimes even 64 bit ones). This creates the inconvenience of having to
19 define "high" and "low" portions of register fields within the struct.
21 required fields by shifting the appropriate number of bits. But this would
23 were performed byte-by-byte. Also the code can easily get cluttered, and the
24 high-level idea might get lost among the many bit shifts required.
25 Many drivers take the bit-shifting approach and then attempt to reduce the
30 ------------
34 - Packing a CPU-usable number into a memory buffer (with hardware
36 - Unpacking a memory buffer (which has hardware constraints/quirks)
37 into a CPU-usable number.
43 The basic unit of these API functions is the u64. From the CPU's
44 perspective, bit 63 always means bit offset 7 of byte 7, albeit only
47 The following examples cover the memory layout of a packed u64 field.
48 The byte offsets in the packed buffer are always implicitly 0, 1, ... 7.
51 1. Normally (no quirks), we would do it like this:
56 7 6 5 4
57 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
58 3 2 1 0
60 That is, the MSByte (7) of the CPU-usable u64 sits at memory offset 0, and the
61 LSByte (0) of the u64 sits at memory offset 7.
72 7 6 5 4
73 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7
74 3 2 1 0
85 4 5 6 7
86 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24
87 0 1 2 3
90 byte from each 4-byte word is placed at its mirrored position compared to
91 the boundary of that word.
93 4. If QUIRK_MSB_ON_THE_RIGHT and QUIRK_LITTLE_ENDIAN are both set, we do it
99 4 5 6 7
100 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
101 0 1 2 3
108 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
109 3 2 1 0
111 7 6 5 4
114 4 bytes correspond to the least significant 4-byte word, next 4 bytes to
115 the more significant 4-byte word.
123 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7
124 3 2 1 0
126 7 6 5 4
134 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24
135 0 1 2 3
137 4 5 6 7
145 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
146 0 1 2 3
148 4 5 6 7
151 We always think of our offsets as if there were no quirk, and we translate
155 ------------
157 Drivers that opt to use this API first need to identify which of the above 3
158 quirk combinations (for a total of 8) match what the hardware documentation
160 xxx_packing() that calls it using the proper QUIRK_* one-hot bits set.
162 The packing() function returns an int-encoded error code, which protects the