aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java/lang/ArrayStoreException.java
blob: 042e78c5515750fa65e1ff41546703572d20fda1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* ArrayStoreException.java -- exception thrown to when trying to store an
   object into an array of a different type.
   Copyright (C) 1998, 1999, 2001, 2002, 2005  Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */


package java.lang;

/**
 * Thrown when trying to store an object of the wrong runtime type in an
 * array. For example:<br>
 * <pre>
 * Object[] o = new Integer[1];
 * o[0] = "oops";
 * </pre>
 *
 * @author Brian Jones
 * @author Warren Levy (warrenl@cygnus.com)
 * @status updated to 1.4
 */
public class ArrayStoreException extends RuntimeException
{
  /**
   * Compatible with JDK 1.0+.
   */
  private static final long serialVersionUID = -4522193890499838241L;

  /**
   * Create an exception without a message.
   */
  public ArrayStoreException()
  {
  }

  /**
   * Create an exception with a message.
   *
   * @param s the message
   */
  public ArrayStoreException(String s)
  {
    super(s);
  }
}
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
/***************************************************************************
*   Copyright (C) 2005 by Dominic Rath                                    *
*   Dominic.Rath@gmx.de                                                   *
*                                                                         *
*   Copyright (C) 2007-2010 Øyvind Harboe                                 *
*   oyvind.harboe@zylin.com                                               *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/
#ifndef JTAG_H
#define JTAG_H

#include <helper/binarybuffer.h>
#include <helper/log.h>

#ifdef _DEBUG_JTAG_IO_
#define DEBUG_JTAG_IO(expr ...) \
	do { if (1) LOG_DEBUG(expr); } while (0)
#else
#define DEBUG_JTAG_IO(expr ...) \
	do { if (0) LOG_DEBUG(expr); } while (0)
#endif

#ifndef DEBUG_JTAG_IOZ
#define DEBUG_JTAG_IOZ 64
#endif

/*-----</Macros>-------------------------------------------------*/

/**
 * Defines JTAG Test Access Port states.
 *
 * These definitions were gleaned from the ARM7TDMI-S Technical
 * Reference Manual and validated against several other ARM core
 * technical manuals.
 *
 * FIXME some interfaces require specific numbers be used, as they
 * are handed-off directly to their hardware implementations.
 * Fix those drivers to map as appropriate ... then pick some
 * sane set of numbers here (where 0/uninitialized == INVALID).
 */
typedef enum tap_state
{
	TAP_INVALID = -1,

#if BUILD_ZY1000
	/* These are the old numbers. Leave as-is for now... */
	TAP_RESET    = 0, TAP_IDLE = 8,
	TAP_DRSELECT = 1, TAP_DRCAPTURE = 2, TAP_DRSHIFT = 3, TAP_DREXIT1 = 4,
	TAP_DRPAUSE  = 5, TAP_DREXIT2 = 6, TAP_DRUPDATE = 7,
	TAP_IRSELECT = 9, TAP_IRCAPTURE = 10, TAP_IRSHIFT = 11, TAP_IREXIT1 = 12,
	TAP_IRPAUSE  = 13, TAP_IREXIT2 = 14, TAP_IRUPDATE = 15,

#else
	/* Proper ARM recommended numbers */
	TAP_DREXIT2 = 0x0,
	TAP_DREXIT1 = 0x1,
	TAP_DRSHIFT = 0x2,
	TAP_DRPAUSE = 0x3,
	TAP_IRSELECT = 0x4,
	TAP_DRUPDATE = 0x5,
	TAP_DRCAPTURE = 0x6,
	TAP_DRSELECT = 0x7,
	TAP_IREXIT2 = 0x8,
	TAP_IREXIT1 = 0x9,
	TAP_IRSHIFT = 0xa,
	TAP_IRPAUSE = 0xb,
	TAP_IDLE = 0xc,
	TAP_IRUPDATE = 0xd,
	TAP_IRCAPTURE = 0xe,
	TAP_RESET = 0x0f,

#endif
} tap_state_t;

/**
 * Function tap_state_name
 * Returns a string suitable for display representing the JTAG tap_state
 */
const char *tap_state_name(tap_state_t state);

/// Provides user-friendly name lookup of TAP states.
tap_state_t tap_state_by_name(const char *name);

/// The current TAP state of the pending JTAG command queue.
extern tap_state_t cmd_queue_cur_state;

/**
 * This structure defines a single scan field in the scan. It provides
 * fields for the field's width and pointers to scan input and output
 * values.
 *
 * In addition, this structure includes a value and mask that is used by
 * jtag_add_dr_scan_check() to validate the value that was scanned out.
 *
 * The allocated, modified, and intmp fields are internal work space.
 */
struct scan_field {
	/// The number of bits this field specifies (up to 32)
	int num_bits;
	/// A pointer to value to be scanned into the device
	const uint8_t* out_value;
	/// A pointer to a 32-bit memory location for data scanned out
	uint8_t* in_value;

	/// The value used to check the data scanned out.
	uint8_t* check_value;
	/// The mask to go with check_value
	uint8_t* check_mask;

	/// in_value has been allocated for the queue
	int allocated;
	/// Indicates we modified the in_value.
	int modified;
	/// temporary storage for performing value checks synchronously
	uint8_t intmp[4];
};

struct jtag_tap {
	const char* chip;
	const char* tapname;
	const char* dotted_name;
	int abs_chain_position;
	/// Is this TAP disabled after JTAG reset?
	bool disabled_after_reset;
	/// Is this TAP currently enabled?
	bool enabled;
	int ir_length; /**< size of instruction register */
	uint32_t ir_capture_value;
	uint8_t* expected; /**< Capture-IR expected value */
	uint32_t ir_capture_mask;
	uint8_t* expected_mask; /**< Capture-IR expected mask */
	uint32_t idcode; /**< device identification code */
	/** not all devices have idcode,
	 * we'll discover this during chain examination */
	bool hasidcode;

	/// Array of expected identification codes */
	uint32_t* expected_ids;
	/// Number of expected identification codes
	uint8_t expected_ids_cnt;

	/// Flag saying whether to ignore version field in expected_ids[]
	bool ignore_version;

	/// current instruction
	uint8_t* cur_instr;
	/// Bypass register selected
	int bypass;

	struct jtag_tap_event_action *event_action;

	struct jtag_tap* next_tap;
	/* dap instance if some null if no instance , initialized to 0 by calloc*/
	struct adiv5_dap *dap; 
};

void jtag_tap_init(struct jtag_tap *tap);
void jtag_tap_free(struct jtag_tap *tap);

struct jtag_tap* jtag_all_taps(void);
const char *jtag_tap_name(const struct jtag_tap *tap);
struct jtag_tap* jtag_tap_by_string(const char* dotted_name);
struct jtag_tap* jtag_tap_by_jim_obj(Jim_Interp* interp, Jim_Obj* obj);
struct jtag_tap* jtag_tap_by_position(unsigned abs_position);
struct jtag_tap* jtag_tap_next_enabled(struct jtag_tap* p);
unsigned jtag_tap_count_enabled(void);
unsigned jtag_tap_count(void);


/*
 * - TRST_ASSERTED triggers two sets of callbacks, after operations to
 *   reset the scan chain -- via TMS+TCK signaling, or deasserting the
 *   nTRST signal -- are queued:
 *
 *    + Callbacks in C code fire first, patching internal state
 *    + Then post-reset event scripts fire ... activating JTAG circuits
 *      via TCK cycles, exiting SWD mode via TMS sequences, etc
 *
 *   During those callbacks, scan chain contents have not been validated.
 *   JTAG operations that address a specific TAP (primarily DR/IR scans)
 *   must *not* be queued.
 *
 * - TAP_EVENT_SETUP is reported after TRST_ASSERTED, and after the scan
 *   chain has been validated.  JTAG operations including scans that
 *   target specific TAPs may be performed.
 *
 * - TAP_EVENT_ENABLE and TAP_EVENT_DISABLE implement TAP activation and
 *   deactivation outside the core using scripted code that understands
 *   the specific JTAG router type.  They might be triggered indirectly
 *   from EVENT_SETUP operations.
 */
enum jtag_event {
	JTAG_TRST_ASSERTED,
	JTAG_TAP_EVENT_SETUP,
	JTAG_TAP_EVENT_ENABLE,
	JTAG_TAP_EVENT_DISABLE,
};

struct jtag_tap_event_action
{
	/// The event for which this action will be triggered.
	enum jtag_event event;
	/// The interpreter to use for evaluating the @c body.
	Jim_Interp *interp;
	/// Contains a script to 'eval' when the @c event is triggered.
	Jim_Obj *body;
	// next action in linked list
	struct jtag_tap_event_action *next;
};

/**
 * Defines the function signature requide for JTAG event callback
 * functions, which are added with jtag_register_event_callback()
 * and removed jtag_unregister_event_callback().
 * @param event The event to handle.
 * @param prive A pointer to data that was passed to
 *	jtag_register_event_callback().
 * @returns Must return ERROR_OK on success, or an error code on failure.
 *
 * @todo Change to return void or define a use for its return code.
 */
typedef int (*jtag_event_handler_t)(enum jtag_event event, void* priv);

int jtag_register_event_callback(jtag_event_handler_t f, void *x);
int jtag_unregister_event_callback(jtag_event_handler_t f, void *x);

int jtag_call_event_callbacks(enum jtag_event event);


/// @returns The current JTAG speed setting.
int jtag_get_speed(int *speed);

/**
 * Given a @a speed setting, use the interface @c speed_div callback to
 * adjust the setting.
 * @param speed The speed setting to convert back to readable KHz.
 * @returns ERROR_OK if the interface has not been initialized or on success;
 *	otherwise, the error code produced by the @c speed_div callback.
 */
int jtag_get_speed_readable(int *speed);

/// Attempt to configure the interface for the specified KHz.
int jtag_config_khz(unsigned khz);

/**
 * Attempt to enable RTCK/RCLK. If that fails, fallback to the
 * specified frequency.
 */
int jtag_config_rclk(unsigned fallback_speed_khz);

/// Retreives the clock speed of the JTAG interface in KHz.
unsigned jtag_get_speed_khz(void);


enum reset_types {
	RESET_NONE            = 0x0,
	RESET_HAS_TRST        = 0x1,
	RESET_HAS_SRST        = 0x2,
	RESET_TRST_AND_SRST   = 0x3,
	RESET_SRST_PULLS_TRST = 0x4,
	RESET_TRST_PULLS_SRST = 0x8,
	RESET_TRST_OPEN_DRAIN = 0x10,
	RESET_SRST_PUSH_PULL  = 0x20,
	RESET_SRST_NO_GATING  = 0x40,
};

enum reset_types jtag_get_reset_config(void);
void jtag_set_reset_config(enum reset_types type);

void jtag_set_nsrst_delay(unsigned delay);
unsigned jtag_get_nsrst_delay(void);

void jtag_set_ntrst_delay(unsigned delay);
unsigned jtag_get_ntrst_delay(void);

void jtag_set_nsrst_assert_width(unsigned delay);
unsigned jtag_get_nsrst_assert_width(void);

void jtag_set_ntrst_assert_width(unsigned delay);
unsigned jtag_get_ntrst_assert_width(void);

/// @returns The current state of TRST.
int jtag_get_trst(void);
/// @returns The current state of SRST.
int jtag_get_srst(void);

/// Enable or disable data scan verification checking.
void jtag_set_verify(bool enable);
/// @returns True if data scan verification will be performed.
bool jtag_will_verify(void);

/// Enable or disable verification of IR scan checking.
void jtag_set_verify_capture_ir(bool enable);
/// @returns True if IR scan verification will be performed.
bool jtag_will_verify_capture_ir(void);

/** Initialize debug adapter upon startup.  */
int  adapter_init(struct command_context* cmd_ctx);

/// Shutdown the debug adapter upon program exit.
int  adapter_quit(void);

/// Set ms to sleep after jtag_execute_queue() flushes queue. Debug
/// purposes.
void jtag_set_flush_queue_sleep(int ms);

/**
 * Initialize JTAG chain using only a RESET reset. If init fails,
 * try reset + init.
 */
int  jtag_init(struct command_context* cmd_ctx);

/// reset, then initialize JTAG chain
int jtag_init_reset(struct command_context* cmd_ctx);
int jtag_register_commands(struct command_context* cmd_ctx);
int jtag_init_inner(struct command_context *cmd_ctx);

/**
 * @file
 * The JTAG interface can be implemented with a software or hardware fifo.
 *
 * TAP_DRSHIFT and TAP_IRSHIFT are illegal end states; however,
 * TAP_DRSHIFT/IRSHIFT can be emulated as end states, by using longer
 * scans.
 *
 * Code that is relatively insensitive to the path taken through state
 * machine (as long as it is JTAG compliant) can use @a endstate for
 * jtag_add_xxx_scan(). Otherwise, the pause state must be specified as
 * end state and a subsequent jtag_add_pathmove() must be issued.
 */

/**
 * Generate an IR SCAN with a list of scan fields with one entry for
 * each enabled TAP.
 *
 * If the input field list contains an instruction value for a TAP then
 * that is used otherwise the TAP is set to bypass.
 *
 * TAPs for which no fields are passed are marked as bypassed for
 * subsequent DR SCANs.
 *
 */
void jtag_add_ir_scan(struct jtag_tap* tap,
		struct scan_field* fields, tap_state_t endstate);
/**
 * The same as jtag_add_ir_scan except no verification is performed out
 * the output values.
 */
void jtag_add_ir_scan_noverify(struct jtag_tap* tap,
		const struct scan_field *fields, tap_state_t state);
/**
 * Scan out the bits in ir scan mode.
 *
 * If in_bits == NULL, discard incoming bits.
 */
void jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits,
		tap_state_t endstate);


/**
 * Set in_value to point to 32 bits of memory to scan into. This
 * function is a way to handle the case of synchronous and asynchronous
 * JTAG queues.
 *
 * In the event of an asynchronous queue execution the queue buffer
 * allocation method is used, for the synchronous case the temporary 32
 * bits come from the input field itself.
 */
void jtag_alloc_in_value32(struct scan_field *field);

/**
 * Generate a DR SCAN using the fields passed to the function.
 * For connected TAPs, the function checks in_fields and uses fields
 * specified there.  For bypassed TAPs, the function generates a dummy
 * 1-bit field.  The bypass status of TAPs is set by jtag_add_ir_scan().
 */
void jtag_add_dr_scan(struct jtag_tap* tap, int num_fields,
		const struct scan_field* fields, tap_state_t endstate);
/// A version of jtag_add_dr_scan() that uses the check_value/mask fields
void jtag_add_dr_scan_check(struct jtag_tap* tap, int num_fields,
		struct scan_field* fields, tap_state_t endstate);
/**
 * Scan out the bits in ir scan mode.
 *
 * If in_bits == NULL, discard incoming bits.
 */
void jtag_add_plain_dr_scan(int num_bits,
		const uint8_t *out_bits, uint8_t *in_bits, tap_state_t endstate);

/**
 * Defines the type of data passed to the jtag_callback_t interface.
 * The underlying type must allow storing an @c int or pointer type.
 */
typedef intptr_t jtag_callback_data_t;

/**
 * Defines a simple JTAG callback that can allow conversions on data
 * scanned in from an interface.
 *
 * This callback should only be used for conversion that cannot fail.
 * For conversion types or checks that can fail, use the more complete
 * variant: jtag_callback_t.
 */
typedef void (*jtag_callback1_t)(jtag_callback_data_t data0);

/// A simpler version of jtag_add_callback4().
void jtag_add_callback(jtag_callback1_t, jtag_callback_data_t data0);


/**
 * Defines the interface of the JTAG callback mechanism.  Such
 * callbacks can be executed once the queue has been flushed.
 *
 * The JTAG queue can be executed synchronously or asynchronously.
 * Typically for USB, the queue is executed asynchronously.  For
 * low-latency interfaces, the queue may be executed synchronously.
 *
 * The callback mechanism is very general and does not make many
 * assumptions about what the callback does or what its arguments are.
 * These callbacks are typically executed *after* the *entire* JTAG
 * queue has been executed for e.g. USB interfaces, and they are
 * guaranteeed to be invoked in the order that they were queued.
 *
 * If the execution of the queue fails before the callbacks, then --
 * depending on driver implementation -- the callbacks may or may not be
 * invoked.
 *
 * @todo Make that behavior consistent.
 *
 * @param data0 Typically used to point to the data to operate on.
 * Frequently this will be the data clocked in during a shift operation.
 * @param data1 An integer big enough to use as an @c int or a pointer.
 * @param data2 An integer big enough to use as an @c int or a pointer.
 * @param data3 An integer big enough to use as an @c int or a pointer.
 * @returns an error code
 */
typedef int (*jtag_callback_t)(jtag_callback_data_t data0,
				jtag_callback_data_t data1,
				jtag_callback_data_t data2,
				jtag_callback_data_t data3);

/**
 * Run a TAP_RESET reset where the end state is TAP_RESET,
 * regardless of the start state.