Clean up initialization. Add NVRAM code for uC5282.

This commit is contained in:
W. Eric Norum
2005-02-01 20:42:14 +00:00
parent bf69293239
commit ee794ebf54
5 changed files with 13 additions and 205 deletions

View File

@@ -15,10 +15,7 @@ SRCS += rtems_config.c
SRCS += rtems_netconfig.c
SRCS += rtems_util.c
SRCS += rtems_dummyreg.c
SRCS_RTEMS-mvme2100 += setBootConfigFromPPCBUGNVRAM.c
SRCS_RTEMS-mvme5500 += setBootConfigFromMOTLOADNVRAM.c
SRCS += $(SRCS_$(T_A))
SRCS += setBootConfigFromNVRAM.c
LIBRARY_RTEMS = rtemsCom
LIBRARY_SRCS = $(SRCS) $(BUILD_ARCHS)

View File

@@ -48,7 +48,7 @@ rtems_task Init (rtems_task_argument argument);
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#ifndef __mc68040__ /* MVME167 doesn't have RTC code 'yet' */
#if !defined(__mc68040__) && !defined(__mcf5200__) /* don't have RTC code */
#define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
#endif

View File

@@ -377,18 +377,10 @@ Init (rtems_task_argument ignored)
#if defined(__i386__)
initRemoteGdb(ticksPerSecond);
#endif
#if defined(HAVE_PPCBUG)
{
extern void setBootConfigFromPPCBUGNVRAM(void);
setBootConfigFromPPCBUGNVRAM();
if (rtems_bsdnet_config.bootp == NULL) {
extern void setBootConfigFromNVRAM(void);
setBootConfigFromNVRAM();
}
#endif
#if defined(HAVE_MOTLOAD)
{
extern void setBootConfigFromMOTLOADNVRAM(void);
setBootConfigFromMOTLOADNVRAM();
}
#endif
/*
* Override RTEMS configuration
@@ -403,8 +395,15 @@ Init (rtems_task_argument ignored)
*/
initConsole ();
putenv ("TERM=xterm");
putenv ("IOCSH_PS1=epics> ");
putenv ("IOCSH_HISTSIZE=20");
if (rtems_bsdnet_config.hostname) {
char *cp = mustMalloc(strlen(rtems_bsdnet_config.hostname)+15, "iocsh prompt");
sprintf(cp, "IOCSH_PS1=%s> ", rtems_bsdnet_config.hostname);
putenv (cp);
}
else {
putenv ("IOCSH_PS1=epics> ");
}
/*
* Start network

View File

@@ -1,105 +0,0 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <rtems/rtems_bsdnet.h>
#include <bsp.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
static char *
gev(const char *parm)
{
volatile char *nvp = (volatile unsigned char *)(GT64260_DEV1_BASE + 0x10000 + 0x70F8);
const char *val;
const char *name;
char *ret;
char c;
for (;;) {
if (*nvp == '\0')
return NULL;
name = parm;
while ((c = *nvp++) != '\0') {
if ((c == '=') && (*name == '\0')) {
val = (char *)nvp;
while (*nvp++ != '\0')
continue;
ret = malloc(nvp - val);
if (ret == NULL)
return NULL;
strcpy(ret, val);
return ret;
}
if (c != *name++) {
while (*nvp++ != '\0')
continue;
break;
}
}
}
}
static char *
motScriptParm(const char *mot_script_boot, char parm)
{
const char *cp;
char *ret;
int l;
while (*mot_script_boot != '\0') {
if (isspace(*mot_script_boot)
&& (*(mot_script_boot+1) == '-')
&& (*(mot_script_boot+2) == parm)) {
mot_script_boot += 3;
cp = mot_script_boot;
while ((*mot_script_boot != '\0') && !isspace(*mot_script_boot))
mot_script_boot++;
l = mot_script_boot - cp;
ret = malloc(l+1);
if (ret == NULL)
return NULL;
strncpy(ret, cp, l);
*(ret+l) = '\0';
return ret;
}
mot_script_boot++;
}
return NULL;
}
void
setBootConfigFromMOTLOADNVRAM(void)
{
char *cp;
const char *mot_script_boot;
if (rtems_bsdnet_config.bootp != NULL)
return;
mot_script_boot = gev("mot-script-boot");
if ((rtems_bsdnet_bootp_server_name = gev("mot-/dev/enet0-sipa")) == NULL)
rtems_bsdnet_bootp_server_name = motScriptParm(mot_script_boot, 's');
if ((rtems_bsdnet_config.gateway = gev("mot-/dev/enet0-gipa")) == NULL)
rtems_bsdnet_config.gateway = motScriptParm(mot_script_boot, 'g');
if ((rtems_bsdnet_config.ifconfig->ip_netmask = gev("mot-/dev/enet0-snma")) == NULL)
rtems_bsdnet_config.ifconfig->ip_netmask = motScriptParm(mot_script_boot, 'm');
rtems_bsdnet_config.name_server[0] = gev("rtems-dns-server");
if (rtems_bsdnet_config.name_server[0] == NULL)
rtems_bsdnet_config.name_server[0] = rtems_bsdnet_bootp_server_name;
rtems_bsdnet_config.log_host = rtems_bsdnet_bootp_server_name;
cp = gev("rtems-dns-domainname");
if (cp)
rtems_bsdnet_config.domainname = cp;
if ((rtems_bsdnet_config.ifconfig->ip_address = gev("mot-/dev/enet0-cipa")) == NULL)
rtems_bsdnet_config.ifconfig->ip_address = motScriptParm(mot_script_boot, 'c');
rtems_bsdnet_config.hostname = gev("rtems-client-name");
if (rtems_bsdnet_config.hostname == NULL)
rtems_bsdnet_config.hostname = rtems_bsdnet_config.ifconfig->ip_address;
if ((rtems_bsdnet_bootp_boot_file_name = gev("mot-/dev/enet0-file")) == NULL)
rtems_bsdnet_bootp_boot_file_name = motScriptParm(mot_script_boot, 'f');
rtems_bsdnet_bootp_cmdline = gev("epics-script");
}

View File

@@ -1,83 +0,0 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <rtems/rtems_bsdnet.h>
struct ppcbug_nvram {
rtems_unsigned32 PacketVersionIdentifier;
rtems_unsigned32 NodeControlMemoryAddress;
rtems_unsigned32 BootFileLoadAddress;
rtems_unsigned32 BootFileExecutionAddress;
rtems_unsigned32 BootFileExecutionDelay;
rtems_unsigned32 BootFileLength;
rtems_unsigned32 BootFileByteOffset;
rtems_unsigned32 TraceBufferAddress;
rtems_unsigned32 ClientIPAddress;
rtems_unsigned32 ServerIPAddress;
rtems_unsigned32 SubnetIPAddressMask;
rtems_unsigned32 BroadcastIPAddressMask;
rtems_unsigned32 GatewayIPAddress;
rtems_unsigned8 BootpRarpRetry;
rtems_unsigned8 TftpRarpRetry;
rtems_unsigned8 BootpRarpControl;
rtems_unsigned8 UpdateControl;
char BootFilenameString[64];
char ArgumentFilenameString[64];
};
static char *addr(char *cbuf, rtems_unsigned32 addr)
{
struct in_addr a;
if ((a.s_addr = addr) == 0)
return NULL;
return (char *)inet_ntop(AF_INET, &a, cbuf, INET_ADDRSTRLEN);
}
void
setBootConfigFromPPCBUGNVRAM(void)
{
static struct ppcbug_nvram nvram;
static char ip_address[INET_ADDRSTRLEN];
static char ip_netmask[INET_ADDRSTRLEN];
static char server[INET_ADDRSTRLEN];
static char gateway[INET_ADDRSTRLEN];
if (rtems_bsdnet_config.bootp != NULL)
return;
/*
* Get network configuation from PPCBUG.
* The 'correct' way to do this would be to issue a .NETCFIG PPCBUG
* system call. Unfortunately it is very difficult to issue such a
* call once RTEMS is up and running so we just copy from the 'known'
* location of the network configuration parameters.
* Care must be taken to access the NVRAM a byte at a time.
*/
{
volatile char *s = (volatile char *)0xFFE81000;
char *d = (char *)&nvram;
while (d < ((char *)&nvram + sizeof nvram))
*d++ = *s++;
}
/*
* Assume that the boot server is also the name server and log server!
*/
rtems_bsdnet_config.name_server[0] =
rtems_bsdnet_bootp_server_name =
rtems_bsdnet_config.log_host = addr(server, nvram.ServerIPAddress);
rtems_bsdnet_bootp_server_address.s_addr = nvram.ServerIPAddress;
/*
* Nothing better to use as host name!
*/
rtems_bsdnet_config.ifconfig->ip_address =
rtems_bsdnet_config.hostname = addr(ip_address, nvram.ClientIPAddress);
rtems_bsdnet_config.gateway = addr(gateway, nvram.GatewayIPAddress);
rtems_bsdnet_config.ifconfig->ip_netmask = addr(ip_netmask, nvram.SubnetIPAddressMask);
rtems_bsdnet_bootp_boot_file_name = nvram.BootFilenameString;
rtems_bsdnet_bootp_cmdline = nvram.ArgumentFilenameString;
}