.. | .. |
---|
34 | 34 | * bits 0-15: vlen (e.g. # of struct's members) |
---|
35 | 35 | * bits 16-23: unused |
---|
36 | 36 | * bits 24-27: kind (e.g. int, ptr, array...etc) |
---|
37 | | - * bits 28-31: unused |
---|
| 37 | + * bits 28-30: unused |
---|
| 38 | + * bit 31: kind_flag, currently used by |
---|
| 39 | + * struct, union and fwd |
---|
38 | 40 | */ |
---|
39 | 41 | __u32 info; |
---|
40 | | - /* "size" is used by INT, ENUM, STRUCT and UNION. |
---|
| 42 | + /* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC. |
---|
41 | 43 | * "size" tells the size of the type it is describing. |
---|
42 | 44 | * |
---|
43 | | - * "type" is used by PTR, TYPEDEF, VOLATILE, CONST and RESTRICT. |
---|
| 45 | + * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT, |
---|
| 46 | + * FUNC, FUNC_PROTO and VAR. |
---|
44 | 47 | * "type" is a type_id referring to another type. |
---|
45 | 48 | */ |
---|
46 | 49 | union { |
---|
.. | .. |
---|
51 | 54 | |
---|
52 | 55 | #define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f) |
---|
53 | 56 | #define BTF_INFO_VLEN(info) ((info) & 0xffff) |
---|
| 57 | +#define BTF_INFO_KFLAG(info) ((info) >> 31) |
---|
54 | 58 | |
---|
55 | 59 | #define BTF_KIND_UNKN 0 /* Unknown */ |
---|
56 | 60 | #define BTF_KIND_INT 1 /* Integer */ |
---|
.. | .. |
---|
64 | 68 | #define BTF_KIND_VOLATILE 9 /* Volatile */ |
---|
65 | 69 | #define BTF_KIND_CONST 10 /* Const */ |
---|
66 | 70 | #define BTF_KIND_RESTRICT 11 /* Restrict */ |
---|
67 | | -#define BTF_KIND_MAX 11 |
---|
68 | | -#define NR_BTF_KINDS 12 |
---|
| 71 | +#define BTF_KIND_FUNC 12 /* Function */ |
---|
| 72 | +#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */ |
---|
| 73 | +#define BTF_KIND_VAR 14 /* Variable */ |
---|
| 74 | +#define BTF_KIND_DATASEC 15 /* Section */ |
---|
| 75 | +#define BTF_KIND_MAX BTF_KIND_DATASEC |
---|
| 76 | +#define NR_BTF_KINDS (BTF_KIND_MAX + 1) |
---|
69 | 77 | |
---|
70 | 78 | /* For some specific BTF_KIND, "struct btf_type" is immediately |
---|
71 | 79 | * followed by extra data. |
---|
.. | .. |
---|
75 | 83 | * is the 32 bits arrangement: |
---|
76 | 84 | */ |
---|
77 | 85 | #define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) |
---|
78 | | -#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) |
---|
| 86 | +#define BTF_INT_OFFSET(VAL) (((VAL) & 0x00ff0000) >> 16) |
---|
79 | 87 | #define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff) |
---|
80 | 88 | |
---|
81 | 89 | /* Attributes stored in the BTF_INT_ENCODING */ |
---|
.. | .. |
---|
107 | 115 | struct btf_member { |
---|
108 | 116 | __u32 name_off; |
---|
109 | 117 | __u32 type; |
---|
110 | | - __u32 offset; /* offset in bits */ |
---|
| 118 | + /* If the type info kind_flag is set, the btf_member offset |
---|
| 119 | + * contains both member bitfield size and bit offset. The |
---|
| 120 | + * bitfield size is set for bitfield members. If the type |
---|
| 121 | + * info kind_flag is not set, the offset contains only bit |
---|
| 122 | + * offset. |
---|
| 123 | + */ |
---|
| 124 | + __u32 offset; |
---|
| 125 | +}; |
---|
| 126 | + |
---|
| 127 | +/* If the struct/union type info kind_flag is set, the |
---|
| 128 | + * following two macros are used to access bitfield_size |
---|
| 129 | + * and bit_offset from btf_member.offset. |
---|
| 130 | + */ |
---|
| 131 | +#define BTF_MEMBER_BITFIELD_SIZE(val) ((val) >> 24) |
---|
| 132 | +#define BTF_MEMBER_BIT_OFFSET(val) ((val) & 0xffffff) |
---|
| 133 | + |
---|
| 134 | +/* BTF_KIND_FUNC_PROTO is followed by multiple "struct btf_param". |
---|
| 135 | + * The exact number of btf_param is stored in the vlen (of the |
---|
| 136 | + * info in "struct btf_type"). |
---|
| 137 | + */ |
---|
| 138 | +struct btf_param { |
---|
| 139 | + __u32 name_off; |
---|
| 140 | + __u32 type; |
---|
| 141 | +}; |
---|
| 142 | + |
---|
| 143 | +enum { |
---|
| 144 | + BTF_VAR_STATIC = 0, |
---|
| 145 | + BTF_VAR_GLOBAL_ALLOCATED = 1, |
---|
| 146 | + BTF_VAR_GLOBAL_EXTERN = 2, |
---|
| 147 | +}; |
---|
| 148 | + |
---|
| 149 | +enum btf_func_linkage { |
---|
| 150 | + BTF_FUNC_STATIC = 0, |
---|
| 151 | + BTF_FUNC_GLOBAL = 1, |
---|
| 152 | + BTF_FUNC_EXTERN = 2, |
---|
| 153 | +}; |
---|
| 154 | + |
---|
| 155 | +/* BTF_KIND_VAR is followed by a single "struct btf_var" to describe |
---|
| 156 | + * additional information related to the variable such as its linkage. |
---|
| 157 | + */ |
---|
| 158 | +struct btf_var { |
---|
| 159 | + __u32 linkage; |
---|
| 160 | +}; |
---|
| 161 | + |
---|
| 162 | +/* BTF_KIND_DATASEC is followed by multiple "struct btf_var_secinfo" |
---|
| 163 | + * to describe all BTF_KIND_VAR types it contains along with it's |
---|
| 164 | + * in-section offset as well as size. |
---|
| 165 | + */ |
---|
| 166 | +struct btf_var_secinfo { |
---|
| 167 | + __u32 type; |
---|
| 168 | + __u32 offset; |
---|
| 169 | + __u32 size; |
---|
111 | 170 | }; |
---|
112 | 171 | |
---|
113 | 172 | #endif /* _UAPI__LINUX_BTF_H__ */ |
---|