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

updated libdvdcss and libdvdcss-dev (1.2.12 -> 1.4.2)
author Hans-G?nter Theisgen
date Mon Apr 01 15:12:18 2019 +0100 (2019-04-01)
parents cbcb33ee9044
children 87b6697bb350
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 u32 root_dev;
12 u32 vid_mode; // -3 = ask
13 // -2 = Extended VGA
14 // -1 = Normal VGA
15 // n = as "n" was pressed
16 u32 topmem;
18 inline void syntax() {
19 die("Syntax:" NL
20 "LINLD [image=file] [initrd=files] [vga=mode] [root=num] [mem=max] [cl=cmdline]" NL
21 "vga mode: ask,extended,normal or dec/oct/hex number" NL
22 "-f force" NL
23 "Defaults:" NL
24 "\timage=bzImage" NL
25 "\tinitrd,vga,root=(void)" NL
26 "\tmem=256m" NL
27 "\tcl=auto" NL
28 #ifdef USE_ARGSTR
29 "\t-b=1088k" NL
30 #else
31 "\t-b 1088k" NL
32 #endif
33 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL
34 "Use cl=@filename to get it from a file"
35 #if 1
36 NL NL "Examples:" NL
37 #ifdef USE_ARGSTR
38 "\tLINLD -f -b=64m initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz \"cl=rw root=/dev/null video=-32\""
39 #else
40 "\tLINLD -f -b 64m initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz \"cl=rw root=/dev/null video=-32\""
41 #endif
42 NL NL "\tLINLD image=memtest"
43 #endif
44 );
45 }
47 static char buf_cmdline[128];
48 int main(int argc, char *argv[]) {
50 (void) argc;
52 // Believe it or not - this enables A20
53 // on my box! Must be DOS in HMA... -vda
54 puts("LINLD v" VERSION_STR "+");
56 // Parse command line
57 #ifdef USE_ARGSTR
58 if (argv[1]) {for (;;) {
59 const char **clp = &cmdline;
60 next:
61 argv++;
62 if (!*argv) {
63 puts(*clp);
64 set_cmdline(*clp);
65 puts(load_kernel());
66 load_initrd();
67 boot_kernel();
68 }
69 if ((*(u16 *)*argv|0x2002) == 0x662F) { // -F /f
70 skip_alloc++;
71 goto next;
72 }
73 if (argstr(*argv,"cl|image|initrd",clp) == 0);
74 else if (fileexist(*argv) >= 0)
75 kernel_name=*argv;
76 else if (*argv) {
77 argnum(*argv,"root|vga|mem|-b",&root_dev);
78 *clp = (const char *) buf_cmdline + 1;
79 strcatb((const char *) buf_cmdline,*argv);
80 }
81 else
82 break;
83 }
84 }
85 #else
86 if (argv[1]) while (1) {
87 char *s;
88 next:
89 argv++;
90 s=*argv;
91 if (!s) {
92 puts(load_kernel());
93 load_initrd();
94 boot_kernel();
95 }
96 if(strhead(s,"image=") == 0) {
97 s+=6;
98 set_kernel_name:
99 kernel_name=s;
100 }
101 else if(strhead(s,"initrd=") == 0) {
102 s+=7;
103 initrd_name=s;
104 }
105 else if(strhead(s,"vga=") == 0) {
106 s+=4;
107 vid_mode = strtol(s); // support normal, extended & ask
108 }
109 else switch (*(u16 *)s|0x2002) {
110 case 0x662F: // -F /f
111 skip_alloc++;
112 goto next;
113 case 0x622F: // -B /b
114 argv++;
115 base_himem = strtol(*argv);
116 goto next;
117 default:
118 if(strhead(s,"cl=") == 0) {
119 cmdline=s+=3;
120 if (*s == '@') {
121 static struct image_himem image;
122 char c;
124 s++;
125 image.errmsg = "Error in cl=@file";
126 open_image(s, &image);
127 cmdline=s=(char *)malloc_or_die(image.size);
128 s+=image.size;
129 read(image.fd, (void *)cmdline, image.size);
130 // Strip any trailing cr/lf
131 c='\0';
132 do {
133 // Replace all other cr/lfs with spaces
134 s--;
135 if(*s>=' ') c=' ';
136 else *s = c;
137 } while (s>cmdline);
138 puts("Kernel command line:");
139 puts(cmdline);
140 }
141 }
142 else if(strhead(s,"root=") == 0) {
143 s+=5;
144 root_dev = strtol(s);
145 goto addincmdline;
146 }
147 else if(strhead(s,"mem=") == 0) {
148 s+=4;
149 topmem = strtol(s);
150 goto addincmdline;
151 }
152 else {
153 addincmdline:
154 if(cmdline == (const char *) buf_cmdline + 1) {
155 strcatb(buf_cmdline,*argv);
156 }
157 else {
158 if(fileexist(s) != -1) goto set_kernel_name;
159 cmdline = (const char *) buf_cmdline + 1;
160 goto addincmdline;
161 }
162 }
163 }
164 }
165 #endif
166 syntax();
168 // Let compiler be happy
169 return _AX;
170 }