#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/mman.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_gdbstub.h"
#include "arm_memory_mmap.h"
#include "arm_sfa_cmdseq.h"
Example memory map layout
_________________ | memMapContainer | +-----------------+ | numberOfMemMaps | = 2 +-----------------+ | firstMap | +-----------------+ | | _______Y_________ _________________ | memMapHead | | memMapHead | +-----------------+ +-----------------+ | nextHead |----->| nextHead |--->(NULL) +-----------------+ +-----------------+ | numberOfEntrys | = 3 | numberOfEntrys | = 0 +-----------------+ +-----------------+ | firstMapEntry | | firstMapEntry | +-----------------+ +-----------------+ | | | Y | (NULL) | _______Y_________ _________________ _________________ | memMap | | memMap | | memMap | +-----------------+ +-----------------+ +-----------------+ | nextMap |--->| nextMap |--->| nextMap |--->(NULL) +-----------------+ +-----------------+ +-----------------+
#define XML_PROLOG_STRING |
Referenced by activateMemMap().
#define XML_EPILOG_STRING "</memory-map>\n" |
Referenced by activateMemMap().
#define PAGE_BUF 512*2 |
Referenced by activateMemMap().
int AllocMemMaps | ( | int | total_number_of_MemMaps | ) |
_________________ | memMapContainer | +-----------------+ | numberOfMemMaps | = 3 +-----------------+ | firstMap | +-----------------+ | _______Y_________ _________________ _________________ | memMapHead | | memMapHead | | memMapHead | +-----------------+ +-----------------+ +-----------------+ | nextHead |--->| nextHead |--->| nextHead |--->(NULL) +-----------------+ +-----------------+ +-----------------+
Allocate one (or more or non) memory MAP's and append it (or those) at our list.
total_number_of_MemMaps | request a maximum number of MAP's (memMapHeads) |
0 | on success | |
!=0 | error number |
References memMapContainer::firstMap, memMapHead::nextHead, and memMapContainer::numberOfMemMaps.
Referenced by gdb_monitor_Rcmd().
struct memMapHead* searchMemMapHead | ( | int | num | ) | [read] |
collect memMapHead number num from list
num | number of map |
NULL | map dosn't exist | |
!=NULL | pointer to memMapHead |
References memMapContainer::firstMap, memMapHead::nextHead, and memMapContainer::numberOfMemMaps.
Referenced by activateMemMap(), and gdb_monitor_Rcmd().
int AllocateMemMapEntrys | ( | struct memMapHead * | mh, | |
int | total_num | |||
) |
_________________ | memMapHead | +-----------------+ | numberOfEntrys | = 3 +-----------------+ | firstMapEntry | +-----------------+ | _______Y_________ _________________ _________________ | memMap | | memMap | | memMap | +-----------------+ +-----------------+ +-----------------+ | nextMap |--->| nextMap |--->| nextMap |--->(NULL) +-----------------+ +-----------------+ +-----------------+
Allocate one (or more or non) memory map entries and append it (or those) at our list.
total_num | request a maximum number of memMap entries | |
mh | pointer to head of MAP |
0 | OK | |
EINVAL | if no head given | |
ENOMEM | if out of memory |
References memMapHead::firstMapEntry, memMap::nextMap, and memMapHead::numberOfEntrys.
Referenced by gdb_monitor_Rcmd().
struct memMap* searchMemMapEntry | ( | struct memMapHead * | mh, | |
int | num | |||
) | [read] |
collect memMap entry number (num) of MAP memMapHead (mh) from list
num | entry number of memMap | |
mh | pointer to head of MAP |
NULL | map entry dosn't exist | |
!=NULL | pointer to memMap entry |
References memMapHead::firstMapEntry, memMap::nextMap, and memMapHead::numberOfEntrys.
struct memMap* findMemMapOfAddr | ( | uint32_t | addr | ) | [read] |
search at our active MAP for an entry where the address is somewhere within this entry.
addr | address |
References memMapContainer::activeMap, memMap::baseAddr, memMapHead::firstMapEntry, memMap::length, memMap::nextMap, and memMapHead::numberOfEntrys.
Referenced by doCmdSequence(), gdb_monitor_Rcmd(), gdb_read_mem(), gdb_write_mem(), gdbLookupArmInstr(), gdbLookupThumbInstr(), and InsertBreakpoint().
int updateMemMap | ( | struct memMapHead * | mh, | |
int | num, | |||
enum memMapType | type, | |||
uint32_t | busSize, | |||
uint32_t | baseAddr, | |||
uint32_t | length | |||
) |
update a single memMap entry
mh | pointer to head of MAP | |
num | number of entry (to update) | |
type | type of memory | |
busSize | bus size | |
baseAddr | start adderss of memMap entry (at target) | |
length | length of memory space (at target) |
References memMapContainer::activeNumber, memMap::MemBufferType::Flash::algo, memMap::baseAddr, memMap::busSize, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), memMapHead::firstMapEntry, memMap::MemBufferType::Flash, FLASH_ALGORITHEM_UNKNOWN, memMap::MemBufferType::Flash::infoString, memMap::length, memMap::memBufferType, MMAP_T_APPLICATION_FLASH, MMAP_T_FLASH, MMAP_T_UNUSED, memMap::nextMap, memMapHead::numberOfEntrys, memMap::MemBufferType::Flash::numberOfSectors, memMap::MemBufferType::Flash::sectorList, and memMap::type.
Referenced by gdb_monitor_Rcmd().
static int detectFlash | ( | struct memMap * | m | ) | [static] |
The memMap entry telling us something about here is a FLASH. But we need some more information about the FLASH-layout. Here we try to detect this info.
m | pointer to memMap entry |
0 | OK - we have all we need | |
1 | Failure/flash not supported |
References memMap::MemBufferType::Flash::algo, memMap::baseAddr, memMap::busSize, memMap::MemBufferType::Flash::chipsPerBus, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), error_exit_code, memMap::MemBufferType::Flash, FLASH_ALGORITHEM_AMD, FLASH_ALGORITHEM_ATMEL, FLASH_ALGORITHEM_INTEL, FLASH_ALGORITHEM_PHILIPS, FLASH_ALGORITHEM_STM32, FLASH_ALGORITHEM_STR7, FLASH_ALGORITHEM_STR9, memMap::MemBufferType::Flash::infoString, jt_amdflashGetInfoByte(), jt_amdflashGetInfoHalfword(), jt_amdflashGetInfoWord(), jt_atmelflashGetInfo(), jt_intelflashGetInfoByte(), jt_intelflashGetInfoHalfword(), jt_philipsflashGetInfo(), jt_stflashGetInfo(), memMap::length, memMap::memBufferType, memMap::MemBufferType::Flash::numberOfSectors, memMap::MemBufferType::Flash::sectorList, and sector::size.
Referenced by activateMemMap().
static int defaultFlash | ( | struct memMap * | m | ) | [static] |
default value for appl Falsh only (this kind of flash will never be programed)
m | pointer to memMap entry |
0 | OK - we have all we need | |
1 | Failure/flash not supported |
References memMap::MemBufferType::Flash::algo, memMap::MemBufferType::Flash::chipsPerBus, memMap::MemBufferType::Flash, FLASH_ALGORITHEM_UNKNOWN, memMap::MemBufferType::Flash::infoString, jt_flash_create_sector_info(), memMap::length, MAX_FLASH_INFO_STRING_LEN, memMap::memBufferType, memMap::MemBufferType::Flash::numberOfSectors, and memMap::MemBufferType::Flash::sectorList.
Referenced by activateMemMap().
int activateMemMap | ( | int | num | ) |
activate the previous configured memMap[num]
num | number of memMap to activate |
0 | SUCCESS | |
error | = EINVAL, ENOMEM |
References memMapContainer::activeMap, memMapContainer::activeNumber, memMap::baseAddr, memMap::MemBuffer::Byte, changeWorkSpaceMode(), DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), defaultFlash(), detectFlash(), error_exit_code, memMapHead::firstMapEntry, cmdSequenceHead::firstSequenceEntry, memMap::MemBufferType::Flash, memMap::MemBufferType::Workspace::info, is_workspace_big_enough(), memMap::length, memMap::memBuffer, memMap::memBufferLength, memMap::memBufferType, cmdSequence::memMap, cmdSequence::memMapNumber, MMAP_T_APPLICATION_FLASH, MMAP_T_FLASH, MMAP_T_RAM, MMAP_T_REREAD_ROM, MMAP_T_ROM, MMAP_T_UNREAL, MMAP_T_WORKSPACE, cmdSequenceHead::nextHead, memMap::nextMap, cmdSequence::nextSequence, memMapHead::numberOfEntrys, memMap::MemBufferType::Flash::numberOfSectors, PAGE_BUF, memMap::MemBufferType::Ram, RAM_PAGE_SIZE, memMap::MemBufferType::Ram::readPageBitmap, searchMemMapHead(), memMap::MemBufferType::Flash::sectorList, sector::size, STAND_ALONE_WORKSPACE, memMap::MemBufferType::Workspace::state, memMap::type, memMap::MemBuffer::Word, memMap::MemBufferType::Workspace, memMapContainer::workspace, memMapContainer::workspace_mode, WORKSPACE_UNTESTED, memMap::MemBufferType::Ram::writeByteBitmap, memMap::MemBufferType::Flash::writeByteBitmap, memMapContainer::xml_buf, XML_EPILOG_STRING, memMapContainer::xml_len, and XML_PROLOG_STRING.
Referenced by gdb_monitor_Rcmd().
void deactivateMemMap | ( | void | ) |
deactivate the current active memMap
- |
References memMapContainer::activeMap, memMapContainer::activeNumber, memMap::MemBufferType::Flash::algo, memMap::MemBuffer::Byte, memMap::MemBufferType::Flash::chipsPerBus, memMapHead::firstMapEntry, cmdSequenceHead::firstSequenceEntry, memMap::MemBufferType::Flash, FLASH_ALGORITHEM_UNKNOWN, memMap::MemBufferType::Flash::infoString, memMap::memBuffer, memMap::memBufferLength, memMap::memBufferType, cmdSequence::memMap, cmdSequence::memMapNumber, MMAP_T_APPLICATION_FLASH, MMAP_T_FLASH, cmdSequenceHead::nextHead, memMap::nextMap, cmdSequence::nextSequence, memMapHead::numberOfEntrys, memMap::MemBufferType::Flash::numberOfSectors, memMap::MemBufferType::Flash::sectorList, memMap::type, memMap::MemBuffer::Word, memMapContainer::workspace, memMapContainer::xml_buf, and memMapContainer::xml_len.
Referenced by gdb_monitor_Rcmd().
int printmemMapCB_info | ( | int | currMemMapHeadCnt, | |
int | currEntryCnt, | |||
struct context * | contextSrc | |||
) |
Callback function to print memory map info at gdb's console
currMemMapHeadCnt | memMap Head counter | |
currEntryCnt | entry counter | |
contextSrc | callback context |
References memMap::MemBufferType::Flash::algo, allocateCmdCallbackEntry(), allocateGdbSprintfBuf(), memMap::baseAddr, BUFMAX, memMap::busSize, CB_ACTION_MEMMAPINFO_FAIL, CB_ACTION_MEMMAPINFO_SUCCEED, CB_ACTION_NON, memMapCBContext::curr_Map, memMapCBContext::curr_memMap, memMapCBContext::curr_secCnt, DBG_LEVEL_GDB_ARM_ERROR, dbgPrintf(), memMapHead::firstMapEntry, memMap::MemBufferType::Flash, FLASH_ALGORITHEM_AMD, FLASH_ALGORITHEM_ATMEL, FLASH_ALGORITHEM_INTEL, FLASH_ALGORITHEM_NOSUPPORT, FLASH_ALGORITHEM_PHILIPS, FLASH_ALGORITHEM_STM32, FLASH_ALGORITHEM_STR7, FLASH_ALGORITHEM_STR9, FLASH_ALGORITHEM_UNKNOWN, gdbPrintf(), memMap::MemBufferType::Flash::infoString, inQueueCmdCallbackEntry(), inQueueGdbSprintfBuf(), memMap::length, memMapCBContext::max_MapEntry_number, memMapCBContext::max_secCnt, memMap::memBufferType, memMapContainer::memStat, MMAP_T_APPLICATION_FLASH, MMAP_T_CACHE, MMAP_T_FLASH, MMAP_T_IO, MMAP_T_RAM, MMAP_T_REREAD_ROM, MMAP_T_ROM, MMAP_T_SFA, MMAP_T_UNREAL, MMAP_T_UNUSED, MMAP_T_WORKSPACE, memMapHead::nextHead, memMap::nextMap, memMapHead::numberOfEntrys, memMap::MemBufferType::Flash::numberOfSectors, memMapContainer::MemStat::pending, SECTOR_FLAG_DIRTY, SECTOR_FLAG_ERASED, SECTOR_FLAG_RW, SECTOR_INVALID, SECTOR_READ_ERASED_VALID, SECTOR_READ_VALID, SECTOR_WRITE, SECTOR_WRITE_DIRTY, SECTOR_WRITE_DIRTY_ERASED, memMap::MemBufferType::Flash::sectorList, memMapContainer::MemStat::stopTime, and memMap::type.
Referenced by gdb_monitor_Rcmd().
struct memMapContainer memMapContainer |