ipm.py
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 def _getImg():
00025 """__NATIVE__
00026 PmReturn_t retval;
00027 uint8_t imgType;
00028 uint16_t imgSize;
00029 uint8_t *pchunk;
00030 pPmCodeImgObj_t pimg;
00031 uint16_t i;
00032 uint8_t b;
00033
00034 /* Get the image type */
00035 retval = plat_getByte(&imgType);
00036 PM_RETURN_IF_ERROR(retval);
00037
00038 /* Quit if a code image type was not received */
00039 if (imgType != OBJ_TYPE_CIM)
00040 {
00041 PM_RAISE(retval, PM_RET_EX_STOP);
00042 return retval;
00043 }
00044
00045 /* Get the image size (little endien) */
00046 retval = plat_getByte(&b);
00047 PM_RETURN_IF_ERROR(retval);
00048 imgSize = b;
00049 retval = plat_getByte(&b);
00050 PM_RETURN_IF_ERROR(retval);
00051 imgSize |= (b << 8);
00052
00053 /* Get space for CodeImgObj */
00054 retval = heap_getChunk(sizeof(PmCodeImgObj_t) + imgSize, &pchunk);
00055 PM_RETURN_IF_ERROR(retval);
00056 pimg = (pPmCodeImgObj_t)pchunk;
00057 OBJ_SET_TYPE(pimg, OBJ_TYPE_CIO);
00058
00059 /* Start the image with the bytes that have already been received */
00060 i = 0;
00061 pimg->val[i++] = imgType;
00062 pimg->val[i++] = imgSize & 0xFF;
00063 pimg->val[i++] = (imgSize >> 8) & 0xFF;
00064
00065 /* Get the remaining bytes in the image */
00066 for(; i < imgSize; i++)
00067 {
00068 retval = plat_getByte(&b);
00069 PM_RETURN_IF_ERROR(retval);
00070
00071 pimg->val[i] = b;
00072 }
00073
00074 /* Return the image as a code image object on the stack */
00075 NATIVE_SET_TOS((pPmObj_t)pimg);
00076 return retval;
00077 """
00078 pass
00079
00080
00081 def x04():
00082 """__NATIVE__
00083 NATIVE_SET_TOS(PM_NONE);
00084 return plat_putByte(0x04);
00085 """
00086 pass
00087
00088
00089
00090
00091
00092 def ipm(g={}):
00093 while 1:
00094
00095
00096
00097 s = _getImg()
00098 co = Co(s)
00099 rv = eval(co, g)
00100 x04()
00101
00102
00103
00104 assert False
00105
00106