Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    r28f8f6f2 r51da086  
    3434 */
    3535
    36 #include <fibril.h>
    3736#include <stdio.h>
    3837#include <stdarg.h>
     
    4847#include <config.h>
    4948#include <io/logctl.h>
    50 #include <vfs/vfs.h>
    5149#include <vol.h>
    5250#include "untar.h"
    5351#include "init.h"
    5452
     53#define BANNER_LEFT   "######> "
     54#define BANNER_RIGHT  " <######"
     55
    5556#define ROOT_DEVICE       "bd/initrd"
    5657#define ROOT_MOUNT_POINT  "/"
     
    6566#define APP_GETTERM  "/app/getterm"
    6667
    67 #define SRV_DISPLAY  "/srv/hid/display"
    68 #define DISPLAY_SVC  "hid/display"
     68#define SRV_COMPOSITOR  "/srv/hid/compositor"
    6969
    7070#define HID_INPUT              "hid/input"
    7171#define HID_OUTPUT             "hid/output"
     72#define HID_COMPOSITOR_SERVER  ":0"
    7273
    7374#define srv_start(path, ...) \
     
    8384{
    8485        printf("%s: HelenOS init\n", NAME);
     86}
     87
     88static void oom_check(errno_t rc, const char *path)
     89{
     90        if (rc == ENOMEM) {
     91                printf("%sOut-of-memory condition detected%s\n", BANNER_LEFT,
     92                    BANNER_RIGHT);
     93                printf("%sBailing out of the boot process after %s%s\n",
     94                    BANNER_LEFT, path, BANNER_RIGHT);
     95                printf("%sMore physical memory is required%s\n", BANNER_LEFT,
     96                    BANNER_RIGHT);
     97                exit(ENOMEM);
     98        }
    8599}
    86100
     
    201215
    202216        if (rc != EOK) {
     217                oom_check(rc, path);
    203218                printf("%s: Error spawning %s (%s)\n", NAME, path,
    204219                    str_error(rc));
     
    256271}
    257272
    258 static errno_t display_server(void)
    259 {
    260         return srv_start(SRV_DISPLAY);
    261 }
    262 
    263 static int gui_start(const char *app, const char *display_svc)
    264 {
    265         printf("%s: Spawning %s\n", NAME, app);
     273static errno_t compositor(const char *isvc, const char *name)
     274{
     275        /* Wait for the input service to be ready */
     276        service_id_t service_id;
     277        errno_t rc = loc_service_get_id(isvc, &service_id, IPC_FLAG_BLOCKING);
     278        if (rc != EOK) {
     279                printf("%s: Error waiting on %s (%s)\n", NAME, isvc,
     280                    str_error(rc));
     281                return rc;
     282        }
     283
     284        return srv_start(SRV_COMPOSITOR, isvc, name);
     285}
     286
     287static int gui_start(const char *app, const char *srv_name)
     288{
     289        char winreg[50];
     290        snprintf(winreg, sizeof(winreg), "%s%s%s", "comp", srv_name, "/winreg");
     291
     292        printf("%s: Spawning %s %s\n", NAME, app, winreg);
    266293
    267294        task_id_t id;
    268295        task_wait_t wait;
    269         errno_t rc = task_spawnl(&id, &wait, app, app, display_svc, NULL);
    270         if (rc != EOK) {
    271                 printf("%s: Error spawning %s (%s)\n", NAME, app,
    272                     str_error(rc));
    273                 return -1;
     296        errno_t rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
     297        if (rc != EOK) {
     298                oom_check(rc, app);
     299                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
     300                    winreg, str_error(rc));
     301                return rc;
    274302        }
    275303
     
    280308                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
    281309                    app, str_error(rc));
    282                 return -1;
     310                return rc;
    283311        }
    284312
     
    294322                errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    295323                    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
    296                 if (rc != EOK)
     324                if (rc != EOK) {
     325                        oom_check(rc, APP_GETTERM);
    297326                        printf("%s: Error spawning %s %s %s --msg --wait -- %s\n",
    298327                            NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
     328                }
    299329        } else {
    300330                printf("%s: Spawning %s %s %s --wait -- %s\n", NAME,
     
    303333                errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    304334                    LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
    305                 if (rc != EOK)
     335                if (rc != EOK) {
     336                        oom_check(rc, APP_GETTERM);
    306337                        printf("%s: Error spawning %s %s %s --wait -- %s\n",
    307338                            NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
     339                }
    308340        }
    309341}
     
    448480
    449481        if (!config_key_exists("console")) {
    450                 rc = display_server();
     482                rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER);
    451483                if (rc == EOK) {
    452                         gui_start("/app/barber", DISPLAY_SVC);
    453                         gui_start("/app/vlaunch", DISPLAY_SVC);
    454                         gui_start("/app/vterm", DISPLAY_SVC);
     484                        gui_start("/app/barber", HID_COMPOSITOR_SERVER);
     485                        gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
     486                        gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
    455487                }
    456488        }
Note: See TracChangeset for help on using the changeset viewer.