Rev 4420 | Rev 4668 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4420 | Rev 4537 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | #include <errno.h> |
42 | #include <errno.h> |
43 | #include <fcntl.h> |
43 | #include <fcntl.h> |
44 | #include <task.h> |
44 | #include <task.h> |
45 | #include <malloc.h> |
45 | #include <malloc.h> |
46 | #include <macros.h> |
46 | #include <macros.h> |
47 | #include <console.h> |
- | |
48 | #include <string.h> |
47 | #include <string.h> |
- | 48 | #include <devmap.h> |
|
49 | #include "init.h" |
49 | #include "init.h" |
50 | #include "version.h" |
- | |
51 | 50 | ||
- | 51 | static void info_print(void) |
|
- | 52 | { |
|
- | 53 | printf(NAME ": HelenOS init\n"); |
|
- | 54 | } |
|
- | 55 | ||
52 | static bool mount_fs(const char *fstype) |
56 | static bool mount_root(const char *fstype) |
53 | { |
57 | { |
54 | int rc = -1; |
58 | int rc = -1; |
55 | char *opts = ""; |
59 | char *opts = ""; |
- | 60 | const char *root_dev = "initrd"; |
|
56 | 61 | ||
57 | if (str_cmp(fstype, "tmpfs") == 0) |
62 | if (str_cmp(fstype, "tmpfs") == 0) |
58 | opts = "restore"; |
63 | opts = "restore"; |
59 | 64 | ||
60 | while (rc < 0) { |
65 | while (rc < 0) { |
61 | rc = mount(fstype, "/", "initrd", opts, IPC_FLAG_BLOCKING); |
66 | rc = mount(fstype, "/", root_dev, opts, IPC_FLAG_BLOCKING); |
62 | 67 | ||
63 | switch (rc) { |
68 | switch (rc) { |
64 | case EOK: |
69 | case EOK: |
65 | printf(NAME ": Root filesystem mounted\n"); |
70 | printf(NAME ": Root filesystem mounted, %s at %s\n", |
- | 71 | fstype, root_dev); |
|
66 | break; |
72 | break; |
67 | case EBUSY: |
73 | case EBUSY: |
68 | printf(NAME ": Root filesystem already mounted\n"); |
74 | printf(NAME ": Root filesystem already mounted\n"); |
69 | break; |
75 | break; |
70 | case ELIMIT: |
76 | case ELIMIT: |
Line 116... | Line 122... | ||
116 | 122 | ||
117 | if (!task_spawn(fname, argv)) |
123 | if (!task_spawn(fname, argv)) |
118 | printf(NAME ": Error spawning %s\n", fname); |
124 | printf(NAME ": Error spawning %s\n", fname); |
119 | } |
125 | } |
120 | 126 | ||
- | 127 | static void getvc(char *dev, char *app) |
|
- | 128 | { |
|
- | 129 | char *argv[4]; |
|
- | 130 | char vc[MAX_DEVICE_NAME]; |
|
- | 131 | ||
- | 132 | snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev); |
|
- | 133 | ||
- | 134 | printf(NAME ": Spawning getvc on %s\n", vc); |
|
- | 135 | ||
- | 136 | dev_handle_t handle; |
|
- | 137 | devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); |
|
- | 138 | ||
- | 139 | if (handle >= 0) { |
|
- | 140 | argv[0] = "/app/getvc"; |
|
- | 141 | argv[1] = vc; |
|
- | 142 | argv[2] = app; |
|
- | 143 | argv[3] = NULL; |
|
- | 144 | ||
- | 145 | if (!task_spawn("/app/getvc", argv)) |
|
- | 146 | printf(NAME ": Error spawning getvc on %s\n", vc); |
|
- | 147 | } else |
|
- | 148 | printf(NAME ": Error waiting on %s\n", vc); |
|
- | 149 | } |
|
- | 150 | ||
121 | int main(int argc, char *argv[]) |
151 | int main(int argc, char *argv[]) |
122 | { |
152 | { |
123 | info_print(); |
153 | info_print(); |
124 | 154 | ||
125 | if (!mount_fs(STRING(RDFMT))) { |
155 | if (!mount_root(STRING(RDFMT))) { |
126 | printf(NAME ": Exiting\n"); |
156 | printf(NAME ": Exiting\n"); |
127 | return -1; |
157 | return -1; |
128 | } |
158 | } |
129 | 159 | ||
130 | spawn("/srv/devfs"); |
160 | spawn("/srv/devfs"); |
Line 138... | Line 168... | ||
138 | spawn("/srv/kbd"); |
168 | spawn("/srv/kbd"); |
139 | spawn("/srv/console"); |
169 | spawn("/srv/console"); |
140 | spawn("/srv/fhc"); |
170 | spawn("/srv/fhc"); |
141 | spawn("/srv/obio"); |
171 | spawn("/srv/obio"); |
142 | 172 | ||
143 | console_wait(); |
173 | getvc("vc0", "/app/bdsh"); |
144 | version_print(); |
174 | getvc("vc1", "/app/bdsh"); |
145 | - | ||
- | 175 | getvc("vc2", "/app/bdsh"); |
|
- | 176 | getvc("vc3", "/app/bdsh"); |
|
146 | spawn("/app/klog"); |
177 | getvc("vc4", "/app/bdsh"); |
147 | spawn("/app/bdsh"); |
178 | getvc("vc5", "/app/bdsh"); |
- | 179 | getvc("vc6", "/app/klog"); |
|
148 | 180 | ||
149 | usleep(1000000); |
181 | usleep(1000000); |
150 | spawn("/srv/pci"); |
182 | spawn("/srv/pci"); |
151 | 183 | ||
152 | return 0; |
184 | return 0; |