Removed obsolete netflash code.
Flashing on JS2x is done via the "update-flash" Forth code nowadays (see the file slof/fs/update_flash.fs for details), so there is no need to maintain the obsolete netflash code anymore. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
This commit is contained in:
parent
cf13fc9bee
commit
a603c2e6f4
|
@ -20,7 +20,6 @@ CFLAGS +=$(ADDCFLAGS)
|
|||
|
||||
OBJS = main.o
|
||||
OBJDIRS = netlib/netlib.o netapps/netboot.o
|
||||
OBJDIRS += netapps/netflash.o
|
||||
OBJDIRS += netapps/ping.o
|
||||
OBJDIRS += netapps/args.o
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ main(int argc, char *argv[])
|
|||
|
||||
if (strcmp(argv[0], "netboot") == 0 && argc >= 5)
|
||||
return netboot(argc, argv);
|
||||
if (strcmp(argv[0], "netflash") == 0)
|
||||
return netflash(argc, argv);
|
||||
if (strcmp(argv[0], "ping") == 0)
|
||||
return ping(argc, argv);
|
||||
#ifdef SNK_BIOSEMU_APPS
|
||||
|
|
|
@ -17,13 +17,12 @@ endif
|
|||
include $(TOP)/make.rules
|
||||
|
||||
CFLAGS += -I../ -I../../../../lib/ -Wall -W
|
||||
OBJS = netboot.o netflash.o
|
||||
OBJS += ping.o
|
||||
OBJS += args.o
|
||||
|
||||
OBJS = netboot.o ping.o args.o
|
||||
|
||||
all: $(OBJS)
|
||||
|
||||
clean:
|
||||
$(RM) -f *.o *.a *.i
|
||||
clean:
|
||||
$(RM) -f *.o *.a *.i
|
||||
|
||||
include $(TOP)/make.depend
|
||||
|
|
|
@ -1,188 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2004, 2008 IBM Corporation
|
||||
* All rights reserved.
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the BSD License
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial implementation
|
||||
*****************************************************************************/
|
||||
|
||||
#include <netlib/tftp.h>
|
||||
#include <netlib/dhcp.h>
|
||||
#include <netlib/ethernet.h>
|
||||
#include <netlib/ipv4.h>
|
||||
#include <rtas.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include "netapps.h"
|
||||
|
||||
int netflash(int argc, char * argv[])
|
||||
{
|
||||
char buf[256];
|
||||
int rc;
|
||||
int manage_mode = 0;
|
||||
static int len = 0x800000; //max flash size
|
||||
char * buffer = NULL;
|
||||
short arp_failed = 0;
|
||||
filename_ip_t fn_ip;
|
||||
int fd_device;
|
||||
tftp_err_t tftp_err;
|
||||
char * ptr;
|
||||
uint8_t own_mac[6];
|
||||
|
||||
printf("\n Flasher 1.4 \n");
|
||||
memset(&fn_ip, 0, sizeof(filename_ip_t));
|
||||
|
||||
if (argc == 3 && argv[2][0] == '-' && argv[2][1] == 'c' && argv[2][2] == 0)
|
||||
manage_mode = 1;
|
||||
else if (argc == 3 &&
|
||||
argv[2][0] == '-' && argv[2][1] == 'r' && argv[2][2] == 0)
|
||||
manage_mode = 1;
|
||||
else if (argc == 4 &&
|
||||
argv[2][0] == '-' && argv[2][1] == 'f' && argv[2][2] == 0)
|
||||
{
|
||||
manage_mode = 0;
|
||||
buffer = (char *)strtol(argv[1],0,16);
|
||||
if ((long)buffer == -1) {
|
||||
printf(" Bad buffer address. Exiting...\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" Usage: netflash [options] [<filename>]\n");
|
||||
printf(" Options:\n");
|
||||
printf(" -f <filename> flash temporary image\n");
|
||||
printf(" -c commit temporary image\n");
|
||||
printf(" -r reject temporary image\n");
|
||||
printf(" Bad arguments. Exiting...\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (manage_mode == 1) {
|
||||
if (argv[2][1] == 99)
|
||||
return rtas_ibm_manage_flash(1);
|
||||
else
|
||||
return rtas_ibm_manage_flash(0);
|
||||
}
|
||||
|
||||
/* Get mac_addr from device */
|
||||
printf(" Reading MAC address from device: ");
|
||||
fd_device = socket(0, 0, 0, (char *) own_mac);
|
||||
if (fd_device == -1) {
|
||||
printf("\nE3000: Could not read MAC address\n");
|
||||
return -100;
|
||||
}
|
||||
else if (fd_device == -2) {
|
||||
printf("\nE3006: Could not initialize network device\n");
|
||||
return -101;
|
||||
}
|
||||
|
||||
printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
own_mac[0], own_mac[1], own_mac[2],
|
||||
own_mac[3], own_mac[4], own_mac[5]);
|
||||
|
||||
// init ethernet layer
|
||||
set_mac_address(own_mac);
|
||||
|
||||
// identify the BOOTP/DHCP server via broadcasts
|
||||
// don't do this, when using DHCP !!!
|
||||
// fn_ip.server_ip = 0xFFFFFFFF;
|
||||
// memset(fn_ip.server_mac, 0xff, 6);
|
||||
|
||||
/* Get ip address for our mac address */
|
||||
printf(" Requesting IP address via DHCP: ");
|
||||
arp_failed = dhcp(0, &fn_ip, 30);
|
||||
|
||||
if(arp_failed >= 0) {
|
||||
// reinit network stack
|
||||
set_ipv4_address(fn_ip.own_ip);
|
||||
}
|
||||
|
||||
if (arp_failed == -1) {
|
||||
printf("\n DHCP: Could not get ip address\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arp_failed == -2) {
|
||||
sprintf
|
||||
(buf,"\n ARP request to TFTP server (%d.%d.%d.%d) failed",
|
||||
((fn_ip.server_ip >> 24) & 0xFF), ((fn_ip.server_ip >> 16) & 0xFF),
|
||||
((fn_ip.server_ip >> 8) & 0xFF), ( fn_ip.server_ip & 0xFF));
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("%d.%d.%d.%d\n",
|
||||
((fn_ip.own_ip >> 24) & 0xFF), ((fn_ip.own_ip >> 16) & 0xFF),
|
||||
((fn_ip.own_ip >> 8) & 0xFF), (fn_ip.own_ip & 0xFF));
|
||||
|
||||
/* Load file via TFTP into buffer provided by OpenFirmware */
|
||||
|
||||
for(ptr = argv[3]; *ptr != 0; ++ptr)
|
||||
if(*ptr == '\\')
|
||||
*ptr = '/';
|
||||
|
||||
printf(" Requesting file \"%s\" via TFTP\n",argv[3]);
|
||||
|
||||
strcpy((char *) fn_ip.filename,argv[3]);
|
||||
|
||||
rc = tftp(&fn_ip, (unsigned char*) buffer, len, 20, &tftp_err, 0, 512, 4);
|
||||
|
||||
dhcp_send_release();
|
||||
|
||||
if (rc > 0)
|
||||
{
|
||||
printf (" TFTP: Received %s (%d KBytes)\n", fn_ip.filename, rc/1024);
|
||||
printf (" Now flashing:\n");
|
||||
rc = rtas_ibm_update_flash_64((long long)buffer, rc);
|
||||
return rc;
|
||||
}
|
||||
else if (rc == -1)
|
||||
{
|
||||
printf (" Tftp: Could not load file %s\n", fn_ip.filename);
|
||||
return 1;
|
||||
}
|
||||
else if (rc == -2)
|
||||
{
|
||||
printf (" Tftp: Buffer to small for %s\n", fn_ip.filename);
|
||||
return 1;
|
||||
}
|
||||
else if (rc <= -10 && rc >= -15)
|
||||
{
|
||||
printf("\n ICMP ERROR: Destination unreachable: ");
|
||||
switch(rc) {
|
||||
case -ICMP_NET_UNREACHABLE-10:
|
||||
printf("net unreachable");
|
||||
break;
|
||||
case -ICMP_HOST_UNREACHABLE-10:
|
||||
printf("host unreachable");
|
||||
break;
|
||||
case -ICMP_PROTOCOL_UNREACHABLE-10:
|
||||
printf("protocol unreachable");
|
||||
break;
|
||||
case -ICMP_PORT_UNREACHABLE-10:
|
||||
printf("port unreachable");
|
||||
break;
|
||||
case -ICMP_FRAGMENTATION_NEEDED-10:
|
||||
printf("fragmentation needed and DF set");
|
||||
break;
|
||||
case -ICMP_SOURCE_ROUTE_FAILED-10:
|
||||
printf("source route failed");
|
||||
break;
|
||||
default:
|
||||
printf(" UNKNOWN: this should not happen!");
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
return 1;
|
||||
}
|
||||
else if(rc < 0)
|
||||
printf(" UNKNOWN: rc = %d!", rc);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -150,14 +150,7 @@ static int read_pci_config_token = 0;
|
|||
static int write_pci_config_token = 0;
|
||||
static int ibm_read_pci_config_token = 0;
|
||||
static int ibm_write_pci_config_token = 0;
|
||||
static int ibm_update_flash_64_and_reboot_token = 0;
|
||||
static int ibm_update_flash_64_token = 0;
|
||||
static int manage_flash_token = 0;
|
||||
static int system_reboot_token = 0;
|
||||
static int get_time_of_day_token = 0;
|
||||
static int set_time_of_day_token = 0;
|
||||
static int start_cpu_token = 0;
|
||||
static int stop_self_token = 0;
|
||||
|
||||
void
|
||||
rtas_init()
|
||||
|
@ -170,15 +163,7 @@ rtas_init()
|
|||
ibm_read_pci_config_token = rtas_token("ibm,read-pci-config");
|
||||
write_pci_config_token = rtas_token("write-pci-config");
|
||||
ibm_write_pci_config_token = rtas_token("ibm,write-pci-config");
|
||||
ibm_update_flash_64_and_reboot_token =
|
||||
rtas_token("ibm,update-flash-64-and-reboot");
|
||||
ibm_update_flash_64_token = rtas_token("ibm,update-flash-64");
|
||||
manage_flash_token = rtas_token("ibm,manage-flash-image");
|
||||
system_reboot_token = rtas_token("system-reboot");
|
||||
get_time_of_day_token = rtas_token("get-time-of-day");
|
||||
set_time_of_day_token = rtas_token("set-time-of-day");
|
||||
start_cpu_token = rtas_token("start-cpu");
|
||||
stop_self_token = rtas_token("stop-self");
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,62 +201,6 @@ rtas_pci_config_write(long long puid, int size, int bus, int devfn,
|
|||
return rc;
|
||||
}
|
||||
|
||||
/* a simple blocklist like this will us give no animation during flashing */
|
||||
|
||||
struct block_list {
|
||||
long long size; //size of blocklist in bytes
|
||||
long long address; //address of memory area
|
||||
long long length; //lenght of memory area
|
||||
};
|
||||
|
||||
int
|
||||
rtas_ibm_update_flash_64_and_reboot(long long address, long long length)
|
||||
{
|
||||
int rc;
|
||||
struct block_list block_list;
|
||||
block_list.size = sizeof(block_list);
|
||||
block_list.address = address;
|
||||
block_list.length = length;
|
||||
if (ibm_update_flash_64_and_reboot_token)
|
||||
rtas_call(ibm_update_flash_64_and_reboot_token, 1, 1, &rc,
|
||||
&block_list);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
rtas_ibm_manage_flash(int mode)
|
||||
{
|
||||
int rc;
|
||||
if (manage_flash_token)
|
||||
rtas_call(manage_flash_token, 1, 1, &rc, mode);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
rtas_ibm_update_flash_64(long long address, long long length)
|
||||
{
|
||||
int rc;
|
||||
struct block_list block_list;
|
||||
block_list.size = sizeof(block_list);
|
||||
block_list.address = address;
|
||||
block_list.length = length;
|
||||
if (ibm_update_flash_64_token)
|
||||
rtas_call(ibm_update_flash_64_token, 1, 1, &rc, &block_list);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
rtas_system_reboot()
|
||||
{
|
||||
int rc;
|
||||
if (system_reboot_token)
|
||||
rtas_call(system_reboot_token, 0, 1, &rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rtas_get_time_of_day(dtime * get)
|
||||
{
|
||||
|
@ -298,41 +227,3 @@ rtas_get_time_of_day(dtime * get)
|
|||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
rtas_set_time_of_day(dtime * set)
|
||||
{
|
||||
int rc = -1;
|
||||
if (set_time_of_day_token)
|
||||
rtas_call(set_time_of_day_token, 7, 1, &rc, set->year,
|
||||
set->month, set->day, set->hour, set->minute,
|
||||
set->second, set->nano);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rtas_start_cpu(int pid, thread_t func_ptr, int r3)
|
||||
{
|
||||
int rc;
|
||||
if (start_cpu_token)
|
||||
rtas_call(start_cpu_token, 3, 1, &rc, pid,
|
||||
(int) (long) func_ptr, (int) r3);
|
||||
printk("start-cpu called %d %x %x %x\n", rc, start_cpu_token, pid,
|
||||
(long) func_ptr);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
rtas_stop_self()
|
||||
{
|
||||
int rc;
|
||||
// fixme
|
||||
stop_self_token = 0x20;
|
||||
|
||||
if (stop_self_token) {
|
||||
rtas_call(stop_self_token, 0, 1, &rc);
|
||||
printk("TOK\n");
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue