AC_CANONICAL_HOST
+AC_C_BIGENDIAN
+
+AC_CHECK_FUNCS(strndup)
+
build_bitbang=no
is_cygwin=no
at91sam7_info->lockbits = status>>16;
at91sam7_info->securitybit = (status>>4)&0x01;
- if (at91sam7_info->cidr_arch == 0x70 ) {
+ if (at91sam7_info->cidr_arch == 0x70 )
+ {
at91sam7_info->num_nvmbits = 2;
at91sam7_info->nvmbits = (status>>8)&0x03;
bank->base = 0x100000;
return ERROR_OK;
}
- if (at91sam7_info->cidr_arch == 0x71 ) {
+ if (at91sam7_info->cidr_arch == 0x71 )
+ {
at91sam7_info->num_nvmbits = 2;
at91sam7_info->nvmbits = (status>>8)&0x03;
bank->base = 0x100000;
return ERROR_OK;
}
- if (at91sam7_info->cidr_arch == 0x75 ) {
+ if (at91sam7_info->cidr_arch == 0x75 )
+ {
at91sam7_info->num_nvmbits = 3;
at91sam7_info->nvmbits = (status>>8)&0x07;
bank->base = 0x100000;
return ERROR_OK;
}
- if (at91sam7_info->cidr_arch != 0x70 )
+ if (at91sam7_info->cidr_arch == 0x60 )
{
- WARNING("at91sam7 flash only tested for AT91SAM7Sxx series");
+ at91sam7_info->num_nvmbits = 3;
+ at91sam7_info->nvmbits = (status>>8)&0x07;
+ bank->base = 0x100000;
+ bank->bus_width = 4;
+
+ if (bank->size == 0x40000) /* AT91SAM7A3 */
+ {
+ at91sam7_info->num_lockbits = 16;
+ at91sam7_info->pagesize = 256;
+ at91sam7_info->pages_in_lockregion = 64;
+ at91sam7_info->num_pages = 16*64;
+ }
+ return ERROR_OK;
}
- return ERROR_OK;
+
+ WARNING("at91sam7 flash only tested for AT91SAM7Sxx series");
+
+ return ERROR_OK;
}
int at91sam7_erase_check(struct flash_bank_s *bank)
int at91sam7_register_commands(struct command_context_s *cmd_ctx)
{
- command_t *at91sam7_cmd = register_command(cmd_ctx, NULL, "cfi", NULL, COMMAND_ANY, NULL);
+ command_t *at91sam7_cmd = register_command(cmd_ctx, NULL, "at91sam7", NULL, COMMAND_ANY, "at91sam7 specific commands");
return ERROR_OK;
}
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-
#ifndef TYPES_H
#define TYPES_H
+#include "config.h"
+
#ifndef u8
typedef unsigned char u8;
#endif
typedef unsigned int u32;
#endif
+#ifdef WORDS_BIGENDIAN /* big endian host */
+
+#define le_to_h_u32(x) (u32)(x[0] | x[1] << 8 | x[2] << 16 | x[3] << 24)
+#define le_to_h_u16(x) (u16)(x[0] | x[1] << 8)
+#define be_to_h_u32(x) (*(u32*)(x))
+#define be_to_h_u16(x) (*(u16*)(x))
+
+#define h_u32_to_le(buf, val) \
+ do { \
+ buf[3] = (val & 0xff000000) >> 24; \
+ buf[2] = (val & 0x00ff0000) >> 16; \
+ buf[1] = (val & 0x0000ff00) >> 8; \
+ buf[0] = (val & 0x000000ff); \
+ } while (0)
+
+#define h_u16_to_le(buf, val) \
+ do { \
+ buf[0] = (val & 0xff000) >> 8; \
+ buf[1] = (val & 0x00ff); \
+ } while (0)
+
+#define h_u32_to_be(buf, val) do { *(u32*)(buf) = (val); } while (0)
+#define h_u16_to_be(buf, val) do { *(u16*)(buf) = (val); } while (0)
+
+#else /* little endian host */
+#define le_to_h_u32(x) (*(u32*)(x))
+#define le_to_h_u16(x) (*(u16*)(x))
+#define be_to_h_u32(x) (u32)(x[3] | x[2] << 8 | x[1] << 16 | x[0] << 24)
+#define be_to_h_u16(x) (u16)(x[1] | x[0] << 8)
+
+#define h_u32_to_le(buf, val) do { *(u32*)(buf) = (val); } while (0)
+#define h_u16_to_le(buf, val) do { *(u16*)(buf) = (val); } while (0)
+
+#define h_u32_to_be(buf, val) \
+ do { \
+ buf[0] = (val & 0xff000000) >> 24; \
+ buf[1] = (val & 0x00ff0000) >> 16; \
+ buf[2] = (val & 0x0000ff00) >> 8; \
+ buf[3] = (val & 0x000000ff); \
+ } while (0)
+
+#define h_u16_to_be(buf, val) \
+ do { \
+ buf[0] = (val & 0xff000) >> 8; \
+ buf[1] = (val & 0x00ff); \
+ } while (0)
+#endif
+
#endif /* TYPES_H */
if (argc == 0)
return ERROR_OK;
- ftd2xx_layout = malloc(strlen(args[0]));
+ ftd2xx_layout = malloc(strlen(args[0]) + 1);
strcpy(ftd2xx_layout, args[0]);
return ERROR_OK;
#include "command.h"
-#if 0
+#if 1
#define _DEBUG_JTAG_IO_
#endif
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "config.h"
+
#include "gdb_server.h"
#include "server.h"
#include <stdlib.h>
// -ino: 060521-1116
-#ifdef __FreeBSD__
+#ifndef HAVE_STRNDUP
#include <stdio.h>
char * strndup(char * str, int n) {
unsigned char * tmp = malloc((size_t)n+1);
return tmp;
}
#endif
+
#if 0
#define _DEBUG_GDB_IO_
#endif
u32 *reg_p[16];
int num_accesses = 0;
int thisrun_accesses;
- u32 *buf32;
- u16 *buf16;
- u8 *buf8;
int i;
u32 cpsr;
int retval;
switch (size)
{
case 4:
- buf32 = (u32*)buffer;
while (num_accesses < count)
{
u32 reg_list;
{
if (i > last_reg)
last_reg = i;
- *(buf32++) = reg[i];
+ target_buffer_set_u32(target, buffer, reg[i]);
+ buffer += 4;
}
num_accesses += thisrun_accesses;
}
break;
case 2:
- buf16 = (u16*)buffer;
while (num_accesses < count)
{
u32 reg_list;
for (i = 1; i <= thisrun_accesses; i++)
{
- *(buf16++) = reg[i] & 0xffff;
+ target_buffer_set_u16(target, buffer, reg[i]);
+ buffer += 2;
}
num_accesses += thisrun_accesses;
}
break;
case 1:
- buf8 = buffer;
while (num_accesses < count)
{
u32 reg_list;
for (i = 1; i <= thisrun_accesses; i++)
{
- *(buf8++) = reg[i] & 0xff;
+ *(buffer++) = reg[i] & 0xff;
}
num_accesses += thisrun_accesses;
}
u32 reg[16];
int num_accesses = 0;
int thisrun_accesses;
- u32 *buf32;
- u16 *buf16;
- u8 *buf8;
int i;
u32 cpsr;
int retval;
switch (size)
{
case 4:
- buf32 = (u32*)buffer;
while (num_accesses < count)
{
u32 reg_list;
{
if (i > last_reg)
last_reg = i;
- reg[i] = *buf32++;
+ reg[i] = target_buffer_get_u32(target, buffer);
+ buffer += 4;
}
arm7_9->write_core_regs(target, reg_list, reg);
}
break;
case 2:
- buf16 = (u16*)buffer;
while (num_accesses < count)
{
u32 reg_list;
{
if (i > last_reg)
last_reg = i;
- reg[i] = *buf16++ & 0xffff;
+ reg[i] = target_buffer_get_u16(target, buffer) & 0xffff;
+ buffer += 2;
}
arm7_9->write_core_regs(target, reg_list, reg);
}
break;
case 1:
- buf8 = buffer;
while (num_accesses < count)
{
u32 reg_list;
{
if (i > last_reg)
last_reg = i;
- reg[i] = *buf8++ & 0xff;
+ reg[i] = *buffer++ & 0xff;
}
arm7_9->write_core_regs(target, reg_list, reg);
for (i = 0; i < count; i++)
{
- embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_COMMS_DATA], buf_get_u32(buffer, 0, 32));
+ embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_COMMS_DATA], target_buffer_get_u32(target, buffer));
buffer += 4;
}
static int target_continous_poll = 1;
+/* read a u32 from a buffer in target memory endianness */
+u32 target_buffer_get_u32(target_t *target, u8 *buffer)
+{
+ if (target->endianness == TARGET_LITTLE_ENDIAN)
+ return le_to_h_u32(buffer);
+ else
+ return be_to_h_u32(buffer);
+}
+
+/* read a u16 from a buffer in target memory endianness */
+u16 target_buffer_get_u16(target_t *target, u8 *buffer)
+{
+ if (target->endianness == TARGET_LITTLE_ENDIAN)
+ return le_to_h_u16(buffer);
+ else
+ return be_to_h_u16(buffer);
+}
+
+/* write a u32 to a buffer in target memory endianness */
+void target_buffer_set_u32(target_t *target, u8 *buffer, u32 value)
+{
+ if (target->endianness == TARGET_LITTLE_ENDIAN)
+ h_u32_to_le(buffer, value);
+ else
+ h_u32_to_be(buffer, value);
+}
+
+/* write a u16 to a buffer in target memory endianness */
+void target_buffer_set_u16(target_t *target, u8 *buffer, u16 value)
+{
+ if (target->endianness == TARGET_LITTLE_ENDIAN)
+ h_u16_to_le(buffer, value);
+ else
+ h_u16_to_be(buffer, value);
+}
+
/* returns a pointer to the n-th configured target */
target_t* get_target_by_num(int num)
{
extern target_event_callback_t *target_event_callbacks;
extern target_timer_callback_t *target_timer_callbacks;
+extern u32 target_buffer_get_u32(target_t *target, u8 *buffer);
+extern u16 target_buffer_get_u16(target_t *target, u8 *buffer);
+extern void target_buffer_set_u32(target_t *target, u8 *buffer, u32 value);
+extern void target_buffer_set_u16(target_t *target, u8 *buffer, u16 value);
+
#define ERROR_TARGET_INVALID (-300)
#define ERROR_TARGET_INIT_FAILED (-301)
#define ERROR_TARGET_TIMEOUT (-302)