python-on-a-chip online compiler

Dependencies:   mbed TSI

/media/uploads/va009039/p14p-f446re.png

more info: python-on-a-chip

Committer:
va009039
Date:
Thu Apr 14 22:32:57 2016 +0000
Revision:
15:94ca5c8003e5
Parent:
0:65f1469d6bfb
update Nucleo-F401RE.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:65f1469d6bfb 1 /*
va009039 0:65f1469d6bfb 2 # This file is Copyright 2002 Dean Hall.
va009039 0:65f1469d6bfb 3 # This file is part of the PyMite VM.
va009039 0:65f1469d6bfb 4 # This file is licensed under the MIT License.
va009039 0:65f1469d6bfb 5 # See the LICENSE file for details.
va009039 0:65f1469d6bfb 6 */
va009039 0:65f1469d6bfb 7
va009039 0:65f1469d6bfb 8
va009039 0:65f1469d6bfb 9 #ifndef __MEM_H__
va009039 0:65f1469d6bfb 10 #define __MEM_H__
va009039 0:65f1469d6bfb 11
va009039 0:65f1469d6bfb 12
va009039 0:65f1469d6bfb 13 /**
va009039 0:65f1469d6bfb 14 * \file
va009039 0:65f1469d6bfb 15 * \brief VM Memory
va009039 0:65f1469d6bfb 16 *
va009039 0:65f1469d6bfb 17 * VM memory header.
va009039 0:65f1469d6bfb 18 */
va009039 0:65f1469d6bfb 19
va009039 0:65f1469d6bfb 20
va009039 0:65f1469d6bfb 21 /**
va009039 0:65f1469d6bfb 22 * Memory Space enum.
va009039 0:65f1469d6bfb 23 *
va009039 0:65f1469d6bfb 24 * Defines the different addressable areas of the system.
va009039 0:65f1469d6bfb 25 */
va009039 0:65f1469d6bfb 26 typedef enum PmMemSpace_e
va009039 0:65f1469d6bfb 27 {
va009039 0:65f1469d6bfb 28 MEMSPACE_RAM = 0,
va009039 0:65f1469d6bfb 29 MEMSPACE_PROG,
va009039 0:65f1469d6bfb 30 MEMSPACE_EEPROM,
va009039 0:65f1469d6bfb 31 MEMSPACE_SEEPROM,
va009039 0:65f1469d6bfb 32 MEMSPACE_OTHER0,
va009039 0:65f1469d6bfb 33 MEMSPACE_OTHER1,
va009039 0:65f1469d6bfb 34 MEMSPACE_OTHER2,
va009039 0:65f1469d6bfb 35 MEMSPACE_OTHER3
va009039 0:65f1469d6bfb 36 } PmMemSpace_t, *pPmMemSpace_t;
va009039 0:65f1469d6bfb 37
va009039 0:65f1469d6bfb 38
va009039 0:65f1469d6bfb 39 /**
va009039 0:65f1469d6bfb 40 * Returns the byte at the given address in memspace.
va009039 0:65f1469d6bfb 41 *
va009039 0:65f1469d6bfb 42 * Increments the address (just like getc and read(1))
va009039 0:65f1469d6bfb 43 * to make image loading work (recursive).
va009039 0:65f1469d6bfb 44 *
va009039 0:65f1469d6bfb 45 * @param memspace memory space/type
va009039 0:65f1469d6bfb 46 * @param paddr ptr to address
va009039 0:65f1469d6bfb 47 * @return byte from memory.
va009039 0:65f1469d6bfb 48 * paddr - points to the next byte
va009039 0:65f1469d6bfb 49 */
va009039 0:65f1469d6bfb 50 #define mem_getByte(memspace, paddr) plat_memGetByte((memspace), (paddr))
va009039 0:65f1469d6bfb 51
va009039 0:65f1469d6bfb 52 /**
va009039 0:65f1469d6bfb 53 * Returns the 2-byte word at the given address in memspace.
va009039 0:65f1469d6bfb 54 *
va009039 0:65f1469d6bfb 55 * Word obtained in LITTLE ENDIAN order (per Python convention).
va009039 0:65f1469d6bfb 56 * afterward, addr points one byte past the word.
va009039 0:65f1469d6bfb 57 *
va009039 0:65f1469d6bfb 58 * @param memspace memory space
va009039 0:65f1469d6bfb 59 * @param paddr ptr to address
va009039 0:65f1469d6bfb 60 * @return word from memory.
va009039 0:65f1469d6bfb 61 * addr - points one byte past the word
va009039 0:65f1469d6bfb 62 */
va009039 0:65f1469d6bfb 63 uint16_t mem_getWord(PmMemSpace_t memspace, uint8_t const **paddr);
va009039 0:65f1469d6bfb 64
va009039 0:65f1469d6bfb 65 /**
va009039 0:65f1469d6bfb 66 * Returns the 4-byte int at the given address in memspace.
va009039 0:65f1469d6bfb 67 *
va009039 0:65f1469d6bfb 68 * Int obtained in LITTLE ENDIAN order (per Python convention).
va009039 0:65f1469d6bfb 69 * afterward, addr points one byte past the int.
va009039 0:65f1469d6bfb 70 *
va009039 0:65f1469d6bfb 71 * @param memspace memory space
va009039 0:65f1469d6bfb 72 * @param paddr ptr to address
va009039 0:65f1469d6bfb 73 * @return int from memory.
va009039 0:65f1469d6bfb 74 * addr - points one byte past the word
va009039 0:65f1469d6bfb 75 */
va009039 0:65f1469d6bfb 76 uint32_t mem_getInt(PmMemSpace_t memspace, uint8_t const **paddr);
va009039 0:65f1469d6bfb 77
va009039 0:65f1469d6bfb 78 #ifdef HAVE_FLOAT
va009039 0:65f1469d6bfb 79 /**
va009039 0:65f1469d6bfb 80 * Returns the 4-byte float at the given address in memspace.
va009039 0:65f1469d6bfb 81 *
va009039 0:65f1469d6bfb 82 * Float obtained in LITTLE ENDIAN order (per Python convention).
va009039 0:65f1469d6bfb 83 * afterward, addr points one byte past the float.
va009039 0:65f1469d6bfb 84 *
va009039 0:65f1469d6bfb 85 * @param memspace memory space
va009039 0:65f1469d6bfb 86 * @param paddr ptr to address
va009039 0:65f1469d6bfb 87 * @return float from memory.
va009039 0:65f1469d6bfb 88 * addr - points one byte past the word
va009039 0:65f1469d6bfb 89 */
va009039 0:65f1469d6bfb 90 float mem_getFloat(PmMemSpace_t memspace, uint8_t const **paddr);
va009039 0:65f1469d6bfb 91 #endif /* HAVE_FLOAT */
va009039 0:65f1469d6bfb 92
va009039 0:65f1469d6bfb 93 /**
va009039 0:65f1469d6bfb 94 * Copies count number of bytes from src in memspace to dest in RAM.
va009039 0:65f1469d6bfb 95 * Leaves dest and src pointing one byte past end of the data.
va009039 0:65f1469d6bfb 96 *
va009039 0:65f1469d6bfb 97 * @param memspace memory space/type of source
va009039 0:65f1469d6bfb 98 * @param pdest ptr to destination address
va009039 0:65f1469d6bfb 99 * @param psrc ptr to source address
va009039 0:65f1469d6bfb 100 * @param count number of bytes to copy
va009039 0:65f1469d6bfb 101 * @return nothing.
va009039 0:65f1469d6bfb 102 * src, dest - point 1 past end of data
va009039 0:65f1469d6bfb 103 * @see sli_memcpy
va009039 0:65f1469d6bfb 104 */
va009039 0:65f1469d6bfb 105 void mem_copy(PmMemSpace_t memspace,
va009039 0:65f1469d6bfb 106 uint8_t **pdest, uint8_t const **psrc, uint16_t count);
va009039 0:65f1469d6bfb 107
va009039 0:65f1469d6bfb 108 /**
va009039 0:65f1469d6bfb 109 * Returns the number of bytes in the C string pointed to by pstr.
va009039 0:65f1469d6bfb 110 * Does not modify pstr
va009039 0:65f1469d6bfb 111 *
va009039 0:65f1469d6bfb 112 * @param memspace memory space/type of source
va009039 0:65f1469d6bfb 113 * @param pstr ptr to source C string
va009039 0:65f1469d6bfb 114 * @return Number of bytes in the string.
va009039 0:65f1469d6bfb 115 */
va009039 0:65f1469d6bfb 116 uint16_t mem_getStringLength(PmMemSpace_t memspace,
va009039 0:65f1469d6bfb 117 uint8_t const *const pstr);
va009039 0:65f1469d6bfb 118
va009039 0:65f1469d6bfb 119 /**
va009039 0:65f1469d6bfb 120 * Compares a byte array in RAM to a byte array in the given memory space
va009039 0:65f1469d6bfb 121 *
va009039 0:65f1469d6bfb 122 * @param cname Pointer to byte array in RAM
va009039 0:65f1469d6bfb 123 * @param cnamelen Length of byte array to compare
va009039 0:65f1469d6bfb 124 * @param memspace Memory space of other byte array
va009039 0:65f1469d6bfb 125 * @param paddr Pointer to address of other byte array
va009039 0:65f1469d6bfb 126 * @return PM_RET_OK if all bytes in both arrays match; PM_RET_NO otherwise
va009039 0:65f1469d6bfb 127 */
va009039 0:65f1469d6bfb 128 PmReturn_t mem_cmpn(uint8_t *cname, uint16_t cnamelen, PmMemSpace_t memspace,
va009039 0:65f1469d6bfb 129 uint8_t const **paddr);
va009039 0:65f1469d6bfb 130
va009039 0:65f1469d6bfb 131 #endif /* __MEM_H__ */