paul@181 | 1 | /* |
paul@181 | 2 | * Base types used by various other types. |
paul@181 | 3 | * |
paul@479 | 4 | * Copyright (C) 2019, 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk> |
paul@181 | 5 | * |
paul@181 | 6 | * This program is free software; you can redistribute it and/or |
paul@181 | 7 | * modify it under the terms of the GNU General Public License as |
paul@181 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@181 | 9 | * the License, or (at your option) any later version. |
paul@181 | 10 | * |
paul@181 | 11 | * This program is distributed in the hope that it will be useful, |
paul@181 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@181 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@181 | 14 | * GNU General Public License for more details. |
paul@181 | 15 | * |
paul@181 | 16 | * You should have received a copy of the GNU General Public License |
paul@181 | 17 | * along with this program; if not, write to the Free Software |
paul@181 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@181 | 19 | * Boston, MA 02110-1301, USA |
paul@181 | 20 | */ |
paul@181 | 21 | |
paul@181 | 22 | #pragma once |
paul@181 | 23 | |
paul@181 | 24 | #include <l4/sys/compiler.h> |
paul@181 | 25 | |
paul@181 | 26 | #include <systypes/factory.h> |
paul@181 | 27 | |
paul@181 | 28 | EXTERN_C_BEGIN |
paul@181 | 29 | |
paul@181 | 30 | /* Types for file access (access flags, offsets) and IPC operations. */ |
paul@181 | 31 | |
paul@410 | 32 | typedef l4_uint64_t flags_t; /* see systypes/fcntl.h */ |
paul@410 | 33 | typedef l4_uint64_t offset_t; |
paul@181 | 34 | typedef l4_addr_t address_t; /* unsigned long */ |
paul@181 | 35 | |
paul@181 | 36 | /* Dataspace mapping flags. |
paul@181 | 37 | See: pkg/l4re-core/l4re_c/include/dataspace.h */ |
paul@181 | 38 | |
paul@410 | 39 | typedef l4_uint64_t map_address_t; |
paul@410 | 40 | typedef unsigned long map_flags_t; |
paul@181 | 41 | |
paul@472 | 42 | /* Conversions. */ |
paul@472 | 43 | |
paul@472 | 44 | map_flags_t map_flags_for_fault(l4_umword_t flags); |
paul@472 | 45 | |
paul@181 | 46 | /* Types and values for notification. */ |
paul@181 | 47 | |
paul@410 | 48 | typedef l4_uint64_t notify_flags_t; |
paul@181 | 49 | |
paul@481 | 50 | typedef struct |
paul@481 | 51 | { |
paul@481 | 52 | unsigned long sig, val; /* signal-specific values */ |
paul@481 | 53 | |
paul@481 | 54 | } notify_values_t; |
paul@481 | 55 | |
paul@481 | 56 | #define NOTIFY_VALUES_NULL ((notify_values_t) {0, 0}) |
paul@481 | 57 | |
paul@181 | 58 | enum notify_flags |
paul@181 | 59 | { |
paul@479 | 60 | NOTIFY_CONTENT_AVAILABLE = 0x001, /* reading files and pipes */ |
paul@479 | 61 | NOTIFY_SPACE_AVAILABLE = 0x002, /* writing pipes */ |
paul@479 | 62 | NOTIFY_PEER_CLOSED = 0x004, /* closing files and pipes */ |
paul@479 | 63 | NOTIFY_FILE_OPENED = 0x008, /* opening files in directories */ |
paul@479 | 64 | NOTIFY_TASK_SIGNAL = 0x100, /* signal from task */ |
paul@181 | 65 | }; |
paul@181 | 66 | |
paul@479 | 67 | /* Notifiable object types. */ |
paul@479 | 68 | |
paul@479 | 69 | typedef struct |
paul@479 | 70 | { |
paul@479 | 71 | l4_cap_idx_t ref; |
paul@479 | 72 | |
paul@479 | 73 | } notifiable_base_t; |
paul@479 | 74 | |
paul@479 | 75 | typedef struct |
paul@479 | 76 | { |
paul@479 | 77 | notifiable_base_t *base; /* access to the specific object */ |
paul@481 | 78 | notify_flags_t notifications; /* essential notifications */ |
paul@481 | 79 | notify_values_t values; /* signal-specific values */ |
paul@555 | 80 | void *handler; /* associated notification handler */ |
paul@479 | 81 | |
paul@479 | 82 | } notifiable_t; |
paul@479 | 83 | |
paul@181 | 84 | /* Filesystem object properties. */ |
paul@181 | 85 | |
paul@181 | 86 | typedef unsigned long object_flags_t; |
paul@181 | 87 | |
paul@181 | 88 | enum object_flags |
paul@181 | 89 | { |
paul@181 | 90 | OBJECT_SUPPORTS_MMAP = 1, |
paul@181 | 91 | OBJECT_HAS_SIZE = 2 |
paul@181 | 92 | }; |
paul@181 | 93 | |
paul@330 | 94 | /* Memory mapping protection flags compatible with sys/mman.h (and incompatible |
paul@330 | 95 | with comparable L4Re flags). */ |
paul@330 | 96 | |
paul@330 | 97 | typedef unsigned long prot_t; |
paul@330 | 98 | |
paul@330 | 99 | enum prot_flags |
paul@330 | 100 | { |
paul@330 | 101 | PROT_NONE = 0, |
paul@330 | 102 | PROT_READ = 1, |
paul@330 | 103 | PROT_WRITE = 2, |
paul@330 | 104 | PROT_EXEC = 4 |
paul@330 | 105 | }; |
paul@330 | 106 | |
paul@181 | 107 | /* Equivalent types are defined in sys/types.h typically. In newlib, they are |
paul@181 | 108 | defined in sys/_types.h if not defined elsewhere (such as in |
paul@463 | 109 | machine/_types.h). In uclibc, the following file is informative: |
paul@463 | 110 | |
paul@463 | 111 | pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/bits/types.h |
paul@181 | 112 | |
paul@269 | 113 | These types are intended for IPC, permitting different parties to employ |
paul@269 | 114 | different library implementations where these types may be different. |
paul@269 | 115 | */ |
paul@269 | 116 | |
paul@463 | 117 | typedef l4_uint64_t sys_dev_t; /* device number */ |
paul@269 | 118 | typedef unsigned long int sys_ino_t; /* inode number */ |
paul@181 | 119 | typedef unsigned int sys_mode_t; /* file permissions */ |
paul@269 | 120 | typedef unsigned long int sys_nlink_t; /* link count */ |
paul@181 | 121 | typedef unsigned int sys_uid_t; /* user identifier */ |
paul@181 | 122 | typedef unsigned int sys_gid_t; /* group identifier */ |
paul@181 | 123 | typedef long sys_off_t; /* file offset/position */ |
paul@181 | 124 | typedef long sys_blksize_t; /* input/output block size */ |
paul@181 | 125 | typedef long sys_blkcnt_t; /* number of 512-byte blocks */ |
paul@181 | 126 | |
paul@271 | 127 | /* Conversions. */ |
paul@271 | 128 | |
paul@271 | 129 | #define systypes_from_sys_mode(mode) \ |
paul@271 | 130 | ((mode_t) mode) |
paul@271 | 131 | |
paul@271 | 132 | #define systypes_to_sys_mode(mode) \ |
paul@271 | 133 | ((sys_mode_t) mode) |
paul@271 | 134 | |
paul@181 | 135 | /* Factory types for L4 factory interface invocations. */ |
paul@181 | 136 | |
paul@181 | 137 | ipc_varg_typedef(sys_mode_t, ipc_varg_sys_mode_t) |
paul@181 | 138 | ipc_varg_typedef(sys_uid_t, ipc_varg_sys_uid_t) |
paul@181 | 139 | ipc_varg_typedef(sys_gid_t, ipc_varg_sys_gid_t) |
paul@181 | 140 | |
paul@181 | 141 | #define ipc_varg_sys_mode(value) \ |
paul@181 | 142 | ipc_varg_umword(ipc_varg_sys_mode_t, value) |
paul@181 | 143 | |
paul@181 | 144 | #define ipc_varg_sys_uid(value) \ |
paul@181 | 145 | ipc_varg_umword(ipc_varg_sys_uid_t, value) |
paul@181 | 146 | |
paul@181 | 147 | #define ipc_varg_sys_gid(value) \ |
paul@181 | 148 | ipc_varg_umword(ipc_varg_sys_gid_t, value) |
paul@181 | 149 | |
paul@181 | 150 | EXTERN_C_END |
paul@181 | 151 | |
paul@181 | 152 | // vim: tabstop=2 expandtab shiftwidth=2 |