1 /* 2 * Base types used by various other types. 3 * 4 * Copyright (C) 2019, 2021, 2022, 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 <l4/sys/compiler.h> 25 26 #include <systypes/factory.h> 27 28 EXTERN_C_BEGIN 29 30 /* Types for file access (access flags, offsets) and IPC operations. */ 31 32 typedef l4_uint64_t flags_t; /* see systypes/fcntl.h */ 33 typedef l4_uint64_t offset_t; 34 typedef l4_addr_t address_t; /* unsigned long */ 35 36 /* Dataspace mapping flags. 37 See: pkg/l4re-core/l4re_c/include/dataspace.h */ 38 39 typedef l4_uint64_t map_address_t; 40 typedef unsigned long map_flags_t; 41 42 /* Conversions. */ 43 44 map_flags_t map_flags_for_fault(l4_umword_t flags); 45 46 /* Types and values for notification. */ 47 48 typedef l4_uint64_t notify_flags_t; 49 50 typedef struct 51 { 52 unsigned long sig, val; /* signal-specific values */ 53 54 } notify_values_t; 55 56 #define NOTIFY_VALUES_NULL ((notify_values_t) {0, 0}) 57 58 enum notify_flags 59 { 60 NOTIFY_CONTENT_AVAILABLE = 0x001, /* reading files and pipes */ 61 NOTIFY_SPACE_AVAILABLE = 0x002, /* writing pipes */ 62 NOTIFY_PEER_CLOSED = 0x004, /* closing files and pipes */ 63 NOTIFY_FILE_OPENED = 0x008, /* opening files in directories */ 64 NOTIFY_TASK_SIGNAL = 0x100, /* signal from task */ 65 }; 66 67 /* Notifiable object types. */ 68 69 typedef struct 70 { 71 l4_cap_idx_t ref; 72 73 } notifiable_base_t; 74 75 typedef struct 76 { 77 notifiable_base_t *base; /* access to the specific object */ 78 notify_flags_t notifications; /* essential notifications */ 79 notify_values_t values; /* signal-specific values */ 80 81 } notifiable_t; 82 83 /* Filesystem object properties. */ 84 85 typedef unsigned long object_flags_t; 86 87 enum object_flags 88 { 89 OBJECT_SUPPORTS_MMAP = 1, 90 OBJECT_HAS_SIZE = 2 91 }; 92 93 /* Memory mapping protection flags compatible with sys/mman.h (and incompatible 94 with comparable L4Re flags). */ 95 96 typedef unsigned long prot_t; 97 98 enum prot_flags 99 { 100 PROT_NONE = 0, 101 PROT_READ = 1, 102 PROT_WRITE = 2, 103 PROT_EXEC = 4 104 }; 105 106 /* Equivalent types are defined in sys/types.h typically. In newlib, they are 107 defined in sys/_types.h if not defined elsewhere (such as in 108 machine/_types.h). In uclibc, the following file is informative: 109 110 pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/bits/types.h 111 112 These types are intended for IPC, permitting different parties to employ 113 different library implementations where these types may be different. 114 */ 115 116 typedef l4_uint64_t sys_dev_t; /* device number */ 117 typedef unsigned long int sys_ino_t; /* inode number */ 118 typedef unsigned int sys_mode_t; /* file permissions */ 119 typedef unsigned long int sys_nlink_t; /* link count */ 120 typedef unsigned int sys_uid_t; /* user identifier */ 121 typedef unsigned int sys_gid_t; /* group identifier */ 122 typedef long sys_off_t; /* file offset/position */ 123 typedef long sys_blksize_t; /* input/output block size */ 124 typedef long sys_blkcnt_t; /* number of 512-byte blocks */ 125 126 /* Conversions. */ 127 128 #define systypes_from_sys_mode(mode) \ 129 ((mode_t) mode) 130 131 #define systypes_to_sys_mode(mode) \ 132 ((sys_mode_t) mode) 133 134 /* Factory types for L4 factory interface invocations. */ 135 136 ipc_varg_typedef(sys_mode_t, ipc_varg_sys_mode_t) 137 ipc_varg_typedef(sys_uid_t, ipc_varg_sys_uid_t) 138 ipc_varg_typedef(sys_gid_t, ipc_varg_sys_gid_t) 139 140 #define ipc_varg_sys_mode(value) \ 141 ipc_varg_umword(ipc_varg_sys_mode_t, value) 142 143 #define ipc_varg_sys_uid(value) \ 144 ipc_varg_umword(ipc_varg_sys_uid_t, value) 145 146 #define ipc_varg_sys_gid(value) \ 147 ipc_varg_umword(ipc_varg_sys_gid_t, value) 148 149 EXTERN_C_END 150 151 // vim: tabstop=2 expandtab shiftwidth=2