wok-next diff gpxe/stuff/cmdline.u @ rev 1121
gpxe: add cmdline support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Jul 21 14:22:01 2008 +0000 (2008-07-21) |
parents | |
children | a08b2e53cf96 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gpxe/stuff/cmdline.u Mon Jul 21 14:22:01 2008 +0000 1.3 @@ -0,0 +1,183 @@ 1.4 +--- gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S 1.5 ++++ gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S 1.6 +@@ -77,7 +77,9 @@ 1.7 + popw %ax 1.8 + addw $(0x100/16), %ax /* Adjust cs */ 1.9 + pushw %ax 1.10 +- jmp go_setup_code 1.11 ++ pushw $run_etherboot_floppy 1.12 ++ /* Calculated lcall to _start with %cs:0000 = image start */ 1.13 ++ lret 1.14 + 1.15 + bootsector: 1.16 + jmp $BOOTSEG, $go /* reload cs:ip to match relocation addr */ 1.17 +@@ -197,7 +199,7 @@ 1.18 + */ 1.19 + 1.20 + /* Jump to loaded copy */ 1.21 +- ljmp $SYSSEG, $run_etherboot2 1.22 ++ ljmp $SYSSEG, $run_etherboot_floppy 1.23 + 1.24 + endseg: .word SYSSEG + _load_size_pgh 1.25 + .section ".zinfo.fixup", "a" /* Compressor fixup information */ 1.26 +@@ -436,8 +438,7 @@ 1.27 + * we just have to ensure that %cs:0000 is where the start of 1.28 + * the Etherboot image *would* be. 1.29 + */ 1.30 +-go_setup_code: 1.31 +- pushw $run_etherboot 1.32 ++ pushw $run_etherboot_zImage 1.33 + /* Calculated lcall to _start with %cs:0000 = image start */ 1.34 + lret 1.35 + 1.36 +@@ -448,7 +449,23 @@ 1.37 + /* 1.38 + We're now at the beginning of the kernel proper. 1.39 + */ 1.40 +-run_etherboot2: 1.41 ++run_etherboot_zImage: 1.42 ++ mov $0x0020, %si 1.43 ++ lodsw 1.44 ++ cmp $0xA33F, %ax 1.45 ++ jne run_etherboot 1.46 ++ lodsw 1.47 ++ xchg %ax, %si 1.48 ++ push %ds 1.49 ++ pop %es 1.50 ++ movw $boot_url, %di 1.51 ++copy_cmdline: 1.52 ++ lodsb 1.53 ++ stosb 1.54 ++ or %al, %al 1.55 ++ jne copy_cmdline 1.56 ++ jmp run_etherboot 1.57 ++run_etherboot_floppy: 1.58 + push %cs 1.59 + pop %ds 1.60 + run_etherboot: 1.61 + 1.62 +--- gpxe-0.9.3/src/net/udp/dns.c 1.63 ++++ gpxe-0.9.3/src/net/udp/dns.c 1.64 +@@ -506,6 +506,19 @@ 1.65 + .resolv = dns_resolv, 1.66 + }; 1.67 + 1.68 ++int apply_nameserver(struct in_addr sin_addr) 1.69 ++{ 1.70 ++ struct sockaddr_in *sin_nameserver; 1.71 ++ 1.72 ++ sin_nameserver = ( struct sockaddr_in * ) &nameserver; 1.73 ++ sin_nameserver->sin_family = AF_INET; 1.74 ++ sin_nameserver->sin_addr = sin_addr; 1.75 ++ DBG ( "DNS using nameserver %s\n", 1.76 ++ inet_ntoa ( sin_addr ) ); 1.77 ++ 1.78 ++ return 0; 1.79 ++} 1.80 ++ 1.81 + /** 1.82 + * Apply DHCP nameserver option 1.83 + * 1.84 +@@ -514,16 +527,10 @@ 1.85 + */ 1.86 + static int apply_dhcp_nameserver ( unsigned int tag __unused, 1.87 + struct dhcp_option *option ) { 1.88 +- struct sockaddr_in *sin_nameserver; 1.89 +- 1.90 +- sin_nameserver = ( struct sockaddr_in * ) &nameserver; 1.91 +- sin_nameserver->sin_family = AF_INET; 1.92 +- dhcp_ipv4_option ( option, &sin_nameserver->sin_addr ); 1.93 +- 1.94 +- DBG ( "DNS using nameserver %s\n", 1.95 +- inet_ntoa ( sin_nameserver->sin_addr ) ); 1.96 ++ struct in_addr sin_addr; 1.97 + 1.98 +- return 0; 1.99 ++ dhcp_ipv4_option ( option, &sin_addr ); 1.100 ++ return apply_nameserver(sin_addr); 1.101 + } 1.102 + 1.103 + /** DHCP nameserver applicator */ 1.104 + 1.105 +--- gpxe-0.9.3/src/usr/autoboot.c 1.106 ++++ gpxe-0.9.3/src/usr/autoboot.c 1.107 +@@ -23,6 +23,7 @@ 1.108 + #include <gpxe/dhcp.h> 1.109 + #include <gpxe/image.h> 1.110 + #include <gpxe/embedded.h> 1.111 ++#include <gpxe/ip.h> 1.112 + #include <usr/ifmgmt.h> 1.113 + #include <usr/route.h> 1.114 + #include <usr/dhcpmgmt.h> 1.115 +@@ -150,16 +151,68 @@ 1.116 + */ 1.117 + static int netboot ( struct net_device *netdev ) { 1.118 + char buf[256]; 1.119 +- int rc; 1.120 ++ int rc, nodhcp; 1.121 ++ char *ip, *gw, *dns, *s; 1.122 ++ extern int apply_nameserver(struct in_addr sin_addr); 1.123 + 1.124 + /* Open device and display device status */ 1.125 + if ( ( rc = ifopen ( netdev ) ) != 0 ) 1.126 + return rc; 1.127 + ifstat ( netdev ); 1.128 + 1.129 ++ ip = gw = dns = NULL; 1.130 ++ nodhcp = 0; 1.131 ++ for (s = forced_url.url; *s && s < forced_url.url + 256;) { 1.132 ++ while (*s == ' ') s++; 1.133 ++ if (!strncmp(s,"ip=",3)) ip = s + 3, *s++ = 0; 1.134 ++ if (!strncmp(s,"gw=",3)) gw = s + 3, *s++ = 0; 1.135 ++ if (!strncmp(s,"dns=",4)) dns = s + 4, *s++ = 0; 1.136 ++ if (!strncmp(s,"nodhcp",5)) nodhcp++, *s++ = 0; 1.137 ++ if (!strncmp(s,"url=",4)) { 1.138 ++ char *p = forced_url.url; 1.139 ++ for (s += 4; *s && *s != ' '; *p++ = *s++); 1.140 ++ *p = 0; 1.141 ++ } 1.142 ++ while (*s && *s != ' ') s++; 1.143 ++ *s++ = 0; 1.144 ++ } 1.145 ++ 1.146 + /* Configure device via DHCP */ 1.147 +- if ( ( rc = dhcp ( netdev ) ) != 0 ) 1.148 +- return rc; 1.149 ++ if (forced_url.url[0]) printf("url=%s\n",forced_url.url); 1.150 ++ if ( nodhcp || ( rc = dhcp ( netdev ) ) != 0 ) { 1.151 ++#define IN_CLASSA(x) (( (x).s_addr & 0x80000000) == 0) 1.152 ++#define IN_CLASSB(x) (( (x).s_addr & 0xc0000000) == 0x80000000) 1.153 ++#define IN_CLASSA_NET 0xff000000 1.154 ++#define IN_CLASSB_NET 0xffff0000 1.155 ++#define IN_CLASSC_NET 0xffffff00 1.156 ++#define IN_CLASSLESS_NET(x) (0xffffffff << (32 - (x))) 1.157 ++ struct in_addr address, netmask, gateway, nameserver; 1.158 ++ char *p; 1.159 ++ 1.160 ++ if (!ip || !gw || !inet_aton(gw, &gateway)) 1.161 ++ return rc; 1.162 ++ p = strchr(ip,'/'); 1.163 ++ if (p) *p++ = 0; 1.164 ++ if (!inet_aton(ip, &address)) 1.165 ++ return rc; 1.166 ++ if (p) { 1.167 ++ int n; 1.168 ++ for (n = 0; *p >= '0' && *p <= '9'; 1.169 ++ n *= 10, n += *p++ - 10); 1.170 ++ netmask.s_addr = IN_CLASSLESS_NET(n); 1.171 ++ } 1.172 ++ else if (IN_CLASSA(address)) netmask.s_addr = IN_CLASSA_NET; 1.173 ++ else if (IN_CLASSB(address)) netmask.s_addr = IN_CLASSB_NET; 1.174 ++ else netmask.s_addr = IN_CLASSC_NET; 1.175 ++ del_ipv4_address ( netdev ); 1.176 ++ if ( ( rc = add_ipv4_address ( netdev, address, netmask, 1.177 ++ gateway ) ) != 0 ) { 1.178 ++ return rc; 1.179 ++ } 1.180 ++ if (dns) printf("dns=%s\n",dns); 1.181 ++ if (dns && inet_aton(dns, &nameserver)) 1.182 ++ apply_nameserver(nameserver); 1.183 ++ } 1.184 + route(); 1.185 + 1.186 + /* Try to boot an embedded image if we have one */