X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=net%2Fnfs.c;h=68992655144af692e164ef81e585aaab098ad24a;hb=e3f422f27ec884c8ae64b5b5d26f7929c95a3a0e;hp=381b75f1c5b091799876aa77ec8997c97ea14fa9;hpb=ca85eb8c4271509aaac1ccb26ae3eb1a7827b4e6;p=karo-tx-uboot.git diff --git a/net/nfs.c b/net/nfs.c index 381b75f1c5..6899265514 100644 --- a/net/nfs.c +++ b/net/nfs.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "nfs.h" #include "bootp.h" @@ -50,7 +51,7 @@ static char dirfh[NFS_FHSIZE]; /* file handle of directory */ static char filefh[NFS_FHSIZE]; /* file handle of kernel image */ static enum net_loop_state nfs_download_state; -static IPaddr_t NfsServerIP; +static struct in_addr nfs_server_ip; static int NfsSrvMountPort; static int NfsSrvNfsPort; static int NfsOurPort; @@ -93,11 +94,14 @@ store_block(uchar *src, unsigned offset, unsigned len) } else #endif /* CONFIG_SYS_DIRECT_FLASH_NFS */ { - (void)memcpy((void *)(load_addr + offset), src, len); + void *ptr = map_sysmem(load_addr + offset, len); + + memcpy(ptr, src, len); + unmap_sysmem(ptr); } - if (NetBootFileXferSize < (offset+len)) - NetBootFileXferSize = newsize; + if (net_boot_file_size < (offset + len)) + net_boot_file_size = newsize; return 0; } @@ -197,8 +201,8 @@ rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt; - memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE, - (char *)&pkt, pktlen); + memcpy((char *)net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE, + (char *)&pkt, pktlen); if (rpc_prog == PROG_PORTMAP) sport = SUNRPC_PORT; @@ -207,8 +211,8 @@ rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) else sport = NfsSrvNfsPort; - NetSendUDPPacket(NetServerEther, NfsServerIP, sport, NfsOurPort, - pktlen); + net_send_udp_packet(net_server_ethaddr, nfs_server_ip, sport, + NfsOurPort, pktlen); } /************************************************************************** @@ -596,8 +600,8 @@ NfsTimeout(void) } } -static void -NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) +static void nfs_handler(uchar *pkt, unsigned dest, struct in_addr sip, + unsigned src, unsigned len) { int rlen; int reply; @@ -711,7 +715,7 @@ NfsStart(void) debug("%s\n", __func__); nfs_download_state = NETLOOP_FAIL; - NfsServerIP = NetServerIP; + nfs_server_ip = net_server_ip; nfs_path = (char *)nfs_path_buff; if (nfs_path == NULL) { @@ -720,27 +724,27 @@ NfsStart(void) return; } - if (BootFile[0] == '\0') { + if (net_boot_file_name[0] == '\0') { sprintf(default_filename, "/nfsroot/%02X%02X%02X%02X.img", - NetOurIP & 0xFF, - (NetOurIP >> 8) & 0xFF, - (NetOurIP >> 16) & 0xFF, - (NetOurIP >> 24) & 0xFF); + net_ip.s_addr & 0xFF, + (net_ip.s_addr >> 8) & 0xFF, + (net_ip.s_addr >> 16) & 0xFF, + (net_ip.s_addr >> 24) & 0xFF); strcpy(nfs_path, default_filename); printf("*** Warning: no boot file name; using '%s'\n", nfs_path); } else { - char *p = BootFile; + char *p = net_boot_file_name; p = strchr(p, ':'); if (p != NULL) { - NfsServerIP = string_to_ip(BootFile); + nfs_server_ip = string_to_ip(net_boot_file_name); ++p; strcpy(nfs_path, p); } else { - strcpy(nfs_path, BootFile); + strcpy(nfs_path, net_boot_file_name); } } @@ -749,29 +753,32 @@ NfsStart(void) printf("Using %s device\n", eth_get_name()); - printf("File transfer via NFS from server %pI4" - "; our IP address is %pI4", &NfsServerIP, &NetOurIP); + printf("File transfer via NFS from server %pI4; our IP address is %pI4", + &nfs_server_ip, &net_ip); /* Check if we need to send across this subnet */ - if (NetOurGatewayIP && NetOurSubnetMask) { - IPaddr_t OurNet = NetOurIP & NetOurSubnetMask; - IPaddr_t ServerNet = NetServerIP & NetOurSubnetMask; + if (net_gateway.s_addr && net_netmask.s_addr) { + struct in_addr our_net; + struct in_addr server_net; - if (OurNet != ServerNet) + our_net.s_addr = net_ip.s_addr & net_netmask.s_addr; + server_net.s_addr = net_server_ip.s_addr & net_netmask.s_addr; + if (our_net.s_addr != server_net.s_addr) printf("; sending through gateway %pI4", - &NetOurGatewayIP); + &net_gateway); } printf("\nFilename '%s/%s'.", nfs_path, nfs_filename); - if (NetBootFileSize) { - printf(" Size is 0x%x Bytes = ", NetBootFileSize<<9); - print_size(NetBootFileSize<<9, ""); + if (net_boot_file_expected_size_in_blocks) { + printf(" Size is 0x%x Bytes = ", + net_boot_file_expected_size_in_blocks << 9); + print_size(net_boot_file_expected_size_in_blocks << 9, ""); } printf("\nLoad address: 0x%lx\n" "Loading: *\b", load_addr); NetSetTimeout(nfs_timeout, NfsTimeout); - net_set_udp_handler(NfsHandler); + net_set_udp_handler(nfs_handler); NfsTimeoutCount = 0; NfsState = STATE_PRCLOOKUP_PROG_MOUNT_REQ; @@ -781,7 +788,7 @@ NfsStart(void) NfsOurPort = 1000; /* zero out server ether in case the server ip has changed */ - memset(NetServerEther, 0, 6); + memset(net_server_ethaddr, 0, 6); NfsSend(); }