Norimasa Okamoto
/
pymite
python-on-a-chip online compiler
- http://pymbed.appspot.com/
- https://code.google.com/p/python-on-a-chip/
- http://www.youtube.com/watch?v=Oyqc2bFRW9I
- https://bitbucket.org/va009039/pymbed/
more info: python-on-a-chip
Diff: vm/img.h
- Revision:
- 0:65f1469d6bfb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm/img.h Sat Mar 02 11:54:20 2013 +0000 @@ -0,0 +1,75 @@ +/* +# This file is Copyright 2002 Dean Hall. +# This file is part of the PyMite VM. +# This file is licensed under the MIT License. +# See the LICENSE file for details. +*/ + + +#ifndef __IMG_H__ +#define __IMG_H__ + + +/** + * \file + * \brief Image header + * + * Created to eliminate a circular include + * among mem, string and obj. + */ + + +/** The maximum number of paths available in PmImgPaths */ +#define PM_NUM_IMG_PATHS 4 + + +typedef struct PmImgPaths_s +{ + PmMemSpace_t memspace[PM_NUM_IMG_PATHS]; + uint8_t const *pimg[PM_NUM_IMG_PATHS]; + uint8_t pathcount; +} +PmImgPaths_t, *pPmImgPaths_t; + + +/** + * Code image object + * + * A type to hold code images in the heap. + * A code image with an object descriptor at the front. + * Used for storing image objects during ipm; + * the code object keeps a reference to this object. + */ +typedef struct PmCodeImgObj_s +{ + /** Object descriptor */ + PmObjDesc_t od; + + /** Null-term? char array */ + uint8_t val[1]; +} PmCodeImgObj_t, + *pPmCodeImgObj_t; + + +/** + * Iterates over all paths in the paths array until the named module is found. + * Returns the memspace,address of the head of the module. + * + * @param pname Pointer to the name of the desired module + * @param r_memspace Return by reference the memory space of the module + * @param r_imgaddr Return by reference the address of the module's image + * @return Return status + */ +PmReturn_t img_findInPaths(pPmObj_t pname, PmMemSpace_t *r_memspace, + uint8_t const **r_imgaddr); + +/** + * Appends the given memspace and address to the image path array + * + * @param memspace The memspace + * @param paddr The address + * @return Return status + */ +PmReturn_t img_appendToPath(PmMemSpace_t memspace, uint8_t const * const paddr); + +#endif /* __IMG_H__ */