| 30 | #endif |
| 31 | |
| 32 | static int rootfs_mnt_init(void) |
| 33 | { |
| 34 | rt_err_t err = -RT_ERROR; |
| 35 | void *fsdata = RT_NULL; |
| 36 | const char *cromfs_type = "crom"; |
| 37 | const char *dev = bootargs_select("root=", 0); |
| 38 | const char *fstype = bootargs_select("rootfstype=", 0); |
| 39 | const char *rw = bootargs_select("rw", 0); |
| 40 | |
| 41 | if (!dev || !fstype) |
| 42 | { |
| 43 | const char *name = "initrd"; |
| 44 | rt_uint64_t initrd_start = 0, initrd_end = 0; |
| 45 | struct rt_mmblk_reg *iter = RT_NULL; |
| 46 | |
| 47 | rt_slist_for_each_entry(iter, &(rt_memblock_get_reserved()->reg_list), node) |
| 48 | { |
| 49 | if (rt_strcmp(iter->memreg.name, name) == 0) |
| 50 | { |
| 51 | initrd_start = iter->memreg.start; |
| 52 | initrd_end = iter->memreg.end; |
| 53 | break; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if (initrd_start && initrd_end) |
| 58 | { |
| 59 | size_t initrd_size = initrd_end - initrd_start; |
| 60 | |
| 61 | if ((fsdata = rt_ioremap_cached((void *)initrd_start, initrd_size))) |
| 62 | { |
| 63 | fstype = cromfs_type; |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | if (fstype != cromfs_type && dev) |
| 69 | { |
| 70 | rt_tick_t timeout = 0; |
| 71 | const char *rootwait, *rootdelay = RT_NULL; |
| 72 | |
| 73 | rootwait = bootargs_select("rootwait", 0); |
| 74 | |
| 75 | /* Maybe it is undefined or 'rootwaitABC' */ |
| 76 | if (!rootwait || *rootwait) |
| 77 | { |
| 78 | rootdelay = bootargs_select("rootdelay=", 0); |
| 79 | |
| 80 | if (rootdelay) |
| 81 | { |
| 82 | timeout = rt_tick_from_millisecond(atoi(rootdelay)); |
| 83 | } |
| 84 | |
| 85 | rootwait = RT_NULL; |
| 86 | } |
| 87 | |
| 88 | /* |
| 89 | * Delays in boot flow is a terrible behavior in RTOS, but the RT-Thread |
nothing calls this directly
no test coverage detected