Changeset 1178
- Timestamp:
- 05/08/11 23:32:48 (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
core/luascript.c (modified) (4 diffs)
-
platform/a590/platform_camera.h (modified) (1 diff)
-
platform/sx20/platform_camera.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/luascript.c
r1155 r1178 1076 1076 } 1077 1077 1078 static void set_number_field(lua_State* L, const char *key, int val) 1079 { 1080 lua_pushnumber(L, val); 1081 lua_setfield(L, -2, key); 1082 } 1083 1078 1084 static int luaCB_get_buildinfo( lua_State* L ) 1079 1085 { … … 1090 1096 set_string_field( L,"os", "dryos" ); 1091 1097 #endif 1092 lua_pushnumber( L, PLATFORMID ); 1093 lua_setfield(L, -2, "platformid"); 1098 set_number_field( L, "platformid", PLATFORMID ); 1094 1099 return 1; 1095 1100 } … … 1579 1584 } 1580 1585 #endif 1586 1587 /* helper for meminfo to set table field only if valid */ 1588 static void set_meminfo_num( lua_State* L,const char *name, int val) { 1589 if(val != -1) { 1590 set_number_field( L, name, val ); 1591 } 1592 } 1593 /* 1594 meminfo=get_meminfo([heapname]) 1595 get camera memory information 1596 heapname="system" or "exmem" if not given, meminfo is returned for heap used by CHDK for malloc 1597 meminfo is false if the requested heapname isn't valid ("exmem" when exmem is not enabled, or unknown) 1598 otherwise, a table of the form 1599 meminfo = { 1600 name -- string "system" or "exmem" 1601 chdk_malloc -- bool, this is the heap used by CHDK for malloc 1602 chdk_start -- number, load address of CHDK 1603 chdk_size -- number, size of CHDK image 1604 -- all the following are numbers, will not be set if not available 1605 start_address 1606 end_address 1607 total_size 1608 allocated_size 1609 allocated_peak 1610 allocated_count 1611 free_size 1612 free_block_max_size 1613 free_block_count 1614 } 1615 NOTES 1616 * under vxworks and cameras without GetMemInfo only the only valid fields 1617 for the system heap will be those defined by chdk and free_block_max_size 1618 * the meaning of fields may not correspond exactly between exmem and system 1619 */ 1620 static int luaCB_get_meminfo( lua_State* L ) { 1621 // for memory info, duplicated from lowlevel 1622 extern const char _start,_end; 1623 1624 #if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) 1625 const char *default_heapname="exmem"; 1626 #else 1627 const char *default_heapname="system"; 1628 #endif 1629 const char *heapname = luaL_optstring( L, 1, default_heapname ); 1630 cam_meminfo meminfo; 1631 1632 if(strcmp(heapname,"system") == 0) { 1633 #if defined(CAM_FIRMWARE_MEMINFO) 1634 GetMemInfo(&meminfo); 1635 #else 1636 memset(&meminfo,0xFF,sizeof(cam_meminfo)); 1637 meminfo.free_block_max_size = core_get_free_memory(); 1638 #endif 1639 } 1640 #if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) 1641 else if(strcmp(heapname,"exmem") == 0) { 1642 GetExMemInfo(&meminfo); 1643 meminfo.allocated_count = -1; // not implemented in suba 1644 } 1645 #endif 1646 else { 1647 lua_pushboolean(L,0); 1648 return 1; 1649 } 1650 // adjust start and size, if CHDK is loaded at heap start 1651 if(meminfo.start_address == (int)(&_start)) { 1652 meminfo.start_address += MEMISOSIZE; 1653 meminfo.total_size -= MEMISOSIZE; 1654 } 1655 lua_createtable(L, 0, 13); // might not always use 13, but doesn't hurt 1656 set_string_field( L,"name", heapname ); 1657 lua_pushboolean( L, (strcmp(heapname,default_heapname)==0)); 1658 lua_setfield(L, -2, "chdk_malloc"); 1659 set_number_field( L, "chdk_start", (int)(&_start) ); 1660 set_number_field( L, "chdk_size", MEMISOSIZE ); 1661 set_meminfo_num( L, "start_address", meminfo.start_address ); 1662 set_meminfo_num( L, "end_address", meminfo.end_address); 1663 set_meminfo_num( L, "total_size", meminfo.total_size); 1664 set_meminfo_num( L, "allocated_size", meminfo.allocated_size); 1665 set_meminfo_num( L, "allocated_peak", meminfo.allocated_peak); 1666 set_meminfo_num( L, "allocated_count", meminfo.allocated_count); 1667 set_meminfo_num( L, "free_size", meminfo.free_size); 1668 set_meminfo_num( L, "free_block_max_size", meminfo.free_block_max_size); 1669 set_meminfo_num( L, "free_block_count", meminfo.free_block_count); 1670 return 1; 1671 } 1581 1672 1582 1673 void register_lua_funcs( lua_State* L ) … … 1772 1863 1773 1864 #endif 1774 } 1865 FUNC(get_meminfo); 1866 } -
trunk/platform/a590/platform_camera.h
r1147 r1178 66 66 #define CAM_MULTIPART 1 67 67 #define CAM_STARTUP_CRASH_FILE_OPEN_FIX 1 68 69 #define CAM_FIRMWARE_MEMINFO 1 // Use 'GetMemInfo' to get free memory size. 70 68 71 //---------------------------------------------------------- 69 72 -
trunk/platform/sx20/platform_camera.h
r1146 r1178 120 120 // see http://chdk.setepontos.com/index.php?topic=6179.0 121 121 122 #define CAM_FIRMWARE_MEMINFO 1 // Use 'GetMemInfo' to get free memory size. 122 123 //---------------------------------------------------------- 123 124
Note: See TracChangeset
for help on using the changeset viewer.