2005-10-20 22:31:18 +02:00
|
|
|
/* This table has one slot per system process. It contains information for
|
|
|
|
* servers and driver needed by the reincarnation server to keep track of
|
|
|
|
* each process' status.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Space reserved for program and arguments. */
|
|
|
|
#define MAX_COMMAND_LEN 512 /* maximum argument string length */
|
2006-10-20 17:01:32 +02:00
|
|
|
#define MAX_LABEL_LEN 16 /* Unique name of (this instance of)
|
|
|
|
* the driver
|
|
|
|
*/
|
|
|
|
#define MAX_SCRIPT_LEN 256 /* maximum restart script name length */
|
2005-10-20 22:31:18 +02:00
|
|
|
#define MAX_NR_ARGS 4 /* maximum number of arguments */
|
2005-10-21 15:28:26 +02:00
|
|
|
#define MAX_RESCUE_DIR_LEN 64 /* maximum rescue dir length */
|
2005-10-20 22:31:18 +02:00
|
|
|
|
2008-02-21 17:20:22 +01:00
|
|
|
#define MAX_IPC_LIST 256 /* Max size of list for IPC target
|
|
|
|
* process names
|
|
|
|
*/
|
2009-09-21 16:49:04 +02:00
|
|
|
#define MAX_VM_LIST 256
|
2006-10-20 17:01:32 +02:00
|
|
|
|
2005-10-20 22:31:18 +02:00
|
|
|
/* Definition of the system process table. This table only has entries for
|
|
|
|
* the servers and drivers, and thus is not directly indexed by slot number.
|
|
|
|
*/
|
|
|
|
extern struct rproc {
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int r_proc_nr_e; /* process endpoint number */
|
2006-10-20 17:01:32 +02:00
|
|
|
pid_t r_pid; /* process id, -1 if the process is not there */
|
2005-10-20 22:31:18 +02:00
|
|
|
dev_t r_dev_nr; /* major device number */
|
|
|
|
int r_dev_style; /* device style */
|
|
|
|
|
|
|
|
int r_restarts; /* number of restarts (initially zero) */
|
|
|
|
long r_backoff; /* number of periods to wait before revive */
|
|
|
|
unsigned r_flags; /* status and policy flags */
|
|
|
|
|
|
|
|
long r_period; /* heartbeat period (or zero) */
|
|
|
|
clock_t r_check_tm; /* timestamp of last check */
|
|
|
|
clock_t r_alive_tm; /* timestamp of last heartbeat */
|
|
|
|
clock_t r_stop_tm; /* timestamp of SIGTERM signal */
|
2007-01-22 17:44:03 +01:00
|
|
|
endpoint_t r_caller; /* RS_LATEREPLY caller */
|
2005-10-20 22:31:18 +02:00
|
|
|
|
2006-05-11 16:58:33 +02:00
|
|
|
char *r_exec; /* Executable image */
|
|
|
|
size_t r_exec_len; /* Length of image */
|
|
|
|
|
2006-10-20 17:01:32 +02:00
|
|
|
char r_label[MAX_LABEL_LEN]; /* unique name of this driver */
|
2005-10-20 22:31:18 +02:00
|
|
|
char r_cmd[MAX_COMMAND_LEN]; /* raw command plus arguments */
|
2006-10-20 17:01:32 +02:00
|
|
|
char r_script[MAX_SCRIPT_LEN]; /* name of the restart script executable */
|
2005-10-20 22:31:18 +02:00
|
|
|
char *r_argv[MAX_NR_ARGS+2]; /* parsed arguments vector */
|
|
|
|
int r_argc; /* number of arguments */
|
2006-10-20 17:01:32 +02:00
|
|
|
|
|
|
|
/* Resources */
|
|
|
|
int r_set_resources;
|
|
|
|
struct priv r_priv; /* Privilege structure to be passed to the
|
|
|
|
* kernel.
|
|
|
|
*/
|
|
|
|
uid_t r_uid;
|
|
|
|
int r_nice;
|
|
|
|
int r_nr_pci_id; /* Number of PCI devices IDs */
|
2009-12-02 10:54:50 +01:00
|
|
|
struct { u16_t vid; u16_t did; } r_pci_id[RSS_NR_PCI_ID];
|
2006-10-20 17:01:32 +02:00
|
|
|
int r_nr_pci_class; /* Number of PCI class IDs */
|
2009-12-02 10:54:50 +01:00
|
|
|
struct { u32_t class; u32_t mask; } r_pci_class[RSS_NR_PCI_CLASS];
|
2006-10-20 17:01:32 +02:00
|
|
|
|
2009-12-02 10:54:50 +01:00
|
|
|
u32_t r_call_mask[RSS_NR_SYSTEM];
|
2008-02-21 17:20:22 +01:00
|
|
|
char r_ipc_list[MAX_IPC_LIST];
|
2009-12-02 10:54:50 +01:00
|
|
|
bitchunk_t r_vm[RSS_VM_CALL_SIZE];
|
|
|
|
int r_nr_control;
|
|
|
|
char r_control[RSS_NR_CONTROL][MAX_LABEL_LEN];
|
2005-10-20 22:31:18 +02:00
|
|
|
} rproc[NR_SYS_PROCS];
|
|
|
|
|
|
|
|
/* Mapping for fast access to the system process table. */
|
|
|
|
extern struct rproc *rproc_ptr[NR_PROCS];
|
|
|
|
|
2007-04-23 16:42:08 +02:00
|
|
|
/* Pipe for detection of exec failures. The pipe is close-on-exec, and
|
|
|
|
* no data will be written to the pipe if the exec succeeds. After an
|
|
|
|
* exec failure, the slot number is written to the pipe. After each exit,
|
|
|
|
* a non-blocking read retrieves the slot number from the pipe.
|
|
|
|
*/
|
|
|
|
int exec_pipe[2];
|
|
|
|
|
2005-10-20 22:31:18 +02:00
|
|
|
/* Flag values. */
|
|
|
|
#define RS_IN_USE 0x001 /* set when process slot is in use */
|
2006-10-20 17:01:32 +02:00
|
|
|
#define RS_EXITING 0x004 /* set when exit is expected */
|
|
|
|
#define RS_REFRESHING 0x008 /* set when refresh must be done */
|
|
|
|
#define RS_NOPINGREPLY 0x010 /* driver failed to reply to a ping request */
|
|
|
|
#define RS_KILLED 0x020 /* driver is killed */
|
|
|
|
#define RS_CRASHED 0x040 /* driver crashed */
|
2007-01-22 17:44:03 +01:00
|
|
|
#define RS_LATEREPLY 0x080 /* no reply sent to RS_DOWN caller yet */
|
2007-04-23 16:42:08 +02:00
|
|
|
#define RS_SIGNALED 0x100 /* driver crashed */
|
2005-10-20 22:31:18 +02:00
|
|
|
|
|
|
|
/* Constants determining RS period and binary exponential backoff. */
|
|
|
|
#define RS_DELTA_T 60 /* check every T ticks */
|
|
|
|
#define BACKOFF_BITS (sizeof(long)*8) /* bits in backoff field */
|
|
|
|
#define MAX_BACKOFF 30 /* max backoff in RS_DELTA_T */
|
|
|
|
|
|
|
|
/* Magic process table addresses. */
|
|
|
|
#define BEG_RPROC_ADDR (&rproc[0])
|
|
|
|
#define END_RPROC_ADDR (&rproc[NR_SYS_PROCS])
|
|
|
|
#define NIL_RPROC ((struct mproc *) 0)
|
|
|
|
|