Changeset 0f81ceb7 in mainline for kernel/generic/src/console/cmd.c


Ignore:
Timestamp:
2009-02-12T20:03:07Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
95b9963
Parents:
8a72a9a
Message:

remove platform dependent constructs from generic code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    r8a72a9a r0f81ceb7  
    617617        uintptr_t symaddr;
    618618        char *symbol;
    619         unative_t (*f)(void);
    620 #ifdef ia64
    621         struct {
    622                 unative_t f;
    623                 unative_t gp;
    624         } fptr;
    625 #endif
    626 
     619        unative_t (*fnc)(void);
     620        fncptr_t fptr;
     621       
    627622        symaddr = get_symbol_addr((char *) argv->buffer);
    628623        if (!symaddr)
     
    633628        } else {
    634629                symbol = get_symtab_entry(symaddr);
     630                fnc = (unative_t (*)(void)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call0);
    635631                printf("Calling %s() (%p)\n", symbol, symaddr);
    636 #ifdef ia64
    637                 fptr.f = symaddr;
    638                 fptr.gp = ((unative_t *)cmd_call2)[1];
    639                 f =  (unative_t (*)(void)) &fptr;
    640 #else
    641                 f =  (unative_t (*)(void)) symaddr;
    642 #endif
    643                 printf("Result: %#" PRIxn "\n", f());
     632                printf("Result: %#" PRIxn "\n", fnc());
    644633        }
    645634       
     
    681670        uintptr_t symaddr;
    682671        char *symbol;
    683         unative_t (*f)(unative_t,...);
     672        unative_t (*fnc)(unative_t, ...);
    684673        unative_t arg1 = argv[1].intval;
    685 #ifdef ia64
    686         struct {
    687                 unative_t f;
    688                 unative_t gp;
    689         } fptr;
    690 #endif
    691 
     674        fncptr_t fptr;
     675       
    692676        symaddr = get_symbol_addr((char *) argv->buffer);
    693677        if (!symaddr)
     
    698682        } else {
    699683                symbol = get_symtab_entry(symaddr);
    700 
     684                fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1);
    701685                printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol);
    702 #ifdef ia64
    703                 fptr.f = symaddr;
    704                 fptr.gp = ((unative_t *)cmd_call2)[1];
    705                 f =  (unative_t (*)(unative_t,...)) &fptr;
    706 #else
    707                 f =  (unative_t (*)(unative_t,...)) symaddr;
    708 #endif
    709                 printf("Result: %#" PRIxn "\n", f(arg1));
     686                printf("Result: %#" PRIxn "\n", fnc(arg1));
    710687        }
    711688       
     
    718695        uintptr_t symaddr;
    719696        char *symbol;
    720         unative_t (*f)(unative_t,unative_t,...);
     697        unative_t (*fnc)(unative_t, unative_t, ...);
    721698        unative_t arg1 = argv[1].intval;
    722699        unative_t arg2 = argv[2].intval;
    723 #ifdef ia64
    724         struct {
    725                 unative_t f;
    726                 unative_t gp;
    727         }fptr;
    728 #endif
    729 
     700        fncptr_t fptr;
     701       
    730702        symaddr = get_symbol_addr((char *) argv->buffer);
    731703        if (!symaddr)
     
    736708        } else {
    737709                symbol = get_symtab_entry(symaddr);
     710                fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2);
    738711                printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
    739712                       arg1, arg2, symaddr, symbol);
    740 #ifdef ia64
    741                 fptr.f = symaddr;
    742                 fptr.gp = ((unative_t *)cmd_call2)[1];
    743                 f =  (unative_t (*)(unative_t,unative_t,...)) &fptr;
    744 #else
    745                 f =  (unative_t (*)(unative_t,unative_t,...)) symaddr;
    746 #endif
    747                 printf("Result: %#" PRIxn "\n", f(arg1, arg2));
     713                printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
    748714        }
    749715       
     
    756722        uintptr_t symaddr;
    757723        char *symbol;
    758         unative_t (*f)(unative_t,unative_t,unative_t,...);
     724        unative_t (*fnc)(unative_t, unative_t, unative_t, ...);
    759725        unative_t arg1 = argv[1].intval;
    760726        unative_t arg2 = argv[2].intval;
    761727        unative_t arg3 = argv[3].intval;
    762 #ifdef ia64
    763         struct {
    764                 unative_t f;
    765                 unative_t gp;
    766         }fptr;
    767 #endif
    768 
     728        fncptr_t fptr;
     729       
    769730        symaddr = get_symbol_addr((char *) argv->buffer);
    770731        if (!symaddr)
     
    775736        } else {
    776737                symbol = get_symtab_entry(symaddr);
     738                fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call3);
    777739                printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
    778740                       arg1, arg2, arg3, symaddr, symbol);
    779 #ifdef ia64
    780                 fptr.f = symaddr;
    781                 fptr.gp = ((unative_t *)cmd_call2)[1];
    782                 f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr;
    783 #else
    784                 f =  (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr;
    785 #endif
    786                 printf("Result: %#" PRIxn "\n", f(arg1, arg2, arg3));
     741                printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
    787742        }
    788743       
     
    997952       
    998953        for (test = tests; test->name != NULL; test++)
    999                 printf("%s\t\t%s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)"));
    1000        
    1001         printf("*\t\tRun all safe tests\n");
     954                printf("%-10s %s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)"));
     955       
     956        printf("%-10s Run all safe tests\n", "*");
    1002957        return 1;
    1003958}
Note: See TracChangeset for help on using the changeset viewer.