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

Up tazlito (534)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Feb 27 21:20:06 2022 +0000 (2022-02-27)
parents 8db826af003e
children 048ed88bf832
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};
12 inline void syntax() {
13 die("Syntax:" NL
14 "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=topLoad] [cl=cmdline] "
15 #ifdef ISO9660
16 "[iso=file] "
17 #endif
18 "..." NL
19 "\tvga mode: ask,extended,normal or dec/oct/hex number" NL
20 "\t-b baseLoad" NL
21 #ifdef MINRAM
22 "\t-r minRAM" NL
23 #endif
24 #ifdef CPUTYPE
25 "\t-c minCPU\tfamily*256+model" NL
26 #endif
27 #ifdef CPU64
28 "\t-64\t\t64 bits cpu" NL
29 #endif
30 #ifdef WITH_XMM_ALLOC
31 "\t-f\t\tskip XMMS alloc" NL
32 #endif
33 #ifdef QUICK_BOOT
34 # ifdef VCPI
35 "\t-v\t\tV86 mode" NL
36 # endif
37 "\t-q\t\tskip shutdown" NL
38 #endif
39 "Defaults:\t"
40 "image=bzImage "
41 "mem=256m "
42 "cl=auto "
43 "-b 1088k" NL
44 "Use quotes \"cl=...\" for spaces in cmdline"
45 ", cl=@filename to get it from a file"
46 #if 1
47 NL NL "Examples:" NL
48 "\tLINLD "
49 #ifdef MINRAM
50 "-r 96m "
51 #endif
52 #ifdef CPUTYPE
53 "-c 0x600 "
54 #endif
55 "initrd=rootfs.gz,mycfg.gz "
56 "\"cl=root=/dev/null video=-32\""
57 NL "\tLINLD memtest"
58 NL "\tLINLD @linld.cmd"
59 #endif
60 );
61 }
63 int main(int argc, char *argv[]) {
65 (void) argc;
67 ((u16*) &base_himem)[1] |= (_1m+_64k)>>16; // base_himem = _1m+_64k
68 puts("LINLD v" VERSION_STR "+");
70 // Parse command line
71 if (!*++argv) syntax();
72 const char **clp = &cmdline;
73 do {
74 #ifdef CPU64
75 if ((*(u16 *)*argv|2) == 0x362F) { // -64 /64
76 if (cpuhaslm() == 0) exit();
77 }
78 #endif
79 if (argstr(*argv,"cl|image|initrd" CMDSTR_EXTRA,clp) == (int) clp) continue;
80 if (argnum(*argv,"root|vga|mem|-b|" CMDNUM_EXTRA
81 #ifdef WITH_XMM_ALLOC
82 "-f~"
83 #endif
84 ,&root_dev) >= (int) &base_himem) continue;
85 if (fileexist(*argv) != -1) {
86 kernel_name=*argv;
87 continue;
88 }
89 *clp = (const char *) heap_top +1;
90 strcatb((const char *) heap_top,*argv);
91 } while (*++argv);
92 #ifdef MINRAM
93 if ((minram>>16) > (memtop()>>16)) exit();
94 #endif
95 #ifdef CPUTYPE
96 if (mincpu > cputype) exit();
97 #endif
99 puts(*clp);
100 asm{
101 xchg ax,bx
102 mov bx,offset _heap_top
103 cmp ax,[bx]
104 jc skip
105 mov [bx],ax
106 }
107 skip:
108 #ifdef ISO9660
109 if (isofile) setiso(isofile);
110 #endif
111 set_cmdline(*clp);
112 load_kernel();
113 load_initrd();
114 //boot_kernel();
116 // Let compiler be happy
117 return _AX;
118 }