Ignore:
Timestamp:
2010-06-11T15:31:03Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
214ec25c
Parents:
be06914
Message:

distinguish between "hot" and "cold" exceptions
display only "hot" exceptions by default
add top to help

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/interrupt/interrupt.c

    rbe06914 rb3b7e14  
    6161/** Register exception handler
    6262 *
    63  * @param n       Exception number
    64  * @param name    Description
    65  * @param handler Exception handler
    66  *
    67  */
    68 iroutine exc_register(int n, const char *name, iroutine handler)
    69 {
     63 * @param n       Exception number.
     64 * @param name    Description.
     65 * @param hot     Whether the exception is actually handled
     66 *                in any meaningful way.
     67 * @param handler New exception handler.
     68 *
     69 * @return Previously registered exception handler.
     70 *
     71 */
     72iroutine_t exc_register(unsigned int n, const char *name, bool hot,
     73    iroutine_t handler)
     74{
     75#if (IVT_ITEMS > 0)
    7076        ASSERT(n < IVT_ITEMS);
     77#endif
    7178       
    7279        irq_spinlock_lock(&exctbl_lock, true);
    7380       
    74         iroutine old = exc_table[n].f;
    75         exc_table[n].f = handler;
     81        iroutine_t old = exc_table[n].handler;
     82        exc_table[n].handler = handler;
    7683        exc_table[n].name = name;
     84        exc_table[n].hot = hot;
    7785        exc_table[n].cycles = 0;
    7886        exc_table[n].count = 0;
     
    8997 *
    9098 */
    91 void exc_dispatch(int n, istate_t *istate)
    92 {
     99void exc_dispatch(unsigned int n, istate_t *istate)
     100{
     101#if (IVT_ITEMS > 0)
    93102        ASSERT(n < IVT_ITEMS);
     103#endif
    94104       
    95105        uint64_t begin_cycle = get_cycle();
     
    107117#endif
    108118       
    109         exc_table[n].f(n + IVT_FIRST, istate);
     119        exc_table[n].handler(n + IVT_FIRST, istate);
    110120       
    111121#ifdef CONFIG_UDEBUG
     
    185195#ifdef CONFIG_KCONSOLE
    186196
     197static char flag_buf[MAX_CMDLINE + 1];
     198
    187199/** Print all exceptions
    188200 *
     
    190202static int cmd_exc_print(cmd_arg_t *argv)
    191203{
     204        bool excs_all;
     205       
     206        if (str_cmp(flag_buf, "-a") == 0)
     207                excs_all = true;
     208        else if (str_cmp(flag_buf, "") == 0)
     209                excs_all = false;
     210        else {
     211                printf("Unknown argument \"%s\".\n", flag_buf);
     212                return 1;
     213        }
     214       
    192215#if (IVT_ITEMS > 0)
    193216        unsigned int i;
     217        unsigned int rows;
    194218       
    195219        irq_spinlock_lock(&exctbl_lock, true);
    196220       
    197221#ifdef __32_BITS__
    198         printf("Exc Description          Count      Cycles     Handler    Symbol\n");
    199         printf("--- -------------------- ---------- ---------- ---------- --------\n");
     222        printf("[exc   ] [description       ] [count   ] [cycles  ]"
     223            " [handler ] [symbol\n");
     224        rows = 1;
    200225#endif
    201226       
    202227#ifdef __64_BITS__
    203         printf("Exc Description          Count      Cycles     Handler            Symbol\n");
    204         printf("--- -------------------- ---------- ---------- ------------------ --------\n");
     228        printf("[exc   ] [description       ] [count   ] [cycles  ]"
     229            " [handler         ]\n");
     230        printf("         [symbol\n");
     231        rows = 2;
    205232#endif
    206233       
    207234        for (i = 0; i < IVT_ITEMS; i++) {
     235                if ((!excs_all) && (!exc_table[i].hot))
     236                        continue;
     237               
    208238                uint64_t count;
    209239                char count_suffix;
     
    217247               
    218248                const char *symbol =
    219                     symtab_fmt_name_lookup((unative_t) exc_table[i].f);
     249                    symtab_fmt_name_lookup((unative_t) exc_table[i].handler);
    220250               
    221251#ifdef __32_BITS__
    222                 printf("%-3u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %10p %s\n",
     252                printf("%-8u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %10p %s\n",
    223253                    i + IVT_FIRST, exc_table[i].name, count, count_suffix,
    224                     cycles, cycles_suffix, exc_table[i].f, symbol);
     254                    cycles, cycles_suffix, exc_table[i].handler, symbol);
     255               
     256                PAGING(rows, 1, irq_spinlock_unlock(&exctbl_lock, true),
     257                    irq_spinlock_lock(&exctbl_lock, true));
    225258#endif
    226259               
    227260#ifdef __64_BITS__
    228                 printf("%-3u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %18p %s\n",
     261                printf("%-8u %-20s %9" PRIu64 "%c %9" PRIu64 "%c %18p\n",
    229262                    i + IVT_FIRST, exc_table[i].name, count, count_suffix,
    230                     cycles, cycles_suffix, exc_table[i].f, symbol);
    231 #endif
    232                
    233                 if (((i + 1) % 20) == 0) {
    234                         printf(" -- Press any key to continue -- ");
    235                         irq_spinlock_unlock(&exctbl_lock, true);
    236                         indev_pop_character(stdin);
    237                         irq_spinlock_lock(&exctbl_lock, true);
    238                         printf("\n");
    239                 }
     263                    cycles, cycles_suffix, exc_table[i].handler);
     264                printf("         %s\n", symbol);
     265               
     266                PAGING(rows, 2, irq_spinlock_unlock(&exctbl_lock, true),
     267                    irq_spinlock_lock(&exctbl_lock, true));
     268#endif
    240269        }
    241270       
    242271        irq_spinlock_unlock(&exctbl_lock, true);
    243 #endif
     272#else /* (IVT_ITEMS > 0) */
     273       
     274        printf("No exception table%s.\n", excs_all ? " (showing all exceptions)" : "");
     275       
     276#endif /* (IVT_ITEMS > 0) */
    244277       
    245278        return 1;
    246279}
     280
     281static cmd_arg_t exc_argv = {
     282        .type = ARG_TYPE_STRING_OPTIONAL,
     283        .buffer = flag_buf,
     284        .len = sizeof(flag_buf)
     285};
    247286
    248287static cmd_info_t exc_info = {
    249288        .name = "exc",
    250         .description = "Print exception table.",
     289        .description = "Print exception table (use -a for all exceptions).",
    251290        .func = cmd_exc_print,
    252291        .help = NULL,
    253         .argc = 0,
    254         .argv = NULL
     292        .argc = 1,
     293        .argv = &exc_argv
    255294};
    256295
     
    268307       
    269308        for (i = 0; i < IVT_ITEMS; i++)
    270                 exc_register(i, "undef", (iroutine) exc_undef);
     309                exc_register(i, "undef", false, (iroutine_t) exc_undef);
    271310#endif
    272311       
Note: See TracChangeset for help on using the changeset viewer.