#include "config.h"
#endif
-#include "replacements.h"
-#include "target.h"
-#include "target_request.h"
-
-#include "log.h"
-#include "configuration.h"
-#include "binarybuffer.h"
-#include "jtag.h"
-#include "flash.h"
+#include "tclapi.h"
+#include "../target/target.h"
+#include "../jtag/jtag.h"
+#include "../flash/flash.h"
#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <sys/time.h>
-#include <time.h>
-#include <time_support.h>
-
-#include <fileio.h>
-#include <image.h>
static int new_int_array_element(Jim_Interp * interp, const char *varname, int idx, u32 val)
{
command_context_t *context;
long l;
u32 width;
- u32 len;
+ int len;
u32 addr;
- u32 count;
+ unsigned count;
u32 v;
const char *varname;
u8 buffer[4096];
- int i, n, e, retval;
+ unsigned i, n;
+ int e, retval;
/* argv[1] = name of array to receive the data
* argv[2] = desired width
command_context_t *context;
long l;
u32 width;
- u32 len;
+ int len;
u32 addr;
u32 count;
u32 v;
const char *varname;
u8 buffer[4096];
- int i, n, e, retval;
+ int n, e, retval;
/* argv[1] = name of array to get the data
* argv[2] = desired width
}
v = 0; /* shut up gcc */
- for (i = 0 ;i < count ;i++, n++) {
+ for (unsigned i = 0 ;i < count ;i++, n++) {
get_int_array_element(interp, varname, n, &v);
switch (width) {
case 4:
Jim_GetLong(interp, args[i], &bits);
str = Jim_GetString(args[i+1], &len);
- fields[field_count].device = device;
fields[field_count].num_bits = bits;
fields[field_count].out_value = malloc(CEIL(bits, 8));
str_to_buf(str, len, fields[field_count].out_value, bits, 0);
- fields[field_count].out_mask = NULL;
fields[field_count].in_value = fields[field_count].out_value;
- fields[field_count].in_check_mask = NULL;
- fields[field_count].in_check_value = NULL;
- fields[field_count].in_handler = NULL;
- fields[field_count++].in_handler_priv = NULL;
}
jtag_add_dr_scan(num_fields, fields, TAP_INVALID);
static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
- flash_bank_t *p;
if (argc != 1) {
Jim_WrongNumArgs(interp, 1, argv, "no arguments to flash_banks command");
return JIM_ERR;
}
+ unsigned flash_banks = flash_get_bank_count();
if (!flash_banks)
{
return JIM_ERR;
}
Jim_Obj *list=Jim_NewListObj(interp, NULL, 0);
- for (p = flash_banks; p; p = p->next)
+ for (unsigned i = 0; i < flash_banks; i++)
{
+ flash_bank_t *p = get_flash_bank_by_num(i);
Jim_Obj *elem=Jim_NewListObj(interp, NULL, 0);
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "name", -1));
return JIM_OK;
}
-int tclapi_register_commands()
+int tclapi_register_commands(struct command_context_s *cmd_ctx)
{
- register_jim("ocd_mem2array", jim_mem2array, "read memory and return as a TCL array for script processing");
- register_jim("ocd_array2mem", jim_array2mem, "convert a TCL array to memory locations and write the values");
- register_jim("drscan", Jim_Command_drscan, "execute DR scan <device> <num_bits> <value> <num_bits1> <value2> ...");
- register_jim("ocd_flash_banks", jim_flash_banks, "return information about the flash banks");
-
+ register_jim(cmd_ctx, "ocd_mem2array", &jim_mem2array,
+ "read memory and return as a TCL array for script processing");
+ register_jim(cmd_ctx, "ocd_array2mem", &jim_array2mem,
+ "convert a TCL array to memory locations and write the values");
+ register_jim(cmd_ctx, "drscan", &Jim_Command_drscan,
+ "execute DR scan <device> <num_bits> <value> <num_bits1> <value2> ...");
+ register_jim(cmd_ctx, "ocd_flash_banks", &jim_flash_banks,
+ "return information about the flash banks");
+ return ERROR_OK;
}