#include "config.h"
#endif
-#include "configuration.h"
-#include "time_support.h"
-
+#include "log.h"
+#include "types.h"
#include "jtag.h"
+#include "configuration.h"
#include "xsvf.h"
#include "svf.h"
#include "target.h"
#include "flash.h"
#include "nand.h"
#include "pld.h"
-#include "rom.h"
+#include "command.h"
#include "server.h"
#include "telnet_server.h"
#include "gdb_server.h"
+#include <time_support.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <cyg/io/flash.h>
#include <pkgconf/fs_jffs2.h> // Address of JFFS2
#include <network.h>
-#include <arpa/inet.h>
-#include <dirent.h>
-#include <net/if.h>
-#include <netdb.h>
-#include <netinet/tcp.h>
-#include <stdarg.h>
-#include <sys/ioctl.h>
+#include <fcntl.h>
#include <sys/stat.h>
-
+#include <cyg/fileio/fileio.h>
+#include <dirent.h>
#include <cyg/athttpd/http.h>
#include <cyg/athttpd/socket.h>
#include <cyg/athttpd/handler.h>
#include <cyg/athttpd/cgi.h>
#include <cyg/athttpd/forms.h>
#include <cyg/discover/discover.h>
-#include <cyg/fileio/fileio.h>
#include <cyg/hal/hal_diag.h>
-#include <cyg/io/flash.h>
+#include <cyg/kernel/kapi.h>
#include <cyg/io/serialio.h>
#include <cyg/io/io.h>
-#include <cyg/kernel/kapi.h>
-
-#ifdef HAVE_IFADDRS_H
+#include <netinet/tcp.h>
+#include "rom.h"
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <arpa/inet.h>
+#include <stdio.h>
#include <ifaddrs.h>
-#endif
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
+#include <string.h>
+
+#include <unistd.h>
+#include <stdio.h>
+
#define MAX_IFS 64
#if defined(CYGPKG_NET_FREEBSD_STACK)
}
#endif
-extern int eth0_up;
static FILE *log;
static char reboot_stack[2048];
}
#ifdef CYGPKG_PROFILE_GPROF
-extern void start_profile(void);
int eCosBoard_handle_eCosBoard_profile_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
}
cyg_io_flash_getconfig_erase_t e;
- void *err_addr;
len = sizeof(e);
e.offset = 0;
e.len = ds.dev_size;
- e.err_address = &err_addr;
- diag_printf("Formatting 0x%08x bytes\n", ds.dev_size);
+ diag_printf("Formatting 0x%08x bytes\n", (int)ds.dev_size);
err = cyg_io_get_config(handle, CYG_IO_GET_CONFIG_FLASH_ERASE, &e, &len);
if (err != ENOERR)
{
- diag_printf("Flash erase error %d offset 0x%p\n", err, err_addr);
+ diag_printf("Flash erase error %d offset 0x%08x\n", err, e.err_address);
reboot();
}
}
-extern Jim_Interp *interp;
-
static void zylinjtag_startNetwork(void)
{
// Bring TCP/IP up immediately before we're ready to accept commands.
#ifdef CYGPKG_PROFILE_GPROF
start_profile();
#endif
- int actual = 0;
- int actual2 = 0;
- int pos, pos2;
+ size_t actual = 0;
+ size_t actual2 = 0;
+ size_t pos, pos2;
pos = 0;
pos2 = 0;
cur = 0;
if (actual2 <= 0)
{
memset(backwardBuffer, 's', sizeof(backwardBuffer));
- actual2 = read(serHandle, backwardBuffer,
+ int t;
+ t = read(serHandle, backwardBuffer,
sizeof(backwardBuffer));
- if (actual2 < 0)
+ actual2 = t;
+ if (t < 0)
{
if (errno != EAGAIN)
{
pos2 = 0;
}
- int x = actual2;
- int y = 0;
+ size_t x = actual2;
+ size_t y = 0;
if (actual2 > 0)
{
int written = write(session, backwardBuffer + pos2, actual2);
command_context_t *setup_command_handler(void);
-extern const char *zylin_config_dir;
+static const char *zylin_config_dir="/config/settings";
int add_default_dirs(void)
{
command_run_linef(cmd_ctx, "script /rom/openocd.cfg");
+ /* we MUST always run the init command as it will launch telnet sessions */
+ command_run_line(cmd_ctx, "init");
+
// FIX!!! Yuk!
// diag_printf() is really invoked from many more places than we trust it
// not to cause instabilities(e.g. invoking fputc() from an interrupt is *BAD*).
return ENOERR;
}
+int loadFile(const char *fileName, void **data, int *len);
+
+/* boolean parameter stored on config */
+int boolParam(char *var)
+{
+ bool result = false;
+ char *name = alloc_printf("%s/%s", zylin_config_dir, var);
+ if (name == NULL)
+ return result;
+
+ void *data;
+ int len;
+ if (loadFile(name, &data, &len) == ERROR_OK)
+ {
+ if (len > 1)
+ len = 1;
+ result = strncmp((char *) data, "1", len) == 0;
+ free(data);
+ }
+ free(name);
+ return result;
+}
+