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