xref: /minix/minix/include/minix/rs.h (revision 9f988b79)
1 #ifndef RS_H
2 #define RS_H
3 
4 /*
5 minix/rs.h
6 
7 Interface to the reincarnation server
8 */
9 
10 #include <minix/bitmap.h>
11 #include <minix/com.h>
12 #include <minix/ipc_filter.h>
13 
14 #define SERVICE_LOGIN	"service"	/* passwd file entry for services */
15 
16 /* The following definition should be kept in sync with the actual /etc/passwd
17  * value for SERVICE_LOGIN for now, and removed altogether once we are able to
18  * obtain its value dynamically everywhere.
19  */
20 #define SERVICE_UID		12		/* user ID for services */
21 
22 /* RSS definitions. */
23 #define RSS_NR_IRQ		16
24 #define RSS_NR_IO		16
25 #define RSS_IRQ_ALL		(RSS_NR_IRQ+1)
26 #define RSS_IO_ALL		(RSS_NR_IO+1)
27 #define RSS_IPC_ALL		"IPC_ALL"
28 #define RSS_IPC_ALL_SYS		"IPC_ALL_SYS"
29 
30 /* RSS flags. */
31 #define RSS_COPY	0x01	/* keep an in-memory copy of the binary */
32 #define RSS_REUSE	0x04	/* Try to reuse previously copied binary */
33 #define RSS_NOBLOCK	0x08	/* unblock caller immediately */
34 #define RSS_REPLICA	0x10	/* keep a replica of the service */
35 #define RSS_BATCH	0x20	/* batch mode */
36 #define RSS_SELF_LU	0x40	/* perform self update */
37 #define RSS_ASR_LU	0x80	/* perform ASR update */
38 #define RSS_FORCE_SELF_LU	0x0100	/* force self update */
39 #define RSS_PREPARE_ONLY_LU	0x0200	/* request prepare-only update */
40 #define RSS_FORCE_INIT_CRASH    0x0400  /* force crash at initialization time (for debugging) */
41 #define RSS_FORCE_INIT_FAIL     0x0800  /* force failure at initialization time (for debugging) */
42 #define RSS_FORCE_INIT_TIMEOUT  0x1000  /* force timeout at initialization time (for debugging) */
43 #define RSS_FORCE_INIT_DEFCB    0x2000  /* force default cb at initialization time (for debugging) */
44 #define RSS_SYS_BASIC_CALLS	0x4000	/* include basic kernel calls */
45 #define RSS_VM_BASIC_CALLS	0x8000	/* include basic vm calls */
46 #define RSS_NOMMAP_LU          0x10000  /* don't inherit mmapped regions */
47 #define RSS_DETACH             0x20000  /* detach on update/restart */
48 #define RSS_NORESTART          0x40000  /* don't restart */
49 #define RSS_FORCE_INIT_ST      0x80000  /* force state transfer at initialization time */
50 #define RSS_NO_BIN_EXP        0x100000  /* suppress binary exponential offset */
51 
52 /* Common definitions. */
53 #define RS_NR_CONTROL		 8
54 #define RS_NR_PCI_DEVICE	32
55 #define RS_NR_PCI_CLASS		 4
56 #define RS_MAX_LABEL_LEN	16
57 #define RS_MAX_IPCF_STR_LEN	 (RS_MAX_LABEL_LEN+12)
58 #define RS_MAX_IPC_FILTERS	 4
59 
60 /* CPU special values */
61 #define RS_CPU_DEFAULT		-1 /* use the default cpu or do not change the current one */
62 #define RS_CPU_BSP		-2 /* use the bootstrap cpu */
63 
64 /* Labels are copied over separately. */
65 struct rss_label
66 {
67 	char *l_addr;
68 	size_t l_len;
69 };
70 
71 struct rs_pci_id {
72 	u16_t vid;
73 	u16_t did;
74 	u16_t sub_vid;
75 	u16_t sub_did;
76 };
77 #define NO_SUB_VID	0xffff
78 #define NO_SUB_DID	0xffff
79 
80 struct rs_pci_class {
81 	u32_t pciclass;
82 	u32_t mask;
83 };
84 
85 /* State-related data. */
86 struct rs_ipc_filter_el {
87 	int flags;
88 	char m_label[RS_MAX_LABEL_LEN];
89 	int m_type;
90 };
91 struct rs_state_data {
92 	size_t size;
93 	void *ipcf_els;
94 	size_t ipcf_els_size;
95 	int ipcf_els_gid;
96 	void *eval_addr;
97 	size_t eval_len;
98 	int eval_gid;
99 };
100 
101 /* Arguments needed to start a new driver or server */
102 struct rs_start
103 {
104 	unsigned rss_flags;
105 	char *rss_cmd;
106 	size_t rss_cmdlen;
107 	uid_t rss_uid;
108 	endpoint_t rss_sigmgr;
109 	endpoint_t rss_scheduler;
110 	int rss_priority;
111 	int rss_quantum;
112 	int rss_major;
113 	long rss_period;
114 	char *rss_script;
115 	size_t rss_scriptlen;
116 	long rss_asr_count;
117 	long rss_restarts;
118 	long rss_heap_prealloc_bytes;
119 	long rss_map_prealloc_bytes;
120 	int rss_nr_irq;
121 	int rss_irq[RSS_NR_IRQ];
122 	int rss_nr_io;
123 	struct { unsigned base; unsigned len; } rss_io[RSS_NR_IO];
124 	int rss_nr_pci_id;
125 	struct rs_pci_id rss_pci_id[RS_NR_PCI_DEVICE];
126 	int rss_nr_pci_class;
127 	struct rs_pci_class rss_pci_class[RS_NR_PCI_CLASS];
128 	bitchunk_t rss_system[SYS_CALL_MASK_SIZE];
129 	struct rss_label rss_label;
130 	struct rss_label rss_trg_label;
131 	char *rss_ipc;
132 	size_t rss_ipclen;
133 	bitchunk_t rss_vm[VM_CALL_MASK_SIZE];
134 	int rss_nr_control;
135 	struct rss_label rss_control[RS_NR_CONTROL];
136 	struct rs_state_data rss_state_data;
137 	int devman_id;
138 	/*
139 	 * SMP specific data
140 	 *
141 	 * must be at the end of the structure for binary compatibility with
142 	 * non-smp sysytems
143 	 */
144 	int rss_cpu;
145 };
146 
147 /* ACL information for access to PCI devices */
148 struct rs_pci
149 {
150 	char rsp_label[RS_MAX_LABEL_LEN];
151 	int rsp_endpoint;
152 	int rsp_nr_device;
153 	struct rs_pci_id rsp_device[RS_NR_PCI_DEVICE];
154 	int rsp_nr_class;
155 	struct rs_pci_class rsp_class[RS_NR_PCI_CLASS];
156 };
157 
158 /* Definition of a public entry of the system process table. */
159 struct rprocpub {
160   short in_use; 		  /* set when the entry is in use */
161   unsigned sys_flags; 		  /* sys flags */
162   endpoint_t endpoint;		  /* process endpoint number */
163   endpoint_t old_endpoint;	  /* old instance endpoint number (for VM, when updating) */
164   endpoint_t new_endpoint;	  /* new instance endpoint number (for VM, when updating) */
165 
166   devmajor_t dev_nr;		  /* major device number or NO_DEV */
167 
168   char label[RS_MAX_LABEL_LEN];	  /* label of this service */
169   char proc_name[RS_MAX_LABEL_LEN]; /* process name of this service */
170 
171   bitchunk_t vm_call_mask[VM_CALL_MASK_SIZE]; /* vm call mask */
172 
173   struct rs_pci pci_acl;	  /* pci acl */
174   int devman_id;
175 };
176 
177 /* Return whether the given boot process is a user process, as opposed to a
178  * system process. Only usable by core services during SEF initialization.
179  */
180 #define IS_RPUB_BOOT_USR(rpub) ((rpub)->endpoint == INIT_PROC_NR)
181 
182 /* Sys flag values. */
183 #define SF_CORE_SRV     0x001    /* set for core system services */
184 #define SF_SYNCH_BOOT   0X002    /* set when process needs synch boot init */
185 #define SF_NEED_COPY    0x004    /* set when process needs copy to start */
186 #define SF_USE_COPY     0x008    /* set when process has a copy in memory */
187 #define SF_NEED_REPL    0x010    /* set when process needs replica to start */
188 #define SF_USE_REPL     0x020    /* set when process has a replica */
189 #define SF_VM_UPDATE    0x040    /* set when process needs vm update */
190 #define SF_VM_ROLLBACK  0x080    /* set when vm update is a rollback */
191 #define SF_VM_NOMMAP    0x100    /* set when vm update ignores mmapped regions */
192 #define SF_USE_SCRIPT   0x200    /* set when process has restart script */
193 #define SF_DET_RESTART  0x400    /* set when process detaches on restart */
194 #define SF_NORESTART    0x800    /* set when process should not be restarted */
195 #define SF_NO_BIN_EXP  0x1000    /* set when we should ignore binary exp. offset */
196 
197 #define IMM_SF          \
198     (SF_NO_BIN_EXP | SF_CORE_SRV | SF_SYNCH_BOOT | SF_NEED_COPY | SF_NEED_REPL) /* immutable */
199 
200 int minix_rs_lookup(const char *name, endpoint_t *value);
201 
202 #endif
203