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