The way the parsing works is examining one character at a time.
First, if we had `rootfstype=... root=...`, the parsing would jump and
ignore `root=...`, which sucks.
To fix this, we scan multiple times a copy of the cmdline.
Now, we have a new problem: `root=... altroot=...` lead to opts.device
being equal to the altroot as we are looking one char at a time, so we
will arrive at a moment looking at `root=...` for `altroot=...`.
To avoid this, we rename `altroot` in `rootalt`, cheap, I know.
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
In A/B schemas, it is possible to have multiple rootfs.
Thus, it is necessary to let the B kernel preinitialize either the A
rootfs or the B rootfs failing to mount the A rootfs.
Ideally, we should also try to switch to the B rootfs if we cannot start
up the init on the A rootfs, but that's a FUTUREWORK.
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
By using the kernel "nolibc" header to avoid requiring a C library, we
can bring the initramfs size to around 4k
This does involve a tiny bit of inline mips assembly which I'm not
sure about. gcc seems unwilling to generate the code to load $gp at
function entry of main(), so we do it by hand - but I'd rather find
out why gcc doesn't.