\hypertarget{memmap_8c}{
\section{memmap.c File Reference}
\label{memmap_8c}\index{memmap.c@{memmap.c}}
}
Memory Map functions.  


{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$MEM/MEM\_\-cmddefs.h$>$}\par
{\tt \#include $<$MEM/MEM\_\-map.h$>$}\par
{\tt \#include $<$MEM/MEM\_\-msgs.h$>$}\par
{\tt \#include $<$MSG/MSG\_\-pubdefs.h$>$}\par
{\tt \#include $<$mempriv.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{memmap_8c_3cd6b7e9d8bf36acee07edeb6a94c9f2}{
\#define \hyperlink{memmap_8c_3cd6b7e9d8bf36acee07edeb6a94c9f2}{DIM}(a)~(sizeof (a) / sizeof ((a)\mbox{[}0\mbox{]}))}
\label{memmap_8c_3cd6b7e9d8bf36acee07edeb6a94c9f2}

\begin{CompactList}\small\item\em Dimension of an array. \item\end{CompactList}\item 
\hypertarget{memmap_8c_fc59f6ec8c062649ae8c420372bd39a9}{
\#define \hyperlink{memmap_8c_fc59f6ec8c062649ae8c420372bd39a9}{mem\_\-NUM\_\-MEM\_\-MAP\_\-TABLE\_\-ENTRIES}~(64)}
\label{memmap_8c_fc59f6ec8c062649ae8c420372bd39a9}

\begin{CompactList}\small\item\em Maximum number of mem\_\-mapMemoryTable entries. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void $\ast$ \hyperlink{memmap_8c_50b7e1865a3bbbde7b751240a41c906e}{MEM\_\-mapRWGeneric} (void $\ast$dest\_\-p, const void $\ast$source\_\-p, const size\_\-t nbytes, void $\ast$context\_\-p, size\_\-t $\ast$bytes\_\-moved\_\-p)
\begin{CompactList}\small\item\em Generic memory access callback. \item\end{CompactList}\item 
void $\ast$ \hyperlink{memmap_8c_e14831a7c97ed0fcb0f57776c0205686}{MEM\_\-mapRead32Swap} (void $\ast$dest\_\-p, const void $\ast$source\_\-p, const size\_\-t nbytes, void $\ast$context\_\-p, size\_\-t $\ast$bytes\_\-read\_\-p)
\begin{CompactList}\small\item\em Byte-swapped 32-bit memory read callback. \item\end{CompactList}\item 
void $\ast$ \hyperlink{memmap_8c_eeae6e7f2e650f0a8444cf30842ca29f}{MEM\_\-mapWrite32Swap} (void $\ast$dest\_\-p, const void $\ast$source\_\-p, const size\_\-t nbytes, void $\ast$context\_\-p, size\_\-t $\ast$bytes\_\-written\_\-p)
\begin{CompactList}\small\item\em Byte-swapped 32-bit memory write callback. \item\end{CompactList}\item 
void $\ast$ \hyperlink{memmap_8c_6b3ac3e1263def2686ecef7cb47c3504}{MEM\_\-mapReadBuffer} (void $\ast$dest\_\-p, const void $\ast$offset, const size\_\-t nbytes, void $\ast$buf\_\-p, size\_\-t $\ast$bytes\_\-read\_\-p)
\begin{CompactList}\small\item\em Buffer read access. \item\end{CompactList}\item 
void $\ast$ \hyperlink{memmap_8c_e78f4aa811e2df438b5bd5b1af8a5dc0}{MEM\_\-mapWriteBuffer} (void $\ast$offset, const void $\ast$src\_\-p, const size\_\-t nbytes, void $\ast$buf\_\-p, size\_\-t $\ast$bytes\_\-written\_\-p)
\begin{CompactList}\small\item\em Buffer write access. \item\end{CompactList}\item 
unsigned int \hyperlink{memmap_8c_7cbd73e6cc61830e081fee011f9ae1a1}{Mem\_\-ValidateMemoryRange} (const \hyperlink{struct__MEM__Descriptor}{MEM\_\-Descriptor} $\ast$md, const \hyperlink{MEM__map_8h_2bae3ac52980771990081eae1c7106dd}{MEM\_\-mapAccessType} accessType, const \hyperlink{struct__mem__mapEntry}{mem\_\-mapEntry} $\ast$$\ast$mapEntry)
\begin{CompactList}\small\item\em Validate memory descriptor against memory map table. \item\end{CompactList}\item 
unsigned int \hyperlink{memmap_8c_e47b73abb75c3ce781831d0ac1c03ab3}{MEM\_\-mapInit} (void)
\begin{CompactList}\small\item\em Start the Memory Map system. \item\end{CompactList}\item 
unsigned int \hyperlink{memmap_8c_5dfa1ab032fc4827f970af79379df760}{MEM\_\-mapAddEntry} (const caddr\_\-t start\_\-addr, const size\_\-t num\_\-bytes, const \hyperlink{MEM__map_8h_2bae3ac52980771990081eae1c7106dd}{MEM\_\-mapAccessType} access\_\-flags, \hyperlink{MEM__map_8h_6745aa4036d4ba62fafb7f95756be0d7}{MEM\_\-mapAccessCb} $\ast$read\_\-cb, \hyperlink{MEM__map_8h_6745aa4036d4ba62fafb7f95756be0d7}{MEM\_\-mapAccessCb} $\ast$write\_\-cb, void $\ast$context\_\-p)
\begin{CompactList}\small\item\em Add an entry to the memory map table. \item\end{CompactList}\item 
unsigned int \hyperlink{memmap_8c_ed5e64b685075af835c40acdcdab2f6d}{MEM\_\-mapAddPpciEntries} (void)
\begin{CompactList}\small\item\em Add memory map table entries for the PPCI bridge chip. \item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
static \hyperlink{struct__mem__mapEntry}{mem\_\-mapEntry} \hyperlink{memmap_8c_e6fbdb18a9881e9cb20961ea8d396d4b}{mem\_\-mapMemoryTable} \mbox{[}mem\_\-NUM\_\-MEM\_\-MAP\_\-TABLE\_\-ENTRIES\mbox{]}
\begin{CompactList}\small\item\em Memory map table for 'memory' accesses. \item\end{CompactList}\item 
\hypertarget{memmap_8c_ded3bed3b6d6eab0fa236ca748b469cb}{
static unsigned char \hyperlink{memmap_8c_ded3bed3b6d6eab0fa236ca748b469cb}{mem\_\-mapFakeRegs} \mbox{[}MEM\_\-REGISTER\_\-SET\_\-BYTES\mbox{]}}
\label{memmap_8c_ded3bed3b6d6eab0fa236ca748b469cb}

\begin{CompactList}\small\item\em Buffer for simulating CPU register accesses. \item\end{CompactList}\item 
static unsigned char \hyperlink{memmap_8c_3f9b2f3dee2fe1408d8a7329ba70fc49}{mem\_\-mapFakePci} \mbox{[}65536\mbox{]}
\begin{CompactList}\small\item\em Buffer for simulating PCI device header accesses. \item\end{CompactList}\item 
static \hyperlink{struct__mem__mapEntry}{mem\_\-mapEntry} \hyperlink{memmap_8c_f0320a1cd6da8ada329fd22801a88b8b}{mem\_\-mapRegisterTable} \mbox{[}$\,$\mbox{]}
\begin{CompactList}\small\item\em Memory map table for 'register' accesses. \item\end{CompactList}\item 
static \hyperlink{struct__mem__mapEntry}{mem\_\-mapEntry} \hyperlink{memmap_8c_9fb55d2c7adc5c3950899c1464074a9f}{mem\_\-mapPciConfigTable} \mbox{[}$\,$\mbox{]}
\begin{CompactList}\small\item\em Memory map table for 'PCI Configuration' accesses. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Memory Map functions. 

These functions manipulate memory maps.



\footnotesize\begin{verbatim}
  CVS $Id: memmap.c,v 1.21 2011/03/29 01:58:53 apw Exp $
  \end{verbatim}
\normalsize
 

\subsection{Function Documentation}
\hypertarget{memmap_8c_5dfa1ab032fc4827f970af79379df760}{
\index{memmap.c@{memmap.c}!MEM\_\-mapAddEntry@{MEM\_\-mapAddEntry}}
\index{MEM\_\-mapAddEntry@{MEM\_\-mapAddEntry}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapAddEntry}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-mapAddEntry (const caddr\_\-t {\em start\_\-addr}, \/  const size\_\-t {\em num\_\-bytes}, \/  const {\bf MEM\_\-mapAccessType} {\em access\_\-flags}, \/  {\bf MEM\_\-mapAccessCb} $\ast$ {\em read\_\-cb}, \/  {\bf MEM\_\-mapAccessCb} $\ast$ {\em write\_\-cb}, \/  void $\ast$ {\em context\_\-p})}}
\label{memmap_8c_5dfa1ab032fc4827f970af79379df760}


Add an entry to the memory map table. 

Add an entry to the memory map table, which defines all the valid locations within the memory address space. Each table entry defines a contiguous region of the memory address space, including the types of accesses allowed to the region and pointers to callback functions that can be used to read and write the region.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em start\_\-addr}]Start address of region. \item[{\em num\_\-bytes}]Size of region, in bytes. \item[{\em access\_\-flags}]Bitmap of allowed accesses to the region. \item[{\em read\_\-cb}]Pointer to callback function for reading from region. \item[{\em write\_\-cb}]Pointer to callback function for writing to region. \item[{\em context\_\-p}]Generic pointer passed to callback functions.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code.\end{Desc}
Add an entry to the memory map table, which defines all the valid locations within the memory address space. Each table entry defines a contiguous region of the memory address space, including the types of accesses allowed to the region and pointers to callback functions that can be used to read and write the region.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em start\_\-addr}]Start address of region. \item[{\em num\_\-bytes}]Size of region, in bytes. \item[{\em access\_\-flags}]Bitmap of allowed accesses to the region. \item[{\em read\_\-cb}]Pointer to callback function for reading from region. \item[{\em write\_\-cb}]Pointer to callback function for writing to region. \item[{\em context\_\-p}]Generic pointer passed to callback functions.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}


References \_\-mem\_\-mapEntry::access\_\-flags, \_\-mem\_\-mapEntry::context\_\-p, DIM, MEM\_\-MAP\_\-ACCESS\_\-READ\_\-ANY, MEM\_\-MAP\_\-ACCESS\_\-WRITE\_\-ANY, MEM\_\-MSG, \_\-mem\_\-mapEntry::num\_\-bytes, \_\-mem\_\-mapEntry::read\_\-cb, \_\-mem\_\-mapEntry::start\_\-addr, \_\-mem\_\-mapEntry::valid, and \_\-mem\_\-mapEntry::write\_\-cb.

Referenced by MEM\_\-mapAddPpciEntries().\hypertarget{memmap_8c_ed5e64b685075af835c40acdcdab2f6d}{
\index{memmap.c@{memmap.c}!MEM\_\-mapAddPpciEntries@{MEM\_\-mapAddPpciEntries}}
\index{MEM\_\-mapAddPpciEntries@{MEM\_\-mapAddPpciEntries}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapAddPpciEntries}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-mapAddPpciEntries (void)}}
\label{memmap_8c_ed5e64b685075af835c40acdcdab2f6d}


Add memory map table entries for the PPCI bridge chip. 

Add memory map table entries for the registers within the powerPCI bridge chip on the RAD750 board.

\begin{Desc}
\item[Returns:]A MEM MSG code.\end{Desc}
Add memory map table entries for the registers within the powerPCI bridge chip on the RAD750 board.

\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}


References DIM, MEM\_\-MAP\_\-ACCESS\_\-32, MEM\_\-mapAddEntry(), MEM\_\-mapRead32Swap(), and MEM\_\-mapWrite32Swap().\hypertarget{memmap_8c_e47b73abb75c3ce781831d0ac1c03ab3}{
\index{memmap.c@{memmap.c}!MEM\_\-mapInit@{MEM\_\-mapInit}}
\index{MEM\_\-mapInit@{MEM\_\-mapInit}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapInit}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-mapInit (void)}}
\label{memmap_8c_e47b73abb75c3ce781831d0ac1c03ab3}


Start the Memory Map system. 

Start the Memory Map system. This function should be called once to initialize the internal state associated with the Memory Map functions.

\begin{Desc}
\item[Returns:]A MEM MSG code.\end{Desc}
Start the Memory Map system. This function should be called once to initialize the internal state associated with the Memory Map functions.

\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}


References DIM.\hypertarget{memmap_8c_e14831a7c97ed0fcb0f57776c0205686}{
\index{memmap.c@{memmap.c}!MEM\_\-mapRead32Swap@{MEM\_\-mapRead32Swap}}
\index{MEM\_\-mapRead32Swap@{MEM\_\-mapRead32Swap}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapRead32Swap}]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ MEM\_\-mapRead32Swap (void $\ast$ {\em dest\_\-p}, \/  const void $\ast$ {\em source\_\-p}, \/  const size\_\-t {\em nbytes}, \/  void $\ast$ {\em context\_\-p}, \/  size\_\-t $\ast$ {\em bytes\_\-read\_\-p})}}
\label{memmap_8c_e14831a7c97ed0fcb0f57776c0205686}


Byte-swapped 32-bit memory read callback. 

This is a callback function for reading 32-bit words that require byte swapping. Accesses must be a multiple of 32-bits and aligned on a 32-bit boundary.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the read. \item[{\em source\_\-p}]Pointer to source of the read. \item[{\em nbytes}]Number of bytes to read. \item[{\em context\_\-p}]Pointer to generic context (unused). \item[{\em bytes\_\-read\_\-p}]Pointer to location to return number of bytes read.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred.\end{Desc}
This is a callback function for reading 32-bit words that require byte swapping. Accesses must be a multiple of 32-bits and aligned on a 32-bit boundary.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the read. \item[{\em source\_\-p}]Pointer to source of the read. \item[{\em nbytes}]Number of bytes to read. \item[{\em context\_\-p}]Pointer to generic context (unused). \item[{\em bytes\_\-read\_\-p}]Pointer to location to return number of bytes read.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred. \end{Desc}


Referenced by MEM\_\-mapAddPpciEntries().\hypertarget{memmap_8c_6b3ac3e1263def2686ecef7cb47c3504}{
\index{memmap.c@{memmap.c}!MEM\_\-mapReadBuffer@{MEM\_\-mapReadBuffer}}
\index{MEM\_\-mapReadBuffer@{MEM\_\-mapReadBuffer}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapReadBuffer}]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ MEM\_\-mapReadBuffer (void $\ast$ {\em dest\_\-p}, \/  const void $\ast$ {\em offset}, \/  const size\_\-t {\em nbytes}, \/  void $\ast$ {\em buf\_\-p}, \/  size\_\-t $\ast$ {\em bytes\_\-read\_\-p})}}
\label{memmap_8c_6b3ac3e1263def2686ecef7cb47c3504}


Buffer read access. 

This is a callback function for reading values from a buffer. This would be used, for example, to read a snapshot of the CPU register values or the PCI configuration space values which have been captured in a buffer. A pointer to the beginning of this snapshot buffer must be provided as the {\em buf\_\-p\/} parameter.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the buffer read. \item[{\em offset}]Offset from {\em buf\_\-p\/} to begin reading. \item[{\em nbytes}]Number of bytes to read. \item[{\em buf\_\-p}]Pointer to start of buffer. \item[{\em bytes\_\-read\_\-p}]Pointer to location to return number of bytes read.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred.\end{Desc}
This is a callback function for reading values from a buffer. This would be used, for example, to read a snapshot of the CPU register values or the PCI configuration space values which have been captured in a buffer. A pointer to the beginning of this snapshot buffer must be provided as the {\em buf\_\-p\/} parameter.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the buffer read. \item[{\em offset}]Offset from {\em buf\_\-p\/} to begin reading. \item[{\em nbytes}]Number of bytes to read. \item[{\em buf\_\-p}]Pointer to start of buffer. \item[{\em bytes\_\-read\_\-p}]Pointer to location to return number of bytes read.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred. \end{Desc}
\hypertarget{memmap_8c_50b7e1865a3bbbde7b751240a41c906e}{
\index{memmap.c@{memmap.c}!MEM\_\-mapRWGeneric@{MEM\_\-mapRWGeneric}}
\index{MEM\_\-mapRWGeneric@{MEM\_\-mapRWGeneric}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapRWGeneric}]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ MEM\_\-mapRWGeneric (void $\ast$ {\em dest\_\-p}, \/  const void $\ast$ {\em source\_\-p}, \/  const size\_\-t {\em nbytes}, \/  void $\ast$ {\em context\_\-p}, \/  size\_\-t $\ast$ {\em bytes\_\-moved\_\-p})}}
\label{memmap_8c_50b7e1865a3bbbde7b751240a41c906e}


Generic memory access callback. 

This is a callback function for reading and writing generic memory. It is suitable for RAM or other memory that has no alignment or access restrictions.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the memory read or write. \item[{\em source\_\-p}]Pointer to source of the memory read or write. \item[{\em nbytes}]Number of bytes to read or write. \item[{\em context\_\-p}]Pointer to generic context (unused). \item[{\em bytes\_\-moved\_\-p}]Pointer to location to return number of bytes moved.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred.\end{Desc}
This is a callback function for reading and writing generic memory. It is suitable for RAM or other memory that has no alignment or access restrictions.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the memory read or write. \item[{\em source\_\-p}]Pointer to source of the memory read or write. \item[{\em nbytes}]Number of bytes to read or write. \item[{\em context\_\-p}]Pointer to generic context (unused). \item[{\em bytes\_\-moved\_\-p}]Pointer to location to return number of bytes moved.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred. \end{Desc}
\hypertarget{memmap_8c_eeae6e7f2e650f0a8444cf30842ca29f}{
\index{memmap.c@{memmap.c}!MEM\_\-mapWrite32Swap@{MEM\_\-mapWrite32Swap}}
\index{MEM\_\-mapWrite32Swap@{MEM\_\-mapWrite32Swap}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapWrite32Swap}]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ MEM\_\-mapWrite32Swap (void $\ast$ {\em dest\_\-p}, \/  const void $\ast$ {\em source\_\-p}, \/  const size\_\-t {\em nbytes}, \/  void $\ast$ {\em context\_\-p}, \/  size\_\-t $\ast$ {\em bytes\_\-written\_\-p})}}
\label{memmap_8c_eeae6e7f2e650f0a8444cf30842ca29f}


Byte-swapped 32-bit memory write callback. 

This is a callback function for writing 32-bit words that require byte swapping. Accesses must be a multiple of 32-bits and aligned on a 32-bit boundary.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the write. \item[{\em source\_\-p}]Pointer to source of the write. \item[{\em nbytes}]Number of bytes to write. \item[{\em context\_\-p}]Pointer to generic context (unused). \item[{\em bytes\_\-written\_\-p}]Pointer to location to return num bytes written.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred.\end{Desc}
This is a callback function for writing 32-bit words that require byte swapping. Accesses must be a multiple of 32-bits and aligned on a 32-bit boundary.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dest\_\-p}]Pointer to destination of the write. \item[{\em source\_\-p}]Pointer to source of the write. \item[{\em nbytes}]Number of bytes to write. \item[{\em context\_\-p}]Pointer to generic context (unused). \item[{\em bytes\_\-written\_\-p}]Pointer to location to return num bytes written.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]dest\_\-p if no error occurred, NULL if an error occurred. \end{Desc}


Referenced by MEM\_\-mapAddPpciEntries().\hypertarget{memmap_8c_e78f4aa811e2df438b5bd5b1af8a5dc0}{
\index{memmap.c@{memmap.c}!MEM\_\-mapWriteBuffer@{MEM\_\-mapWriteBuffer}}
\index{MEM\_\-mapWriteBuffer@{MEM\_\-mapWriteBuffer}!memmap.c@{memmap.c}}
\subsubsection[{MEM\_\-mapWriteBuffer}]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ MEM\_\-mapWriteBuffer (void $\ast$ {\em offset}, \/  const void $\ast$ {\em src\_\-p}, \/  const size\_\-t {\em nbytes}, \/  void $\ast$ {\em buf\_\-p}, \/  size\_\-t $\ast$ {\em bytes\_\-written\_\-p})}}
\label{memmap_8c_e78f4aa811e2df438b5bd5b1af8a5dc0}


Buffer write access. 

This is a callback function for writing values to a buffer. A pointer to the beginning of the buffer must be provided as the {\em buf\_\-p\/} parameter.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em offset}]Offset from {\em buf\_\-p\/} to begin writing. \item[{\em src\_\-p}]Pointer to source of the buffer write. \item[{\em nbytes}]Number of bytes to write. \item[{\em buf\_\-p}]Pointer to start of buffer. \item[{\em bytes\_\-written\_\-p}]Pointer to location to return num bytes written.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]offset if no error occurred, NULL if an error occurred.\end{Desc}
This is a callback function for writing values to a buffer. A pointer to the beginning of the buffer must be provided as the {\em buf\_\-p\/} parameter.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em offset}]Offset from {\em buf\_\-p\/} to begin writing. \item[{\em src\_\-p}]Pointer to source of the buffer write. \item[{\em nbytes}]Number of bytes to write. \item[{\em buf\_\-p}]Pointer to start of buffer. \item[{\em bytes\_\-written\_\-p}]Pointer to location to return num bytes written.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]offset if no error occurred, NULL if an error occurred. \end{Desc}
\hypertarget{memmap_8c_7cbd73e6cc61830e081fee011f9ae1a1}{
\index{memmap.c@{memmap.c}!Mem\_\-ValidateMemoryRange@{Mem\_\-ValidateMemoryRange}}
\index{Mem\_\-ValidateMemoryRange@{Mem\_\-ValidateMemoryRange}!memmap.c@{memmap.c}}
\subsubsection[{Mem\_\-ValidateMemoryRange}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int Mem\_\-ValidateMemoryRange (const {\bf MEM\_\-Descriptor} $\ast$ {\em md}, \/  const {\bf MEM\_\-mapAccessType} {\em accessType}, \/  const {\bf mem\_\-mapEntry} $\ast$$\ast$ {\em mapEntry})}}
\label{memmap_8c_7cbd73e6cc61830e081fee011f9ae1a1}


Validate memory descriptor against memory map table. 

This function verifies that a memory descriptor is valid for a given set of access types. Potential access types are specified in {\em accessType\/} as a bitfield. If at least one of the access types specified is legal for the memory descriptor, a handle to the appropriate memory map entry is passed back for future use. If, instead, the caller wants to know if $\ast$all$\ast$ specified access types are valid, then this function must be called once for each type.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em md}]Pointer to memory descriptor to be validated. \item[{\em accessType}]Bitfield of types of accesses to validate. \item[{\em mapEntry}]Pointer to location to return map table entry handle.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em MEM\_\-SUCCESS}]md is OK for accessType. \item[{\em MEM\_\-OUTOFRNG}]md does not fit in any memory map. \item[{\em MEM\_\-BADMAP}]md does not contain a legal memory map type. \item[{\em MEM\_\-BADACC}]accessType is not legal for md.\end{description}
\end{Desc}
This function verifies that a memory descriptor is valid for a given set of access types. Potential access types are specified in {\em accessType\/} as a bitfield. If at least one of the access types specified is legal for the memory descriptor, a handle to the appropriate memory map entry is passed back for future use. If, instead, the caller wants to know if $\ast$all$\ast$ specified access types are valid, then this function must be called once for each type.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em md}]Pointer to memory descriptor to be validated. \item[{\em accessType}]Bitfield of types of accesses to validate. \item[{\em mapEntry}]Pointer to location to return map table entry handle.\end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em MEM\_\-SUCCESS}]md is OK for accessType. \item[{\em MEM\_\-OUTOFRNG}]md does not fit in any memory map. \item[{\em MEM\_\-BADMAP}]md does not contain a legal memory map type. \item[{\em MEM\_\-BADACC}]accessType is not legal for md. \end{description}
\end{Desc}


References \_\-mem\_\-mapEntry::access\_\-flags, \_\-MEM\_\-Descriptor::addr, \_\-MEM\_\-Descriptor::bytes, DIM, MEM\_\-MAP\_\-ACCESS\_\-16, MEM\_\-MAP\_\-ACCESS\_\-8, MEM\_\-MSG, \_\-MEM\_\-Descriptor::memmap, \_\-mem\_\-mapEntry::num\_\-bytes, and \_\-mem\_\-mapEntry::start\_\-addr.

Referenced by mem\_\-loadStart(), and mem\_\-ValidateDumpDescriptor().

\subsection{Variable Documentation}
\hypertarget{memmap_8c_3f9b2f3dee2fe1408d8a7329ba70fc49}{
\index{memmap.c@{memmap.c}!mem\_\-mapFakePci@{mem\_\-mapFakePci}}
\index{mem\_\-mapFakePci@{mem\_\-mapFakePci}!memmap.c@{memmap.c}}
\subsubsection[{mem\_\-mapFakePci}]{\setlength{\rightskip}{0pt plus 5cm}{\bf mem\_\-mapFakePci}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{memmap_8c_3f9b2f3dee2fe1408d8a7329ba70fc49}


\textbf{Initial value:}

\begin{Code}\begin{verbatim}
    {
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
    }
\end{verbatim}
\end{Code}
Buffer for simulating PCI device header accesses. 

\hypertarget{memmap_8c_e6fbdb18a9881e9cb20961ea8d396d4b}{
\index{memmap.c@{memmap.c}!mem\_\-mapMemoryTable@{mem\_\-mapMemoryTable}}
\index{mem\_\-mapMemoryTable@{mem\_\-mapMemoryTable}!memmap.c@{memmap.c}}
\subsubsection[{mem\_\-mapMemoryTable}]{\setlength{\rightskip}{0pt plus 5cm}{\bf mem\_\-mapMemoryTable}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{memmap_8c_e6fbdb18a9881e9cb20961ea8d396d4b}


Memory map table for 'memory' accesses. 

Describes the memory map for MEM\_\-MEMMAP\_\-MEMORY loads and dumps. \hypertarget{memmap_8c_9fb55d2c7adc5c3950899c1464074a9f}{
\index{memmap.c@{memmap.c}!mem\_\-mapPciConfigTable@{mem\_\-mapPciConfigTable}}
\index{mem\_\-mapPciConfigTable@{mem\_\-mapPciConfigTable}!memmap.c@{memmap.c}}
\subsubsection[{mem\_\-mapPciConfigTable}]{\setlength{\rightskip}{0pt plus 5cm}{\bf mem\_\-mapPciConfigTable}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{memmap_8c_9fb55d2c7adc5c3950899c1464074a9f}


\textbf{Initial value:}

\begin{Code}\begin{verbatim} 
    {
        { 1,                        
          (void *)0x0,              
          0x10000,                  
          MEM_MAP_ACCESS_ANY,       









          MEM_mapReadBuffer,        
          MEM_mapWriteBuffer,       
          mem_mapFakePci            



        },
    }
\end{verbatim}
\end{Code}
Memory map table for 'PCI Configuration' accesses. 

Describes the memory map for MEM\_\-MEMMAP\_\-PCI\_\-CFG loads and dumps. The PCI configuration space is a 256-byte address space for each device on the PCI bus. \hypertarget{memmap_8c_f0320a1cd6da8ada329fd22801a88b8b}{
\index{memmap.c@{memmap.c}!mem\_\-mapRegisterTable@{mem\_\-mapRegisterTable}}
\index{mem\_\-mapRegisterTable@{mem\_\-mapRegisterTable}!memmap.c@{memmap.c}}
\subsubsection[{mem\_\-mapRegisterTable}]{\setlength{\rightskip}{0pt plus 5cm}{\bf mem\_\-mapRegisterTable}\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{memmap_8c_f0320a1cd6da8ada329fd22801a88b8b}


\textbf{Initial value:}

\begin{Code}\begin{verbatim} 
    {
        { 1,                        
          (void *)0x0,              
          MEM_REGISTER_SET_BYTES,   
          MEM_MAP_ACCESS_ANY,       









          MEM_mapReadBuffer,        
          MEM_mapWriteBuffer,       
          mem_mapFakeRegs           



        },
    }
\end{verbatim}
\end{Code}
Memory map table for 'register' accesses. 

Describes the memory map for MEM\_\-MEMMAP\_\-REGISTER loads and dumps. 