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