pm.h

Go to the documentation of this file.
00001 /*
00002 # This file is Copyright 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 __PM_H__
00017 #define __PM_H__
00018 
00019 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #include <stdint.h>
00033 #include <stdio.h>
00034 
00035 
00043 #define PM_RELEASE 8
00044 
00045 
00047 #define C_NULL 0
00048 
00050 #define C_FALSE 0
00051 
00053 #define C_TRUE (!C_FALSE)
00054 
00056 #define C_SAME (int8_t)0
00057 
00059 #define C_DIFFER (int8_t)-1
00060 
00062 #define INLINE __inline__
00063 
00064 
00071 #if __DEBUG__
00072 #define PM_RAISE(retexn, exn) \
00073         do \
00074         { \
00075             retexn = (exn); \
00076             gVmGlobal.errFileId = __FILE_ID__; \
00077             gVmGlobal.errLineNum = (uint16_t)__LINE__; \
00078         } while (0)
00079 #else
00080 #define PM_RAISE(retexn, exn) \
00081         retexn = (exn)
00082 #endif
00083 
00085 #define PM_BREAK_IF_ERROR(retval) if((retval) != PM_RET_OK)break
00086 
00088 #define PM_RETURN_IF_ERROR(retval)  if((retval) != PM_RET_OK) \
00089                                         return (retval)
00090 
00092 #define PM_REPORT_IF_ERROR(retval)   if ((retval) != PM_RET_OK) \
00093                                         plat_reportError(retval)
00094 
00095 #if __DEBUG__
00096 
00097 #define C_ASSERT(boolexpr) \
00098     do \
00099     { \
00100         if (!((boolexpr))) \
00101         { \
00102             gVmGlobal.errFileId = __FILE_ID__; \
00103             gVmGlobal.errLineNum = (uint16_t)__LINE__; \
00104             return PM_RET_ASSERT_FAIL; \
00105         } \
00106     } \
00107     while (0)
00108 
00109 #else
00110 
00111 #define C_ASSERT(boolexpr)
00112 #endif
00113 
00115 #define VERBOSITY_LOW 1
00116 
00118 #define VERBOSITY_MEDIUM 2
00119 
00121 #define VERBOSITY_HIGH 3
00122 
00123 #if __DEBUG__
00124 
00126 #define VERBOSITY_OFF 0
00127 
00129 #define DEBUG_PRINT_VERBOSITY VERBOSITY_OFF
00130 
00132 #define C_DEBUG_PRINT(v, f, ...) \
00133     do \
00134     { \
00135         if (DEBUG_PRINT_VERBOSITY >= (v)) \
00136         { \
00137             printf("PM_DEBUG: " f, ## __VA_ARGS__); \
00138         } \
00139     } \
00140     while (0)
00141 
00142 #else
00143 #define C_DEBUG_PRINT(...)
00144 #endif
00145 
00146 
00154 typedef enum PmReturn_e
00155 {
00156     /* general status return values */
00157     PM_RET_OK = 0,              
00158     PM_RET_NO = 0xFF,           
00159     PM_RET_ERR = 0xFE,          
00160     PM_RET_STUB = 0xFD,         
00161     PM_RET_ASSERT_FAIL = 0xFC,  
00162     PM_RET_FRAME_SWITCH = 0xFB, 
00164     /* return vals that indicate an exception occured */
00165     PM_RET_EX = 0xE0,           
00166     PM_RET_EX_EXIT = 0xE1,      
00167     PM_RET_EX_IO = 0xE2,        
00168     PM_RET_EX_ZDIV = 0xE3,      
00169     PM_RET_EX_ASSRT = 0xE4,     
00170     PM_RET_EX_ATTR = 0xE5,      
00171     PM_RET_EX_IMPRT = 0xE6,     
00172     PM_RET_EX_INDX = 0xE7,      
00173     PM_RET_EX_KEY = 0xE8,       
00174     PM_RET_EX_MEM = 0xE9,       
00175     PM_RET_EX_NAME = 0xEA,      
00176     PM_RET_EX_SYNTAX = 0xEB,    
00177     PM_RET_EX_SYS = 0xEC,       
00178     PM_RET_EX_TYPE = 0xED,      
00179     PM_RET_EX_VAL = 0xEE,       
00180     PM_RET_EX_STOP = 0xEF,      
00181     PM_RET_EX_WARN = 0xF0,      
00182 } PmReturn_t;
00183 
00184 
00185 extern volatile uint32_t pm_timerMsTicks;
00186 
00187 
00188 /* WARNING: The order of the following includes is critical */
00189 #include "pmfeatures.h"
00190 #include "sli.h"
00191 #include "mem.h"
00192 #include "obj.h"
00193 #include "seq.h"
00194 #include "tuple.h"
00195 #include "strobj.h"
00196 #include "heap.h"
00197 #include "int.h"
00198 #include "seglist.h"
00199 #include "list.h"
00200 #include "dict.h"
00201 #include "codeobj.h"
00202 #include "func.h"
00203 #include "module.h"
00204 #include "frame.h"
00205 #include "interp.h"
00206 #include "img.h"
00207 #include "global.h"
00208 #include "class.h"
00209 #include "thread.h"
00210 #include "float.h"
00211 #include "plat.h"
00212 
00213 
00223 PmReturn_t pm_init(PmMemSpace_t memspace, uint8_t *pusrimg);
00224 
00231 PmReturn_t pm_run(uint8_t const *modstr);
00232 
00243 PmReturn_t pm_vmPeriodic(uint16_t usecsSinceLastCall);
00244 
00245 #endif /* __PM_H__ */
00246 
00247 
00248 #ifdef __cplusplus
00249 }
00250 #endif

Generated on Wed Feb 24 13:37:02 2010 for Python-on-a-chip by  doxygen 1.5.9