Changeset 76fca31 in mainline for kernel/arch


Ignore:
Timestamp:
2008-12-16T19:02:07Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5ae4443
Parents:
8fe5980
Message:

kconsole is optional
kernel & uspace framebuffer rewrite with speedups (some things are slightly broken yet)

Location:
kernel/arch
Files:
9 edited

Legend:

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

    r8fe5980 r76fca31  
    5555SPINLOCK_INITIALIZE(bkpoint_lock);
    5656
     57#ifdef CONFIG_KCONSOLE
     58
    5759static int cmd_print_breakpoints(cmd_arg_t *argv);
    5860static cmd_info_t bkpts_info = {
     
    100102};
    101103
    102 #endif
    103 
    104 /** Print table of active breakpoints */
    105 int cmd_print_breakpoints(cmd_arg_t *argv __attribute__((unused)))
    106 {
    107         unsigned int i;
    108         char *symbol;
    109 
    110 #ifdef __32_BITS__     
    111         printf("#  Count Address    In symbol\n");
    112         printf("-- ----- ---------- ---------\n");
    113 #endif
    114 
    115 #ifdef __64_BITS__
    116         printf("#  Count Address            In symbol\n");
    117         printf("-- ----- ------------------ ---------\n");
    118 #endif
    119        
    120         for (i = 0; i < BKPOINTS_MAX; i++)
    121                 if (breakpoints[i].address) {
    122                         symbol = get_symtab_entry(breakpoints[i].address);
    123 
    124 #ifdef __32_BITS__
    125                         printf("%-2u %-5d %#10zx %s\n", i,
    126                             breakpoints[i].counter, breakpoints[i].address,
    127                             symbol);
    128 #endif
    129 
    130 #ifdef __64_BITS__
    131                         printf("%-2u %-5d %#18zx %s\n", i,
    132                             breakpoints[i].counter, breakpoints[i].address,
    133                             symbol);
    134 #endif
    135 
    136                 }
    137         return 1;
    138 }
     104#endif /* CONFIG_DEBUG_AS_WATCHPOINT */
     105#endif /* CONFIG_KCONSOLE */
    139106
    140107/* Setup DR register according to table */
     
    268235        printf("Reached breakpoint %d:%lx(%s)\n", slot, getip(istate),
    269236            get_symtab_entry(getip(istate)));
    270         printf("***Type 'exit' to exit kconsole.\n");
    271         atomic_set(&haltstate,1);
    272         kconsole((void *) "debug");
    273         atomic_set(&haltstate,0);
     237
     238#ifdef CONFIG_KCONSOLE
     239        atomic_set(&haltstate, 1);
     240        kconsole("debug", "Debug console ready (type 'exit' to continue)\n", false);
     241        atomic_set(&haltstate, 0);
     242#endif
    274243}
    275244
     
    300269}
    301270
    302 #ifndef CONFIG_DEBUG_AS_WATCHPOINT
    303 
    304 /** Remove breakpoint from table */
    305 int cmd_del_breakpoint(cmd_arg_t *argv)
    306 {
    307         unative_t bpno = argv->intval;
    308         if (bpno > BKPOINTS_MAX) {
    309                 printf("Invalid breakpoint number.\n");
    310                 return 0;
    311         }
    312         breakpoint_del(argv->intval);
    313         return 1;
    314 }
    315 
    316 /** Add new breakpoint to table */
    317 static int cmd_add_breakpoint(cmd_arg_t *argv)
    318 {
    319         int flags;
    320         int id;
    321 
    322         if (argv == &add_argv) {
    323                 flags = BKPOINT_INSTR;
    324         } else { /* addwatchp */
    325                 flags = BKPOINT_WRITE;
    326         }
    327         printf("Adding breakpoint on address: %p\n", argv->intval);
    328         id = breakpoint_add((void *)argv->intval, flags, -1);
    329         if (id < 0)
    330                 printf("Add breakpoint failed.\n");
    331         else
    332                 printf("Added breakpoint %d.\n", id);
    333        
    334         return 1;
    335 }
    336 #endif
     271
    337272
    338273static void debug_exception(int n __attribute__((unused)), istate_t *istate)
     
    380315        for (i = 0; i < BKPOINTS_MAX; i++)
    381316                breakpoints[i].address = NULL;
    382        
     317
     318#ifdef CONFIG_KCONSOLE
    383319        cmd_initialize(&bkpts_info);
    384320        if (!cmd_register(&bkpts_info))
    385                 panic("could not register command %s\n", bkpts_info.name);
     321                printf("Cannot register command %s\n", bkpts_info.name);
    386322
    387323#ifndef CONFIG_DEBUG_AS_WATCHPOINT
    388324        cmd_initialize(&delbkpt_info);
    389325        if (!cmd_register(&delbkpt_info))
    390                 panic("could not register command %s\n", delbkpt_info.name);
     326                printf("Cannot register command %s\n", delbkpt_info.name);
    391327
    392328        cmd_initialize(&addbkpt_info);
    393329        if (!cmd_register(&addbkpt_info))
    394                 panic("could not register command %s\n", addbkpt_info.name);
     330                printf("Cannot register command %s\n", addbkpt_info.name);
    395331
    396332        cmd_initialize(&addwatchp_info);
    397333        if (!cmd_register(&addwatchp_info))
    398                 panic("could not register command %s\n", addwatchp_info.name);
    399 #endif
     334                printf("Cannot register command %s\n", addwatchp_info.name);
     335#endif /* CONFIG_DEBUG_AS_WATCHPOINT */
     336#endif /* CONFIG_KCONSOLE */
    400337       
    401338        exc_register(VECTOR_DEBUG, "debugger", debug_exception);
     
    405342}
    406343
     344#ifdef CONFIG_KCONSOLE
     345/** Print table of active breakpoints */
     346int cmd_print_breakpoints(cmd_arg_t *argv __attribute__((unused)))
     347{
     348        unsigned int i;
     349        char *symbol;
     350
     351#ifdef __32_BITS__     
     352        printf("#  Count Address    In symbol\n");
     353        printf("-- ----- ---------- ---------\n");
     354#endif
     355
     356#ifdef __64_BITS__
     357        printf("#  Count Address            In symbol\n");
     358        printf("-- ----- ------------------ ---------\n");
     359#endif
     360       
     361        for (i = 0; i < BKPOINTS_MAX; i++)
     362                if (breakpoints[i].address) {
     363                        symbol = get_symtab_entry(breakpoints[i].address);
     364
     365#ifdef __32_BITS__
     366                        printf("%-2u %-5d %#10zx %s\n", i,
     367                            breakpoints[i].counter, breakpoints[i].address,
     368                            symbol);
     369#endif
     370
     371#ifdef __64_BITS__
     372                        printf("%-2u %-5d %#18zx %s\n", i,
     373                            breakpoints[i].counter, breakpoints[i].address,
     374                            symbol);
     375#endif
     376
     377                }
     378        return 1;
     379}
     380
     381#ifndef CONFIG_DEBUG_AS_WATCHPOINT
     382
     383/** Remove breakpoint from table */
     384int cmd_del_breakpoint(cmd_arg_t *argv)
     385{
     386        unative_t bpno = argv->intval;
     387        if (bpno > BKPOINTS_MAX) {
     388                printf("Invalid breakpoint number.\n");
     389                return 0;
     390        }
     391        breakpoint_del(argv->intval);
     392        return 1;
     393}
     394
     395/** Add new breakpoint to table */
     396static int cmd_add_breakpoint(cmd_arg_t *argv)
     397{
     398        int flags;
     399        int id;
     400
     401        if (argv == &add_argv) {
     402                flags = BKPOINT_INSTR;
     403        } else { /* addwatchp */
     404                flags = BKPOINT_WRITE;
     405        }
     406        printf("Adding breakpoint on address: %p\n", argv->intval);
     407        id = breakpoint_add((void *)argv->intval, flags, -1);
     408        if (id < 0)
     409                printf("Add breakpoint failed.\n");
     410        else
     411                printf("Added breakpoint %d.\n", id);
     412       
     413        return 1;
     414}
     415#endif /* CONFIG_DEBUG_AS_WATCHPOINT */
     416#endif /* CONFIG_KCONSOLE */
     417
    407418/** @}
    408419 */
  • kernel/arch/ia32/include/drivers/ega.h

    r8fe5980 r76fca31  
    4141#define SCREEN          (ROW * ROWS)
    4242
     43extern void ega_redraw(void);
    4344extern void ega_init(void);
    4445
  • kernel/arch/ia32/include/drivers/vesa.h

    r8fe5980 r76fca31  
    3737
    3838extern int vesa_present(void);
     39extern void vesa_redraw(void);
    3940extern void vesa_init(void);
    4041
  • kernel/arch/ia32/src/cpu/cpu.c

    r8fe5980 r76fca31  
    6666static char *vendor_str[] = {
    6767        "Unknown Vendor",
    68         "AuthenticAMD",
    69         "GenuineIntel"
     68        "AMD",
     69        "Intel"
    7070};
    7171
     
    7878                :
    7979                :
    80                 :"%eax"
     80                : "%eax"
    8181        );
    8282}
     
    9090                :
    9191                :
    92                 :"%eax"
     92                : "%eax"
    9393        );     
    9494}
     
    141141                 * Check for AMD processor.
    142142                 */
    143                 if (info.cpuid_ebx==AMD_CPUID_EBX && info.cpuid_ecx==AMD_CPUID_ECX && info.cpuid_edx==AMD_CPUID_EDX) {
     143                if ((info.cpuid_ebx == AMD_CPUID_EBX)
     144                    && (info.cpuid_ecx == AMD_CPUID_ECX)
     145                        && (info.cpuid_edx == AMD_CPUID_EDX))
    144146                        CPU->arch.vendor = VendorAMD;
    145                 }
    146 
     147               
    147148                /*
    148149                 * Check for Intel processor.
    149150                 */             
    150                 if (info.cpuid_ebx==INTEL_CPUID_EBX && info.cpuid_ecx==INTEL_CPUID_ECX && info.cpuid_edx==INTEL_CPUID_EDX) {
     151                if ((info.cpuid_ebx == INTEL_CPUID_EBX)
     152                    && (info.cpuid_ecx == INTEL_CPUID_ECX)
     153                        && (info.cpuid_edx == INTEL_CPUID_EDX))
    151154                        CPU->arch.vendor = VendorIntel;
    152                 }
    153                                
     155               
    154156                cpuid(1, &info);
    155                 CPU->arch.family = (info.cpuid_eax>>8)&0xf;
    156                 CPU->arch.model = (info.cpuid_eax>>4)&0xf;
    157                 CPU->arch.stepping = (info.cpuid_eax>>0)&0xf;                                           
     157                CPU->arch.family = (info.cpuid_eax >> 8) & 0x0f;
     158                CPU->arch.model = (info.cpuid_eax >> 4) & 0x0f;
     159                CPU->arch.stepping = (info.cpuid_eax >> 0) & 0x0f;                                             
    158160        }
    159161}
    160162
    161 void cpu_print_report(cpu_t* m)
     163void cpu_print_report(cpu_t* cpu)
    162164{
    163         printf("cpu%d: (%s family=%d model=%d stepping=%d) %dMHz\n",
    164                 m->id, vendor_str[m->arch.vendor], m->arch.family, m->arch.model, m->arch.stepping,
    165                 m->frequency_mhz);
     165        printf("cpu%u: (%s family=%u model=%u stepping=%u) %" PRIu16 " MHz\n",
     166                cpu->id, vendor_str[cpu->arch.vendor], cpu->arch.family,
     167                cpu->arch.model, cpu->arch.stepping, cpu->frequency_mhz);
    166168}
    167169
  • kernel/arch/ia32/src/drivers/vesa.c

    r8fe5980 r76fca31  
    9898}
    9999
     100void vesa_redraw(void)
     101{
     102        fb_redraw();
     103}
     104
    100105#endif
    101106
  • kernel/arch/ia32/src/ia32.c

    r8fe5980 r76fca31  
    9494                else
    9595#endif
    96                         ega_init();     /* video */
     96                        ega_init(); /* video */
    9797               
    9898                /* Enable debugger */
     
    160160void arch_grab_console(void)
    161161{
     162#ifdef CONFIG_FB
     163        vesa_redraw();
     164#else
     165        ega_redraw();
     166#endif
     167       
    162168        i8042_grab();
    163169}
     170
    164171/** Return console to userspace
    165172 *
  • kernel/arch/mips32/src/cpu/cpu.c

    r8fe5980 r76fca31  
    4949        { "MIPS", "R3000" },            /* 0x02 */
    5050        { "MIPS", "R6000" },            /* 0x03 */
    51         { "MIPS", " R4000/R4400" },     /* 0x04 */
     51        { "MIPS", "R4000/R4400" },      /* 0x04 */
    5252        { "LSI Logic", "R3000" },       /* 0x05 */
    5353        { "MIPS", "R6000A" },           /* 0x06 */
     
    124124        }
    125125
    126         printf("cpu%d: %s %s (rev=%d.%d, imp=%d)\n",
     126        printf("cpu%u: %s %s (rev=%d.%d, imp=%d)\n",
    127127                m->id, data->vendor, data->model, m->arch.rev_num >> 4,
    128                 m->arch.rev_num & 0xf, m->arch.imp_num);
     128                m->arch.rev_num & 0x0f, m->arch.imp_num);
    129129}
    130130
  • kernel/arch/mips32/src/debugger.c

    r8fe5980 r76fca31  
    4747bpinfo_t breakpoints[BKPOINTS_MAX];
    4848SPINLOCK_INITIALIZE(bkpoint_lock);
     49
     50#ifdef CONFIG_KCONSOLE
    4951
    5052static int cmd_print_breakpoints(cmd_arg_t *argv);
     
    124126};
    125127
     128
    126129/** Test, if the given instruction is a jump or branch instruction
    127130 *
    128131 * @param instr Instruction code
    129132 * @return true - it is jump instruction, false otherwise
     133 *
    130134 */
    131135static bool is_jump(unative_t instr)
     
    268272}
    269273
     274#endif
     275
    270276/** Initialize debugger */
    271277void debugger_init()
     
    275281        for (i = 0; i < BKPOINTS_MAX; i++)
    276282                breakpoints[i].address = NULL;
    277        
     283
     284#ifdef CONFIG_KCONSOLE
    278285        cmd_initialize(&bkpts_info);
    279286        if (!cmd_register(&bkpts_info))
    280                 panic("could not register command %s\n", bkpts_info.name);
     287                printf("Cannot register command %s\n", bkpts_info.name);
    281288
    282289        cmd_initialize(&delbkpt_info);
    283290        if (!cmd_register(&delbkpt_info))
    284                 panic("could not register command %s\n", delbkpt_info.name);
     291                printf("Cannot register command %s\n", delbkpt_info.name);
    285292
    286293        cmd_initialize(&addbkpt_info);
    287294        if (!cmd_register(&addbkpt_info))
    288                 panic("could not register command %s\n", addbkpt_info.name);
     295                printf("Cannot register command %s\n", addbkpt_info.name);
    289296
    290297        cmd_initialize(&addbkpte_info);
    291298        if (!cmd_register(&addbkpte_info))
    292                 panic("could not register command %s\n", addbkpte_info.name);
     299                printf("Cannot register command %s\n", addbkpte_info.name);
     300#endif
    293301}
    294302
     
    368376                        cur->bkfunc(cur, istate);
    369377        } else {
    370                 printf("***Type 'exit' to exit kconsole.\n");
     378#ifdef CONFIG_KCONSOLE
    371379                /* This disables all other processors - we are not SMP,
    372380                 * actually this gets us to cpu_halt, if scheduler() is run
     
    374382                 *   so this is a good idea
    375383                 */     
    376                 atomic_set(&haltstate,1);
     384                atomic_set(&haltstate, 1);
    377385                spinlock_unlock(&bkpoint_lock);
    378 
    379                 kconsole("debug");
    380 
     386               
     387                kconsole("debug", "Debug console ready (type 'exit' to continue)\n", false);
     388               
    381389                spinlock_lock(&bkpoint_lock);
    382                 atomic_set(&haltstate,0);
     390                atomic_set(&haltstate, 0);
     391#endif
    383392        }
    384393        if (cur && cur->address == fireaddr && (cur->flags & BKPOINT_INPROG)) {
  • kernel/arch/mips32/src/exception.c

    r8fe5980 r76fca31  
    4646#include <interrupt.h>
    4747#include <func.h>
    48 #include <console/kconsole.h>
    4948#include <ddi/irq.h>
    5049#include <arch/debugger.h>
Note: See TracChangeset for help on using the changeset viewer.