OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orpmon/] [services/] [tftp.c] - Diff between revs 810 and 817

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 810 Rev 817
Line 26... Line 26...
#define TFTP_DATA       3
#define TFTP_DATA       3
#define TFTP_ACK        4
#define TFTP_ACK        4
#define TFTP_ERROR      5
#define TFTP_ERROR      5
 
 
 
 
extern unsigned long load_addr;
 
 
 
static int      TftpServerPort;         /* The UDP port at their end            */
static int      TftpServerPort;         /* The UDP port at their end            */
static int      TftpOurPort;            /* The UDP port at our end              */
static int      TftpOurPort;            /* The UDP port at our end              */
static int      TftpTimeoutCount;
static int      TftpTimeoutCount;
static unsigned TftpBlock;
static unsigned TftpBlock;
static unsigned TftpLastBlock;
static unsigned TftpLastBlock;
Line 41... Line 39...
#define STATE_TOO_LARGE 3
#define STATE_TOO_LARGE 3
#define STATE_BAD_MAGIC 4
#define STATE_BAD_MAGIC 4
 
 
#define DEFAULT_NAME_LEN        (8 + 4 + 1)
#define DEFAULT_NAME_LEN        (8 + 4 + 1)
static char default_filename[DEFAULT_NAME_LEN] = "tftpboot.img";
static char default_filename[DEFAULT_NAME_LEN] = "tftpboot.img";
static char *tftp_filename;
char *tftp_filename;
 
 
#ifdef CFG_DIRECT_FLASH_TFTP
#ifdef CFG_DIRECT_FLASH_TFTP
extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
#endif
#endif
 
 
Line 56... Line 54...
#ifdef CFG_DIRECT_FLASH_TFTP
#ifdef CFG_DIRECT_FLASH_TFTP
        int i, rc = 0;
        int i, rc = 0;
 
 
        for (i=0; i<CFG_MAX_FLASH_BANKS; i++) {
        for (i=0; i<CFG_MAX_FLASH_BANKS; i++) {
                /* start address in flash? */
                /* start address in flash? */
                if (load_addr + offset >= flash_info[i].start[0]) {
                if (global.src_addr + offset >= flash_info[i].start[0]) {
                        rc = 1;
                        rc = 1;
                        break;
                        break;
                }
                }
        }
        }
 
 
        if (rc) { /* Flash is destination for this packet */
        if (rc) { /* Flash is destination for this packet */
                rc = flash_write ((unsigned char *)src, (unsigned long)(load_addr+offset), len);
                rc = flash_write ((unsigned char *)src, (unsigned long)(global.src_addr+offset), len);
                switch (rc) {
                switch (rc) {
                case 0:  /* OK */
                case 0:  /* OK */
                        break;
                        break;
                case 1: printf ("Timeout writing to Flash\n");
                case 1: printf ("Timeout writing to Flash\n");
                        break;
                        break;
Line 88... Line 86...
                        return;
                        return;
                }
                }
        }
        }
        else
        else
#endif /* CFG_DIRECT_FLASH_TFTP */
#endif /* CFG_DIRECT_FLASH_TFTP */
        (void)memcpy((void *)(load_addr + offset), src, len);
        (void)memcpy((void *)(global.src_addr + offset), src, len);
 
 
        if (NetBootFileXferSize < newsize)
        if (NetBootFileXferSize < newsize)
                NetBootFileXferSize = newsize;
                NetBootFileXferSize = newsize;
}
}
 
 
Line 272... Line 270...
                NetServerEther[4],
                NetServerEther[4],
                NetServerEther[5]
                NetServerEther[5]
        );
        );
#endif /* DEBUG */
#endif /* DEBUG */
 
 
        if (BootFile[0] == '\0') {
 
                tftp_filename = default_filename;
 
 
 
                printf ("*** Warning: no boot file name; using '%s'\n",
 
                        tftp_filename);
 
        } else {
 
                tftp_filename = BootFile;
 
        }
 
 
 
        printf ("TFTP from server ");   print_IPaddr (NetServerIP);
        printf ("TFTP from server ");   print_IPaddr (NetServerIP);
        printf ("; our IP address is ");        print_IPaddr (NetOurIP);
        printf ("; our IP address is ");        print_IPaddr (NetOurIP);
 
 
        // Check if we need to send across this subnet
        // Check if we need to send across this subnet
        if (NetOurGatewayIP && NetOurSubnetMask) {
        if (NetOurGatewayIP && NetOurSubnetMask) {
Line 307... Line 296...
                NetBootFileSize<<9);
                NetBootFileSize<<9);
        }
        }
 
 
        putc ('\n');
        putc ('\n');
 
 
        printf ("Load address: 0x%lx\n", load_addr);
        printf ("Load address: 0x%lx\n", global.src_addr);
 
 
        printf ("Loading: *\b");
        printf ("Loading: *\b");
 
 
        NetSetTimeout (TIMEOUT * IN_CLK, TftpTimeout);
        NetSetTimeout (TIMEOUT * IN_CLK, TftpTimeout);
        NetSetHandler (TftpHandler);
        NetSetHandler (TftpHandler);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.