aboutsummaryrefslogtreecommitdiffstats
path: root/include/boardobj/boardobjgrpmask.h
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2023-06-28 18:24:25 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2023-06-28 18:24:25 -0400
commit01e6fac4d61fdd7fff5433942ec93fc2ea1e4df1 (patch)
tree4ef34501728a087be24f4ba0af90f91486bf780b /include/boardobj/boardobjgrpmask.h
parent306a03d18b305e4e573be3b2931978fa10679eb9 (diff)
Include nvgpu headers
These are needed to build on NVIDIA's Jetson boards for the time being. Only a couple structs are required, so it should be fairly easy to remove this dependency at some point in the future.
Diffstat (limited to 'include/boardobj/boardobjgrpmask.h')
-rw-r--r--include/boardobj/boardobjgrpmask.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/include/boardobj/boardobjgrpmask.h b/include/boardobj/boardobjgrpmask.h
new file mode 100644
index 0000000..f4ed0af
--- /dev/null
+++ b/include/boardobj/boardobjgrpmask.h
@@ -0,0 +1,119 @@
1/*
2 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef NVGPU_BOARDOBJGRPMASK_H
24#define NVGPU_BOARDOBJGRPMASK_H
25
26#include "ctrl/ctrlboardobj.h"
27
28
29/*
30* Board Object Group Mask super-structure.
31* Used to unify access to all BOARDOBJGRPMASK_E** child classes
32*/
33struct boardobjgrpmask {
34 /* Number of bits supported by the mask */
35 u8 bitcount;
36 /* Number of 32-bit words required to store all @ref bitCount bits */
37 u8 maskdatacount;
38 /*
39 * Bit-mask of used-bits within last 32-bit word. Used to
40 * normalize data
41 */
42 u32 lastmaskfilter;
43 /*
44 * Start of the array of 32-bit words representing the bit-mask
45 * Must be the last element of the structure.
46 */
47 u32 data[CTRL_BOARDOBJGRP_MASK_ARRAY_START_SIZE];
48};
49
50struct boardobjgrpmask_e32 {
51 /*
52 * BOARDOBJGRPMASK super-class. Must be the first element of the
53 * structure.
54 */
55 struct boardobjgrpmask super;
56 /*u32 data_e32[1]; */
57};
58
59struct boardobjgrpmask_e255 {
60 /*
61 * BOARDOBJGRPMASK super-class. Must be the first element of the
62 * structure.
63 */
64 struct boardobjgrpmask super;
65 u32 data_e255[254];
66};
67
68/* Init and I/O operations.*/
69u32 boardobjgrpmask_init(struct boardobjgrpmask *mask, u8 bitsize,
70 struct ctrl_boardobjgrp_mask *extmask);
71u32 boardobjgrpmask_import(struct boardobjgrpmask *mask, u8 bitsize,
72 struct ctrl_boardobjgrp_mask *extmask);
73u32 boardobjgrpmask_export(struct boardobjgrpmask *mask, u8 bitsize,
74 struct ctrl_boardobjgrp_mask *extmask);
75
76/* Operations on all bits of a single mask.*/
77u32 boardobjgrpmask_clr(struct boardobjgrpmask *mask);
78u32 boardobjgrpmask_set(struct boardobjgrpmask *mask);
79u32 boardobjgrpmask_inv(struct boardobjgrpmask *mask);
80bool boardobjgrpmask_iszero(struct boardobjgrpmask *mask);
81u8 boardobjgrpmask_bitsetcount(struct boardobjgrpmask *mask);
82u8 boardobjgrpmask_bitidxlowest(struct boardobjgrpmask *mask);
83u8 boardobjgrpmask_bitidxhighest(struct boardobjgrpmask *mask);
84
85/* Operations on a single bit of a single mask */
86int boardobjgrpmask_bitclr(struct boardobjgrpmask *mask, u8 bitidx);
87int boardobjgrpmask_bitset(struct boardobjgrpmask *mask, u8 bitidx);
88u32 boardobjgrpmask_bitinv(struct boardobjgrpmask *mask, u8 bitidx);
89bool boardobjgrpmask_bitget(struct boardobjgrpmask *mask, u8 bitidx);
90
91/* Operations on a multiple masks */
92u32 boardobjgrpmask_and(struct boardobjgrpmask *dst,
93 struct boardobjgrpmask *op1,
94 struct boardobjgrpmask *op2);
95u32 boardobjgrpmask_or(struct boardobjgrpmask *dst, struct boardobjgrpmask *op1,
96 struct boardobjgrpmask *op2);
97u32 boardobjgrpmask_xor(struct boardobjgrpmask *dst,
98 struct boardobjgrpmask *op1,
99 struct boardobjgrpmask *op2);
100
101/* Special interfaces */
102u32 boardobjgrpmask_copy(struct boardobjgrpmask *dst,
103 struct boardobjgrpmask *src);
104bool boardobjgrpmask_sizeeq(struct boardobjgrpmask *op1,
105 struct boardobjgrpmask *op2);
106bool boardobjgrpmask_issubset(struct boardobjgrpmask *op1,
107 struct boardobjgrpmask *op2);
108
109/* init boardobjgrpmask_e32 structure */
110#define boardobjgrpmask_e32_init(pmaske32, pextmask) \
111 boardobjgrpmask_init(&(pmaske32)->super, \
112 CTRL_BOARDOBJGRP_E32_MAX_OBJECTS, (pextmask))
113
114/* init boardobjgrpmask_e255 structure */
115#define boardobjgrpmask_e255_init(pmaske255, pextmask) \
116 boardobjgrpmask_init(&(pmaske255)->super, \
117 CTRL_BOARDOBJGRP_E255_MAX_OBJECTS, (pextmask))
118
119#endif /* NVGPU_BOARDOBJGRPMASK_H */