#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <ctype.h>
#include <unistd.h>
#include "dbg_msg.h"
#include "jt_arm.h"
#include "jt_flash.h"
#include "arm_emu.h"
#include "arm_gdbstub.h"
#include "arm_memory_mmap.h"
#include "arm_sfa_cmdseq.h"
Example layout
______________________ | cmdSequenceContainer | +----------------------+ | numberOfCmdSequences | =2 +----------------------+ | firstSequence | +----------------------+ | | | _________Y____________ ______________________ | cmdSequenceHead | | cmdSequenceHead | +----------------------+ +----------------------+ | nextHead |---->| nextHead |--->(NULL) +----------------------+ +----------------------+ | numberOfEntrys | =3 | numberOfEntrys | =0 +----------------------+ +----------------------+ | firstSequenceEntry | | firstSequenceEntry | +----------------------+ +----------------------+ | | | Y | (NULL) | __________Y__________ _________________ _________________ | cmdSequence | | cmdSequence | | cmdSequence | +--------------------+ +-----------------+ +-----------------+ | nextSequence |--->| nextSequence |--->| nextSequence |--->(NULL) +--------------------+ +-----------------+ +-----------------+
#define BIND_BUF_LEN 256 |
Referenced by readStringBindingCmdSequence().
#define CMDSEQ_STRING_BUF_LEN 100 |
Referenced by readStringCmdSequence().
int AllocCmdDataStore | ( | struct cmdDataStoreHead * | sh, | |
uint32_t ** | dataStart, | |||
int | size | |||
) |
____________________ | cmdDataStoreHead | +--------------------+ | numberOfStores | = 3 +--------------------+ | firstStore | +--------------------+ | _________Y__________ ______________ ______________ | cmdDataStore | | cmdDataStore | | cmdDataStore | +--------------------+ +--------------+ +--------------+ | nextStore |--->| nextStore |--->| nextStore |--->(NULL) +--------------------+ +--------------+ +--------------+
Allocate a cmdDataStore and append it at our list.
sh | pointer to head of the store | |
dataStart | output pointer to return start addess of allocated data | |
size | requested data size |
0 | OK | |
EINVAL | if no head given | |
ENOMEM | if out of memory |
References cmdDataStore::data, cmdDataStoreHead::firstStore, cmdDataStore::nextStore, cmdDataStoreHead::numberOfStores, and cmdDataStore::size.
Referenced by arm_sfa_ResetCPU(), arm_sfa_StartTarget(), arm_sfa_StopTarget(), armOsabiGetCurrentTid(), armOsabiGetMinimalThreadId(), armOsabiGetSavedRegSet(), armOsabiGetTLSAddr(), armOsabiMultiThreading(), armOsabiThreadAlive(), armOsabiThreadInfo(), and doCmdSequence().
void ReleaseAllCmdDataStores | ( | struct cmdDataStoreHead * | sh | ) |
Releases all previous allocated data stores
sh | pointer to head of the store |
References cmdDataStoreHead::firstStore, cmdDataStore::nextStore, and cmdDataStoreHead::numberOfStores.
Referenced by arm_sfa_ResetCPU(), arm_sfa_StartTarget(), arm_sfa_StopTarget(), armOsabiGetCurrentTid(), armOsabiGetMinimalThreadId(), armOsabiGetSavedRegSet(), armOsabiGetTLSAddr(), armOsabiMultiThreading(), armOsabiThreadAlive(), armOsabiThreadInfo(), and doCmdSequence().
int isAValidDataStoreAddress | ( | struct cmdDataStoreHead * | sh, | |
uint32_t | address | |||
) |
References cmdDataStore::data, cmdDataStoreHead::firstStore, cmdDataStore::nextStore, and cmdDataStore::size.
Referenced by doCmdSequence().
int AllocCmdSeqences | ( | int | total_number_of_cmdSequences | ) |
______________________ | cmdSequenceContainer | +----------------------+ | numberOfCmdSequences | = 3 +----------------------+ | firstSequence | +----------------------+ | _______Y______________ ______________________ ______________________ | cmdSequenceHead | | cmdSequenceHead | | cmdSequenceHead | +----------------------+ +----------------------+ +----------------------+ | nextHead |--->| nextHead |--->| nextHead |--->(NULL) +----------------------+ +----------------------+ +----------------------+
Allocate one (or more or non) Command Sequence Head's and append it (or those) at our list.
total_number_of_cmdSequences | request a maximum number of Command Sequence Head's |
0 | on success | |
!=0 | error number |
References cmdSequenceContainer::firstSequence, cmdSequenceHead::nextHead, and cmdSequenceContainer::numberOfCmdSequences.
Referenced by gdb_monitor_Rcmd().
struct cmdSequenceHead* searchCmdSequenceHead | ( | int | num | ) | [read] |
collect cmdSequenceHead number num from list
num | number of command sequence |
NULL | command sequence dosn't exist | |
!=NULL | pointer to cmdSequenceHead |
References cmdSequenceContainer::firstSequence, cmdSequenceHead::nextHead, and cmdSequenceContainer::numberOfCmdSequences.
Referenced by doCmdSequence(), gdb_monitor_Rcmd(), readaddrCmdSequence(), readStringBindingCmdSequence(), readStringCmdSequence(), and readvalCmdSequence().
int AllocCmdSequenceEntrys | ( | struct cmdSequenceHead * | sh, | |
int | total_num | |||
) |
____________________ | cmdSequenceHead | +--------------------+ | numberOfEntrys | = 3 +--------------------+ | firstSequenceEntry | +--------------------+ | _________Y__________ _________________ _________________ | cmdSequence | | cmdSequence | | cmdSequence | +--------------------+ +-----------------+ +-----------------+ | nextSequence |--->| nextSequence |--->| nextSequence |--->(NULL) +--------------------+ +-----------------+ +-----------------+
Allocate one (or more or non) command sequence entries and append it (or those) at our list.
total_num | request a maximum number of command sequence entries | |
sh | pointer to head of command sequence |
0 | OK | |
EINVAL | if no head given | |
ENOMEM | if out of memory |
References cmdSequenceHead::firstSequenceEntry, cmdSequence::memMapNumber, cmdSequence::nextSequence, and cmdSequenceHead::numberOfEntrys.
Referenced by gdb_monitor_Rcmd().
struct cmdSequence* searchCmdSequenceEntry | ( | struct cmdSequenceHead * | sh, | |
int | num | |||
) | [read] |
collect command sequence entry number (num) of cmdSequenceHead (sh) from list
num | entry number of command sequence | |
sh | pointer to head of command sequence |
NULL | sequence entry dosn't exist | |
!=NULL | pointer to cmdSequence entry |
References cmdSequenceHead::firstSequenceEntry, cmdSequence::nextSequence, and cmdSequenceHead::numberOfEntrys.
Referenced by doCmdSequence(), readaddrCmdSequence(), readStringCmdSequence(), readvalCmdSequence(), and updateCmdSequence().
int updateCmdSequence | ( | struct cmdSequenceHead * | sh, | |
int | num, | |||
uint32_t | cmdSize, | |||
uint32_t | addr, | |||
uint32_t | val, | |||
enum CmdSequenceFlag | flag | |||
) |
Update a specific command sequence entry.
sh | pointer to Head of command sequence | |
num | entry number within the sequence list | |
cmdSize | bus size (should be 8,16 or 32 Bit) | |
addr | target address | |
val | target value | |
flag | CMDSEQUFLAG_WRITE CMDSEQUFLAG_READ CMDSEQUFLAG_FORCE |
0 | OK | |
EINVAL | Failure |
References cmdSequence::addr, cmdSequence::cmdSize, cmdSequence::flag, cmdSequence::memMap, cmdSequence::memMapNumber, cmdSequence::mov_srcSequence, searchCmdSequenceEntry(), and cmdSequence::val.
Referenced by gdb_monitor_Rcmd().
uint32_t readvalCmdSequence | ( | int | num, | |
int | entryNum | |||
) |
Read the previous saved value of command sequence.
num | command sequence number | |
entryNum | entry number within the sequence list |
References cmdSequenceHead::numberOfEntrys, searchCmdSequenceEntry(), searchCmdSequenceHead(), and cmdSequence::val.
Referenced by gdb_monitor_Rcmd().
uint32_t readaddrCmdSequence | ( | int | num, | |
int | entryNum | |||
) |
Read the defined address of a command sequence.
num | command sequence number | |
entryNum | entry number within the sequence list |
References cmdSequence::addr, cmdSequenceHead::numberOfEntrys, searchCmdSequenceEntry(), and searchCmdSequenceHead().
Referenced by gdb_monitor_Rcmd().
char* readStringBindingCmdSequence | ( | int | num | ) |
References BIND_BUF_LEN, cmdSequenceContainer::cmdSequenceNumber, cmdSequenceNumber::GetCurrentThreadId, cmdSequenceNumber::GetSavedRegisterSet, cmdSequenceNumber::GetThreadInfo, cmdSequenceNumber::GetTLSAddr, cmdSequenceNumber::IsTheadIdAlive, cmdSequenceNumber::MinimalThreadId, cmdSequenceNumber::MultiThreadActive, cmdSequenceHead::numberOfEntrys, cmdSequenceNumber::ResetCPU, searchCmdSequenceHead(), cmdSequenceNumber::StartTarget, and cmdSequenceNumber::StopTarget.
Referenced by gdb_monitor_Rcmd().
char* readStringCmdSequence | ( | int | num, | |
int | entryNum | |||
) |
References cmdSequence::addr, CMDSEQ_STRING_BUF_LEN, CMDSEQUFLAG_ACCESS_FLAG, CMDSEQUFLAG_ADD, CMDSEQUFLAG_ADDRREF, CMDSEQUFLAG_ALLOC, CMDSEQUFLAG_AND, CMDSEQUFLAG_CALL, CMDSEQUFLAG_CALLWVAR, CMDSEQUFLAG_DIV, CMDSEQUFLAG_DUPARG, CMDSEQUFLAG_DUPRETVAL, CMDSEQUFLAG_DUPVAR, CMDSEQUFLAG_EXPORT_DATA_STORE, CMDSEQUFLAG_FORCE, CMDSEQUFLAG_INTERNAL, CMDSEQUFLAG_JMP_COND_MSK, CMDSEQUFLAG_JMP_FLAG, CMDSEQUFLAG_LSL, CMDSEQUFLAG_LSR, CMDSEQUFLAG_MOV, CMDSEQUFLAG_MUL, CMDSEQUFLAG_NOT, CMDSEQUFLAG_OR, CMDSEQUFLAG_READ, CMDSEQUFLAG_RETURN, CMDSEQUFLAG_ROR, CMDSEQUFLAG_SETVAR, CMDSEQUFLAG_SUB, CMDSEQUFLAG_SUBREV, CMDSEQUFLAG_VALREF, CMDSEQUFLAG_XOR, cmdSequence::cmdSize, cmdSequence::flag, cmdSequenceHead::numberOfEntrys, searchCmdSequenceEntry(), searchCmdSequenceHead(), and cmdSequence::val.
Referenced by gdb_monitor_Rcmd().
int doCmdSequence | ( | int | num, | |
struct cmdCallStack * | callStack | |||
) |
Execute command sequence number "num" .
cmd[0]
Run through all entries of the command sequence list "cmdSequence" and if the CmdSequenceFlag of the entry is set to CMDSEQUFLAG_WRITE then write each value to its address, or read out the value and keep it in an entry variable.
The address should be inside of a SFA-MemMap.
If the flag CMDSEQUFLAG_FORCE is set all kind of defined MemMap's (except MMAP_T_UNUSED, MMAP_T_UNREAL or MMAP_T_CACHE) can be used.
num | command sequence number | |
callStack | pointer to context of caller |
0 | OK | |
!= | 0 Failure ->EINVAL,ENOTSUP,EOVERFLOW,EFAULT,EACCES |
References cmdSequence::addr, AllocCmdDataStore(), cmdCallStack::arg, arm_emu_add(), arm_emu_lsl(), arm_emu_lsr(), arm_emu_ror(), arm_emu_sub(), arm_recalculate_flags_Z_N(), CMDSEQUFLAG_ACCESS_FLAG, CMDSEQUFLAG_ADD, CMDSEQUFLAG_ADDRREF, CMDSEQUFLAG_ALIVE, CMDSEQUFLAG_ALLOC, CMDSEQUFLAG_AND, CMDSEQUFLAG_CALL, CMDSEQUFLAG_CALL_FLAG, CMDSEQUFLAG_CALLWVAR, CMDSEQUFLAG_DIV, CMDSEQUFLAG_DUPARG, CMDSEQUFLAG_DUPRETVAL, CMDSEQUFLAG_DUPVAR, CMDSEQUFLAG_EXPORT_DATA_STORE, CMDSEQUFLAG_FORCE, CMDSEQUFLAG_INTERNAL, CMDSEQUFLAG_JMP_COND_MSK, CMDSEQUFLAG_JMP_FLAG, CMDSEQUFLAG_LSL, CMDSEQUFLAG_LSR, CMDSEQUFLAG_MOV, CMDSEQUFLAG_MUL, CMDSEQUFLAG_NOT, CMDSEQUFLAG_OR, CMDSEQUFLAG_RDWR_MSK, CMDSEQUFLAG_RETURN, CMDSEQUFLAG_ROR, CMDSEQUFLAG_SETVAR, CMDSEQUFLAG_SUB, CMDSEQUFLAG_SUBREV, CMDSEQUFLAG_VALREF, CMDSEQUFLAG_WRITE, CMDSEQUFLAG_XOR, cmdSequence::cmdSize, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), cmdSequence::entryNum, findMemMapOfAddr(), cmdSequenceHead::firstSequenceEntry, cmdSequence::flag, gdb_rcmd_console_output(), isAValidDataStoreAddress(), jt_arm_condition_check(), jtag_arm_ReadByte(), jtag_arm_ReadHalfword(), jtag_arm_ReadWord(), jtag_arm_WriteByte(), jtag_arm_WriteHalfword(), jtag_arm_WriteWord(), cmdSequence::memMap, cmdSequence::memMapNumber, MMAP_T_CACHE, MMAP_T_SFA, MMAP_T_UNREAL, MMAP_T_UNUSED, cmdSequence::mov_dstSequence, cmdSequence::mov_srcSequence, cmdSequence::nextSequence, cmdSequenceHead::numberOfEntrys, cmdSequence::pre_jmpSequence, ReleaseAllCmdDataStores(), cmdCallStack::retVal, searchCmdSequenceEntry(), searchCmdSequenceHead(), cmdCallStack::store, memMap::type, and cmdSequence::val.
Referenced by arm_sfa_ResetCPU(), arm_sfa_StartTarget(), arm_sfa_StopTarget(), armOsabiGetCurrentTid(), armOsabiGetMinimalThreadId(), armOsabiGetSavedRegSet(), armOsabiGetTLSAddr(), armOsabiMultiThreading(), armOsabiThreadAlive(), armOsabiThreadInfo(), and gdb_monitor_Rcmd().
void arm_sfa_StartTarget | ( | void | ) |
Start Target hook called after leaving gdb prompt (executing stepping or continuing). Here we can do for example a start periphery
- |
References symbolTableEntry::addr, AllocCmdDataStore(), cmdCallStack::arg, cmdSequenceContainer::cmdSequenceNumber, doCmdSequence(), symbolTableHead::firstEntry, symbolTableEntry::nextSymbol, ReleaseAllCmdDataStores(), cmdCallStack::retVal, cmdSequenceNumber::StartTarget, cmdCallStack::store, SYM_START_TARGET, symbolTable, symbolTableEntry::usage, and symbolTableEntry::valid.
Referenced by gdb_action_continue(), gdb_action_step(), and gdb_main_loop().
void arm_sfa_StopTarget | ( | void | ) |
Stop Target hook called before entering to gdb prompt. Here we can do for example a stop periphery
- |
References symbolTableEntry::addr, AllocCmdDataStore(), cmdCallStack::arg, cmdSequenceContainer::cmdSequenceNumber, doCmdSequence(), symbolTableHead::firstEntry, symbolTableEntry::nextSymbol, ReleaseAllCmdDataStores(), cmdCallStack::retVal, cmdSequenceNumber::StopTarget, cmdCallStack::store, SYM_STOP_TARGET, symbolTable, symbolTableEntry::usage, and symbolTableEntry::valid.
Referenced by gdb_main_loop().
void arm_sfa_ResetCPU | ( | void | ) |
Sequence to Reset CPU
- |
References symbolTableEntry::addr, AllocCmdDataStore(), cmdCallStack::arg, cmdSequenceContainer::cmdSequenceNumber, doCmdSequence(), symbolTableHead::firstEntry, symbolTableEntry::nextSymbol, ReleaseAllCmdDataStores(), cmdSequenceNumber::ResetCPU, cmdCallStack::retVal, cmdCallStack::store, SYM_RESET_CPU, symbolTable, symbolTableEntry::usage, and symbolTableEntry::valid.
Referenced by gdb_monitor_Rcmd().
struct cmdDataStoreHead globalStore = {0, NULL} |