root / lab4 / .minix-src / include / minix / const.h @ 14
History | View | Annotate | Download (7.27 KB)
1 |
#ifndef _MINIX_CONST_H
|
---|---|
2 |
#define _MINIX_CONST_H
|
3 |
|
4 |
#include <machine/archconst.h> |
5 |
|
6 |
/* The UNUSED annotation tells the compiler or lint not to complain
|
7 |
* about an unused variable or function parameter.
|
8 |
*
|
9 |
* A number of different annotations are used, depending on the
|
10 |
* compiler or checker that is looking at the code.
|
11 |
*
|
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.
|
15 |
*
|
16 |
* You use it like this:
|
17 |
*
|
18 |
* void foo(int UNUSED(x)){}
|
19 |
*/
|
20 |
|
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
|
32 |
|
33 |
#ifndef _MINIX_MAGIC
|
34 |
#define __ALIGNED(X) __aligned(X)
|
35 |
#else
|
36 |
#define __ALIGNED(X)
|
37 |
#endif
|
38 |
|
39 |
#define EXTERN extern /* used in *.h files */ |
40 |
|
41 |
#define TRUE 1 /* used for turning integers into Booleans */ |
42 |
#define FALSE 0 /* used for turning integers into Booleans */ |
43 |
|
44 |
#define SUPER_USER ((uid_t) 0) /* uid_t of superuser */ |
45 |
|
46 |
#include <sys/null.h> /* NULL Pointer */ |
47 |
|
48 |
#define SCPVEC_NR 64 /* max # of entries in a SYS_VSAFECOPY request */ |
49 |
#define MAPVEC_NR 64 /* max # of entries in a SYS_VUMAP request */ |
50 |
#define NR_IOREQS 64 /* maximum number of entries in an iorequest */ |
51 |
|
52 |
#define VUA_READ 0x01 /* for SYS_VUMAP: read access */ |
53 |
#define VUA_WRITE 0x02 /* for SYS_VUMAP: write access */ |
54 |
|
55 |
/* Message passing constants. */
|
56 |
#define MESS_SIZE (sizeof(message)) /* might need usizeof from FS here */ |
57 |
|
58 |
/* Memory related constants. */
|
59 |
#define SEGMENT_TYPE 0xFF00 /* bit mask to get segment type */ |
60 |
#define SEGMENT_INDEX 0x00FF /* bit mask to get segment index */ |
61 |
|
62 |
#define PHYS_SEG 0x0400 /* flag indicating entire physical memory */ |
63 |
|
64 |
#define LOCAL_VM_SEG 0x1000 /* same as LOCAL_SEG, but with vm lookup */ |
65 |
#define MEM_GRANT 3 |
66 |
#define VIR_ADDR 1 |
67 |
#define VM_D (LOCAL_VM_SEG | VIR_ADDR)
|
68 |
#define VM_GRANT (LOCAL_VM_SEG | MEM_GRANT)
|
69 |
|
70 |
/* Labels used to disable code sections for different reasons. */
|
71 |
#define DEAD_CODE 0 /* unused code in normal configuration */ |
72 |
#define FUTURE_CODE 0 /* new code to be activated + tested later */ |
73 |
#define TEMP_CODE 1 /* active code to be removed later */ |
74 |
|
75 |
/* Miscellaneous */
|
76 |
#define BYTE 0377 /* mask for 8 bits */ |
77 |
#define READING 0 /* copy data to user */ |
78 |
#define WRITING 1 /* copy data from user */ |
79 |
#define PEEKING 2 /* retrieve FS data without copying */ |
80 |
#define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */ |
81 |
|
82 |
/* Memory is allocated in clicks. */
|
83 |
#if defined(__i386__) || defined(__arm__)
|
84 |
#define CLICK_SIZE 4096 /* unit in which memory is allocated */ |
85 |
#define CLICK_SHIFT 12 /* log2 of CLICK_SIZE */ |
86 |
#else
|
87 |
#error Unsupported arch
|
88 |
#endif
|
89 |
|
90 |
/* Click alignment macros. */
|
91 |
#define CLICK_FLOOR(n) (((vir_bytes)(n) / CLICK_SIZE) * CLICK_SIZE)
|
92 |
#define CLICK_CEIL(n) CLICK_FLOOR((vir_bytes)(n) + CLICK_SIZE-1) |
93 |
|
94 |
/* Sizes of memory tables. The boot monitor distinguishes three memory areas,
|
95 |
* namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
|
96 |
* for DOS MINIX.
|
97 |
*/
|
98 |
#define NR_MEMS 16 |
99 |
|
100 |
#define CLICK2ABS(v) ((v) << CLICK_SHIFT)
|
101 |
#define ABS2CLICK(a) ((a) >> CLICK_SHIFT)
|
102 |
|
103 |
/* Flag bits for i_mode in the inode. */
|
104 |
#define I_TYPE 0170000 /* this field gives inode type */ |
105 |
#define I_UNIX_SOCKET 0140000 /* unix domain socket */ |
106 |
#define I_SYMBOLIC_LINK 0120000 /* file is a symbolic link */ |
107 |
#define I_REGULAR 0100000 /* regular file, not dir or special */ |
108 |
#define I_BLOCK_SPECIAL 0060000 /* block special file */ |
109 |
#define I_DIRECTORY 0040000 /* file is a directory */ |
110 |
#define I_CHAR_SPECIAL 0020000 /* character special file */ |
111 |
#define I_NAMED_PIPE 0010000 /* named pipe (FIFO) */ |
112 |
#define I_SET_UID_BIT 0004000 /* set effective uid_t on exec */ |
113 |
#define I_SET_GID_BIT 0002000 /* set effective gid_t on exec */ |
114 |
#define I_SET_STCKY_BIT 0001000 /* sticky bit */ |
115 |
#define ALL_MODES 0007777 /* all bits for user, group and others */ |
116 |
#define RWX_MODES 0000777 /* mode bits for RWX only */ |
117 |
#define R_BIT 0000004 /* Rwx protection bit */ |
118 |
#define W_BIT 0000002 /* rWx protection bit */ |
119 |
#define X_BIT 0000001 /* rwX protection bit */ |
120 |
#define I_NOT_ALLOC 0000000 /* this inode is free */ |
121 |
|
122 |
/* Some limits. */
|
123 |
#define MAX_INODE_NR ((ino_t) 037777777777) /* largest inode number */ |
124 |
#define MAX_FILE_POS ((off_t) 0x7FFFFFFF) /* largest legal file offset */ |
125 |
#define UMAX_FILE_POS ((unsigned) 0x7FFFFFFF) /* largest legal file offset */ |
126 |
|
127 |
#define MAX_SYM_LOOPS 8 /* how many symbolic links are recursed */ |
128 |
|
129 |
#define NO_BLOCK ((block_t) 0) /* absence of a block number */ |
130 |
#define NO_ENTRY ((ino_t) 0) /* absence of a dir entry */ |
131 |
#define NO_ZONE ((zone_t) 0) /* absence of a zone number */ |
132 |
#define NO_DEV ((dev_t) 0) /* absence of a device numb */ |
133 |
#define NO_LINK ((nlink_t) 0) /* absence of incoming links */ |
134 |
#define INVAL_UID ((uid_t) -1) /* invalid uid value */ |
135 |
#define INVAL_GID ((gid_t) -1) /* invalid gid value */ |
136 |
|
137 |
#define SERVARNAME "cttyline" |
138 |
#define ARCHVARNAME "arch" |
139 |
#define BOARDVARNAME "board" |
140 |
#define SERBAUDVARNAME "cttybaud" |
141 |
|
142 |
/* Bits for s_flags in the privilege structure. */
|
143 |
#define PREEMPTIBLE 0x002 /* kernel tasks are not preemptible */ |
144 |
#define BILLABLE 0x004 /* some processes are not billable */ |
145 |
#define DYN_PRIV_ID 0x008 /* privilege id assigned dynamically */ |
146 |
|
147 |
#define SYS_PROC 0x010 /* system processes have own priv structure */ |
148 |
#define CHECK_IO_PORT 0x020 /* check if I/O request is allowed */ |
149 |
#define CHECK_IRQ 0x040 /* check if IRQ can be used */ |
150 |
#define CHECK_MEM 0x080 /* check if (VM) mem map request is allowed */ |
151 |
#define ROOT_SYS_PROC 0x100 /* this is a root system process instance */ |
152 |
#define VM_SYS_PROC 0x200 /* this is a vm system process instance */ |
153 |
#define LU_SYS_PROC 0x400 /* this is a live updated sys proc instance */ |
154 |
#define RST_SYS_PROC 0x800 /* this is a restarted sys proc instance */ |
155 |
|
156 |
/* Values for the "verbose" boot monitor variable */
|
157 |
#define VERBOSEBOOT_QUIET 0 |
158 |
#define VERBOSEBOOT_BASIC 1 |
159 |
#define VERBOSEBOOT_EXTRA 2 |
160 |
#define VERBOSEBOOT_MAX 3 |
161 |
#define VERBOSEBOOTVARNAME "verbose" |
162 |
|
163 |
/* magic value to put in struct proc entries for sanity checks. */
|
164 |
#define PMAGIC 0xC0FFEE1 |
165 |
|
166 |
/* MINIX_KERNFLAGS flags */
|
167 |
#define MKF_I386_INTEL_SYSENTER (1L << 0) /* SYSENTER available and supported */ |
168 |
#define MKF_I386_AMD_SYSCALL (1L << 1) /* SYSCALL available and supported */ |
169 |
|
170 |
/*
|
171 |
* Number of per-CPU states for which time will be accounted. This *must* be
|
172 |
* the same value as NetBSD's CPUSTATES, which is defined in a rather
|
173 |
* unfortunate location (sys/sched.h). If the NetBSD value changes, our kernel
|
174 |
* must be adapted accordingly.
|
175 |
*/
|
176 |
#define MINIX_CPUSTATES 5 |
177 |
|
178 |
/* Network device driver constants. TODO: move to a better location. */
|
179 |
#define NDEV_ETH_PACKET_MIN 60 /* min network packet size, in bytes */ |
180 |
#define NDEV_ETH_PACKET_MAX 1514 /* max network packet size, in bytes */ |
181 |
#define NDEV_ETH_PACKET_TAG 4 /* ethernet VLAN tag size, in bytes */ |
182 |
#define NDEV_ETH_PACKET_CRC 4 /* ethernet CRC size, in bytes */ |
183 |
#define NDEV_ETH_PACKET_MAX_TAGGED (NDEV_ETH_PACKET_MAX + NDEV_ETH_PACKET_TAG)
|
184 |
|
185 |
#endif /* _MINIX_CONST_H */ |