system/core
リビジョン | 915b23670650d75b5d7f5e0355807adab81f910c (tree) |
---|---|
日時 | 2016-09-14 07:21:06 |
作者 | Linux Build Service Account <lnxbuild@loca...> |
コミッター | Gerrit - the friendly Code Review server |
Merge "init: Add support for slow devices"
@@ -12,6 +12,14 @@ endif | ||
12 | 12 | |
13 | 13 | init_options += -DLOG_UEVENTS=0 |
14 | 14 | |
15 | +ifneq ($(TARGET_INIT_COLDBOOT_TIMEOUT),) | |
16 | +init_options += -DCOLDBOOT_TIMEOUT_OVERRIDE=$(TARGET_INIT_COLDBOOT_TIMEOUT) | |
17 | +endif | |
18 | + | |
19 | +ifneq ($(TARGET_INIT_CONSOLE_TIMEOUT),) | |
20 | +init_options += -DCONSOLE_TIMEOUT_SEC=$(TARGET_INIT_CONSOLE_TIMEOUT) | |
21 | +endif | |
22 | + | |
15 | 23 | init_cflags += \ |
16 | 24 | $(init_options) \ |
17 | 25 | -Wall -Wextra \ |
@@ -160,15 +160,19 @@ void handle_control_message(const std::string& msg, const std::string& name) { | ||
160 | 160 | |
161 | 161 | static int wait_for_coldboot_done_action(const std::vector<std::string>& args) { |
162 | 162 | Timer t; |
163 | - | |
163 | + int timeout = 0; | |
164 | +#ifdef COLDBOOT_TIMEOUT_OVERRIDE | |
165 | + timeout = COLDBOOT_TIMEOUT_OVERRIDE; | |
166 | +#else | |
167 | + timeout = 5; | |
168 | +#endif | |
164 | 169 | NOTICE("Waiting for %s...\n", COLDBOOT_DONE); |
165 | 170 | // Any longer than 1s is an unreasonable length of time to delay booting. |
166 | 171 | // If you're hitting this timeout, check that you didn't make your |
167 | 172 | // sepolicy regular expressions too expensive (http://b/19899875). |
168 | - if (wait_for_file(COLDBOOT_DONE, 5)) { | |
173 | + if (wait_for_file(COLDBOOT_DONE, timeout)) { | |
169 | 174 | ERROR("Timed out waiting for %s\n", COLDBOOT_DONE); |
170 | 175 | } |
171 | - | |
172 | 176 | NOTICE("Waiting for %s took %.2fs.\n", COLDBOOT_DONE, t.duration()); |
173 | 177 | return 0; |
174 | 178 | } |
@@ -258,15 +262,31 @@ static int keychord_init_action(const std::vector<std::string>& args) | ||
258 | 262 | |
259 | 263 | static int console_init_action(const std::vector<std::string>& args) |
260 | 264 | { |
265 | + int fd = -1; | |
261 | 266 | std::string console = property_get("ro.boot.console"); |
262 | 267 | if (!console.empty()) { |
263 | 268 | console_name = "/dev/" + console; |
264 | 269 | } |
265 | - | |
266 | - int fd = open(console_name.c_str(), O_RDWR | O_CLOEXEC); | |
270 | + fd = open(console_name.c_str(), O_RDWR | O_CLOEXEC); | |
271 | +#ifdef CONSOLE_TIMEOUT_SEC | |
272 | + int num_console_retries = 0; | |
273 | + while ((fd < 0) && num_console_retries++ < CONSOLE_TIMEOUT_SEC) { | |
274 | + ERROR("Failed to open console device %s(%s)..Retrying\n", | |
275 | + console_name.c_str(), strerror(errno)); | |
276 | + sleep(1); | |
277 | + fd = open(console_name.c_str(), O_RDWR | O_CLOEXEC); | |
278 | + } | |
267 | 279 | if (fd >= 0) |
280 | + INFO("Console device located"); | |
281 | +#endif | |
282 | + if (fd >= 0) { | |
268 | 283 | have_console = 1; |
269 | - close(fd); | |
284 | + close(fd); | |
285 | + } else { | |
286 | + ERROR("console init failed. Open on Console device %s failed(%s)\n", | |
287 | + console.c_str(), strerror(errno)); | |
288 | + return 0; | |
289 | + } | |
270 | 290 | |
271 | 291 | fd = open("/dev/tty0", O_WRONLY | O_CLOEXEC); |
272 | 292 | if (fd >= 0) { |