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

Add veracrypt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 24 11:24:29 2021 +0000 (2021-05-24)
parents 217c02cbbe8d
children 06547d8cf241
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 extern u32 cmdnum[7];
13 #else
14 extern 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 CPU32
26 "-32 for 386+" NL
27 #endif
28 #ifdef CPU64
29 "-64 for cpu64 only" NL
30 #endif
31 "Defaults:" NL
32 "\timage=bzImage" NL
33 "\tinitrd,vga,root=(void)" NL
34 "\tmem=256m" NL
35 "\tcl=auto" NL
36 "\t-b 1088k" NL
37 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL
38 "Use cl=@filename to get it from a file"
39 #if 1
40 NL NL "Examples:" NL
41 "\tLINLD "
42 "-b 64m "
43 "initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz "
44 "\"cl=root=/dev/null video=-32\""
45 NL "\tLINLD memtest"
46 #endif
47 );
48 }
50 int main(int argc, char *argv[]) {
52 (void) argc;
54 ((u16*) &base_himem)[1] |= (_1m+_64k)>>16; // base_himem = _1m+_64k
55 puts("LINLD v" VERSION_STR "+");
57 // Parse command line
58 if (!*++argv) syntax();
59 const char **clp = &cmdline;
60 do {
61 #ifdef CPU32
62 if ((*(u16 *)*argv|2) == 0x332F) { // -32 /32
63 extrn char cpu386;
64 if (cpu386 == 0) exit();
65 }
66 #endif
67 #ifdef CPU64
68 if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64
69 if (cpuhaslm() == 0) exit();
70 }
71 #endif
72 #ifdef ISO9660
73 if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue;
74 #else
75 if (argstr(*argv,"cl|image|initrd",clp) == (int) clp) continue;
76 #endif
77 #ifdef QUICK_BOOT
78 if (argnum(*argv,"root|vga|mem|-b|-f~-q~-v~",&root_dev) >= (int) &base_himem) continue;
79 #else
80 if (argnum(*argv,"root|vga|mem|-b|-f~",&root_dev) >= (int) &base_himem) continue;
81 #endif
82 if (fileexist(*argv) != -1) {
83 kernel_name=*argv;
84 continue;
85 }
86 *clp = (const char *) heap_top +1;
87 strcatb((const char *) heap_top,*argv);
88 } while (*++argv);
89 puts(*clp);
90 asm{
91 xchg ax,bx
92 mov bx,offset _heap_top
93 cmp ax,[bx]
94 jc skip
95 mov [bx],ax
96 }
97 skip:
98 #ifdef ISO9660
99 if (isofile) setiso(isofile);
100 #endif
101 set_cmdline(*clp);
102 load_kernel();
103 load_initrd();
104 //boot_kernel();
106 // Let compiler be happy
107 return _AX;
108 }