Ignore:
Timestamp:
12/26/11 01:24:43 (17 months ago)
Author:
reyalp
Message:

merge tsvstar module code from reyalp-flt branch, + fixups for r1499, see http://chdk.setepontos.com/index.php?topic=847.msg77690#msg77690 and following posts
NOTE modules in CHDK/MODULES are now required for CHDK to work properly. On multi-partition cards, this goes on the large card.
Adds tetris and snake, originally contributed by elektro255 in http://chdk.setepontos.com/index.php?topic=2925.0

Location:
trunk
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/elf2flt/elfflt.c

    r1467 r1505  
    44 *  Target is modified BINARY FLAT 
    55 * 
    6  *      (c)2011 Sergey Taranenko aka @tsv 
     6 *      (c)2011 Sergey Taranenko aka tsvstar 
    77 * 
    88 */ 
     
    270270    printf("%s 0x%x (%s+0x%x)\n",prefix, offs,sect,offs-secoffs); 
    271271} 
     272 
     273 
     274char* get_flat_string( int32_t offs ) 
     275{ 
     276   static char buf[200]; 
     277 
     278    if  ( offs <0 ) 
     279        { 
     280                sprintf(buf," LANGID %d",-offs); 
     281                return buf; 
     282        } 
     283 
     284    if  ( offs >flat->data_end || offs<=flat->data_start ) 
     285          return ""; 
     286 
     287        strncpy( buf, flat_buf+offs, sizeof(buf)-1); 
     288        buf[sizeof(buf)-1]=0; 
     289        return buf; 
     290} 
     291 
    272292 
    273293// Aligning up to int32 bound 
     
    623643          printf(">>elf2flt: lookup entry symbols\n"); 
    624644  flat->_module_loader = find_symbol_inflat("_module_loader", &text ); 
    625 /*  if ( flat->_module_loader <=0 ) { 
    626     PRINTF("No or invalid section of _module_loader(). It have to be exist as executable function.\n"); 
    627     return ELFFLT_NO_STARTPOINT; 
    628   }*/ 
    629645  flat->_module_unloader = find_symbol_inflat("_module_unloader", &text ); 
    630646  flat->_module_run = find_symbol_inflat("_module_run", &text ); 
    631647  flat->_module_exportlist = find_symbol_inflat("MODULE_EXPORT_LIST", 0 ); 
    632648 
    633   flat->chdk_min_version =0; 
    634   flat->chdk_req_platfid =0; 
    635  
    636   int ptr = find_symbol_inflat("_chdk_required_ver", 0 ); 
    637   if ( ptr > 0 ) 
    638     flat->chdk_min_version = *(uint32_t*)(flat_buf+ptr); 
    639  
    640   ptr = find_symbol_inflat("_chdk_required_platfid", 0 ); 
    641   if ( ptr > 0 ) 
    642     flat->chdk_req_platfid = *(uint32_t*)(flat_buf+ptr); 
     649  // 
     650  flat->_module_info = find_symbol_inflat("_module_info", &data ); 
     651  if ( flat->_module_info <=0 ) { 
     652    PRINTERR(stderr, "No or invalid section of _module_info. This symbol should be initialized as ModuleInfo structure.\n"); 
     653    return ELFFLT_NO_MODULEINFO; 
     654  } 
     655 
     656  struct ModuleInfo* _module_info = (struct ModuleInfo*) (flat_buf + flat->_module_info); 
     657  if ( _module_info->magicnum != MODULEINFO_V1_MAGICNUM )  
     658  { 
     659    PRINTERR(stderr, "Wrong _module_info->magicnum value. Please check correct filling of this structure\n"); 
     660    return ELFFLT_NO_MODULEINFO; 
     661  } 
     662  if ( _module_info->sizeof_struct != sizeof(struct ModuleInfo) )  
     663  { 
     664    PRINTERR(stderr, "Wrong _module_info->sizeof_struct value. Please check correct filling of this structure\n"); 
     665    return ELFFLT_NO_MODULEINFO; 
     666  } 
    643667 
    644668  if ( FLAG_DUMP_FLT_HEADERS ) { 
     
    650674        printf("->reloc_start  0x%x (size %d)\n", flat->reloc_start, flat->reloc_count*4 ); 
    651675        printf("->import_start 0x%x (size %d)\n", flat->import_start, flat->import_count*4 ); 
    652         printf("->chdk_min_ver 0x%x\n", flat->chdk_min_version); 
    653         printf("->chdk_platfid 0x%x\n", flat->chdk_req_platfid); 
    654676 
    655677        print_offs("\n.._module_loader()   =", flat->_module_loader); 
     
    657679        print_offs(".._module_run()      = ", flat->_module_run); 
    658680        print_offs("..MODULE_EXPORT_LIST = ", flat->_module_exportlist); 
     681 
     682        printf("\nModule info:\n"); 
     683        printf("->Module Name: %s\n", get_flat_string(_module_info->moduleName) ); 
     684        printf("->Module Ver: %d.%d\n", _module_info->major_ver, _module_info->minor_ver ); 
     685 
     686        char* branches_str[] = {"any branch","CHDK", "CHDK_DE", "CHDK_SDM", "PRIVATEBUILD"}; 
     687        int branch = (_module_info->chdk_required_branch>REQUIRE_CHDK_PRIVATEBUILD) ?  
     688                                                REQUIRE_CHDK_PRIVATEBUILD : _module_info->chdk_required_branch; 
     689        printf("->Require: %s-build%d. ", branches_str[branch], _module_info->chdk_required_ver ); 
     690        if ( _module_info->chdk_required_platfid == 0 ) 
     691                printf("Any platform.\n"); 
     692        else 
     693                printf(" Platform #%d only.\n", _module_info->chdk_required_platfid ); 
     694        if ( _module_info->flags ) { 
     695                printf("->Flags:"); 
     696                if ( _module_info->flags & MODULEINFO_FLAG_SYSTEM ) 
     697                        printf(" SYSTEM "); 
     698            printf("\n"); 
     699        } 
     700        printf("->Module Info: %s\n", get_flat_string(_module_info->description) ); 
    659701  } 
    660702 
Note: See TracChangeset for help on using the changeset viewer.