paul@181 | 1 | /* |
paul@181 | 2 | * Base types used by various other types. |
paul@181 | 3 | * |
paul@330 | 4 | * Copyright (C) 2019, 2021, 2022 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@181 | 42 | /* Types and values for notification. */ |
paul@181 | 43 | |
paul@410 | 44 | typedef l4_uint64_t notify_flags_t; |
paul@181 | 45 | |
paul@181 | 46 | enum notify_flags |
paul@181 | 47 | { |
paul@211 | 48 | NOTIFY_CONTENT_AVAILABLE = 1, /* reading files and pipes */ |
paul@211 | 49 | NOTIFY_SPACE_AVAILABLE = 2, /* writing pipes */ |
paul@211 | 50 | NOTIFY_PEER_CLOSED = 4, /* closing files and pipes */ |
paul@211 | 51 | NOTIFY_FILE_OPENED = 8, /* opening files in directories */ |
paul@181 | 52 | }; |
paul@181 | 53 | |
paul@181 | 54 | /* Filesystem object properties. */ |
paul@181 | 55 | |
paul@181 | 56 | typedef unsigned long object_flags_t; |
paul@181 | 57 | |
paul@181 | 58 | enum object_flags |
paul@181 | 59 | { |
paul@181 | 60 | OBJECT_SUPPORTS_MMAP = 1, |
paul@181 | 61 | OBJECT_HAS_SIZE = 2 |
paul@181 | 62 | }; |
paul@181 | 63 | |
paul@330 | 64 | /* Memory mapping protection flags compatible with sys/mman.h (and incompatible |
paul@330 | 65 | with comparable L4Re flags). */ |
paul@330 | 66 | |
paul@330 | 67 | typedef unsigned long prot_t; |
paul@330 | 68 | |
paul@330 | 69 | enum prot_flags |
paul@330 | 70 | { |
paul@330 | 71 | PROT_NONE = 0, |
paul@330 | 72 | PROT_READ = 1, |
paul@330 | 73 | PROT_WRITE = 2, |
paul@330 | 74 | PROT_EXEC = 4 |
paul@330 | 75 | }; |
paul@330 | 76 | |
paul@181 | 77 | /* Equivalent types are defined in sys/types.h typically. In newlib, they are |
paul@181 | 78 | defined in sys/_types.h if not defined elsewhere (such as in |
paul@269 | 79 | machine/_types.h). |
paul@181 | 80 | |
paul@269 | 81 | These types are intended for IPC, permitting different parties to employ |
paul@269 | 82 | different library implementations where these types may be different. |
paul@269 | 83 | */ |
paul@269 | 84 | |
paul@269 | 85 | typedef unsigned long int sys_dev_t; /* device number */ |
paul@269 | 86 | typedef unsigned long int sys_ino_t; /* inode number */ |
paul@181 | 87 | typedef unsigned int sys_mode_t; /* file permissions */ |
paul@269 | 88 | typedef unsigned long int sys_nlink_t; /* link count */ |
paul@181 | 89 | typedef unsigned int sys_uid_t; /* user identifier */ |
paul@181 | 90 | typedef unsigned int sys_gid_t; /* group identifier */ |
paul@181 | 91 | typedef long sys_off_t; /* file offset/position */ |
paul@181 | 92 | typedef long sys_blksize_t; /* input/output block size */ |
paul@181 | 93 | typedef long sys_blkcnt_t; /* number of 512-byte blocks */ |
paul@181 | 94 | |
paul@271 | 95 | /* Conversions. */ |
paul@271 | 96 | |
paul@271 | 97 | #define systypes_from_sys_mode(mode) \ |
paul@271 | 98 | ((mode_t) mode) |
paul@271 | 99 | |
paul@271 | 100 | #define systypes_to_sys_mode(mode) \ |
paul@271 | 101 | ((sys_mode_t) mode) |
paul@271 | 102 | |
paul@181 | 103 | /* Factory types for L4 factory interface invocations. */ |
paul@181 | 104 | |
paul@181 | 105 | ipc_varg_typedef(sys_mode_t, ipc_varg_sys_mode_t) |
paul@181 | 106 | ipc_varg_typedef(sys_uid_t, ipc_varg_sys_uid_t) |
paul@181 | 107 | ipc_varg_typedef(sys_gid_t, ipc_varg_sys_gid_t) |
paul@181 | 108 | |
paul@181 | 109 | #define ipc_varg_sys_mode(value) \ |
paul@181 | 110 | ipc_varg_umword(ipc_varg_sys_mode_t, value) |
paul@181 | 111 | |
paul@181 | 112 | #define ipc_varg_sys_uid(value) \ |
paul@181 | 113 | ipc_varg_umword(ipc_varg_sys_uid_t, value) |
paul@181 | 114 | |
paul@181 | 115 | #define ipc_varg_sys_gid(value) \ |
paul@181 | 116 | ipc_varg_umword(ipc_varg_sys_gid_t, value) |
paul@181 | 117 | |
paul@181 | 118 | EXTERN_C_END |
paul@181 | 119 | |
paul@181 | 120 | // vim: tabstop=2 expandtab shiftwidth=2 |