arm_memory_mmap.c File Reference

#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"

Defines

Functions

Variables


Detailed Description

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 Documentation

#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().


Function Documentation

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.

Parameters:
total_number_of_MemMaps request a maximum number of MAP's (memMapHeads)
Return values:
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

Parameters:
num number of map
Return values:
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.

Parameters:
total_num request a maximum number of memMap entries
mh pointer to head of MAP
Return values:
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

Parameters:
num entry number of memMap
mh pointer to head of MAP
Return values:
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.

Parameters:
addr address
Returns:
pointer to memMap entry or NULL

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 
)
static int detectFlash ( struct memMap m  )  [static]
static int defaultFlash ( struct memMap m  )  [static]
int activateMemMap ( int  num  ) 

activate the previous configured memMap[num]

Parameters:
num number of memMap to activate
Return values:
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   ) 
int printmemMapCB_info ( int  currMemMapHeadCnt,
int  currEntryCnt,
struct context *  contextSrc 
)

Callback function to print memory map info at gdb's console

Parameters:
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().


Variable Documentation


This file is part of the documentation for JTAG-GDB Server for ARM .

Generated on Mon Feb 15 21:23:21 2010 by doxygen 1.6.2.