1 /* 2 * Factory-related data type macros. 3 * 4 * Copyright (C) 2019, 2023 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <systypes/base.h> 25 26 27 28 EXTERN_C_BEGIN 29 30 /* Type and value constructor macros. */ 31 32 #define ipc_varg_typedef(value_type, type) \ 33 typedef struct { l4_umword_t tag; value_type value; } type; 34 35 #define ipc_varg_mword(type, value) \ 36 ((type) {L4_VARG_TYPE_MWORD | (sizeof(l4_mword_t) << 16), value}) 37 38 #define ipc_varg_umword(type, value) \ 39 ((type) {L4_VARG_TYPE_UMWORD | (sizeof(l4_umword_t) << 16), value}) 40 41 /* Tag inspection macros. */ 42 43 #define ipc_varg_size(tag) ((tag >> 16) & 0xff) 44 45 #define ipc_varg_type(tag) (tag & 0xff) 46 47 #define ipc_varg_word(tag) \ 48 ((ipc_varg_type(tag) == L4_VARG_TYPE_MWORD) || \ 49 (ipc_varg_type(tag) == L4_VARG_TYPE_UMWORD)) 50 51 /* Convenience macro for creating a type name, not necessarily employed by all 52 types. */ 53 54 #define ipc_varg(type) ipc_varg_##type##_t 55 56 57 58 /* Supporting data types for factory invocations. */ 59 60 typedef unsigned long unsigned_long; 61 62 ipc_varg_typedef(long, ipc_varg(long)) 63 ipc_varg_typedef(unsigned_long, ipc_varg(unsigned_long)) 64 65 #define ipc_varg_long(value) \ 66 ipc_varg_mword(ipc_varg(long), value) 67 68 #define ipc_varg_unsigned_long(value) \ 69 ipc_varg_umword(ipc_varg(unsigned_long), value) 70 71 72 73 /* Additional, specific factory types for L4 factory interface invocations. */ 74 75 ipc_varg_typedef(sys_mode_t, ipc_varg_sys_mode_t) 76 ipc_varg_typedef(sys_uid_t, ipc_varg_sys_uid_t) 77 ipc_varg_typedef(sys_gid_t, ipc_varg_sys_gid_t) 78 79 #define ipc_varg_sys_mode(value) \ 80 ipc_varg_umword(ipc_varg_sys_mode_t, value) 81 82 #define ipc_varg_sys_uid(value) \ 83 ipc_varg_umword(ipc_varg_sys_uid_t, value) 84 85 #define ipc_varg_sys_gid(value) \ 86 ipc_varg_umword(ipc_varg_sys_gid_t, value) 87 88 EXTERN_C_END