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


Ignore:
Timestamp:
2007-04-08T23:45:41Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
72bcb25
Parents:
7cb567cd
Message:

add mcall0 command (calling a function on each CPU)

File:
1 edited

Legend:

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

    r7cb567cd re5dbbe5  
    193193
    194194/* Data and methods for 'call0' command. */
    195 static char call0_buf[MAX_CMDLINE+1];
    196 static char carg1_buf[MAX_CMDLINE+1];
    197 static char carg2_buf[MAX_CMDLINE+1];
    198 static char carg3_buf[MAX_CMDLINE+1];
     195static char call0_buf[MAX_CMDLINE + 1];
     196static char carg1_buf[MAX_CMDLINE + 1];
     197static char carg2_buf[MAX_CMDLINE + 1];
     198static char carg3_buf[MAX_CMDLINE + 1];
    199199
    200200static int cmd_call0(cmd_arg_t *argv);
     
    210210        .argc = 1,
    211211        .argv = &call0_argv
     212};
     213
     214/* Data and methods for 'mcall0' command. */
     215static int cmd_mcall0(cmd_arg_t *argv);
     216static cmd_arg_t mcall0_argv = {
     217        .type = ARG_TYPE_STRING,
     218        .buffer = call0_buf,
     219        .len = sizeof(call0_buf)
     220};
     221static cmd_info_t mcall0_info = {
     222        .name = "mcall0",
     223        .description = "mcall0 <function> -> call function() on each CPU.",
     224        .func = cmd_mcall0,
     225        .argc = 1,
     226        .argv = &mcall0_argv
    212227};
    213228
     
    407422static cmd_info_t *basic_commands[] = {
    408423        &call0_info,
     424        &mcall0_info,
    409425        &call1_info,
    410426        &call2_info,
     
    541557                unative_t f;
    542558                unative_t gp;
    543         }fptr;
     559        } fptr;
    544560#endif
    545561
     
    552568        } else {
    553569                symbol = get_symtab_entry(symaddr);
    554                 printf("Calling f(): %.*p: %s\n", sizeof(uintptr_t) * 2, symaddr, symbol);
     570                printf("Calling %s() (%.*p)\n", symbol, sizeof(uintptr_t) * 2, symaddr);
    555571#ifdef ia64
    556572                fptr.f = symaddr;
     
    561577#endif
    562578                printf("Result: %#zx\n", f());
     579        }
     580       
     581        return 1;
     582}
     583
     584/** Call function with zero parameters on each CPU */
     585int cmd_mcall0(cmd_arg_t *argv)
     586{
     587        /*
     588         * For each CPU, create a thread which will
     589         * call the function.
     590         */
     591       
     592        count_t i;
     593        for (i = 0; i < config.cpu_count; i++) {
     594                thread_t *t;
     595                if ((t = thread_create((void (*)(void *)) cmd_call0, (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
     596                        spinlock_lock(&t->lock);
     597                        t->cpu = &cpus[i];
     598                        spinlock_unlock(&t->lock);
     599                        printf("cpu%u: ", i);
     600                        thread_ready(t);
     601                        thread_join(t);
     602                } else
     603                        printf("Unable to create thread for cpu%u\n", i);
    563604        }
    564605       
Note: See TracChangeset for help on using the changeset viewer.