wok view linld/stuff/src/LINLD.CPP @ rev 24014

linld: add quick boot switch (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Feb 19 18:33:17 2021 +0000 (2021-02-19)
parents bc4b94310a29
children 14ca5e18cfd9
line source
1 // This file is distributed under GPL
2 //
3 // LINLD main() lives here
5 #include "crtl.h"
6 #include "common.h"
7 #include "iso9660.h"
9 extern char bzimagestr[];
10 const char* cmdstr[4] = {"auto",bzimagestr,NULL,NULL};
11 #ifdef QUICK_BOOT
12 u32 cmdnum[7];
13 #else
14 u32 cmdnum[5];
15 #endif
17 inline void syntax() {
18 die("Syntax:" NL
19 "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline] [iso=file]" NL
20 "vga mode: ask,extended,normal or dec/oct/hex number" NL
21 "-64 for cpu64 only" NL
22 "Defaults:" NL
23 "\timage=bzImage" NL
24 "\tinitrd,vga,root=(void)" NL
25 "\tmem=256m" NL
26 "\tcl=auto" NL
27 "\t-b 1088k" NL
28 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL
29 "Use cl=@filename to get it from a file"
30 #if 1
31 NL NL "Examples:" NL
32 "\tLINLD "
33 "-b 64m "
34 "initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz "
35 "\"cl=root=/dev/null video=-32\""
36 NL NL "\tLINLD image=memtest"
37 #endif
38 );
39 }
41 extern char buf_cmdline[128];
42 int main(int argc, char *argv[]) {
44 (void) argc;
46 ((u16*) &base_himem)[1] |= (_1m+_64k)>>16; // base_himem = _1m+_64k
47 puts("LINLD v" VERSION_STR "+");
49 // Parse command line
50 if (!*++argv) syntax();
51 const char **clp = &cmdline;
52 do {
53 if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64
54 if (cpuhaslm() != 0) continue;
55 exit();
56 }
57 if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue;
58 #ifdef QUICK_BOOT
59 if (argnum(*argv,"root|vga|mem|-b|-f~-q~-v~",&root_dev) >= (int) &base_himem) continue;
60 #else
61 if (argnum(*argv,"root|vga|mem|-b|-f~",&root_dev) >= (int) &base_himem) continue;
62 #endif
63 if (fileexist(*argv) != -1) {
64 kernel_name=*argv;
65 continue;
66 }
67 *clp = (const char *) buf_cmdline + 1;
68 strcatb((const char *) buf_cmdline,*argv);
69 } while (*++argv);
70 puts(*clp);
71 if (isofile) setiso(isofile);
72 set_cmdline(*clp);
73 load_kernel();
74 load_initrd();
75 boot_kernel();
77 // Let compiler be happy
78 return _AX;
79 }