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

linld: add cpu detection
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jul 05 15:05:16 2021 +0000 (2021-07-05)
parents 324b3fa82b76
children c11594098e34
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=max] [cl=cmdline] "
15 #ifdef ISO9660
16 "[iso=file] "
17 #endif
18 "..." NL
19 "vga mode: ask,extended,normal or dec/oct/hex number" NL
20 #ifdef CPUTYPE
21 "-m mincpu family*256+model" NL
22 #endif
23 #ifdef CPU64
24 "-64 for cpu64 only" NL
25 #endif
26 "Defaults:" NL
27 "\timage=bzImage" NL
28 "\tinitrd,vga,root=(void)" NL
29 "\tmem=256m" NL
30 "\tcl=auto" NL
31 "\t-b 1088k" NL
32 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL
33 "Use cl=@filename to get it from a file"
34 #if 1
35 NL NL "Examples:" NL
36 "\tLINLD "
37 "-b 64m "
38 #ifdef CPUTYPE
39 "-m 0x600 "
40 #endif
41 "initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz "
42 "\"cl=root=/dev/null video=-32\""
43 NL "\tLINLD memtest"
44 #endif
45 );
46 }
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) 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 if (argnum(*argv,"root|vga|mem|-b|"
70 #ifdef CPUTYPE
71 "-m|"
72 #endif
73 "-f~"
74 #ifdef QUICK_BOOT
75 "-q~-v~"
76 #endif
77 ,&root_dev) >= (int) &base_himem) continue;
78 if (fileexist(*argv) != -1) {
79 kernel_name=*argv;
80 continue;
81 }
82 *clp = (const char *) heap_top +1;
83 strcatb((const char *) heap_top,*argv);
84 } while (*++argv);
85 #ifdef CPUTYPE
86 if (mincpu > cputype) exit();
87 #endif
88 puts(*clp);
89 asm{
90 xchg ax,bx
91 mov bx,offset _heap_top
92 cmp ax,[bx]
93 jc skip
94 mov [bx],ax
95 }
96 skip:
97 #ifdef ISO9660
98 if (isofile) setiso(isofile);
99 #endif
100 set_cmdline(*clp);
101 load_kernel();
102 load_initrd();
103 //boot_kernel();
105 // Let compiler be happy
106 return _AX;
107 }