Changeset 371bd7d in mainline for uspace/app/init/init.c
- Timestamp:
- 2010-03-27T09:22:17Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 36a75a2
- Parents:
- cd82bb1 (diff), eaf22d4 (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
rcd82bb1 r371bd7d 46 46 #include <malloc.h> 47 47 #include <macros.h> 48 #include <str ing.h>48 #include <str.h> 49 49 #include <devmap.h> 50 50 #include "init.h" 51 51 52 #define DEVFS_MOUNT_POINT "/dev" 53 54 #define SRV_CONSOLE "/srv/console" 55 #define APP_GETTERM "/app/getterm" 56 52 57 static void info_print(void) 53 58 { … … 57 62 static bool mount_root(const char *fstype) 58 63 { 59 c har *opts = "";60 const char *root_dev = " initrd";64 const char *opts = ""; 65 const char *root_dev = "bd/initrd"; 61 66 62 67 if (str_cmp(fstype, "tmpfs") == 0) … … 89 94 static bool mount_devfs(void) 90 95 { 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); 101 97 102 98 switch (rc) { … … 106 102 case EBUSY: 107 103 printf(NAME ": Device filesystem already mounted\n"); 108 devmap_null_destroy(null_id);109 104 return false; 110 105 case ELIMIT: 111 106 printf(NAME ": Unable to mount device filesystem\n"); 112 devmap_null_destroy(null_id);113 107 return false; 114 108 case ENOENT: 115 109 printf(NAME ": Unknown filesystem type (devfs)\n"); 116 devmap_null_destroy(null_id);117 110 return false; 118 111 default: 119 112 printf(NAME ": Error mounting device filesystem (%d)\n", rc); 120 devmap_null_destroy(null_id);121 113 return false; 122 114 } … … 125 117 } 126 118 127 static void spawn(c har *fname)128 { 129 c har *argv[2];119 static void spawn(const char *fname) 120 { 121 const char *argv[2]; 130 122 struct stat s; 131 123 … … 142 134 } 143 135 144 static void srv_start(c har *fname)145 { 146 c har *argv[2];136 static void srv_start(const char *fname) 137 { 138 const char *argv[2]; 147 139 task_id_t id; 148 140 task_exit_t texit; … … 170 162 } 171 163 172 if ( texit != TASK_EXIT_NORMAL || retval != 0) {164 if ((texit != TASK_EXIT_NORMAL) || (retval != 0)) { 173 165 printf(NAME ": Server %s failed to start (returned %d)\n", 174 166 fname, retval); … … 176 168 } 177 169 178 static void getvc(char *dev, char *app)179 { 180 c har *argv[4];181 char vc[MAX_DEVICE_NAME];170 static void console(const char *dev) 171 { 172 const char *argv[3]; 173 char hid_in[DEVMAP_NAME_MAXLEN]; 182 174 int rc; 183 175 184 snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev); 185 186 printf(NAME ": Spawning getvc on %s\n", vc); 187 176 snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 177 178 printf(NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in); 179 180 /* Wait for the input device to be ready */ 188 181 dev_handle_t handle; 189 182 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 190 183 191 184 if (rc == EOK) { 192 argv[0] = "/app/getvc"; 193 argv[1] = vc; 185 argv[0] = SRV_CONSOLE; 186 argv[1] = hid_in; 187 argv[2] = NULL; 188 189 if (!task_spawn(SRV_CONSOLE, argv)) 190 printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in); 191 } else 192 printf(NAME ": Error waiting on %s\n", hid_in); 193 } 194 195 static void getterm(const char *dev, const char *app) 196 { 197 const char *argv[4]; 198 char term[DEVMAP_NAME_MAXLEN]; 199 int rc; 200 201 snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 202 203 printf(NAME ": Spawning %s with %s %s\n", APP_GETTERM, term, app); 204 205 /* Wait for the terminal device to be ready */ 206 dev_handle_t handle; 207 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 208 209 if (rc == EOK) { 210 argv[0] = APP_GETTERM; 211 argv[1] = term; 194 212 argv[2] = app; 195 213 argv[3] = NULL; 196 214 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)215 if (!task_spawn(APP_GETTERM, argv)) 216 printf(NAME ": Error spawning %s with %s %s\n", APP_GETTERM, 217 term, app); 218 } else 219 printf(NAME ": Error waiting on %s\n", term); 220 } 221 222 static void mount_scratch(void) 205 223 { 206 224 int rc; 207 225 208 printf("Trying to mount disk0 on /data... ");226 printf("Trying to mount null/0 on /scratch... "); 209 227 fflush(stdout); 210 228 211 rc = mount(" fat", "/data", "disk0", "wtcache", 0);229 rc = mount("tmpfs", "/scratch", "null/0", "", 0); 212 230 if (rc == EOK) 213 231 printf("OK\n"); … … 216 234 } 217 235 236 static void mount_data(void) 237 { 238 int rc; 239 240 printf("Trying to mount bd/disk0 on /data... "); 241 fflush(stdout); 242 243 rc = mount("fat", "/data", "bd/disk0", "wtcache", 0); 244 if (rc == EOK) 245 printf("OK\n"); 246 else 247 printf("Failed\n"); 248 } 249 218 250 int main(int argc, char *argv[]) 219 251 { … … 224 256 return -1; 225 257 } 258 259 /* Make sure tmpfs is running. */ 260 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 261 spawn("/srv/tmpfs"); 262 } 226 263 227 264 spawn("/srv/devfs"); 265 spawn("/srv/taskmon"); 228 266 229 267 if (!mount_devfs()) { … … 231 269 return -2; 232 270 } 233 271 272 mount_scratch(); 273 274 spawn("/srv/fhc"); 275 spawn("/srv/obio"); 276 srv_start("/srv/cuda_adb"); 277 srv_start("/srv/i8042"); 278 srv_start("/srv/adb_ms"); 279 srv_start("/srv/char_ms"); 280 234 281 spawn("/srv/fb"); 235 282 spawn("/srv/kbd"); 236 spawn("/srv/console");237 spawn("/srv/fhc");238 spawn("/srv/ obio");283 console("hid_in/kbd"); 284 285 spawn("/srv/clip"); 239 286 240 287 /* … … 255 302 #endif 256 303 257 get vc("vc0", "/app/bdsh");258 get vc("vc1", "/app/bdsh");259 get vc("vc2", "/app/bdsh");260 get vc("vc3", "/app/bdsh");261 get vc("vc4", "/app/bdsh");262 get vc("vc5", "/app/bdsh");263 get vc("vc6", "/app/klog");264 304 getterm("term/vc0", "/app/bdsh"); 305 getterm("term/vc1", "/app/bdsh"); 306 getterm("term/vc2", "/app/bdsh"); 307 getterm("term/vc3", "/app/bdsh"); 308 getterm("term/vc4", "/app/bdsh"); 309 getterm("term/vc5", "/app/bdsh"); 310 getterm("term/vc6", "/app/klog"); 311 265 312 return 0; 266 313 }
Note:
See TracChangeset
for help on using the changeset viewer.