Changeset 7eaeec1 in mainline for uspace/app/init/init.c
- Timestamp:
- 2012-08-20T21:27:38Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a97f2e
- Parents:
- f3a37e28 (diff), dd13349 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
rf3a37e28 r7eaeec1 37 37 #include <stdio.h> 38 38 #include <unistd.h> 39 #include <stdarg.h> 39 40 #include <vfs/vfs.h> 40 41 #include <bool.h> … … 65 66 #define SRV_CONSOLE "/srv/console" 66 67 #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) 67 77 68 78 /** Print banner */ … … 143 153 } 144 154 145 static void spawn(const char *fname) 146 { 147 int rc; 155 static int srv_startl(const char *path, ...) 156 { 148 157 struct stat s; 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 { 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); 163 177 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 187 if (!id) { 188 printf("%s: Error spawning %s (invalid task id)\n", NAME, 189 path); 190 return EINVAL; 191 } 192 164 193 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); 173 if (!id) { 174 printf("%s: Error spawning %s (%s)\n", NAME, fname, 175 str_error(rc)); 176 return; 177 } 178 194 int retval; 179 195 rc = task_wait(id, &texit, &retval); 180 196 if (rc != EOK) { 181 printf("%s: Error waiting for %s (%s)\n", NAME, fname,182 str_error(rc)); 183 return ;197 printf("%s: Error waiting for %s (%s)\n", NAME, path, 198 str_error(rc)); 199 return rc; 184 200 } 185 201 186 202 if (texit != TASK_EXIT_NORMAL) { 187 203 printf("%s: Server %s failed to start (unexpectedly " 188 "terminated)\n", NAME, fname);189 return ;190 } 191 192 if (retval != 0) {204 "terminated)\n", NAME, path); 205 return EINVAL; 206 } 207 208 if (retval != 0) 193 209 printf("%s: Server %s failed to start (exit code %d)\n", NAME, 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 210 path, retval); 211 212 return retval; 213 } 214 215 static int console(const char *isvc, const char *osvc) 216 { 202 217 /* Wait for the input service to be ready */ 203 218 service_id_t service_id; … … 206 221 printf("%s: Error waiting on %s (%s)\n", NAME, isvc, 207 222 str_error(rc)); 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 } 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; 224 276 } 225 277 … … 227 279 { 228 280 char term[LOC_NAME_MAXLEN]; 229 int rc;230 231 281 snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc); 232 282 … … 235 285 /* Wait for the terminal service to be ready */ 236 286 service_id_t service_id; 237 rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);287 int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING); 238 288 if (rc != EOK) { 239 289 printf("%s: Error waiting on %s (%s)\n", NAME, term, … … 279 329 if (!mount_root(STRING(RDFMT))) { 280 330 printf("%s: Exiting\n", NAME); 281 return -1;331 return 1; 282 332 } 283 333 284 334 /* Make sure tmpfs is running. */ 285 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 286 spawn("/srv/tmpfs"); 287 } 288 289 spawn("/srv/locfs"); 290 spawn("/srv/taskmon"); 335 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) 336 srv_start("/srv/tmpfs"); 337 338 srv_start("/srv/locfs"); 339 srv_start("/srv/taskmon"); 291 340 292 341 if (!mount_locfs()) { 293 342 printf("%s: Exiting\n", NAME); 294 return -2;343 return 2; 295 344 } 296 345 297 346 mount_tmpfs(); 298 347 299 s pawn("/srv/devman");300 s pawn("/srv/apic");301 s pawn("/srv/i8259");302 s pawn("/srv/obio");348 srv_start("/srv/devman"); 349 srv_start("/srv/apic"); 350 srv_start("/srv/i8259"); 351 srv_start("/srv/obio"); 303 352 srv_start("/srv/cuda_adb"); 304 353 srv_start("/srv/s3c24xx_uart"); 305 354 srv_start("/srv/s3c24xx_ts"); 306 355 307 spawn("/srv/loopip"); 308 spawn("/srv/ethip"); 309 spawn("/srv/inetsrv"); 310 spawn("/srv/tcp"); 311 spawn("/srv/udp"); 312 313 spawn("/srv/fb"); 314 spawn("/srv/input"); 315 console("hid/input", "hid/fb0"); 316 317 spawn("/srv/clipboard"); 318 spawn("/srv/remcons"); 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 362 srv_start("/srv/clipboard"); 363 srv_start("/srv/remcons"); 319 364 320 365 /* … … 325 370 srv_start("/srv/ata_bd"); 326 371 srv_start("/srv/gxe_bd"); 327 #else328 (void) srv_start;329 372 #endif 330 373 331 374 #ifdef CONFIG_MOUNT_DATA 332 375 /* Make sure fat is running. */ 333 if (str_cmp(STRING(RDFMT), "fat") != 0) {376 if (str_cmp(STRING(RDFMT), "fat") != 0) 334 377 srv_start("/srv/fat"); 335 }378 336 379 mount_data(); 337 380 #else … … 339 382 #endif 340 383 341 getterm("term/vc0", "/app/bdsh", true); 342 getterm("term/vc1", "/app/bdsh", false); 343 getterm("term/vc2", "/app/bdsh", false); 344 getterm("term/vc3", "/app/bdsh", false); 345 getterm("term/vc4", "/app/bdsh", false); 346 getterm("term/vc5", "/app/bdsh", false); 347 getterm("term/vc6", "/app/klog", false); 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 } 348 403 349 404 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.