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

syslinux: fix build
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Feb 28 16:32:57 2021 +0000 (2021-02-28)
parents 14ca5e18cfd9
children 217c02cbbe8d
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] "
20 #ifdef ISO9660
21 "[iso=file] "
22 #endif
23 "..." NL
24 "vga mode: ask,extended,normal or dec/oct/hex number" NL
25 #ifdef CPU64
26 "-64 for cpu64 only" NL
27 #endif
28 "Defaults:" NL
29 "\timage=bzImage" NL
30 "\tinitrd,vga,root=(void)" NL
31 "\tmem=256m" NL
32 "\tcl=auto" NL
33 "\t-b 1088k" NL
34 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL
35 "Use cl=@filename to get it from a file"
36 #if 1
37 NL NL "Examples:" NL
38 "\tLINLD "
39 "-b 64m "
40 "initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz "
41 "\"cl=root=/dev/null video=-32\""
42 NL "\tLINLD memtest"
43 #endif
44 );
45 }
47 extern char buf_cmdline[128];
48 int main(int argc, char *argv[]) {
50 (void) argc;
52 ((u16*) &base_himem)[1] |= (_1m+_64k)>>16; // base_himem = _1m+_64k
53 puts("LINLD v" VERSION_STR "+");
55 // Parse command line
56 if (!*++argv) syntax();
57 const char **clp = &cmdline;
58 do {
59 #ifdef CPU64
60 if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64
61 if (cpuhaslm() != 0) continue;
62 exit();
63 }
64 #endif
65 #ifdef ISO9660
66 if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue;
67 #else
68 if (argstr(*argv,"cl|image|initrd",clp) == (int) clp) continue;
69 #endif
70 #ifdef QUICK_BOOT
71 if (argnum(*argv,"root|vga|mem|-b|-f~-q~-v~",&root_dev) >= (int) &base_himem) continue;
72 #else
73 if (argnum(*argv,"root|vga|mem|-b|-f~",&root_dev) >= (int) &base_himem) continue;
74 #endif
75 if (fileexist(*argv) != -1) {
76 kernel_name=*argv;
77 continue;
78 }
79 *clp = (const char *) buf_cmdline + 1;
80 strcatb((const char *) buf_cmdline,*argv);
81 } while (*++argv);
82 puts(*clp);
83 #ifdef ISO9660
84 if (isofile) setiso(isofile);
85 #endif
86 set_cmdline(*clp);
87 load_kernel();
88 load_initrd();
89 boot_kernel();
91 // Let compiler be happy
92 return _AX;
93 }