Ignore:
File:
1 edited

Legend:

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

    r51da086 r28f8f6f2  
    3434 */
    3535
     36#include <fibril.h>
    3637#include <stdio.h>
    3738#include <stdarg.h>
     
    4748#include <config.h>
    4849#include <io/logctl.h>
     50#include <vfs/vfs.h>
    4951#include <vol.h>
    5052#include "untar.h"
    5153#include "init.h"
    5254
    53 #define BANNER_LEFT   "######> "
    54 #define BANNER_RIGHT  " <######"
    55 
    5655#define ROOT_DEVICE       "bd/initrd"
    5756#define ROOT_MOUNT_POINT  "/"
     
    6665#define APP_GETTERM  "/app/getterm"
    6766
    68 #define SRV_COMPOSITOR  "/srv/hid/compositor"
     67#define SRV_DISPLAY  "/srv/hid/display"
     68#define DISPLAY_SVC  "hid/display"
    6969
    7070#define HID_INPUT              "hid/input"
    7171#define HID_OUTPUT             "hid/output"
    72 #define HID_COMPOSITOR_SERVER  ":0"
    7372
    7473#define srv_start(path, ...) \
     
    8483{
    8584        printf("%s: HelenOS init\n", NAME);
    86 }
    87 
    88 static 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         }
    9985}
    10086
     
    215201
    216202        if (rc != EOK) {
    217                 oom_check(rc, path);
    218203                printf("%s: Error spawning %s (%s)\n", NAME, path,
    219204                    str_error(rc));
     
    271256}
    272257
    273 static 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 
    287 static 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);
     258static errno_t display_server(void)
     259{
     260        return srv_start(SRV_DISPLAY);
     261}
     262
     263static int gui_start(const char *app, const char *display_svc)
     264{
     265        printf("%s: Spawning %s\n", NAME, app);
    293266
    294267        task_id_t id;
    295268        task_wait_t wait;
    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;
     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;
    302274        }
    303275
     
    308280                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
    309281                    app, str_error(rc));
    310                 return rc;
     282                return -1;
    311283        }
    312284
     
    322294                errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    323295                    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
    324                 if (rc != EOK) {
    325                         oom_check(rc, APP_GETTERM);
     296                if (rc != EOK)
    326297                        printf("%s: Error spawning %s %s %s --msg --wait -- %s\n",
    327298                            NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    328                 }
    329299        } else {
    330300                printf("%s: Spawning %s %s %s --wait -- %s\n", NAME,
     
    333303                errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    334304                    LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
    335                 if (rc != EOK) {
    336                         oom_check(rc, APP_GETTERM);
     305                if (rc != EOK)
    337306                        printf("%s: Error spawning %s %s %s --wait -- %s\n",
    338307                            NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    339                 }
    340308        }
    341309}
     
    480448
    481449        if (!config_key_exists("console")) {
    482                 rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER);
     450                rc = display_server();
    483451                if (rc == EOK) {
    484                         gui_start("/app/barber", HID_COMPOSITOR_SERVER);
    485                         gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
    486                         gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
     452                        gui_start("/app/barber", DISPLAY_SVC);
     453                        gui_start("/app/vlaunch", DISPLAY_SVC);
     454                        gui_start("/app/vterm", DISPLAY_SVC);
    487455                }
    488456        }
Note: See TracChangeset for help on using the changeset viewer.