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 extern void reset_cpu(ulong addr);
34 /* we always count down the max. */
35 #define TIMER_LOAD_VAL 0xffff
37 /* macro to read the 16 bit timer */
38 #define READ_TIMER (TCNTO1 & 0xffff)
41 #error CONFIG_USE_IRQ NOT supported
43 void enable_interrupts (void)
47 int disable_interrupts (void)
56 panic ("Resetting CPU ...\n");
60 void show_regs (struct pt_regs *regs)
63 const char *processor_modes[] =
64 { "USER_26", "FIQ_26", "IRQ_26", "SVC_26", "UK4_26", "UK5_26",
66 "UK8_26", "UK9_26", "UK10_26", "UK11_26", "UK12_26", "UK13_26",
68 "USER_32", "FIQ_32", "IRQ_32", "SVC_32", "UK4_32", "UK5_32",
70 "UK8_32", "UK9_32", "UK10_32", "UND_32", "UK12_32", "UK13_32",
74 flags = condition_codes (regs);
76 printf ("pc : [<%08lx>] lr : [<%08lx>]\n"
77 "sp : %08lx ip : %08lx fp : %08lx\n",
78 instruction_pointer (regs),
79 regs->ARM_lr, regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
80 printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
81 regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
82 printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
83 regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
84 printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
85 regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
86 printf ("Flags: %c%c%c%c",
87 flags & CC_N_BIT ? 'N' : 'n',
88 flags & CC_Z_BIT ? 'Z' : 'z',
89 flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
90 printf (" IRQs %s FIQs %s Mode %s%s\n",
91 interrupts_enabled (regs) ? "on" : "off",
92 fast_interrupts_enabled (regs) ? "on" : "off",
93 processor_modes[processor_mode (regs)],
94 thumb_mode (regs) ? " (T)" : "");
97 void do_undefined_instruction (struct pt_regs *pt_regs)
99 printf ("undefined instruction\n");
104 void do_software_interrupt (struct pt_regs *pt_regs)
106 printf ("software interrupt\n");
111 void do_prefetch_abort (struct pt_regs *pt_regs)
113 printf ("prefetch abort\n");
118 void do_data_abort (struct pt_regs *pt_regs)
120 printf ("data abort\n");
125 void do_not_used (struct pt_regs *pt_regs)
127 printf ("not used\n");
132 void do_fiq (struct pt_regs *pt_regs)
134 printf ("fast interrupt request\n");
139 void do_irq (struct pt_regs *pt_regs)
141 printf ("interrupt request\n");
146 static ulong timestamp;
147 static ulong lastdec;
149 int interrupt_init (void)
154 TCNTB1 = TIMER_LOAD_VAL;
160 lastdec = TCNTB1 = TIMER_LOAD_VAL;
166 * timer without interrupts
169 void reset_timer (void)
171 reset_timer_masked ();
174 ulong get_timer (ulong base)
176 return get_timer_masked () - base;
179 void set_timer (ulong t)
184 void udelay (unsigned long usec)
192 tmo += get_timer (0);
194 while (get_timer_masked () < tmo)
198 void reset_timer_masked (void)
201 lastdec = READ_TIMER;
205 ulong get_timer_masked (void)
207 ulong now = READ_TIMER;
209 if (lastdec >= now) {
211 timestamp += lastdec - now;
213 /* we have an overflow ... */
214 timestamp += lastdec + TIMER_LOAD_VAL - now;
221 void udelay_masked (unsigned long usec)
229 tmo += get_timer (0);
231 reset_timer_masked ();
233 while (get_timer_masked () < tmo)