comparison packages/redboot/current/src/flash.c @ 849:23fd347aba65

support multiple net drivers in RedBoot
author msalter
date Thu, 20 Mar 2003 15:44:39 +0000
parents a2dfa8bf3c57
children 0138b3d6b8a0
comparison
equal deleted inserted replaced
848:ddac09c38f55 849:23fd347aba65
6 // 6 //
7 //========================================================================== 7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN#### 8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // ------------------------------------------- 9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System. 10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. 11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
12 // 12 //
13 // eCos is free software; you can redistribute it and/or modify it under 13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free 14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version. 15 // Software Foundation; either version 2 or (at your option) any later version.
16 // 16 //
1401 for (esa_ptr = 0; esa_ptr < sizeof(enet_addr_t); esa_ptr++) { 1401 for (esa_ptr = 0; esa_ptr < sizeof(enet_addr_t); esa_ptr++) {
1402 lp += diag_sprintf(lp, "0x%02X", ((unsigned char *)val_ptr)[esa_ptr]); 1402 lp += diag_sprintf(lp, "0x%02X", ((unsigned char *)val_ptr)[esa_ptr]);
1403 if (esa_ptr < (sizeof(enet_addr_t)-1)) lp += diag_sprintf(lp, ":"); 1403 if (esa_ptr < (sizeof(enet_addr_t)-1)) lp += diag_sprintf(lp, ":");
1404 } 1404 }
1405 break; 1405 break;
1406 #if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
1407 case CONFIG_NETPORT:
1408 lp += diag_sprintf(lp, "%s", (unsigned char *)val_ptr);
1409 break;
1410 #endif
1406 #endif 1411 #endif
1407 case CONFIG_STRING: 1412 case CONFIG_STRING:
1408 lp += diag_sprintf(lp, "%s", (unsigned char *)val_ptr); 1413 lp += diag_sprintf(lp, "%s", (unsigned char *)val_ptr);
1409 break; 1414 break;
1410 case CONFIG_SCRIPT: 1415 case CONFIG_SCRIPT:
1500 } 1505 }
1501 ((unsigned char *)val_ptr)[esa_ptr] = esa_byte; 1506 ((unsigned char *)val_ptr)[esa_ptr] = esa_byte;
1502 } 1507 }
1503 return CONFIG_CHANGED; 1508 return CONFIG_CHANGED;
1504 break; 1509 break;
1510 #if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
1511 case CONFIG_NETPORT:
1512 if (strlen(line) >= MAX_STRING_LENGTH || net_devindex(line) < 0) {
1513 int index;
1514 const char *name;
1515 diag_printf("Sorry, Port name must be one of:\n");
1516 for (index = 0; name = net_devname(index); index++)
1517 diag_printf(" %s\n", name);
1518 return CONFIG_BAD;
1519 }
1520 strcpy((unsigned char *)val_ptr, line);
1521 break;
1522 #endif
1505 #endif 1523 #endif
1506 case CONFIG_SCRIPT: 1524 case CONFIG_SCRIPT:
1507 // Assume it always changes 1525 // Assume it always changes
1508 sp = (unsigned char *)val_ptr; 1526 sp = (unsigned char *)val_ptr;
1509 diag_printf("Enter script, terminate with empty line\n"); 1527 diag_printf("Enter script, terminate with empty line\n");
1548 return sizeof(in_addr_t); 1566 return sizeof(in_addr_t);
1549 case CONFIG_ESA: 1567 case CONFIG_ESA:
1550 // Would like this to be sizeof(enet_addr_t), but that causes much 1568 // Would like this to be sizeof(enet_addr_t), but that causes much
1551 // pain since it fouls the alignment of data which follows. 1569 // pain since it fouls the alignment of data which follows.
1552 return 8; 1570 return 8;
1571 #if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
1572 case CONFIG_NETPORT:
1573 return MAX_STRING_LENGTH;
1574 #endif
1553 #endif 1575 #endif
1554 case CONFIG_STRING: 1576 case CONFIG_STRING:
1555 return MAX_STRING_LENGTH; 1577 return MAX_STRING_LENGTH;
1556 case CONFIG_SCRIPT: 1578 case CONFIG_SCRIPT:
1557 return MAX_SCRIPT_LENGTH; 1579 return MAX_SCRIPT_LENGTH;
1960 memcpy(dp, (void *)&opt->dflt, sizeof(in_addr_t)); 1982 memcpy(dp, (void *)&opt->dflt, sizeof(in_addr_t));
1961 break; 1983 break;
1962 case CONFIG_ESA: 1984 case CONFIG_ESA:
1963 memcpy(dp, (void *)&opt->dflt, sizeof(enet_addr_t)); 1985 memcpy(dp, (void *)&opt->dflt, sizeof(enet_addr_t));
1964 break; 1986 break;
1987 #if defined(CYGHWR_NET_DRIVERS) && (CYGHWR_NET_DRIVERS > 1)
1988 case CONFIG_NETPORT:
1989 // validate dflt and if not acceptable use first port
1990 {
1991 int index;
1992 const char *name;
1993 for (index = 0; (name = net_devname(index)) != NULL; index++)
1994 if (!strcmp((char *)opt->dflt, name))
1995 break;
1996 if (name == NULL)
1997 name = net_devname(0);
1998 memcpy(dp, name, strlen(name) + 1);
1999 }
2000 break;
2001 #endif
1965 #endif 2002 #endif
1966 case CONFIG_STRING: 2003 case CONFIG_STRING:
1967 memcpy(dp, (void *)opt->dflt, config_length(CONFIG_STRING)); 2004 memcpy(dp, (void *)opt->dflt, config_length(CONFIG_STRING));
1968 break; 2005 break;
1969 case CONFIG_SCRIPT: 2006 case CONFIG_SCRIPT: