wok-stable view gpxe/stuff/cmdline.u @ rev 12459
lives: fix symlink (thanks I-Jurij)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Apr 28 08:19:20 2017 +0200 (2017-04-28) |
parents | a08b2e53cf96 |
children |
line source
1 --- gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
2 +++ gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
3 @@ -77,7 +77,9 @@
4 popw %ax
5 addw $(0x100/16), %ax /* Adjust cs */
6 pushw %ax
7 - jmp go_setup_code
8 + pushw $run_etherboot_floppy
9 + /* Calculated lcall to _start with %cs:0000 = image start */
10 + lret
12 bootsector:
13 jmp $BOOTSEG, $go /* reload cs:ip to match relocation addr */
14 @@ -197,7 +199,7 @@
15 */
17 /* Jump to loaded copy */
18 - ljmp $SYSSEG, $run_etherboot2
19 + ljmp $SYSSEG, $run_etherboot_floppy
21 endseg: .word SYSSEG + _load_size_pgh
22 .section ".zinfo.fixup", "a" /* Compressor fixup information */
23 @@ -436,8 +438,7 @@
24 * we just have to ensure that %cs:0000 is where the start of
25 * the Etherboot image *would* be.
26 */
27 -go_setup_code:
28 - pushw $run_etherboot
29 + pushw $run_etherboot_zImage
30 /* Calculated lcall to _start with %cs:0000 = image start */
31 lret
33 @@ -448,7 +449,25 @@
34 /*
35 We're now at the beginning of the kernel proper.
36 */
37 -run_etherboot2:
38 +run_etherboot_zImage:
39 + mov $0x0020, %si
40 + lodsw
41 + cmp $0xA33F, %ax
42 + jne run_etherboot
43 + lodsw
44 + xchg %ax, %si
45 + cmpb (%si),%ah
46 + je run_etherboot
47 + push %ds
48 + pop %es
49 + movw $boot_url, %di
50 +copy_cmdline:
51 + lodsb
52 + stosb
53 + or %al, %al
54 + jne copy_cmdline
55 + jmp run_etherboot
56 +run_etherboot_floppy:
57 push %cs
58 pop %ds
59 run_etherboot:
61 --- gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
62 +++ gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S
63 @@ -461,6 +461,15 @@
64 push %ds
65 pop %es
66 movw $boot_url, %di
67 + cmpw $0x4F42,(%si) /* skip BOOT_IMAGE=.... */
68 + jne copy_cmdline
69 +skip_arg:
70 + lodsb
71 + testb $0xDF, %al
72 + jne skip_arg
73 + or %al, %al
74 + jne copy_cmdline
75 + decw %si
76 copy_cmdline:
77 lodsb
78 stosb
80 --- gpxe-0.9.3/src/net/udp/dns.c
81 +++ gpxe-0.9.3/src/net/udp/dns.c
82 @@ -506,6 +506,19 @@
83 .resolv = dns_resolv,
84 };
86 +int apply_nameserver(struct in_addr sin_addr)
87 +{
88 + struct sockaddr_in *sin_nameserver;
89 +
90 + sin_nameserver = ( struct sockaddr_in * ) &nameserver;
91 + sin_nameserver->sin_family = AF_INET;
92 + sin_nameserver->sin_addr = sin_addr;
93 + DBG ( "DNS using nameserver %s\n",
94 + inet_ntoa ( sin_addr ) );
95 +
96 + return 0;
97 +}
98 +
99 /**
100 * Apply DHCP nameserver option
101 *
102 @@ -514,16 +527,10 @@
103 */
104 static int apply_dhcp_nameserver ( unsigned int tag __unused,
105 struct dhcp_option *option ) {
106 - struct sockaddr_in *sin_nameserver;
107 -
108 - sin_nameserver = ( struct sockaddr_in * ) &nameserver;
109 - sin_nameserver->sin_family = AF_INET;
110 - dhcp_ipv4_option ( option, &sin_nameserver->sin_addr );
111 -
112 - DBG ( "DNS using nameserver %s\n",
113 - inet_ntoa ( sin_nameserver->sin_addr ) );
114 + struct in_addr sin_addr;
116 - return 0;
117 + dhcp_ipv4_option ( option, &sin_addr );
118 + return apply_nameserver(sin_addr);
119 }
121 /** DHCP nameserver applicator */
123 --- gpxe-0.9.3/src/usr/autoboot.c
124 +++ gpxe-0.9.3/src/usr/autoboot.c
125 @@ -23,6 +23,7 @@
126 #include <gpxe/dhcp.h>
127 #include <gpxe/image.h>
128 #include <gpxe/embedded.h>
129 +#include <gpxe/ip.h>
130 #include <usr/ifmgmt.h>
131 #include <usr/route.h>
132 #include <usr/dhcpmgmt.h>
133 @@ -150,16 +151,68 @@
134 */
135 static int netboot ( struct net_device *netdev ) {
136 char buf[256];
137 - int rc;
138 + int rc, nodhcp;
139 + char *ip, *gw, *dns, *s;
140 + extern int apply_nameserver(struct in_addr sin_addr);
142 /* Open device and display device status */
143 if ( ( rc = ifopen ( netdev ) ) != 0 )
144 return rc;
145 ifstat ( netdev );
147 + ip = gw = dns = NULL;
148 + nodhcp = 0;
149 + for (s = forced_url.url; *s && s < forced_url.url + 256;) {
150 + while (*s == ' ') s++;
151 + if (!strncmp(s,"ip=",3)) ip = s + 3, *s++ = 0;
152 + if (!strncmp(s,"gw=",3)) gw = s + 3, *s++ = 0;
153 + if (!strncmp(s,"dns=",4)) dns = s + 4, *s++ = 0;
154 + if (!strncmp(s,"nodhcp",5)) nodhcp++, *s++ = 0;
155 + if (!strncmp(s,"url=",4)) {
156 + char *p = forced_url.url;
157 + for (s += 4; *s && *s != ' '; *p++ = *s++);
158 + *p = 0;
159 + }
160 + while (*s && *s != ' ') s++;
161 + *s++ = 0;
162 + }
163 +
164 /* Configure device via DHCP */
165 - if ( ( rc = dhcp ( netdev ) ) != 0 )
166 - return rc;
167 + if (forced_url.url[0]) printf("url=%s\n",forced_url.url);
168 + if ( nodhcp || ( rc = dhcp ( netdev ) ) != 0 ) {
169 +#define IN_CLASSA(x) (( (x).s_addr & 0x80000000) == 0)
170 +#define IN_CLASSB(x) (( (x).s_addr & 0xc0000000) == 0x80000000)
171 +#define IN_CLASSA_NET 0xff000000
172 +#define IN_CLASSB_NET 0xffff0000
173 +#define IN_CLASSC_NET 0xffffff00
174 +#define IN_CLASSLESS_NET(x) (0xffffffff << (32 - (x)))
175 + struct in_addr address, netmask, gateway, nameserver;
176 + char *p;
177 +
178 + if (!ip || !gw || !inet_aton(gw, &gateway))
179 + return rc;
180 + p = strchr(ip,'/');
181 + if (p) *p++ = 0;
182 + if (!inet_aton(ip, &address))
183 + return rc;
184 + if (p) {
185 + int n;
186 + for (n = 0; *p >= '0' && *p <= '9';
187 + n *= 10, n += *p++ - 10);
188 + netmask.s_addr = IN_CLASSLESS_NET(n);
189 + }
190 + else if (IN_CLASSA(address)) netmask.s_addr = IN_CLASSA_NET;
191 + else if (IN_CLASSB(address)) netmask.s_addr = IN_CLASSB_NET;
192 + else netmask.s_addr = IN_CLASSC_NET;
193 + del_ipv4_address ( netdev );
194 + if ( ( rc = add_ipv4_address ( netdev, address, netmask,
195 + gateway ) ) != 0 ) {
196 + return rc;
197 + }
198 + if (dns) printf("dns=%s\n",dns);
199 + if (dns && inet_aton(dns, &nameserver))
200 + apply_nameserver(nameserver);
201 + }
202 route();
204 /* Try to boot an embedded image if we have one */