4 * http://www.dave-tech.it
5 * http://www.wawnet.biz
6 * mailto:info@wawnet.biz
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/hardware.h>
30 #include <asm/proc-armv/ptrace.h>
32 /* we always count down the max. */
33 #define TIMER_LOAD_VAL 0xffff
35 /* macro to read the 16 bit timer */
36 #define READ_TIMER (TCNTO1 & 0xffff)
39 #error CONFIG_USE_IRQ NOT supported
41 void enable_interrupts (void)
45 int disable_interrupts (void)
54 panic ("Resetting CPU ...\n");
58 void show_regs (struct pt_regs *regs)
61 const char *processor_modes[] =
62 { "USER_26", "FIQ_26", "IRQ_26", "SVC_26", "UK4_26", "UK5_26",
64 "UK8_26", "UK9_26", "UK10_26", "UK11_26", "UK12_26", "UK13_26",
66 "USER_32", "FIQ_32", "IRQ_32", "SVC_32", "UK4_32", "UK5_32",
68 "UK8_32", "UK9_32", "UK10_32", "UND_32", "UK12_32", "UK13_32",
72 flags = condition_codes (regs);
74 printf ("pc : [<%08lx>] lr : [<%08lx>]\n"
75 "sp : %08lx ip : %08lx fp : %08lx\n",
76 instruction_pointer (regs),
77 regs->ARM_lr, regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
78 printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
79 regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
80 printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
81 regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
82 printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
83 regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
84 printf ("Flags: %c%c%c%c",
85 flags & CC_N_BIT ? 'N' : 'n',
86 flags & CC_Z_BIT ? 'Z' : 'z',
87 flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
88 printf (" IRQs %s FIQs %s Mode %s%s\n",
89 interrupts_enabled (regs) ? "on" : "off",
90 fast_interrupts_enabled (regs) ? "on" : "off",
91 processor_modes[processor_mode (regs)],
92 thumb_mode (regs) ? " (T)" : "");
95 void do_undefined_instruction (struct pt_regs *pt_regs)
97 printf ("undefined instruction\n");
102 void do_software_interrupt (struct pt_regs *pt_regs)
104 printf ("software interrupt\n");
109 void do_prefetch_abort (struct pt_regs *pt_regs)
111 printf ("prefetch abort\n");
116 void do_data_abort (struct pt_regs *pt_regs)
118 printf ("data abort\n");
123 void do_not_used (struct pt_regs *pt_regs)
125 printf ("not used\n");
130 void do_fiq (struct pt_regs *pt_regs)
132 printf ("fast interrupt request\n");
137 void do_irq (struct pt_regs *pt_regs)
139 printf ("interrupt request\n");
144 static ulong timestamp;
145 static ulong lastdec;
147 int interrupt_init (void)
152 TCNTB1 = TIMER_LOAD_VAL;
158 lastdec = TCNTB1 = TIMER_LOAD_VAL;
164 * timer without interrupts
167 void reset_timer (void)
169 reset_timer_masked ();
172 ulong get_timer (ulong base)
174 return get_timer_masked () - base;
177 void set_timer (ulong t)
182 void udelay (unsigned long usec)
190 tmo += get_timer (0);
192 while (get_timer_masked () < tmo)
196 void reset_timer_masked (void)
199 lastdec = READ_TIMER;
203 ulong get_timer_masked (void)
205 ulong now = READ_TIMER;
207 if (lastdec >= now) {
209 timestamp += lastdec - now;
211 /* we have an overflow ... */
212 timestamp += lastdec + TIMER_LOAD_VAL - now;
219 void udelay_masked (unsigned long usec)
234 endtime = get_timer(0) + tmo;
237 ulong now = get_timer_masked ();
238 diff = endtime - now;