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

linld: basic iso9660 support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Mar 14 19:55:20 2021 +0000 (2021-03-14)
parents 61df94a0fa43
children 324b3fa82b76
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 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 int main(int argc, char *argv[]) {
49 (void) argc;
51 ((u16*) &base_himem)[1] |= (_1m+_64k)>>16; // base_himem = _1m+_64k
52 puts("LINLD v" VERSION_STR "+");
54 // Parse command line
55 if (!*++argv) syntax();
56 const char **clp = &cmdline;
57 do {
58 #ifdef CPU64
59 if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64
60 if (cpuhaslm() != 0) continue;
61 exit();
62 }
63 #endif
64 #ifdef ISO9660
65 if (argstr(*argv,"cl|image|initrd|iso",clp) == (int) clp) continue;
66 #else
67 if (argstr(*argv,"cl|image|initrd",clp) == (int) clp) continue;
68 #endif
69 #ifdef QUICK_BOOT
70 if (argnum(*argv,"root|vga|mem|-b|-f~-q~-v~",&root_dev) >= (int) &base_himem) continue;
71 #else
72 if (argnum(*argv,"root|vga|mem|-b|-f~",&root_dev) >= (int) &base_himem) continue;
73 #endif
74 if (fileexist(*argv) != -1) {
75 kernel_name=*argv;
76 continue;
77 }
78 *clp = (const char *) heap_top +1;
79 strcatb((const char *) heap_top,*argv);
80 } while (*++argv);
81 puts(*clp);
82 asm{
83 xchg ax,bx
84 mov bx,offset _heap_top
85 cmp ax,[bx]
86 jc skip
87 mov [bx],ax
88 }
89 skip:
90 #ifdef ISO9660
91 if (isofile) setiso(isofile);
92 #endif
93 set_cmdline(*clp);
94 load_kernel();
95 load_initrd();
96 //boot_kernel();
98 // Let compiler be happy
99 return _AX;
100 }