make vfs & filesystems use failable copying
[minix3.git] / include / minix / const.h
blob5131e9a00f4437a050e8982d6b697f3180dc40b7
1 #ifndef _MINIX_CONST_H
2 #define _MINIX_CONST_H
4 #include <machine/archconst.h>
6 /* The UNUSED annotation tells the compiler or lint not to complain
7 * about an unused variable or function parameter.
9 * A number of different annotations are used, depending on the
10 * compiler or checker that is looking at the code.
12 * Note that some variants rename the parameter, so if you use
13 * the parameter after all, you'll get a complaint about a missing
14 * variable.
16 * You use it like this:
18 * void foo(int UNUSED(x)){}
21 #ifndef UNUSED
22 #if defined _lint
23 # define UNUSED(v) /*lint -e(715,818)*/ v
24 #elif defined(__GNUC__)
25 # define UNUSED(v) UNUSED_ ## v __attribute((unused))
26 #elif defined __LCLINT__
27 # define UNUSED(v) /*@unused@*/ v
28 #else
29 # define UNUSED(v) _UNUSED_ ## v
30 #endif
31 #endif
33 #define EXTERN extern /* used in *.h files */
35 #define TRUE 1 /* used for turning integers into Booleans */
36 #define FALSE 0 /* used for turning integers into Booleans */
38 #define SUPER_USER ((uid_t) 0) /* uid_t of superuser */
40 #include <sys/null.h> /* NULL Pointer */
42 #define SCPVEC_NR 64 /* max # of entries in a SYS_VSAFECOPY request */
43 #define MAPVEC_NR 64 /* max # of entries in a SYS_VUMAP request */
44 #define NR_IOREQS 64 /* maximum number of entries in an iorequest */
46 #define VUA_READ 0x01 /* for SYS_VUMAP: read access */
47 #define VUA_WRITE 0x02 /* for SYS_VUMAP: write access */
49 /* Message passing constants. */
50 #define MESS_SIZE (sizeof(message)) /* might need usizeof from FS here */
52 /* Memory related constants. */
53 #define SEGMENT_TYPE 0xFF00 /* bit mask to get segment type */
54 #define SEGMENT_INDEX 0x00FF /* bit mask to get segment index */
56 #define PHYS_SEG 0x0400 /* flag indicating entire physical memory */
58 #define LOCAL_VM_SEG 0x1000 /* same as LOCAL_SEG, but with vm lookup */
59 #define MEM_GRANT 3
60 #define VIR_ADDR 1
61 #define VM_D (LOCAL_VM_SEG | VIR_ADDR)
62 #define VM_GRANT (LOCAL_VM_SEG | MEM_GRANT)
64 /* Labels used to disable code sections for different reasons. */
65 #define DEAD_CODE 0 /* unused code in normal configuration */
66 #define FUTURE_CODE 0 /* new code to be activated + tested later */
67 #define TEMP_CODE 1 /* active code to be removed later */
69 /* Miscellaneous */
70 #define BYTE 0377 /* mask for 8 bits */
71 #define READING 0 /* copy data to user */
72 #define WRITING 1 /* copy data from user */
73 #define PEEKING 2 /* retrieve FS data without copying */
74 #define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */
76 /* Memory is allocated in clicks. */
77 #if defined(__i386__) || defined(__arm__)
78 #define CLICK_SIZE 4096 /* unit in which memory is allocated */
79 #define CLICK_SHIFT 12 /* log2 of CLICK_SIZE */
80 #else
81 #error Unsupported arch
82 #endif
84 /* Click alignment macros. */
85 #define CLICK_FLOOR(n) (((vir_bytes)(n) / CLICK_SIZE) * CLICK_SIZE)
86 #define CLICK_CEIL(n) CLICK_FLOOR((vir_bytes)(n) + CLICK_SIZE-1)
88 /* Sizes of memory tables. The boot monitor distinguishes three memory areas,
89 * namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
90 * for DOS MINIX.
92 #define NR_MEMS 16
94 #define CLICK2ABS(v) ((v) << CLICK_SHIFT)
95 #define ABS2CLICK(a) ((a) >> CLICK_SHIFT)
97 /* Flag bits for i_mode in the inode. */
98 #define I_TYPE 0170000 /* this field gives inode type */
99 #define I_UNIX_SOCKET 0140000 /* unix domain socket */
100 #define I_SYMBOLIC_LINK 0120000 /* file is a symbolic link */
101 #define I_REGULAR 0100000 /* regular file, not dir or special */
102 #define I_BLOCK_SPECIAL 0060000 /* block special file */
103 #define I_DIRECTORY 0040000 /* file is a directory */
104 #define I_CHAR_SPECIAL 0020000 /* character special file */
105 #define I_NAMED_PIPE 0010000 /* named pipe (FIFO) */
106 #define I_SET_UID_BIT 0004000 /* set effective uid_t on exec */
107 #define I_SET_GID_BIT 0002000 /* set effective gid_t on exec */
108 #define I_SET_STCKY_BIT 0001000 /* sticky bit */
109 #define ALL_MODES 0007777 /* all bits for user, group and others */
110 #define RWX_MODES 0000777 /* mode bits for RWX only */
111 #define R_BIT 0000004 /* Rwx protection bit */
112 #define W_BIT 0000002 /* rWx protection bit */
113 #define X_BIT 0000001 /* rwX protection bit */
114 #define I_NOT_ALLOC 0000000 /* this inode is free */
116 /* Some limits. */
117 #define MAX_INODE_NR ((ino_t) 037777777777) /* largest inode number */
118 #define MAX_FILE_POS ((off_t) 0x7FFFFFFF) /* largest legal file offset */
119 #define UMAX_FILE_POS ((unsigned) 0x7FFFFFFF) /* largest legal file offset */
121 #define MAX_SYM_LOOPS 8 /* how many symbolic links are recursed */
123 #define NO_BLOCK ((block_t) 0) /* absence of a block number */
124 #define NO_ENTRY ((ino_t) 0) /* absence of a dir entry */
125 #define NO_ZONE ((zone_t) 0) /* absence of a zone number */
126 #define NO_DEV ((dev_t) 0) /* absence of a device numb */
127 #define NO_LINK ((nlink_t) 0) /* absence of incoming links */
128 #define INVAL_UID ((uid_t) -1) /* invalid uid value */
129 #define INVAL_GID ((gid_t) -1) /* invalid gid value */
131 #define SERVARNAME "cttyline"
132 #define ARCHVARNAME "arch"
133 #define BOARDVARNAME "board"
134 #define SERBAUDVARNAME "cttybaud"
136 /* Bits for s_flags in the privilege structure. */
137 #define PREEMPTIBLE 0x002 /* kernel tasks are not preemptible */
138 #define BILLABLE 0x004 /* some processes are not billable */
139 #define DYN_PRIV_ID 0x008 /* privilege id assigned dynamically */
141 #define SYS_PROC 0x010 /* system processes have own priv structure */
142 #define CHECK_IO_PORT 0x020 /* check if I/O request is allowed */
143 #define CHECK_IRQ 0x040 /* check if IRQ can be used */
144 #define CHECK_MEM 0x080 /* check if (VM) mem map request is allowed */
145 #define ROOT_SYS_PROC 0x100 /* this is a root system process instance */
146 #define VM_SYS_PROC 0x200 /* this is a vm system process instance */
147 #define LU_SYS_PROC 0x400 /* this is a live updated sys proc instance */
148 #define RST_SYS_PROC 0x800 /* this is a restarted sys proc instance */
150 /* Values for the "verbose" boot monitor variable */
151 #define VERBOSEBOOT_QUIET 0
152 #define VERBOSEBOOT_BASIC 1
153 #define VERBOSEBOOT_EXTRA 2
154 #define VERBOSEBOOT_MAX 3
155 #define VERBOSEBOOTVARNAME "verbose"
157 /* magic value to put in struct proc entries for sanity checks. */
158 #define PMAGIC 0xC0FFEE1
160 /* MINIX_KERNFLAGS flags */
161 #define MKF_I386_INTEL_SYSENTER (1L << 0) /* SYSENTER available and supported */
162 #define MKF_I386_AMD_SYSCALL (1L << 1) /* SYSCALL available and supported */
164 #endif /* _MINIX_CONST_H */