wok-6.x view linld/stuff/src/LINLD.CPP @ rev 23996

linld: add iso support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 08 20:15:35 2021 +0000 (2021-01-08)
parents e07718b42e73
children 5c1ce90eb1d6
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 u32 cmdnum[4];
13 inline void syntax() {
14 die("Syntax:" NL
15 "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline] [iso=file]" NL
16 "vga mode: ask,extended,normal or dec/oct/hex number" NL
17 "-64 for cpu64 only" NL
18 "Defaults:" NL
19 "\timage=bzImage" NL
20 "\tinitrd,vga,root=(void)" NL
21 "\tmem=256m" NL
22 "\tcl=auto" NL
23 "\t-b 1088k" NL
24 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL
25 "Use cl=@filename to get it from a file"
26 #if 1
27 NL NL "Examples:" NL
28 "\tLINLD "
29 "-b 64m "
30 "initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz "
31 "\"cl=root=/dev/null video=-32\""
32 NL NL "\tLINLD image=memtest"
33 #endif
34 );
35 }
37 extern char buf_cmdline[128];
38 int main(int argc, char *argv[]) {
40 (void) argc;
42 ((u16*) &base_himem)[1] |= (_1m+_64k)>>16; // base_himem = _1m+_64k
43 puts("LINLD v" VERSION_STR "+");
45 // Parse command line
46 if (!*++argv) syntax();
47 const char **clp = &cmdline;
48 do {
49 if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64
50 if (cpuhaslm() != 0) continue;
51 exit();
52 }
53 if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue;
54 if (argnum(*argv,"root|vga|mem|-b",&root_dev) == (int) &base_himem) continue;
55 if (fileexist(*argv) != -1) {
56 kernel_name=*argv;
57 continue;
58 }
59 *clp = (const char *) buf_cmdline + 1;
60 strcatb((const char *) buf_cmdline,*argv);
61 } while (*++argv);
62 puts(*clp);
63 if (isofile) setiso(isofile);
64 set_cmdline(*clp);
65 load_kernel();
66 load_initrd();
67 boot_kernel();
69 // Let compiler be happy
70 return _AX;
71 }