Changeset b3b7e14 in mainline


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

Files:
23 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/debugger.c

    rbe06914 rb3b7e14  
    333333#endif /* CONFIG_KCONSOLE */
    334334       
    335         exc_register(VECTOR_DEBUG, "debugger", debug_exception);
     335        exc_register(VECTOR_DEBUG, "debugger", true,
     336            debug_exception);
     337       
    336338#ifdef CONFIG_SMP
    337         exc_register(VECTOR_DEBUG_IPI, "debugger_smp", debug_ipi);
     339        exc_register(VECTOR_DEBUG_IPI, "debugger_smp", true,
     340            debug_ipi);
    338341#endif /* CONFIG_SMP */
    339342}
  • kernel/arch/amd64/src/interrupt.c

    rbe06914 rb3b7e14  
    199199void interrupt_init(void)
    200200{
    201         int i;
     201        unsigned int i;
    202202       
    203203        for (i = 0; i < IVT_ITEMS; i++)
    204                 exc_register(i, "null", (iroutine) null_interrupt);
     204                exc_register(i, "null", false, (iroutine_t) null_interrupt);
    205205       
    206206        for (i = 0; i < IRQ_COUNT; i++) {
    207207                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    208                         exc_register(IVT_IRQBASE + i, "irq",
    209                             (iroutine) irq_interrupt);
     208                        exc_register(IVT_IRQBASE + i, "irq", true,
     209                            (iroutine_t) irq_interrupt);
    210210        }
    211211       
    212         exc_register(0, "de_fault", (iroutine) de_fault);
    213         exc_register(7, "nm_fault", (iroutine) nm_fault);
    214         exc_register(12, "ss_fault", (iroutine) ss_fault);
    215         exc_register(13, "gp_fault", (iroutine) gp_fault);
    216         exc_register(14, "ident_mapper", (iroutine) ident_page_fault);
     212        exc_register(0, "de_fault", true, (iroutine_t) de_fault);
     213        exc_register(7, "nm_fault", true, (iroutine_t) nm_fault);
     214        exc_register(12, "ss_fault", true, (iroutine_t) ss_fault);
     215        exc_register(13, "gp_fault", true, (iroutine_t) gp_fault);
     216        exc_register(14, "ident_mapper", true, (iroutine_t) ident_page_fault);
    217217       
    218218#ifdef CONFIG_SMP
    219         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown",
    220             (iroutine) tlb_shootdown_ipi);
     219        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
     220            (iroutine_t) tlb_shootdown_ipi);
    221221#endif
    222222}
  • kernel/arch/amd64/src/mm/page.c

    rbe06914 rb3b7e14  
    116116                page_table_unlock(AS_KERNEL, true);
    117117
    118                 exc_register(14, "page_fault", (iroutine) page_fault);
     118                exc_register(14, "page_fault", true, (iroutine_t) page_fault);
    119119                write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
    120         } else 
     120        } else
    121121                write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
    122122}
  • kernel/arch/arm32/include/ras.h

    rbe06914 rb3b7e14  
    11/*
    2  * Copyright (c) 2009 Jakub Jermar 
     2 * Copyright (c) 2009 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    4040#include <typedefs.h>
    4141
    42 #define RAS_START       0
    43 #define RAS_END         1
     42#define RAS_START  0
     43#define RAS_END    1
    4444
    4545extern uintptr_t *ras_page;
    4646
    4747extern void ras_init(void);
    48 extern void ras_check(int, istate_t *);
     48extern void ras_check(unsigned int, istate_t *);
    4949
    5050#endif
  • kernel/arch/arm32/src/exc_handler.S

    rbe06914 rb3b7e14  
    150150        mov r0, #0
    151151        mov r1, r13
    152         bl ras_check 
     152        bl ras_check
    153153        LOAD_REGS_FROM_STACK
    154154
     
    158158        mov r0, #5
    159159        mov r1, r13
    160         bl ras_check 
     160        bl ras_check
    161161        LOAD_REGS_FROM_STACK
    162162
     
    166166        mov r0, #6
    167167        mov r1, r13
    168         bl ras_check 
     168        bl ras_check
    169169        LOAD_REGS_FROM_STACK
    170170
     
    173173        mov r0, #1
    174174        mov r1, r13
    175         bl ras_check 
     175        bl ras_check
    176176        LOAD_REGS_FROM_STACK
    177177
     
    181181        mov r0, #3
    182182        mov r1, r13
    183         bl ras_check 
     183        bl ras_check
    184184        LOAD_REGS_FROM_STACK
    185185
     
    189189        mov r0, #4
    190190        mov r1, r13
    191         bl ras_check 
     191        bl ras_check
    192192        LOAD_REGS_FROM_STACK
    193193
  • kernel/arch/arm32/src/exception.c

    rbe06914 rb3b7e14  
    165165        install_exception_handlers();
    166166       
    167         exc_register(EXC_IRQ, "interrupt", (iroutine) irq_exception);
    168         exc_register(EXC_PREFETCH_ABORT, "prefetch abort",
    169             (iroutine) prefetch_abort);
    170         exc_register(EXC_DATA_ABORT, "data abort", (iroutine) data_abort);
    171         exc_register(EXC_SWI, "software interrupt", (iroutine) swi_exception);
     167        exc_register(EXC_IRQ, "interrupt", true,
     168            (iroutine_t) irq_exception);
     169        exc_register(EXC_PREFETCH_ABORT, "prefetch abort", true,
     170            (iroutine_t) prefetch_abort);
     171        exc_register(EXC_DATA_ABORT, "data abort", true,
     172            (iroutine_t) data_abort);
     173        exc_register(EXC_SWI, "software interrupt", true,
     174            (iroutine_t) swi_exception);
    172175}
    173176
  • kernel/arch/arm32/src/ras.c

    rbe06914 rb3b7e14  
    11/*
    2  * Copyright (c) 2009 Jakub Jermar 
     2 * Copyright (c) 2009 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    6666}
    6767
    68 void ras_check(int n, istate_t *istate)
     68void ras_check(unsigned int n, istate_t *istate)
    6969{
    7070        uintptr_t rewrite_pc = istate->pc;
  • kernel/arch/ia32/src/drivers/i8259.c

    rbe06914 rb3b7e14  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    7676         * Register interrupt handler for the PIC spurious interrupt.
    7777         */
    78         exc_register(VECTOR_PIC_SPUR, "pic_spurious", (iroutine) pic_spurious);
     78        exc_register(VECTOR_PIC_SPUR, "pic_spurious", false,
     79            (iroutine_t) pic_spurious);
    7980
    8081        /*
  • kernel/arch/ia32/src/interrupt.c

    rbe06914 rb3b7e14  
    215215void interrupt_init(void)
    216216{
    217         int i;
     217        unsigned int i;
    218218       
    219219        for (i = 0; i < IVT_ITEMS; i++)
    220                 exc_register(i, "null", (iroutine) null_interrupt);
     220                exc_register(i, "null", false, (iroutine_t) null_interrupt);
    221221       
    222222        for (i = 0; i < IRQ_COUNT; i++) {
    223223                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
    224                         exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt);
     224                        exc_register(IVT_IRQBASE + i, "irq", true,
     225                            (iroutine_t) irq_interrupt);
    225226        }
    226227       
    227         exc_register(0, "de_fault", (iroutine) de_fault);
    228         exc_register(7, "nm_fault", (iroutine) nm_fault);
    229         exc_register(12, "ss_fault", (iroutine) ss_fault);
    230         exc_register(13, "gp_fault", (iroutine) gp_fault);
    231         exc_register(19, "simd_fp", (iroutine) simd_fp_exception);
     228        exc_register(0, "de_fault", true, (iroutine_t) de_fault);
     229        exc_register(7, "nm_fault", true, (iroutine_t) nm_fault);
     230        exc_register(12, "ss_fault", true, (iroutine_t) ss_fault);
     231        exc_register(13, "gp_fault", true, (iroutine_t) gp_fault);
     232        exc_register(19, "simd_fp", true, (iroutine_t) simd_fp_exception);
    232233       
    233234#ifdef CONFIG_SMP
    234         exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi);
     235        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
     236            (iroutine_t) tlb_shootdown_ipi);
    235237#endif
    236238}
  • kernel/arch/ia32/src/mm/page.c

    rbe06914 rb3b7e14  
    7070                page_table_unlock(AS_KERNEL, true);
    7171               
    72                 exc_register(14, "page_fault", (iroutine) page_fault);
     72                exc_register(14, "page_fault", true, (iroutine_t) page_fault);
    7373                write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
    7474        } else
  • kernel/arch/ia32/src/smp/apic.c

    rbe06914 rb3b7e14  
    157157void apic_init(void)
    158158{
    159         exc_register(VECTOR_APIC_SPUR, "apic_spurious", (iroutine) apic_spurious);
     159        exc_register(VECTOR_APIC_SPUR, "apic_spurious", false,
     160            (iroutine_t) apic_spurious);
    160161       
    161162        enable_irqs_function = io_apic_enable_irqs;
  • kernel/arch/mips32/src/exception.c

    rbe06914 rb3b7e14  
    167167void exception_init(void)
    168168{
    169         int i;
     169        unsigned int i;
    170170       
    171171        /* Clear exception table */
    172172        for (i = 0; i < IVT_ITEMS; i++)
    173                 exc_register(i, "undef", (iroutine) unhandled_exception);
     173                exc_register(i, "undef", false,
     174                    (iroutine_t) unhandled_exception);
    174175       
    175         exc_register(EXC_Bp, "bkpoint", (iroutine) breakpoint_exception);
    176         exc_register(EXC_RI, "resinstr", (iroutine) reserved_instr_exception);
    177         exc_register(EXC_Mod, "tlb_mod", (iroutine) tlbmod_exception);
    178         exc_register(EXC_TLBL, "tlbinvl", (iroutine) tlbinv_exception);
    179         exc_register(EXC_TLBS, "tlbinvl", (iroutine) tlbinv_exception);
    180         exc_register(EXC_Int, "interrupt", (iroutine) interrupt_exception);
     176        exc_register(EXC_Bp, "bkpoint", true,
     177            (iroutine_t) breakpoint_exception);
     178        exc_register(EXC_RI, "resinstr", true,
     179            (iroutine_t) reserved_instr_exception);
     180        exc_register(EXC_Mod, "tlb_mod", true,
     181            (iroutine_t) tlbmod_exception);
     182        exc_register(EXC_TLBL, "tlbinvl", true,
     183            (iroutine_t) tlbinv_exception);
     184        exc_register(EXC_TLBS, "tlbinvl", true,
     185            (iroutine_t) tlbinv_exception);
     186        exc_register(EXC_Int, "interrupt", true,
     187            (iroutine_t) interrupt_exception);
     188       
    181189#ifdef CONFIG_FPU_LAZY
    182         exc_register(EXC_CpU, "cpunus", (iroutine) cpuns_exception);
     190        exc_register(EXC_CpU, "cpunus", true,
     191            (iroutine_t) cpuns_exception);
    183192#endif
    184         exc_register(EXC_Sys, "syscall", (iroutine) syscall_exception);
     193       
     194        exc_register(EXC_Sys, "syscall", true,
     195            (iroutine_t) syscall_exception);
    185196}
    186197
  • kernel/arch/ppc32/src/interrupt.c

    rbe06914 rb3b7e14  
    101101void interrupt_init(void)
    102102{
    103         exc_register(VECTOR_DATA_STORAGE, "data_storage", pht_refill);
    104         exc_register(VECTOR_INSTRUCTION_STORAGE, "instruction_storage", pht_refill);
    105         exc_register(VECTOR_EXTERNAL, "external", exception_external);
    106         exc_register(VECTOR_DECREMENTER, "timer", exception_decrementer);
     103        exc_register(VECTOR_DATA_STORAGE, "data_storage", true,
     104            pht_refill);
     105        exc_register(VECTOR_INSTRUCTION_STORAGE, "instruction_storage", true,
     106            pht_refill);
     107        exc_register(VECTOR_EXTERNAL, "external", true,
     108            exception_external);
     109        exc_register(VECTOR_DECREMENTER, "timer", true,
     110            exception_decrementer);
    107111}
    108112
  • kernel/arch/sparc64/include/sparc64.h

    rbe06914 rb3b7e14  
    3838#include <interrupt.h>
    3939
    40 extern void interrupt_register(int n, const char *name, iroutine f);
     40extern void interrupt_register(unsigned int, const char *, iroutine_t);
    4141
    4242#endif
  • kernel/arch/sparc64/src/trap/interrupt.c

    rbe06914 rb3b7e14  
    5151/** Register Interrupt Level Handler.
    5252 *
    53  * @param n Interrupt Level (1 - 15).
    54  * @param name Short descriptive string.
    55  * @param f Handler.
     53 * @param n       Interrupt Level (1 - 15).
     54 * @param name    Short descriptive string.
     55 * @param handler Handler.
     56 *
    5657 */
    57 void interrupt_register(int n, const char *name, iroutine f)
     58void interrupt_register(unsigned int n, const char *name, iroutine_t handler)
    5859{
    5960        ASSERT(n >= IVT_FIRST && n <= IVT_ITEMS);
    6061       
    61         exc_register(n - 1, name, f);
     62        exc_register(n - IVT_FIRST, name, true, handler);
    6263}
     64
    6365/** @}
    6466 */
  • kernel/generic/include/console/console.h

    rbe06914 rb3b7e14  
    3737
    3838#include <typedefs.h>
     39#include <print.h>
    3940#include <console/chardev.h>
     41
     42#define PAGING(counter, increment, before, after) \
     43        do { \
     44                (counter) += (increment); \
     45                if ((counter) > 23) { \
     46                        before; \
     47                        printf(" -- Press any key to continue -- "); \
     48                        indev_pop_character(stdin); \
     49                        after; \
     50                        printf("\n"); \
     51                        (counter) = 0; \
     52                } \
     53        } while (0)
    4054
    4155extern indev_t *stdin;
  • kernel/generic/include/interrupt.h

    rbe06914 rb3b7e14  
    4444#include <stacktrace.h>
    4545
    46 typedef void (* iroutine)(int, istate_t *);
     46typedef void (* iroutine_t)(int, istate_t *);
    4747
    4848typedef struct {
    4949        const char *name;
    50         iroutine f;
     50        bool hot;
     51        iroutine_t handler;
    5152        uint64_t cycles;
    5253        uint64_t count;
     
    5758
    5859extern void fault_if_from_uspace(istate_t *, const char *, ...);
    59 extern iroutine exc_register(int, const char *, iroutine);
    60 extern void exc_dispatch(int, istate_t *);
     60extern iroutine_t exc_register(unsigned int, const char *, bool, iroutine_t);
     61extern void exc_dispatch(unsigned int, istate_t *);
    6162extern void exc_init(void);
    6263
  • kernel/generic/include/sysinfo/abi.h

    rbe06914 rb3b7e14  
    130130        unsigned int id;             /**< Exception ID */
    131131        char desc[EXC_NAME_BUFLEN];  /**< Description */
     132        bool hot;                    /**< Active or inactive exception */
    132133        uint64_t cycles;             /**< Number of CPU cycles in the handler */
    133134        uint64_t count;              /**< Number of handled exceptions */
  • 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       
  • kernel/generic/src/sysinfo/stats.c

    rbe06914 rb3b7e14  
    562562        }
    563563       
     564#if (IVT_ITEMS > 0)
    564565        /* Messing with exception table, avoid deadlock */
    565566        irq_spinlock_lock(&exctbl_lock, true);
     
    569570                stats_exceptions[i].id = i + IVT_FIRST;
    570571                str_cpy(stats_exceptions[i].desc, EXC_NAME_BUFLEN, exc_table[i].name);
     572                stats_exceptions[i].hot = exc_table[i].hot;
    571573                stats_exceptions[i].cycles = exc_table[i].cycles;
    572574                stats_exceptions[i].count = exc_table[i].count;
     
    574576       
    575577        irq_spinlock_unlock(&exctbl_lock, true);
     578#endif
    576579       
    577580        return ((void *) stats_exceptions);
     
    606609                return ret;
    607610       
    608 #if IVT_FIRST > 0
     611#if (IVT_FIRST > 0)
    609612        if (excn < IVT_FIRST)
    610613                return ret;
    611614#endif
    612615       
     616#if (IVT_ITEMS + IVT_FIRST == 0)
     617        return ret;
     618#else
    613619        if (excn >= IVT_ITEMS + IVT_FIRST)
    614620                return ret;
     621#endif
    615622       
    616623        if (dry_run) {
     
    638645                stats_exception->id = excn;
    639646                str_cpy(stats_exception->desc, EXC_NAME_BUFLEN, exc_table[excn].name);
     647                stats_exception->hot = exc_table[excn].hot;
    640648                stats_exception->cycles = exc_table[excn].cycles;
    641649                stats_exception->count = exc_table[excn].count;
  • uspace/app/top/screen.c

    rbe06914 rb3b7e14  
    259259}
    260260
    261 static inline void print_task_head(void)
     261static inline void print_tasks_head(void)
    262262{
    263263        screen_style_inverted();
     
    371371}
    372372
    373 static inline void print_exc_head(void)
     373static inline void print_excs_head(void)
    374374{
    375375        screen_style_inverted();
     
    379379}
    380380
    381 static inline void print_exc(data_t *data)
     381static inline void print_excs(data_t *data)
    382382{
    383383        ipcarg_t cols;
     
    390390       
    391391        size_t i;
    392         for (i = 0; (i < data->exceptions_count) && (row < rows); i++, row++) {
     392        for (i = 0; (i < data->exceptions_count) && (row < rows); i++) {
     393                /* Filter-out cold exceptions if not instructed otherwise */
     394                if ((!excs_all) && (!data->exceptions[i].hot))
     395                        continue;
     396               
    393397                uint64_t count;
    394398                uint64_t cycles;
     
    409413               
    410414                screen_newline();
    411         }
     415                row++;
     416        }
     417       
     418        while (row < rows) {
     419                screen_newline();
     420                row++;
     421        }
     422}
     423
     424static void print_help(void)
     425{
     426        ipcarg_t cols;
     427        ipcarg_t rows;
     428        screen_get_size(&cols, &rows);
     429       
     430        ipcarg_t col;
     431        ipcarg_t row;
     432        screen_get_pos(&col, &row);
     433       
     434        screen_newline();
     435       
     436        printf("Operation modes:");
     437        screen_newline();
     438       
     439        printf(" t .. tasks statistics");
     440        screen_newline();
     441       
     442        printf(" i .. IPC statistics");
     443        screen_newline();
     444       
     445        printf(" e .. exceptions statistics");
     446        screen_newline();
     447       
     448        printf("      a .. toggle display of all/hot exceptions");
     449        screen_newline();
     450       
     451        row += 6;
    412452       
    413453        while (row < rows) {
     
    430470        screen_newline();
    431471       
    432         switch (operation_type) {
     472        switch (op_mode) {
    433473        case OP_TASKS:
    434                 print_task_head();
     474                print_tasks_head();
    435475                print_tasks(data);
    436476                break;
     
    439479                print_ipc(data);
    440480                break;
    441         case OP_EXC:
    442                 print_exc_head();
    443                 print_exc(data);
     481        case OP_EXCS:
     482                print_excs_head();
     483                print_excs(data);
    444484                break;
     485        case OP_HELP:
     486                print_tasks_head();
     487                print_help();
    445488        }
    446489       
  • uspace/app/top/top.c

    rbe06914 rb3b7e14  
    5656#define MINUTE  60
    5757
    58 int operation_type;
     58op_mode_t op_mode = OP_TASKS;
     59bool excs_all = false;
    5960
    6061static const char *read_data(data_t *target)
     
    338339       
    339340        /* And paint screen until death */
    340         operation_type = OP_TASKS;
    341341        while (true) {
    342342                int c = tgetchar(UPDATE_INTERVAL);
     
    360360               
    361361                switch (c) {
     362                        case 't':
     363                                print_warning("Showing task statistics");
     364                                op_mode = OP_TASKS;
     365                                break;
     366                        case 'i':
     367                                print_warning("Showing IPC statistics");
     368                                op_mode = OP_IPC;
     369                                break;
     370                        case 'e':
     371                                print_warning("Showing exception statistics");
     372                                op_mode = OP_EXCS;
     373                                break;
     374                        case 'h':
     375                                print_warning("Showing help");
     376                                op_mode = OP_HELP;
     377                                break;
    362378                        case 'q':
    363379                                goto out;
    364                         case 'i':
    365                                 print_warning("Showing IPC statistics");
    366                                 operation_type = OP_IPC;
    367                                 break;
    368                         case 't':
    369                                 print_warning("Showing task statistics");
    370                                 operation_type = OP_TASKS;
    371                                 break;
    372                         case 'e':
    373                                 print_warning("Showing exception statistics");
    374                                 operation_type = OP_EXC;
    375                                 break;
     380                        case 'a':
     381                                if (op_mode == OP_EXCS) {
     382                                        excs_all = !excs_all;
     383                                        if (excs_all)
     384                                                print_warning("Showing all exceptions");
     385                                        else
     386                                                print_warning("Showing only hot exceptions");
     387                                        break;
     388                                }
    376389                        default:
    377                                 print_warning("Unknown command: %c", c);
     390                                print_warning("Unknown command \"%c\", use \"h\" for help", c);
    378391                                break;
    379392                }
  • uspace/app/top/top.h

    rbe06914 rb3b7e14  
    4040
    4141#define FRACTION_TO_FLOAT(float, a, b) \
    42         { \
     42        do { \
    4343                if ((b) != 0) { \
    4444                        (float).upper = (a); \
     
    4848                        (float).lower = 1; \
    4949                } \
    50         }
     50        } while (0)
    5151
    52 #define OP_TASKS  1
    53 #define OP_IPC    2
    54 #define OP_EXC    3
     52typedef enum {
     53        OP_TASKS,
     54        OP_IPC,
     55        OP_EXCS,
     56        OP_HELP
     57} op_mode_t;
    5558
    56 extern int operation_type;
     59extern op_mode_t op_mode;
     60extern bool excs_all;
    5761
    5862typedef struct {
Note: See TracChangeset for help on using the changeset viewer.