Changeset 3b3e776 in mainline for uspace/app/init/init.c


Ignore:
Timestamp:
2010-02-05T10:57:50Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0358da0
Parents:
3f085132 (diff), b4cbef1 (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.
Message:

merged with head

File:
1 edited

Legend:

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

    r3f085132 r3b3e776  
    5050#include "init.h"
    5151
     52#define DEVFS_MOUNT_POINT  "/dev"
     53
     54#define SRV_CONSOLE  "/srv/console"
     55#define APP_GETTERM  "/app/getterm"
     56
    5257static void info_print(void)
    5358{
     
    5863{
    5964        char *opts = "";
    60         const char *root_dev = "initrd";
     65        const char *root_dev = "bd/initrd";
    6166       
    6267        if (str_cmp(fstype, "tmpfs") == 0)
     
    8994static bool mount_devfs(void)
    9095{
    91         char null[MAX_DEVICE_NAME];
    92         int null_id = devmap_null_create();
    93        
    94         if (null_id == -1) {
    95                 printf(NAME ": Unable to create null device\n");
    96                 return false;
    97         }
    98        
    99         snprintf(null, MAX_DEVICE_NAME, "null%d", null_id);
    100         int rc = mount("devfs", "/dev", null, "", IPC_FLAG_BLOCKING);
     96        int rc = mount("devfs", DEVFS_MOUNT_POINT, "", "", IPC_FLAG_BLOCKING);
    10197       
    10298        switch (rc) {
     
    106102        case EBUSY:
    107103                printf(NAME ": Device filesystem already mounted\n");
    108                 devmap_null_destroy(null_id);
     104
    109105                return false;
    110106        case ELIMIT:
    111107                printf(NAME ": Unable to mount device filesystem\n");
    112                 devmap_null_destroy(null_id);
     108
    113109                return false;
    114110        case ENOENT:
    115111                printf(NAME ": Unknown filesystem type (devfs)\n");
    116                 devmap_null_destroy(null_id);
     112
    117113                return false;
    118114        default:
    119115                printf(NAME ": Error mounting device filesystem (%d)\n", rc);
    120                 devmap_null_destroy(null_id);
     116
    121117                return false;
    122118        }
     
    170166        }
    171167
    172         if (texit != TASK_EXIT_NORMAL || retval != 0) {
     168        if ((texit != TASK_EXIT_NORMAL) || (retval != 0)) {
    173169                printf(NAME ": Server %s failed to start (returned %d)\n",
    174170                        fname, retval);
     
    176172}
    177173
    178 static void getvc(char *dev, char *app)
    179 {
    180         char *argv[4];
    181         char vc[MAX_DEVICE_NAME];
     174static void console(char *dev)
     175{
     176        char *argv[3];
     177        char hid_in[DEVMAP_NAME_MAXLEN];
    182178        int rc;
    183179       
    184         snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev);
    185        
    186         printf(NAME ": Spawning getvc on %s\n", vc);
    187        
     180        snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev);
     181       
     182        printf(NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in);
     183       
     184        /* Wait for the input device to be ready */
    188185        dev_handle_t handle;
    189186        rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
    190187       
    191188        if (rc == EOK) {
    192                 argv[0] = "/app/getvc";
    193                 argv[1] = vc;
     189                argv[0] = SRV_CONSOLE;
     190                argv[1] = hid_in;
     191                argv[2] = NULL;
     192               
     193                if (!task_spawn(SRV_CONSOLE, argv))
     194                        printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in);
     195        } else
     196                printf(NAME ": Error waiting on %s\n", hid_in);
     197}
     198
     199static void getterm(char *dev, char *app)
     200{
     201        char *argv[4];
     202        char term[DEVMAP_NAME_MAXLEN];
     203        int rc;
     204       
     205        snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev);
     206       
     207        printf(NAME ": Spawning %s with %s %s\n", APP_GETTERM, term, app);
     208       
     209        /* Wait for the terminal device to be ready */
     210        dev_handle_t handle;
     211        rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
     212       
     213        if (rc == EOK) {
     214                argv[0] = APP_GETTERM;
     215                argv[1] = term;
    194216                argv[2] = app;
    195217                argv[3] = NULL;
    196218               
    197                 if (!task_spawn("/app/getvc", argv))
    198                         printf(NAME ": Error spawning getvc on %s\n", vc);
    199         } else {
    200                 printf(NAME ": Error waiting on %s\n", vc);
    201         }
    202 }
    203 
    204 static void mount_data(void)
     219                if (!task_spawn(APP_GETTERM, argv))
     220                        printf(NAME ": Error spawning %s with %s %s\n", APP_GETTERM,
     221                            term, app);
     222        } else
     223                printf(NAME ": Error waiting on %s\n", term);
     224}
     225
     226static void mount_scratch(void)
    205227{
    206228        int rc;
    207229
    208         printf("Trying to mount disk0 on /data... ");
     230        printf("Trying to mount null/0 on /scratch... ");
    209231        fflush(stdout);
    210232
    211         rc = mount("fat", "/data", "disk0", "wtcache", 0);
     233        rc = mount("tmpfs", "/scratch", "null/0", "", 0);
    212234        if (rc == EOK)
    213235                printf("OK\n");
     
    216238}
    217239
     240static void mount_data(void)
     241{
     242        int rc;
     243
     244        printf("Trying to mount bd/disk0 on /data... ");
     245        fflush(stdout);
     246
     247        rc = mount("fat", "/data", "bd/disk0", "wtcache", 0);
     248        if (rc == EOK)
     249                printf("OK\n");
     250        else
     251                printf("Failed\n");
     252}
     253
    218254int main(int argc, char *argv[])
    219255{
     
    224260                return -1;
    225261        }
     262
     263        /* Make sure tmpfs is running. */
     264        if (str_cmp(STRING(RDFMT), "tmpfs") != 0) {
     265                spawn("/srv/tmpfs");
     266        }
    226267       
    227268        spawn("/srv/devfs");
     269        spawn("/srv/taskmon");
    228270       
    229271        if (!mount_devfs()) {
     
    231273                return -2;
    232274        }
    233        
     275
     276        mount_scratch();
     277       
     278        spawn("/srv/fhc");
     279        spawn("/srv/obio");
     280        srv_start("/srv/cuda_adb");
     281        srv_start("/srv/i8042");
     282        srv_start("/srv/adb_ms");
     283        srv_start("/srv/char_ms");
     284
    234285        spawn("/srv/fb");
    235286        spawn("/srv/kbd");
    236         spawn("/srv/console");
    237         spawn("/srv/fhc");
    238         spawn("/srv/obio");
     287        console("hid_in/kbd");
     288       
     289        spawn("/srv/clip");
    239290
    240291        /*
     
    255306#endif
    256307
    257         getvc("vc0", "/app/bdsh");
    258         getvc("vc1", "/app/bdsh");
    259         getvc("vc2", "/app/bdsh");
    260         getvc("vc3", "/app/bdsh");
    261         getvc("vc4", "/app/bdsh");
    262         getvc("vc5", "/app/bdsh");
    263         getvc("vc6", "/app/klog");
    264        
     308        getterm("term/vc0", "/app/bdsh");
     309        getterm("term/vc1", "/app/bdsh");
     310        getterm("term/vc2", "/app/bdsh");
     311        getterm("term/vc3", "/app/bdsh");
     312        getterm("term/vc4", "/app/bdsh");
     313        getterm("term/vc5", "/app/bdsh");
     314        getterm("term/vc6", "/app/klog");
     315
    265316        usleep(1000000);
    266317        spawn("/srv/dd");
Note: See TracChangeset for help on using the changeset viewer.