OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [src/] [generic/] [debug.c] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Basic debug information about the kernel
3
 *
4
 * Copyright (C) 2010 B Labs Ltd.
5
 *
6
 * Written by Bahadir Balban
7
 */
8
#include <l4/lib/printk.h>
9
#include <l4/generic/debug.h>
10
#include INC_SUBARCH(cpu.h)
11
#include <l4/generic/platform.h>
12
 
13
#if defined (CONFIG_DEBUG_ACCOUNTING)
14
 
15
struct system_accounting system_accounting;
16
 
17
void system_accounting_print(struct system_accounting *sys_acc)
18
{
19
        printk("System Operations Accounting:\n\n");
20
 
21
        printk("System calls:\n");
22
        printk("=============\n");
23
        printk("IPC: %llu\n", sys_acc->syscalls.ipc);
24
        printk("Thread Switch: %llu\n", sys_acc->syscalls.tswitch);
25
        printk("Thread Control: %llu\n", sys_acc->syscalls.tctrl);
26
        printk("Exchange Registers: %llu\n", sys_acc->syscalls.exregs);
27
        printk("Unmap: %llu\n", sys_acc->syscalls.unmap);
28
        printk("Irq Control: %llu\n", sys_acc->syscalls.irqctrl);
29
        printk("Map: %llu\n", sys_acc->syscalls.map);
30
        printk("Getid: %llu\n", sys_acc->syscalls.getid);
31
        printk("Capability Control: %llu\n", sys_acc->syscalls.capctrl);
32
        printk("Time: %llu\n", sys_acc->syscalls.time);
33
        printk("Mutex Control: %llu\n", sys_acc->syscalls.mutexctrl);
34
        printk("Cache Control: %llu\n", sys_acc->syscalls.cachectrl);
35
 
36
        printk("\nExceptions:\n");
37
        printk("===========\n");
38
        printk("System call: %llu\n", sys_acc->exceptions.syscall);
39
        printk("Data Abort: %llu\n", sys_acc->exceptions.data_abort);
40
        printk("Prefetch Abort: %llu\n", sys_acc->exceptions.prefetch_abort);
41
        printk("Irq: %llu\n", sys_acc->exceptions.irq);
42
        printk("Undef Abort: %llu\n", sys_acc->exceptions.undefined_abort);
43
        printk("Context Switch: %llu\n", sys_acc->task_ops.context_switch);
44
        printk("Space Switch: %llu\n", sys_acc->task_ops.space_switch);
45
 
46
        printk("\nCache operations:\n");
47
 
48
}
49
#endif
50
 
51
 
52
/*
53
 * For spinlock debugging
54
 */
55
#if defined (CONFIG_DEBUG_SPINLOCKS)
56
 
57
#include <l4/lib/bit.h>
58
 
59
#define DEBUG_SPINLOCK_TOTAL    10
60
 
61
DECLARE_PERCPU(static unsigned long, held_lock_array[DEBUG_SPINLOCK_TOTAL]);
62
DECLARE_PERCPU(static u32, held_lock_bitmap);
63
 
64
void spin_lock_record_check(void *lock_addr)
65
{
66
        int bit = 0;
67
 
68
        /*
69
         * Check if we already hold this lock
70
         */
71
        for (int i = 0; i < DEBUG_SPINLOCK_TOTAL; i++) {
72
                if (per_cpu(held_lock_array[i]) == (unsigned long)lock_addr) {
73
                        print_early("Spinlock already held.\n");
74
                        printk("lock_addr=%p\n", lock_addr);
75
                        BUG();
76
                }
77
        }
78
 
79
        /*
80
         * Add it as a new lock
81
         */
82
        bit = find_and_set_first_free_bit(&per_cpu(held_lock_bitmap),
83
                                          DEBUG_SPINLOCK_TOTAL);
84
        per_cpu(held_lock_array[bit]) = (unsigned long)lock_addr;
85
}
86
 
87
void spin_unlock_delete_check(void *lock_addr)
88
{
89
        /*
90
         * Check if already unlocked
91
         */
92
        if (*((unsigned int *)lock_addr) == 0) {
93
                print_early("Spinlock already unlocked.");
94
                BUG();
95
        }
96
 
97
        /*
98
         * Search for the value
99
         */
100
        for (int i = 0; i < DEBUG_SPINLOCK_TOTAL; i++) {
101
                if (per_cpu(held_lock_array[i]) == (unsigned long)lock_addr) {
102
                        /*
103
                         * Delete its entry
104
                         */
105
                        per_cpu(held_lock_array[i]) = 0;
106
                        BUG_ON(check_and_clear_bit(&per_cpu(held_lock_bitmap),
107
                                                   i) < 0);
108
                        return;
109
                }
110
        }
111
        /*
112
         * It must have been recorded
113
         */
114
        BUG();
115
}
116
 
117
#endif
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.