Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mem.h
00001 /* 00002 # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 00003 # 00004 # This file is part of the PyMite VM. 00005 # The PyMite VM is free software: you can redistribute it and/or modify 00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. 00007 # 00008 # The PyMite VM is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2 00012 # is seen in the file COPYING in this directory. 00013 */ 00014 00015 00016 #ifndef __MEM_H__ 00017 #define __MEM_H__ 00018 00019 00020 /** 00021 * \file 00022 * \brief VM Memory 00023 * 00024 * VM memory header. 00025 */ 00026 00027 00028 /** 00029 * Memory Space enum. 00030 * 00031 * Defines the different addressable areas of the system. 00032 */ 00033 typedef enum PmMemSpace_e 00034 { 00035 MEMSPACE_RAM = 0, 00036 MEMSPACE_PROG, 00037 MEMSPACE_EEPROM, 00038 MEMSPACE_SEEPROM, 00039 MEMSPACE_OTHER0, 00040 MEMSPACE_OTHER1, 00041 MEMSPACE_OTHER2, 00042 MEMSPACE_OTHER3 00043 } PmMemSpace_t, *pPmMemSpace_t; 00044 00045 00046 /** 00047 * Returns the byte at the given address in memspace. 00048 * 00049 * Increments the address (just like getc and read(1)) 00050 * to make image loading work (recursive). 00051 * 00052 * @param memspace memory space/type 00053 * @param paddr ptr to address 00054 * @return byte from memory. 00055 * paddr - points to the next byte 00056 */ 00057 #define mem_getByte(memspace, paddr) plat_memGetByte((memspace), (paddr)) 00058 00059 /** 00060 * Returns the 2-byte word at the given address in memspace. 00061 * 00062 * Word obtained in LITTLE ENDIAN order (per Python convention). 00063 * afterward, addr points one byte past the word. 00064 * 00065 * @param memspace memory space 00066 * @param paddr ptr to address 00067 * @return word from memory. 00068 * addr - points one byte past the word 00069 */ 00070 uint16_t mem_getWord(PmMemSpace_t memspace, uint8_t const **paddr); 00071 00072 /** 00073 * Returns the 4-byte int at the given address in memspace. 00074 * 00075 * Int obtained in LITTLE ENDIAN order (per Python convention). 00076 * afterward, addr points one byte past the int. 00077 * 00078 * @param memspace memory space 00079 * @param paddr ptr to address 00080 * @return int from memory. 00081 * addr - points one byte past the word 00082 */ 00083 uint32_t mem_getInt(PmMemSpace_t memspace, uint8_t const **paddr); 00084 00085 #ifdef HAVE_FLOAT 00086 /** 00087 * Returns the 4-byte float at the given address in memspace. 00088 * 00089 * Float obtained in LITTLE ENDIAN order (per Python convention). 00090 * afterward, addr points one byte past the float. 00091 * 00092 * @param memspace memory space 00093 * @param paddr ptr to address 00094 * @return float from memory. 00095 * addr - points one byte past the word 00096 */ 00097 float mem_getFloat(PmMemSpace_t memspace, uint8_t const **paddr); 00098 #endif /* HAVE_FLOAT */ 00099 00100 /** 00101 * Copies count number of bytes from src in memspace to dest in RAM. 00102 * Leaves dest and src pointing one byte past end of the data. 00103 * 00104 * @param memspace memory space/type of source 00105 * @param pdest ptr to destination address 00106 * @param psrc ptr to source address 00107 * @param count number of bytes to copy 00108 * @return nothing. 00109 * src, dest - point 1 past end of data 00110 * @see sli_memcpy 00111 */ 00112 void mem_copy(PmMemSpace_t memspace, 00113 uint8_t **pdest, uint8_t const **psrc, uint16_t count); 00114 00115 /** 00116 * Returns the number of bytes in the C string pointed to by pstr. 00117 * Does not modify pstr 00118 * 00119 * @param memspace memory space/type of source 00120 * @param pstr ptr to source C string 00121 * @return Number of bytes in the string. 00122 */ 00123 uint16_t mem_getStringLength(PmMemSpace_t memspace, 00124 uint8_t const *const pstr); 00125 00126 /** 00127 * Compares a byte array in RAM to a byte array in the given memory space 00128 * 00129 * @param cname Pointer to byte array in RAM 00130 * @param cnamelen Length of byte array to compare 00131 * @param memspace Memory space of other byte array 00132 * @param paddr Pointer to address of other byte array 00133 * @return PM_RET_OK if all bytes in both arrays match; PM_RET_NO otherwise 00134 */ 00135 PmReturn_t mem_cmpn(uint8_t *cname, uint8_t cnamelen, PmMemSpace_t memspace, 00136 uint8_t const **paddr); 00137 00138 #endif /* __MEM_H__ */
Generated on Tue Jul 12 2022 17:07:01 by
1.7.2