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