wok-next diff gpxe/stuff/patches/cmdline.u @ rev 21678
updated getmail (4.41.0 -> 5.14)
author | Hans-G?nter Theisgen |
---|---|
date | Mon Jun 29 13:44:08 2020 +0100 (2020-06-29) |
parents | e35a8dffd011 |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gpxe/stuff/patches/cmdline.u Mon Jun 29 13:44:08 2020 +0100 1.3 @@ -0,0 +1,204 @@ 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,25 @@ 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 ++ cmpb (%si),%ah 1.49 ++ je run_etherboot 1.50 ++ push %ds 1.51 ++ pop %es 1.52 ++ movw $boot_url, %di 1.53 ++copy_cmdline: 1.54 ++ lodsb 1.55 ++ stosb 1.56 ++ or %al, %al 1.57 ++ jne copy_cmdline 1.58 ++ jmp run_etherboot 1.59 ++run_etherboot_floppy: 1.60 + push %cs 1.61 + pop %ds 1.62 + run_etherboot: 1.63 + 1.64 +--- gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S 1.65 ++++ gpxe-0.9.3/src/arch/i386/prefix/lkrnprefix.S 1.66 +@@ -461,6 +461,15 @@ 1.67 + push %ds 1.68 + pop %es 1.69 + movw $boot_url, %di 1.70 ++ cmpw $0x4F42,(%si) /* skip BOOT_IMAGE=.... */ 1.71 ++ jne copy_cmdline 1.72 ++skip_arg: 1.73 ++ lodsb 1.74 ++ testb $0xDF, %al 1.75 ++ jne skip_arg 1.76 ++ or %al, %al 1.77 ++ jne copy_cmdline 1.78 ++ decw %si 1.79 + copy_cmdline: 1.80 + lodsb 1.81 + stosb 1.82 + 1.83 +--- gpxe-0.9.3/src/net/udp/dns.c 1.84 ++++ gpxe-0.9.3/src/net/udp/dns.c 1.85 +@@ -506,6 +506,19 @@ 1.86 + .resolv = dns_resolv, 1.87 + }; 1.88 + 1.89 ++int apply_nameserver(struct in_addr sin_addr) 1.90 ++{ 1.91 ++ struct sockaddr_in *sin_nameserver; 1.92 ++ 1.93 ++ sin_nameserver = ( struct sockaddr_in * ) &nameserver; 1.94 ++ sin_nameserver->sin_family = AF_INET; 1.95 ++ sin_nameserver->sin_addr = sin_addr; 1.96 ++ DBG ( "DNS using nameserver %s\n", 1.97 ++ inet_ntoa ( sin_addr ) ); 1.98 ++ 1.99 ++ return 0; 1.100 ++} 1.101 ++ 1.102 + /** 1.103 + * Apply DHCP nameserver option 1.104 + * 1.105 +@@ -514,16 +527,10 @@ 1.106 + */ 1.107 + static int apply_dhcp_nameserver ( unsigned int tag __unused, 1.108 + struct dhcp_option *option ) { 1.109 +- struct sockaddr_in *sin_nameserver; 1.110 +- 1.111 +- sin_nameserver = ( struct sockaddr_in * ) &nameserver; 1.112 +- sin_nameserver->sin_family = AF_INET; 1.113 +- dhcp_ipv4_option ( option, &sin_nameserver->sin_addr ); 1.114 +- 1.115 +- DBG ( "DNS using nameserver %s\n", 1.116 +- inet_ntoa ( sin_nameserver->sin_addr ) ); 1.117 ++ struct in_addr sin_addr; 1.118 + 1.119 +- return 0; 1.120 ++ dhcp_ipv4_option ( option, &sin_addr ); 1.121 ++ return apply_nameserver(sin_addr); 1.122 + } 1.123 + 1.124 + /** DHCP nameserver applicator */ 1.125 + 1.126 +--- gpxe-0.9.3/src/usr/autoboot.c 1.127 ++++ gpxe-0.9.3/src/usr/autoboot.c 1.128 +@@ -23,6 +23,7 @@ 1.129 + #include <gpxe/dhcp.h> 1.130 + #include <gpxe/image.h> 1.131 + #include <gpxe/embedded.h> 1.132 ++#include <gpxe/ip.h> 1.133 + #include <usr/ifmgmt.h> 1.134 + #include <usr/route.h> 1.135 + #include <usr/dhcpmgmt.h> 1.136 +@@ -150,16 +151,68 @@ 1.137 + */ 1.138 + static int netboot ( struct net_device *netdev ) { 1.139 + char buf[256]; 1.140 +- int rc; 1.141 ++ int rc, nodhcp; 1.142 ++ char *ip, *gw, *dns, *s; 1.143 ++ extern int apply_nameserver(struct in_addr sin_addr); 1.144 + 1.145 + /* Open device and display device status */ 1.146 + if ( ( rc = ifopen ( netdev ) ) != 0 ) 1.147 + return rc; 1.148 + ifstat ( netdev ); 1.149 + 1.150 ++ ip = gw = dns = NULL; 1.151 ++ nodhcp = 0; 1.152 ++ for (s = forced_url.url; *s && s < forced_url.url + 256;) { 1.153 ++ while (*s == ' ') s++; 1.154 ++ if (!strncmp(s,"ip=",3)) ip = s + 3, *s++ = 0; 1.155 ++ if (!strncmp(s,"gw=",3)) gw = s + 3, *s++ = 0; 1.156 ++ if (!strncmp(s,"dns=",4)) dns = s + 4, *s++ = 0; 1.157 ++ if (!strncmp(s,"nodhcp",5)) nodhcp++, *s++ = 0; 1.158 ++ if (!strncmp(s,"url=",4)) { 1.159 ++ char *p = forced_url.url; 1.160 ++ for (s += 4; *s && *s != ' '; *p++ = *s++); 1.161 ++ *p = 0; 1.162 ++ } 1.163 ++ while (*s && *s != ' ') s++; 1.164 ++ *s++ = 0; 1.165 ++ } 1.166 ++ 1.167 + /* Configure device via DHCP */ 1.168 +- if ( ( rc = dhcp ( netdev ) ) != 0 ) 1.169 +- return rc; 1.170 ++ if (forced_url.url[0]) printf("url=%s\n",forced_url.url); 1.171 ++ if ( nodhcp || ( rc = dhcp ( netdev ) ) != 0 ) { 1.172 ++#define IN_CLASSA(x) (( (x).s_addr & 0x80000000) == 0) 1.173 ++#define IN_CLASSB(x) (( (x).s_addr & 0xc0000000) == 0x80000000) 1.174 ++#define IN_CLASSA_NET 0xff000000 1.175 ++#define IN_CLASSB_NET 0xffff0000 1.176 ++#define IN_CLASSC_NET 0xffffff00 1.177 ++#define IN_CLASSLESS_NET(x) (0xffffffff << (32 - (x))) 1.178 ++ struct in_addr address, netmask, gateway, nameserver; 1.179 ++ char *p; 1.180 ++ 1.181 ++ if (!ip || !gw || !inet_aton(gw, &gateway)) 1.182 ++ return rc; 1.183 ++ p = strchr(ip,'/'); 1.184 ++ if (p) *p++ = 0; 1.185 ++ if (!inet_aton(ip, &address)) 1.186 ++ return rc; 1.187 ++ if (p) { 1.188 ++ int n; 1.189 ++ for (n = 0; *p >= '0' && *p <= '9'; 1.190 ++ n *= 10, n += *p++ - 10); 1.191 ++ netmask.s_addr = IN_CLASSLESS_NET(n); 1.192 ++ } 1.193 ++ else if (IN_CLASSA(address)) netmask.s_addr = IN_CLASSA_NET; 1.194 ++ else if (IN_CLASSB(address)) netmask.s_addr = IN_CLASSB_NET; 1.195 ++ else netmask.s_addr = IN_CLASSC_NET; 1.196 ++ del_ipv4_address ( netdev ); 1.197 ++ if ( ( rc = add_ipv4_address ( netdev, address, netmask, 1.198 ++ gateway ) ) != 0 ) { 1.199 ++ return rc; 1.200 ++ } 1.201 ++ if (dns) printf("dns=%s\n",dns); 1.202 ++ if (dns && inet_aton(dns, &nameserver)) 1.203 ++ apply_nameserver(nameserver); 1.204 ++ } 1.205 + route(); 1.206 + 1.207 + /* Try to boot an embedded image if we have one */