wok-current view linld/stuff/src/LINLD.CPP @ rev 20119
slitaz-base-files (333), slitaz-boot-scripts (445), slitaz-configs (313), slitaz-tools (1025), tazbug (152), tazinst (93), tazirc (22), tazlito (469), tazpanel (617), tazweb (208): revision of german messages
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Oct 14 10:45:51 2017 +0200 (2017-10-14) |
parents | 6f494adb2c71 |
children | bcdfc23ee041 |
line source
1 // This file is distributed under GPL
2 //
3 // LINLD main() lives here
5 #include "crtl.h"
6 #include "common.h"
8 const char* kernel_name = "bzImage";
9 const char* initrd_name;
10 const char* cmdline = "auto";
11 u16 root_dev;
12 u16 vid_mode; // -3 = ask
13 // -2 = Extended VGA
14 // -1 = Normal VGA
15 // n = as "n" was pressed
17 inline void syntax() {
18 die("Syntax:" NL
19 "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline]" NL
20 "vga mode: ask,extended,normal or dec/oct/hex number" NL
21 "-f force" NL
22 "Defaults:" NL
23 "\timage=bzImage" NL
24 "\tinitrd,vga,root=(void)" NL
25 "\tmem=256m" NL
26 "\tcl=auto" NL
27 "\t-b 1088k" NL
28 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL
29 "Use cl=@filename to get it from a file"
30 #if 1
31 NL NL "Examples:" NL
32 "\tlinld -f -b 64m initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz \"cl=rw root=/dev/null video=-32\""
33 NL NL "\tlinld image=memtest"
34 #endif
35 );
36 }
38 static char _cmdline[128];
39 int main(int argc, char *argv[]) {
41 (void) argc;
43 // Believe it or not - this enables A20
44 // on my box! Must be DOS in HMA... -vda
45 puts("LINLD v" VERSION_STR "+");
47 // Parse command line
48 if (argv[1]) {for (char i=0;;) {
49 char *s;
50 next:
51 argv++;
52 s=*argv;
53 i++;
54 if (!s) {
55 puts(load_kernel());
56 load_initrd();
57 boot_kernel();
58 }
59 if(strhead(s,"image=") == 0) {
60 s+=6;
61 set_kernel_name:
62 kernel_name=s;
63 }
64 else if(strhead(s,"initrd=") == 0) {
65 s+=7;
66 initrd_name=s;
67 }
68 else if(strhead(s,"vga=") == 0) {
69 s+=4;
70 vid_mode = strtol(s); // support normal, extended & ask
71 }
72 else switch (*(u16 *)s|0x2002) {
73 case 0x662F: // -F /f
74 skip_alloc++;
75 goto next;
76 case 0x622F: // -B /b
77 argv++;
78 base_himem = strtol(*argv);
79 goto next;
80 default:
81 if(strhead(s,"cl=") == 0) {
82 cmdline=s+=3;
83 if (*s == '@') {
84 static struct image_himem image;
85 char c;
87 s++;
88 image.errmsg = "Error in cl=@file";
89 open_image(s, &image);
90 cmdline=s=(char *)malloc_or_die(image.size);
91 s+=image.size;
92 read(image.fd, (void *)cmdline, image.size);
93 // Strip any trailing cr/lf
94 c='\0';
95 do {
96 // Replace all other cr/lfs with spaces
97 s--;
98 if(*s>=' ') c=' ';
99 else *s = c;
100 } while (s>cmdline);
101 puts("Kernel command line:");
102 puts(cmdline);
103 }
104 }
105 else if(strhead(s,"root=") == 0) {
106 s+=5;
107 root_dev = strtol(s);
108 goto addincmdline;
109 }
110 else if(strhead(s,"mem=") == 0) {
111 s+=4;
112 topmem = strtol(s);
113 goto addincmdline;
114 }
115 else if(cmdline == (const char *) _cmdline + 1) {
116 addincmdline:
117 strcatb(_cmdline,*argv);
118 }
119 else if(i == 1 && fileattr(s) != -1) {
120 cmdline = (const char *) _cmdline + 1;
121 goto set_kernel_name;
122 }
123 else
124 break;
125 }
126 }}
127 syntax();
129 // Let compiler be happy
130 return _AX;
131 }