pm.h

Go to the documentation of this file.
00001 /*
00002 # This file is Copyright 2006, 2007, 2009, 2010 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 1
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) return (retval)
00089 
00091 #define PM_REPORT_IF_ERROR(retval)   if ((retval) != PM_RET_OK) \
00092                                         plat_reportError(retval)
00093 
00095 #define PM_GOTO_IF_ERROR(retval, target) if ((retval) != PM_RET_OK) \
00096                                             goto target
00097 
00098 #if __DEBUG__
00099 
00100 #define C_ASSERT(boolexpr) \
00101     do \
00102     { \
00103         if (!((boolexpr))) \
00104         { \
00105             gVmGlobal.errFileId = __FILE_ID__; \
00106             gVmGlobal.errLineNum = (uint16_t)__LINE__; \
00107             return PM_RET_ASSERT_FAIL; \
00108         } \
00109     } \
00110     while (0)
00111 
00112 #else
00113 
00114 #define C_ASSERT(boolexpr)
00115 #endif
00116 
00118 #define VERBOSITY_LOW 1
00119 
00121 #define VERBOSITY_MEDIUM 2
00122 
00124 #define VERBOSITY_HIGH 3
00125 
00126 #if __DEBUG__
00127 
00129 #define VERBOSITY_OFF 0
00130 
00132 #define DEBUG_PRINT_VERBOSITY VERBOSITY_OFF
00133 
00135 #define C_DEBUG_PRINT(v, f, ...) \
00136     do \
00137     { \
00138         if (DEBUG_PRINT_VERBOSITY >= (v)) \
00139         { \
00140             printf("PM_DEBUG: " f, ## __VA_ARGS__); \
00141         } \
00142     } \
00143     while (0)
00144 
00145 #else
00146 #define C_DEBUG_PRINT(...)
00147 #endif
00148 
00149 
00157 typedef enum PmReturn_e
00158 {
00159     /* general status return values */
00160     PM_RET_OK = 0,              
00161     PM_RET_NO = 0xFF,           
00162     PM_RET_ERR = 0xFE,          
00163     PM_RET_STUB = 0xFD,         
00164     PM_RET_ASSERT_FAIL = 0xFC,  
00165     PM_RET_FRAME_SWITCH = 0xFB, 
00167     /* return vals that indicate an exception occured */
00168     PM_RET_EX = 0xE0,           
00169     PM_RET_EX_EXIT = 0xE1,      
00170     PM_RET_EX_IO = 0xE2,        
00171     PM_RET_EX_ZDIV = 0xE3,      
00172     PM_RET_EX_ASSRT = 0xE4,     
00173     PM_RET_EX_ATTR = 0xE5,      
00174     PM_RET_EX_IMPRT = 0xE6,     
00175     PM_RET_EX_INDX = 0xE7,      
00176     PM_RET_EX_KEY = 0xE8,       
00177     PM_RET_EX_MEM = 0xE9,       
00178     PM_RET_EX_NAME = 0xEA,      
00179     PM_RET_EX_SYNTAX = 0xEB,    
00180     PM_RET_EX_SYS = 0xEC,       
00181     PM_RET_EX_TYPE = 0xED,      
00182     PM_RET_EX_VAL = 0xEE,       
00183     PM_RET_EX_STOP = 0xEF,      
00184     PM_RET_EX_WARN = 0xF0,      
00185 } PmReturn_t;
00186 
00187 
00188 extern volatile uint32_t pm_timerMsTicks;
00189 
00190 
00191 /* WARNING: The order of the following includes is critical */
00192 #include "plat.h"
00193 #include "pmfeatures.h"
00194 #include "pmEmptyPlatformDefs.h"
00195 #include "sli.h"
00196 #include "mem.h"
00197 #include "obj.h"
00198 #include "seq.h"
00199 #include "tuple.h"
00200 #include "strobj.h"
00201 #include "heap.h"
00202 #include "int.h"
00203 #include "seglist.h"
00204 #include "list.h"
00205 #include "dict.h"
00206 #include "codeobj.h"
00207 #include "func.h"
00208 #include "module.h"
00209 #include "frame.h"
00210 #include "interp.h"
00211 #include "img.h"
00212 #include "global.h"
00213 #include "class.h"
00214 #include "thread.h"
00215 #include "float.h"
00216 #include "plat_interface.h"
00217 #include "bytearray.h"
00218 
00219 
00221 typedef PmReturn_t (* pPmNativeFxn_t)(pPmFrame_t *);
00222 extern pPmNativeFxn_t const std_nat_fxn_table[];
00223 extern pPmNativeFxn_t const usr_nat_fxn_table[];
00224 
00225 
00235 PmReturn_t pm_init(PmMemSpace_t memspace, uint8_t const * const pusrimg);
00236 
00243 PmReturn_t pm_run(uint8_t const *modstr);
00244 
00255 PmReturn_t pm_vmPeriodic(uint16_t usecsSinceLastCall);
00256 
00257 #ifdef __cplusplus
00258 }
00259 #endif
00260 
00261 #endif /* __PM_H__ */

Generated on Mon Oct 18 07:40:48 2010 for Python-on-a-chip by  doxygen 1.5.9