From: Ben Gras Date: Tue, 10 Dec 2013 17:49:14 +0000 (+0100) Subject: X-Git-Tag: v3.3.0~461 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch05.html?a=commitdiff_plain;h=1ef83ee9231b1f1248fbaf58574674afc08436c6;p=minix.git Change-Id: I53d0ca207789f27e3a01acdd184ade24630d9a00 --- diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index e4d11ee6d..c0114f304 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -575,7 +575,7 @@ rresvport_af_addr(int *alport, int family, void *addr) s = socket(family, SOCK_STREAM, 0); if (s < 0) return -1; -#ifdef BSD4_4 +#if defined(BSD4_4) && !defined(__minix) switch (family) { case AF_INET: case AF_INET6: diff --git a/sys/sys/param.h b/sys/sys/param.h index d3f50c824..a2fcd5e03 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -44,9 +44,7 @@ */ #define BSD 199506 /* System version (year & month). */ #define BSD4_3 1 -#ifndef __minix #define BSD4_4 1 -#endif /* * #define __NetBSD_Version__ MMmmrrpp00 @@ -116,9 +114,7 @@ #define MAXINTERP PATH_MAX /* max interpreter file name length */ /* DEPRECATED: use LOGIN_NAME_MAX instead. */ #define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */ -#ifndef __minix #define NCARGS ARG_MAX /* max bytes for an exec function */ -#endif #define NGROUPS NGROUPS_MAX /* max number groups */ #define NOGROUP 65535 /* marker for empty group set member */ #define MAXHOSTNAMELEN 256 /* max hostname size */ @@ -134,6 +130,34 @@ #endif /* (MAXUPRC - 0) < CHILD_MAX */ #endif /* !defined(MAXUPRC) */ +/* More types and definitions used throughout the kernel. */ +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include +#include +#ifndef NPROC +#define NPROC (20 + 16 * MAXUSERS) +#endif +#ifndef NTEXT +#define NTEXT (80 + NPROC / 8) /* actually the object cache */ +#endif +#ifndef NVNODE +#define NVNODE (NPROC + NTEXT + 100) +#define NVNODE_IMPLICIT +#endif +#ifndef VNODE_VA_MAXPCT +#define VNODE_VA_MAXPCT 20 +#endif +#ifndef BUFCACHE_VA_MAXPCT +#define BUFCACHE_VA_MAXPCT 20 +#endif +#define VNODE_COST 2048 /* assumed space in bytes */ +#endif /* _KERNEL */ + /* Signals. */ #include @@ -166,6 +190,44 @@ #define MAX_LWP_PER_PROC 8000 #endif +/* + * Stack macros. On most architectures, the stack grows down, + * towards lower addresses; it is the rare architecture where + * it grows up, towards higher addresses. + * + * STACK_GROW and STACK_SHRINK adjust a stack pointer by some + * size, no questions asked. STACK_ALIGN aligns a stack pointer. + * + * STACK_ALLOC returns a pointer to allocated stack space of + * some size; given such a pointer and a size, STACK_MAX gives + * the maximum (in the "maxsaddr" sense) stack address of the + * allocated memory. + */ +#if defined(_KERNEL) || defined(__EXPOSE_STACK) + +#ifndef STACK_ALIGNBYTES +#define STACK_ALIGNBYTES __ALIGNBYTES +#endif + +#ifdef __MACHINE_STACK_GROWS_UP +#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size)) +#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size)) +#define STACK_ALIGN(sp, bytes) \ + ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes))) +#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp)) +#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size)) +#else +#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size)) +#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size)) +#define STACK_ALIGN(sp, bytes) \ + ((char *)(((unsigned long)(sp)) & ~(bytes))) +#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size)) +#define STACK_MAX(p, _size) ((char *)(void *)(p)) +#endif +#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes)) + +#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */ + /* * Round p (pointer or byte index) up to a correctly-aligned value for all * data types (int, long, ...). The result is u_int and must be cast to @@ -185,6 +247,72 @@ #define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t) - 1)) == 0) #endif +/* + * Historic priority levels. These are meaningless and remain only + * for source compatibility. Do not use in new code. + */ +#define PSWP 0 +#define PVM 4 +#define PINOD 8 +#define PRIBIO 16 +#define PVFS 20 +#define PZERO 22 +#define PSOCK 24 +#define PWAIT 32 +#define PLOCK 36 +#define PPAUSE 40 +#define PUSER 50 +#define MAXPRI 127 + +#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ +#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */ + +/* + * New priority levels. + */ +#define PRI_COUNT 224 +#define PRI_NONE (-1) + +#define PRI_KERNEL_RT 192 +#define NPRI_KERNEL_RT 32 +#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1) + +#define PRI_USER_RT 128 +#define NPRI_USER_RT 64 +#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1) + +#define PRI_KTHREAD 96 +#define NPRI_KTHREAD 32 +#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1) + +#define PRI_KERNEL 64 +#define NPRI_KERNEL 32 +#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1) + +#define PRI_USER 0 +#define NPRI_USER 64 +#define MAXPRI_USER (PRI_USER + NPRI_USER - 1) + +/* Priority range used by POSIX real-time features */ +#define SCHED_PRI_MIN 0 +#define SCHED_PRI_MAX 63 + +/* + * Kernel thread priorities. + */ +#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT +#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1) +#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2) +#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3) + +#define PRI_XCALL MAXPRI_KTHREAD +#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1) +#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2) +#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3) +#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4) + +#define PRI_IDLE PRI_USER + /* * Miscellaneous. */ @@ -193,12 +321,6 @@ #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ #define NODEV (dev_t)(-1) /* non-existent device */ -#define CBLOCK 64 /* Clist block size, must be a power of 2. */ -#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ - /* Data chars/clist. */ -#define CBSIZE (CBLOCK - (int)sizeof(struct cblock *) - CBQSIZE) -#define CROUND (CBLOCK - 1) /* Clist rounding. */ - /* * File system parameters and macros. * @@ -255,6 +377,98 @@ #define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) #define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) +/* + * Constants for setting the parameters of the kernel memory allocator. + * + * 2 ** MINBUCKET is the smallest unit of memory that will be + * allocated. It must be at least large enough to hold a pointer. + * + * Units of memory less or equal to MAXALLOCSAVE will permanently + * allocate physical memory; requests for these size pieces of + * memory are quite fast. Allocations greater than MAXALLOCSAVE must + * always allocate and free physical memory; requests for these + * size allocations should be done infrequently as they will be slow. + * + * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and + * MAXALLOCSAVE must be a power of two. + */ +#ifdef _LP64 +#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */ +#else +#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ +#endif +#define MAXALLOCSAVE (2 * NBPG) + +/* + * Scale factor for scaled integers used to count %cpu time and load avgs. + * + * The number of CPU `tick's that map to a unique `%age' can be expressed + * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that + * can be calculated (assuming 32 bits) can be closely approximated using + * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). + * + * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', + * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. + */ +#define FSHIFT 11 /* bits to right of fixed binary point */ +#define FSCALE (1<. + */ + +#ifndef UBC_WINSHIFT +#define UBC_WINSHIFT 13 +#endif +#ifndef UBC_NWINS +#define UBC_NWINS 1024 +#endif + +#ifdef _KERNEL +/* + * macro to convert from milliseconds to hz without integer overflow + * Default version using only 32bits arithmetics. + * 64bit port can define 64bit version in their + * 0x20000 is safe for hz < 20000 + */ +#ifndef mstohz +#define mstohz(ms) \ + (__predict_false((ms) >= 0x20000) ? \ + ((ms +0u) / 1000u) * hz : \ + ((ms +0u) * hz) / 1000u) +#endif +#ifndef hztoms +#define hztoms(t) \ + (__predict_false((t) >= 0x20000) ? \ + ((t +0u) / hz) * 1000u : \ + ((t +0u) * 1000u) / hz) +#endif + +extern const int schedppq; +extern size_t coherency_unit; + +#endif /* _KERNEL */ + +/* + * Minimum alignment of "struct lwp" needed by the architecture. + * This counts when packing a lock byte into a word alongside a + * pointer to an LWP. + */ +#ifndef MIN_LWP_ALIGNMENT +#define MIN_LWP_ALIGNMENT 32 +#endif #endif /* !__ASSEMBLER__ */ #endif /* !_SYS_PARAM_H_ */