wok-current annotate gpxe/stuff/cmdline.u @ rev 1349

php: .php3 .php4 .php5 support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Sep 05 14:50:21 2008 +0000 (2008-09-05)
parents c135cd14d789
children e35a8dffd011
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@1121 61 --- gpxe-0.9.3/src/net/udp/dns.c
pascal@1121 62 +++ gpxe-0.9.3/src/net/udp/dns.c
pascal@1121 63 @@ -506,6 +506,19 @@
pascal@1121 64 .resolv = dns_resolv,
pascal@1121 65 };
pascal@1121 66
pascal@1121 67 +int apply_nameserver(struct in_addr sin_addr)
pascal@1121 68 +{
pascal@1121 69 + struct sockaddr_in *sin_nameserver;
pascal@1121 70 +
pascal@1121 71 + sin_nameserver = ( struct sockaddr_in * ) &nameserver;
pascal@1121 72 + sin_nameserver->sin_family = AF_INET;
pascal@1121 73 + sin_nameserver->sin_addr = sin_addr;
pascal@1121 74 + DBG ( "DNS using nameserver %s\n",
pascal@1121 75 + inet_ntoa ( sin_addr ) );
pascal@1121 76 +
pascal@1121 77 + return 0;
pascal@1121 78 +}
pascal@1121 79 +
pascal@1121 80 /**
pascal@1121 81 * Apply DHCP nameserver option
pascal@1121 82 *
pascal@1121 83 @@ -514,16 +527,10 @@
pascal@1121 84 */
pascal@1121 85 static int apply_dhcp_nameserver ( unsigned int tag __unused,
pascal@1121 86 struct dhcp_option *option ) {
pascal@1121 87 - struct sockaddr_in *sin_nameserver;
pascal@1121 88 -
pascal@1121 89 - sin_nameserver = ( struct sockaddr_in * ) &nameserver;
pascal@1121 90 - sin_nameserver->sin_family = AF_INET;
pascal@1121 91 - dhcp_ipv4_option ( option, &sin_nameserver->sin_addr );
pascal@1121 92 -
pascal@1121 93 - DBG ( "DNS using nameserver %s\n",
pascal@1121 94 - inet_ntoa ( sin_nameserver->sin_addr ) );
pascal@1121 95 + struct in_addr sin_addr;
pascal@1121 96
pascal@1121 97 - return 0;
pascal@1121 98 + dhcp_ipv4_option ( option, &sin_addr );
pascal@1121 99 + return apply_nameserver(sin_addr);
pascal@1121 100 }
pascal@1121 101
pascal@1121 102 /** DHCP nameserver applicator */
pascal@1121 103
pascal@1121 104 --- gpxe-0.9.3/src/usr/autoboot.c
pascal@1121 105 +++ gpxe-0.9.3/src/usr/autoboot.c
pascal@1121 106 @@ -23,6 +23,7 @@
pascal@1121 107 #include <gpxe/dhcp.h>
pascal@1121 108 #include <gpxe/image.h>
pascal@1121 109 #include <gpxe/embedded.h>
pascal@1121 110 +#include <gpxe/ip.h>
pascal@1121 111 #include <usr/ifmgmt.h>
pascal@1121 112 #include <usr/route.h>
pascal@1121 113 #include <usr/dhcpmgmt.h>
pascal@1121 114 @@ -150,16 +151,68 @@
pascal@1121 115 */
pascal@1121 116 static int netboot ( struct net_device *netdev ) {
pascal@1121 117 char buf[256];
pascal@1121 118 - int rc;
pascal@1121 119 + int rc, nodhcp;
pascal@1121 120 + char *ip, *gw, *dns, *s;
pascal@1121 121 + extern int apply_nameserver(struct in_addr sin_addr);
pascal@1121 122
pascal@1121 123 /* Open device and display device status */
pascal@1121 124 if ( ( rc = ifopen ( netdev ) ) != 0 )
pascal@1121 125 return rc;
pascal@1121 126 ifstat ( netdev );
pascal@1121 127
pascal@1121 128 + ip = gw = dns = NULL;
pascal@1121 129 + nodhcp = 0;
pascal@1121 130 + for (s = forced_url.url; *s && s < forced_url.url + 256;) {
pascal@1121 131 + while (*s == ' ') s++;
pascal@1121 132 + if (!strncmp(s,"ip=",3)) ip = s + 3, *s++ = 0;
pascal@1121 133 + if (!strncmp(s,"gw=",3)) gw = s + 3, *s++ = 0;
pascal@1121 134 + if (!strncmp(s,"dns=",4)) dns = s + 4, *s++ = 0;
pascal@1121 135 + if (!strncmp(s,"nodhcp",5)) nodhcp++, *s++ = 0;
pascal@1121 136 + if (!strncmp(s,"url=",4)) {
pascal@1121 137 + char *p = forced_url.url;
pascal@1121 138 + for (s += 4; *s && *s != ' '; *p++ = *s++);
pascal@1121 139 + *p = 0;
pascal@1121 140 + }
pascal@1121 141 + while (*s && *s != ' ') s++;
pascal@1121 142 + *s++ = 0;
pascal@1121 143 + }
pascal@1121 144 +
pascal@1121 145 /* Configure device via DHCP */
pascal@1121 146 - if ( ( rc = dhcp ( netdev ) ) != 0 )
pascal@1121 147 - return rc;
pascal@1121 148 + if (forced_url.url[0]) printf("url=%s\n",forced_url.url);
pascal@1121 149 + if ( nodhcp || ( rc = dhcp ( netdev ) ) != 0 ) {
pascal@1121 150 +#define IN_CLASSA(x) (( (x).s_addr & 0x80000000) == 0)
pascal@1121 151 +#define IN_CLASSB(x) (( (x).s_addr & 0xc0000000) == 0x80000000)
pascal@1121 152 +#define IN_CLASSA_NET 0xff000000
pascal@1121 153 +#define IN_CLASSB_NET 0xffff0000
pascal@1121 154 +#define IN_CLASSC_NET 0xffffff00
pascal@1121 155 +#define IN_CLASSLESS_NET(x) (0xffffffff << (32 - (x)))
pascal@1121 156 + struct in_addr address, netmask, gateway, nameserver;
pascal@1121 157 + char *p;
pascal@1121 158 +
pascal@1121 159 + if (!ip || !gw || !inet_aton(gw, &gateway))
pascal@1121 160 + return rc;
pascal@1121 161 + p = strchr(ip,'/');
pascal@1121 162 + if (p) *p++ = 0;
pascal@1121 163 + if (!inet_aton(ip, &address))
pascal@1121 164 + return rc;
pascal@1121 165 + if (p) {
pascal@1121 166 + int n;
pascal@1121 167 + for (n = 0; *p >= '0' && *p <= '9';
pascal@1121 168 + n *= 10, n += *p++ - 10);
pascal@1121 169 + netmask.s_addr = IN_CLASSLESS_NET(n);
pascal@1121 170 + }
pascal@1121 171 + else if (IN_CLASSA(address)) netmask.s_addr = IN_CLASSA_NET;
pascal@1121 172 + else if (IN_CLASSB(address)) netmask.s_addr = IN_CLASSB_NET;
pascal@1121 173 + else netmask.s_addr = IN_CLASSC_NET;
pascal@1121 174 + del_ipv4_address ( netdev );
pascal@1121 175 + if ( ( rc = add_ipv4_address ( netdev, address, netmask,
pascal@1121 176 + gateway ) ) != 0 ) {
pascal@1121 177 + return rc;
pascal@1121 178 + }
pascal@1121 179 + if (dns) printf("dns=%s\n",dns);
pascal@1121 180 + if (dns && inet_aton(dns, &nameserver))
pascal@1121 181 + apply_nameserver(nameserver);
pascal@1121 182 + }
pascal@1121 183 route();
pascal@1121 184
pascal@1121 185 /* Try to boot an embedded image if we have one */