1433d6423SLionel Sambuc #ifndef _MINIX_CONST_H 2433d6423SLionel Sambuc #define _MINIX_CONST_H 3433d6423SLionel Sambuc 4433d6423SLionel Sambuc #include <machine/archconst.h> 5433d6423SLionel Sambuc 6433d6423SLionel Sambuc /* The UNUSED annotation tells the compiler or lint not to complain 7433d6423SLionel Sambuc * about an unused variable or function parameter. 8433d6423SLionel Sambuc * 9433d6423SLionel Sambuc * A number of different annotations are used, depending on the 10433d6423SLionel Sambuc * compiler or checker that is looking at the code. 11433d6423SLionel Sambuc * 12433d6423SLionel Sambuc * Note that some variants rename the parameter, so if you use 13433d6423SLionel Sambuc * the parameter after all, you'll get a complaint about a missing 14433d6423SLionel Sambuc * variable. 15433d6423SLionel Sambuc * 16433d6423SLionel Sambuc * You use it like this: 17433d6423SLionel Sambuc * 18433d6423SLionel Sambuc * void foo(int UNUSED(x)){} 19433d6423SLionel Sambuc */ 20433d6423SLionel Sambuc 21433d6423SLionel Sambuc #ifndef UNUSED 22433d6423SLionel Sambuc #if defined _lint 23433d6423SLionel Sambuc # define UNUSED(v) /*lint -e(715,818)*/ v 24433d6423SLionel Sambuc #elif defined(__GNUC__) 25433d6423SLionel Sambuc # define UNUSED(v) UNUSED_ ## v __attribute((unused)) 26433d6423SLionel Sambuc #elif defined __LCLINT__ 27433d6423SLionel Sambuc # define UNUSED(v) /*@unused@*/ v 28433d6423SLionel Sambuc #else 29433d6423SLionel Sambuc # define UNUSED(v) _UNUSED_ ## v 30433d6423SLionel Sambuc #endif 31433d6423SLionel Sambuc #endif 32433d6423SLionel Sambuc 3350b7f13fSCristiano Giuffrida #ifndef _MINIX_MAGIC 3450b7f13fSCristiano Giuffrida #define __ALIGNED(X) __aligned(X) 3550b7f13fSCristiano Giuffrida #else 3650b7f13fSCristiano Giuffrida #define __ALIGNED(X) 3750b7f13fSCristiano Giuffrida #endif 3850b7f13fSCristiano Giuffrida 39433d6423SLionel Sambuc #define EXTERN extern /* used in *.h files */ 40433d6423SLionel Sambuc 41433d6423SLionel Sambuc #define TRUE 1 /* used for turning integers into Booleans */ 42433d6423SLionel Sambuc #define FALSE 0 /* used for turning integers into Booleans */ 43433d6423SLionel Sambuc 44433d6423SLionel Sambuc #define SUPER_USER ((uid_t) 0) /* uid_t of superuser */ 45433d6423SLionel Sambuc 46433d6423SLionel Sambuc #include <sys/null.h> /* NULL Pointer */ 47433d6423SLionel Sambuc 48433d6423SLionel Sambuc #define SCPVEC_NR 64 /* max # of entries in a SYS_VSAFECOPY request */ 49433d6423SLionel Sambuc #define MAPVEC_NR 64 /* max # of entries in a SYS_VUMAP request */ 50433d6423SLionel Sambuc #define NR_IOREQS 64 /* maximum number of entries in an iorequest */ 51433d6423SLionel Sambuc 52433d6423SLionel Sambuc #define VUA_READ 0x01 /* for SYS_VUMAP: read access */ 53433d6423SLionel Sambuc #define VUA_WRITE 0x02 /* for SYS_VUMAP: write access */ 54433d6423SLionel Sambuc 55433d6423SLionel Sambuc /* Message passing constants. */ 56433d6423SLionel Sambuc #define MESS_SIZE (sizeof(message)) /* might need usizeof from FS here */ 57433d6423SLionel Sambuc 58433d6423SLionel Sambuc /* Memory related constants. */ 59433d6423SLionel Sambuc #define SEGMENT_TYPE 0xFF00 /* bit mask to get segment type */ 60433d6423SLionel Sambuc #define SEGMENT_INDEX 0x00FF /* bit mask to get segment index */ 61433d6423SLionel Sambuc 62433d6423SLionel Sambuc #define PHYS_SEG 0x0400 /* flag indicating entire physical memory */ 63433d6423SLionel Sambuc 64433d6423SLionel Sambuc #define LOCAL_VM_SEG 0x1000 /* same as LOCAL_SEG, but with vm lookup */ 65433d6423SLionel Sambuc #define MEM_GRANT 3 66433d6423SLionel Sambuc #define VIR_ADDR 1 67433d6423SLionel Sambuc #define VM_D (LOCAL_VM_SEG | VIR_ADDR) 68433d6423SLionel Sambuc #define VM_GRANT (LOCAL_VM_SEG | MEM_GRANT) 69433d6423SLionel Sambuc 70433d6423SLionel Sambuc /* Labels used to disable code sections for different reasons. */ 71433d6423SLionel Sambuc #define DEAD_CODE 0 /* unused code in normal configuration */ 72433d6423SLionel Sambuc #define FUTURE_CODE 0 /* new code to be activated + tested later */ 73433d6423SLionel Sambuc #define TEMP_CODE 1 /* active code to be removed later */ 74433d6423SLionel Sambuc 75433d6423SLionel Sambuc /* Miscellaneous */ 76433d6423SLionel Sambuc #define BYTE 0377 /* mask for 8 bits */ 77433d6423SLionel Sambuc #define READING 0 /* copy data to user */ 78433d6423SLionel Sambuc #define WRITING 1 /* copy data from user */ 79433d6423SLionel Sambuc #define PEEKING 2 /* retrieve FS data without copying */ 80433d6423SLionel Sambuc #define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */ 81433d6423SLionel Sambuc 82433d6423SLionel Sambuc /* Memory is allocated in clicks. */ 83433d6423SLionel Sambuc #if defined(__i386__) || defined(__arm__) 84433d6423SLionel Sambuc #define CLICK_SIZE 4096 /* unit in which memory is allocated */ 85433d6423SLionel Sambuc #define CLICK_SHIFT 12 /* log2 of CLICK_SIZE */ 86433d6423SLionel Sambuc #else 87433d6423SLionel Sambuc #error Unsupported arch 88433d6423SLionel Sambuc #endif 89433d6423SLionel Sambuc 90433d6423SLionel Sambuc /* Click alignment macros. */ 91433d6423SLionel Sambuc #define CLICK_FLOOR(n) (((vir_bytes)(n) / CLICK_SIZE) * CLICK_SIZE) 92433d6423SLionel Sambuc #define CLICK_CEIL(n) CLICK_FLOOR((vir_bytes)(n) + CLICK_SIZE-1) 93433d6423SLionel Sambuc 94433d6423SLionel Sambuc /* Sizes of memory tables. The boot monitor distinguishes three memory areas, 95433d6423SLionel Sambuc * namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed 96433d6423SLionel Sambuc * for DOS MINIX. 97433d6423SLionel Sambuc */ 98433d6423SLionel Sambuc #define NR_MEMS 16 99433d6423SLionel Sambuc 100433d6423SLionel Sambuc #define CLICK2ABS(v) ((v) << CLICK_SHIFT) 101433d6423SLionel Sambuc #define ABS2CLICK(a) ((a) >> CLICK_SHIFT) 102433d6423SLionel Sambuc 103433d6423SLionel Sambuc /* Flag bits for i_mode in the inode. */ 104433d6423SLionel Sambuc #define I_TYPE 0170000 /* this field gives inode type */ 105433d6423SLionel Sambuc #define I_UNIX_SOCKET 0140000 /* unix domain socket */ 106433d6423SLionel Sambuc #define I_SYMBOLIC_LINK 0120000 /* file is a symbolic link */ 107433d6423SLionel Sambuc #define I_REGULAR 0100000 /* regular file, not dir or special */ 108433d6423SLionel Sambuc #define I_BLOCK_SPECIAL 0060000 /* block special file */ 109433d6423SLionel Sambuc #define I_DIRECTORY 0040000 /* file is a directory */ 110433d6423SLionel Sambuc #define I_CHAR_SPECIAL 0020000 /* character special file */ 111433d6423SLionel Sambuc #define I_NAMED_PIPE 0010000 /* named pipe (FIFO) */ 112433d6423SLionel Sambuc #define I_SET_UID_BIT 0004000 /* set effective uid_t on exec */ 113433d6423SLionel Sambuc #define I_SET_GID_BIT 0002000 /* set effective gid_t on exec */ 114433d6423SLionel Sambuc #define I_SET_STCKY_BIT 0001000 /* sticky bit */ 115433d6423SLionel Sambuc #define ALL_MODES 0007777 /* all bits for user, group and others */ 116433d6423SLionel Sambuc #define RWX_MODES 0000777 /* mode bits for RWX only */ 117433d6423SLionel Sambuc #define R_BIT 0000004 /* Rwx protection bit */ 118433d6423SLionel Sambuc #define W_BIT 0000002 /* rWx protection bit */ 119433d6423SLionel Sambuc #define X_BIT 0000001 /* rwX protection bit */ 120433d6423SLionel Sambuc #define I_NOT_ALLOC 0000000 /* this inode is free */ 121433d6423SLionel Sambuc 122433d6423SLionel Sambuc /* Some limits. */ 123433d6423SLionel Sambuc #define MAX_INODE_NR ((ino_t) 037777777777) /* largest inode number */ 124433d6423SLionel Sambuc #define MAX_FILE_POS ((off_t) 0x7FFFFFFF) /* largest legal file offset */ 125433d6423SLionel Sambuc #define UMAX_FILE_POS ((unsigned) 0x7FFFFFFF) /* largest legal file offset */ 126433d6423SLionel Sambuc 127433d6423SLionel Sambuc #define MAX_SYM_LOOPS 8 /* how many symbolic links are recursed */ 128433d6423SLionel Sambuc 129433d6423SLionel Sambuc #define NO_BLOCK ((block_t) 0) /* absence of a block number */ 130433d6423SLionel Sambuc #define NO_ENTRY ((ino_t) 0) /* absence of a dir entry */ 131433d6423SLionel Sambuc #define NO_ZONE ((zone_t) 0) /* absence of a zone number */ 132433d6423SLionel Sambuc #define NO_DEV ((dev_t) 0) /* absence of a device numb */ 133433d6423SLionel Sambuc #define NO_LINK ((nlink_t) 0) /* absence of incoming links */ 134433d6423SLionel Sambuc #define INVAL_UID ((uid_t) -1) /* invalid uid value */ 135433d6423SLionel Sambuc #define INVAL_GID ((gid_t) -1) /* invalid gid value */ 136433d6423SLionel Sambuc 137433d6423SLionel Sambuc #define SERVARNAME "cttyline" 138433d6423SLionel Sambuc #define ARCHVARNAME "arch" 139433d6423SLionel Sambuc #define BOARDVARNAME "board" 140433d6423SLionel Sambuc #define SERBAUDVARNAME "cttybaud" 141433d6423SLionel Sambuc 142433d6423SLionel Sambuc /* Bits for s_flags in the privilege structure. */ 143433d6423SLionel Sambuc #define PREEMPTIBLE 0x002 /* kernel tasks are not preemptible */ 144433d6423SLionel Sambuc #define BILLABLE 0x004 /* some processes are not billable */ 145433d6423SLionel Sambuc #define DYN_PRIV_ID 0x008 /* privilege id assigned dynamically */ 146433d6423SLionel Sambuc 147433d6423SLionel Sambuc #define SYS_PROC 0x010 /* system processes have own priv structure */ 148433d6423SLionel Sambuc #define CHECK_IO_PORT 0x020 /* check if I/O request is allowed */ 149433d6423SLionel Sambuc #define CHECK_IRQ 0x040 /* check if IRQ can be used */ 150433d6423SLionel Sambuc #define CHECK_MEM 0x080 /* check if (VM) mem map request is allowed */ 151433d6423SLionel Sambuc #define ROOT_SYS_PROC 0x100 /* this is a root system process instance */ 152433d6423SLionel Sambuc #define VM_SYS_PROC 0x200 /* this is a vm system process instance */ 153433d6423SLionel Sambuc #define LU_SYS_PROC 0x400 /* this is a live updated sys proc instance */ 154433d6423SLionel Sambuc #define RST_SYS_PROC 0x800 /* this is a restarted sys proc instance */ 155433d6423SLionel Sambuc 156433d6423SLionel Sambuc /* Values for the "verbose" boot monitor variable */ 157433d6423SLionel Sambuc #define VERBOSEBOOT_QUIET 0 158433d6423SLionel Sambuc #define VERBOSEBOOT_BASIC 1 159433d6423SLionel Sambuc #define VERBOSEBOOT_EXTRA 2 160433d6423SLionel Sambuc #define VERBOSEBOOT_MAX 3 161433d6423SLionel Sambuc #define VERBOSEBOOTVARNAME "verbose" 162433d6423SLionel Sambuc 163433d6423SLionel Sambuc /* magic value to put in struct proc entries for sanity checks. */ 164433d6423SLionel Sambuc #define PMAGIC 0xC0FFEE1 165433d6423SLionel Sambuc 166433d6423SLionel Sambuc /* MINIX_KERNFLAGS flags */ 167433d6423SLionel Sambuc #define MKF_I386_INTEL_SYSENTER (1L << 0) /* SYSENTER available and supported */ 168433d6423SLionel Sambuc #define MKF_I386_AMD_SYSCALL (1L << 1) /* SYSCALL available and supported */ 169433d6423SLionel Sambuc 170366d18b2SDavid van Moolenbroek /* 171366d18b2SDavid van Moolenbroek * Number of per-CPU states for which time will be accounted. This *must* be 172366d18b2SDavid van Moolenbroek * the same value as NetBSD's CPUSTATES, which is defined in a rather 173366d18b2SDavid van Moolenbroek * unfortunate location (sys/sched.h). If the NetBSD value changes, our kernel 174366d18b2SDavid van Moolenbroek * must be adapted accordingly. 175366d18b2SDavid van Moolenbroek */ 176366d18b2SDavid van Moolenbroek #define MINIX_CPUSTATES 5 177366d18b2SDavid van Moolenbroek 178*f7df02e7SDavid van Moolenbroek /* Network device driver constants. TODO: move to a better location. */ 179*f7df02e7SDavid van Moolenbroek #define NDEV_ETH_PACKET_MIN 60 /* min network packet size, in bytes */ 180*f7df02e7SDavid van Moolenbroek #define NDEV_ETH_PACKET_MAX 1514 /* max network packet size, in bytes */ 181*f7df02e7SDavid van Moolenbroek #define NDEV_ETH_PACKET_TAG 4 /* ethernet VLAN tag size, in bytes */ 182*f7df02e7SDavid van Moolenbroek #define NDEV_ETH_PACKET_CRC 4 /* ethernet CRC size, in bytes */ 183*f7df02e7SDavid van Moolenbroek #define NDEV_ETH_PACKET_MAX_TAGGED (NDEV_ETH_PACKET_MAX + NDEV_ETH_PACKET_TAG) 184*f7df02e7SDavid van Moolenbroek 185433d6423SLionel Sambuc #endif /* _MINIX_CONST_H */ 186