Changes in uspace/app/init/init.c [31e9fe0:06a1d077] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
r31e9fe0 r06a1d077 37 37 #include <stdio.h> 38 38 #include <unistd.h> 39 #include <stdarg.h>40 39 #include <vfs/vfs.h> 41 #include < stdbool.h>40 #include <bool.h> 42 41 #include <errno.h> 43 42 #include <fcntl.h> … … 66 65 #define SRV_CONSOLE "/srv/console" 67 66 #define APP_GETTERM "/app/getterm" 68 69 #define SRV_COMPOSITOR "/srv/compositor"70 71 #define HID_INPUT "hid/input"72 #define HID_OUTPUT "hid/output"73 #define HID_COMPOSITOR_SERVER ":0"74 75 #define srv_start(path, ...) \76 srv_startl(path, path, ##__VA_ARGS__, NULL)77 67 78 68 /** Print banner */ … … 153 143 } 154 144 155 static int srv_startl(const char *path, ...) 156 { 145 static void spawn(const char *fname) 146 { 147 int rc; 157 148 struct stat s; 158 if (stat(path, &s) == ENOENT) { 159 printf("%s: Unable to stat %s\n", NAME, path); 160 return ENOENT; 161 } 162 163 printf("%s: Starting %s\n", NAME, path); 164 165 va_list ap; 166 const char *arg; 167 int cnt = 0; 168 169 va_start(ap, path); 170 do { 171 arg = va_arg(ap, const char *); 172 cnt++; 173 } while (arg != NULL); 174 va_end(ap); 175 176 va_start(ap, path); 149 150 if (stat(fname, &s) == ENOENT) 151 return; 152 153 printf("%s: Spawning %s\n", NAME, fname); 154 rc = task_spawnl(NULL, fname, fname, NULL); 155 if (rc != EOK) { 156 printf("%s: Error spawning %s (%s)\n", NAME, fname, 157 str_error(rc)); 158 } 159 } 160 161 static void srv_start(const char *fname) 162 { 177 163 task_id_t id; 178 int rc = task_spawn(&id, path, cnt, ap);179 va_end(ap);180 181 if (rc != EOK) {182 printf("%s: Error spawning %s (%s)\n", NAME, path,183 str_error(rc));184 return rc;185 }186 164 task_exit_t texit; 165 int rc, retval; 166 struct stat s; 167 168 if (stat(fname, &s) == ENOENT) 169 return; 170 171 printf("%s: Starting %s\n", NAME, fname); 172 rc = task_spawnl(&id, fname, fname, NULL); 187 173 if (!id) { 188 printf("%s: Error spawning %s (invalid task id)\n", NAME, 189 path); 190 return EINVAL; 191 } 192 193 task_exit_t texit; 194 int retval; 174 printf("%s: Error spawning %s (%s)\n", NAME, fname, 175 str_error(rc)); 176 return; 177 } 178 195 179 rc = task_wait(id, &texit, &retval); 196 180 if (rc != EOK) { 197 printf("%s: Error waiting for %s (%s)\n", NAME, path,198 str_error(rc)); 199 return rc;181 printf("%s: Error waiting for %s (%s)\n", NAME, fname, 182 str_error(rc)); 183 return; 200 184 } 201 185 202 186 if (texit != TASK_EXIT_NORMAL) { 203 187 printf("%s: Server %s failed to start (unexpectedly " 204 "terminated)\n", NAME, path);205 return EINVAL;206 } 207 208 if (retval != 0) 188 "terminated)\n", NAME, fname); 189 return; 190 } 191 192 if (retval != 0) { 209 193 printf("%s: Server %s failed to start (exit code %d)\n", NAME, 210 path, retval); 211 212 return retval; 213 } 214 215 static int console(const char *isvc, const char *osvc) 216 { 194 fname, retval); 195 } 196 } 197 198 static void console(const char *isvc, const char *fbsvc) 199 { 200 printf("%s: Spawning %s %s %s\n", NAME, SRV_CONSOLE, isvc, fbsvc); 201 217 202 /* Wait for the input service to be ready */ 218 203 service_id_t service_id; … … 221 206 printf("%s: Error waiting on %s (%s)\n", NAME, isvc, 222 207 str_error(rc)); 223 return rc; 224 } 225 226 /* Wait for the output service to be ready */ 227 rc = loc_service_get_id(osvc, &service_id, IPC_FLAG_BLOCKING); 228 if (rc != EOK) { 229 printf("%s: Error waiting on %s (%s)\n", NAME, osvc, 230 str_error(rc)); 231 return rc; 232 } 233 234 return srv_start(SRV_CONSOLE, isvc, osvc); 235 } 236 237 static int compositor(const char *isvc, const char *name) 238 { 239 /* Wait for the input service to be ready */ 240 service_id_t service_id; 241 int rc = loc_service_get_id(isvc, &service_id, IPC_FLAG_BLOCKING); 242 if (rc != EOK) { 243 printf("%s: Error waiting on %s (%s)\n", NAME, isvc, 244 str_error(rc)); 245 return rc; 246 } 247 248 return srv_start(SRV_COMPOSITOR, isvc, name); 249 } 250 251 static int gui_start(const char *app, const char *srv_name) 252 { 253 char winreg[50]; 254 snprintf(winreg, sizeof(winreg), "%s%s%s", "comp", srv_name, "/winreg"); 255 256 printf("%s: Spawning %s %s\n", NAME, app, winreg); 257 258 task_id_t id; 259 int rc = task_spawnl(&id, app, app, winreg, NULL); 260 if (rc != EOK) { 261 printf("%s: Error spawning %s %s (%s)\n", NAME, app, 262 winreg, str_error(rc)); 263 return -1; 264 } 265 266 task_exit_t texit; 267 int retval; 268 rc = task_wait(id, &texit, &retval); 269 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) { 270 printf("%s: Error retrieving retval from %s (%s)\n", NAME, 271 app, str_error(rc)); 272 return -1; 273 } 274 275 return retval; 208 return; 209 } 210 211 /* Wait for the framebuffer service to be ready */ 212 rc = loc_service_get_id(fbsvc, &service_id, IPC_FLAG_BLOCKING); 213 if (rc != EOK) { 214 printf("%s: Error waiting on %s (%s)\n", NAME, fbsvc, 215 str_error(rc)); 216 return; 217 } 218 219 rc = task_spawnl(NULL, SRV_CONSOLE, SRV_CONSOLE, isvc, fbsvc, NULL); 220 if (rc != EOK) { 221 printf("%s: Error spawning %s %s %s (%s)\n", NAME, SRV_CONSOLE, 222 isvc, fbsvc, str_error(rc)); 223 } 276 224 } 277 225 … … 279 227 { 280 228 char term[LOC_NAME_MAXLEN]; 229 int rc; 230 281 231 snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc); 282 232 … … 285 235 /* Wait for the terminal service to be ready */ 286 236 service_id_t service_id; 287 intrc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);237 rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING); 288 238 if (rc != EOK) { 289 239 printf("%s: Error waiting on %s (%s)\n", NAME, term, … … 329 279 if (!mount_root(STRING(RDFMT))) { 330 280 printf("%s: Exiting\n", NAME); 331 return 1;281 return -1; 332 282 } 333 283 334 284 /* Make sure tmpfs is running. */ 335 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) 336 srv_start("/srv/tmpfs"); 337 338 srv_start("/srv/locfs"); 339 srv_start("/srv/taskmon"); 285 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 286 spawn("/srv/tmpfs"); 287 } 288 289 spawn("/srv/locfs"); 290 spawn("/srv/taskmon"); 340 291 341 292 if (!mount_locfs()) { 342 293 printf("%s: Exiting\n", NAME); 343 return 2;294 return -2; 344 295 } 345 296 346 297 mount_tmpfs(); 347 298 348 s rv_start("/srv/devman");349 s rv_start("/srv/apic");350 s rv_start("/srv/i8259");351 s rv_start("/srv/obio");299 spawn("/srv/devman"); 300 spawn("/srv/apic"); 301 spawn("/srv/i8259"); 302 spawn("/srv/obio"); 352 303 srv_start("/srv/cuda_adb"); 353 srv_start("/srv/s3c24xx_uart"); 354 srv_start("/srv/s3c24xx_ts"); 355 356 srv_start("/srv/loopip"); 357 srv_start("/srv/ethip"); 358 srv_start("/srv/inetsrv"); 359 srv_start("/srv/tcp"); 360 srv_start("/srv/udp"); 361 srv_start("/srv/dnsrsrv"); 362 363 srv_start("/srv/clipboard"); 364 srv_start("/srv/remcons"); 304 srv_start("/srv/s3c24ser"); 305 srv_start("/srv/s3c24ts"); 306 307 spawn("/srv/ethip"); 308 spawn("/srv/inet"); 309 spawn("/srv/tcp"); 310 spawn("/srv/udp"); 311 312 spawn("/srv/fb"); 313 spawn("/srv/input"); 314 console("hid/input", "hid/fb0"); 315 316 spawn("/srv/clip"); 317 spawn("/srv/remcons"); 365 318 366 319 /* … … 370 323 #ifdef CONFIG_START_BD 371 324 srv_start("/srv/ata_bd"); 325 srv_start("/srv/gxe_bd"); 326 #else 327 (void) srv_start; 372 328 #endif 373 329 374 330 #ifdef CONFIG_MOUNT_DATA 375 331 /* Make sure fat is running. */ 376 if (str_cmp(STRING(RDFMT), "fat") != 0) 332 if (str_cmp(STRING(RDFMT), "fat") != 0) { 377 333 srv_start("/srv/fat"); 378 334 } 379 335 mount_data(); 380 336 #else … … 382 338 #endif 383 339 384 srv_start("/srv/input", HID_INPUT); 385 srv_start("/srv/output", HID_OUTPUT); 386 387 int rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER); 388 if (rc == EOK) { 389 gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER); 390 gui_start("/app/vterm", HID_COMPOSITOR_SERVER); 391 } else { 392 rc = console(HID_INPUT, HID_OUTPUT); 393 if (rc == EOK) { 394 getterm("term/vc0", "/app/bdsh", true); 395 getterm("term/vc1", "/app/bdsh", false); 396 getterm("term/vc2", "/app/bdsh", false); 397 getterm("term/vc3", "/app/bdsh", false); 398 getterm("term/vc4", "/app/bdsh", false); 399 getterm("term/vc5", "/app/bdsh", false); 400 getterm("term/vc6", "/app/klog", false); 401 } 402 } 340 getterm("term/vc0", "/app/bdsh", true); 341 getterm("term/vc1", "/app/bdsh", false); 342 getterm("term/vc2", "/app/bdsh", false); 343 getterm("term/vc3", "/app/bdsh", false); 344 getterm("term/vc4", "/app/bdsh", false); 345 getterm("term/vc5", "/app/bdsh", false); 346 getterm("term/vc6", "/app/klog", false); 403 347 404 348 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.