* Dual timer
*/
-reg trig0, trig1;
reg en0, en1;
reg ar0, ar1;
reg [31:0] counter0, counter1;
en1 <= 1'b0;
ar0 <= 1'b0;
ar1 <= 1'b0;
- trig0 <= 1'b0;
- trig1 <= 1'b0;
counter0 <= 32'd0;
counter1 <= 32'd0;
compare0 <= 32'hFFFFFFFF;
/* Handle timer 0 */
if( en0 & ~match0) counter0 <= counter0 + 32'd1;
- if( en0 & match0) begin
- trig0 <= 1'b1;
- timer0_irq <= 1'b1;
- end
+ if( en0 & match0) timer0_irq <= 1'b1;
if( ar0 & match0) counter0 <= 32'd1;
if(~ar0 & match0) en0 <= 1'b0;
/* Handle timer 1 */
if( en1 & ~match1) counter1 <= counter1 + 32'd1;
- if( en1 & match1) begin
- trig1 <= 1'b1;
- timer1_irq <= 1'b1;
- end
+ if( en1 & match1) timer1_irq <= 1'b1;
if( ar1 & match1) counter1 <= 32'd1;
if(~ar1 & match1) en1 <= 1'b0;
/* Timer 0 registers */
4'b0100: begin
- trig0 <= 1'b0;
+ en0 <= csr_di[0];
ar0 <= csr_di[1];
- en0 <= csr_di[2];
end
4'b0101: compare0 <= csr_di;
4'b0110: counter0 <= csr_di;
/* Timer 1 registers */
4'b1000: begin
- trig1 <= 1'b0;
+ en1 <= csr_di[0];
ar1 <= csr_di[1];
- en1 <= csr_di[2];
end
4'b1001: compare1 <= csr_di;
4'b1010: counter1 <= csr_di;
4'b0010: csr_do <= gpio_irqen;
/* Timer 0 registers */
- 4'b0100: csr_do <= {en0, ar0, trig0};
+ 4'b0100: csr_do <= {ar0, en0};
4'b0101: csr_do <= compare0;
4'b0110: csr_do <= counter0;
/* Timer 1 registers */
- 4'b1000: csr_do <= {en1, ar1, trig1};
+ 4'b1000: csr_do <= {ar1, en1};
4'b1001: csr_do <= compare1;
4'b1010: csr_do <= counter1;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
#include <irq.h>
#include <hal/time.h>
struct timestamp diff;
int usec;
+ if(enter_count == 0) {
+ printf("cpustats_tick() called with enter_count == 0!\n");
+ return;
+ }
+
time_get(&ts);
time_diff(&diff, &ts, &first_enter);
time_add(&acc, &diff);
if(irqs & IRQ_PS2)
ps2_isr();
- if(irqs & IRQ_GPIO)
+ if(irqs & IRQ_GPIO) {
+ irq_ack(IRQ_GPIO);
ui_isr_key();
-
- irq_ack(irqs);
+ }
cpustats_leave();
}
#define CSR_TIMER1_COMPARE MMPTR(0x80001024)
#define CSR_TIMER1_COUNTER MMPTR(0x80001028)
-#define TIMER_MATCH (0x01)
-#define TIMER_AUTORESTART (0x02)
-#define TIMER_ENABLE (0x04)
+#define TIMER_AUTORESTART (0x01)
+#define TIMER_ENABLE (0x02)
#define CSR_SYSTEM_ID MMPTR(0x8000103c)
void uart_async_isr_rx()
{
+ irq_ack(IRQ_UARTRX);
rx_buf[rx_produce] = CSR_UART_RXTX;
rx_produce = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX;
}
void uart_async_isr_tx()
{
+ irq_ack(IRQ_UARTTX);
if(tx_produce != tx_consume) {
CSR_UART_RXTX = tx_buf[tx_consume];
tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX;
void pfpu_isr()
{
+ irq_ack(IRQ_PFPU);
if(queue[consume]->update)
update_registers(queue[consume]->registers);
if(queue[consume]->invalidate) {
void ps2_isr()
{
+ irq_ack(IRQ_PS2);
if(level >= QSIZE) {
printf("PS2: queue overflow\n");
return;
void slowout_isr()
{
+ irq_ack(IRQ_TIMER1);
consume = (consume + 1) & OPQ_MASK;
level--;
if(level > 0)
void snd_isr_crrequest()
{
snd_cr_request = 1;
- CSR_AC97_CRCTL = AC97_CRCTL_REQUEST; /* Ack interrupt */
+ CSR_AC97_CRCTL = AC97_CRCTL_REQUEST;
+ irq_ack(IRQ_AC97CRREQUEST);
}
void snd_isr_crreply()
{
snd_cr_reply = 1;
- CSR_AC97_CRCTL = AC97_CRCTL_REPLY; /* Ack interrupt */
+ CSR_AC97_CRCTL = AC97_CRCTL_REPLY;
+ irq_ack(IRQ_AC97CRREPLY);
}
unsigned int snd_ac97_read(unsigned int addr)
void snd_isr_dmar()
{
+ irq_ack(IRQ_AC97DMAR);
/* NB. the callback can give us buffers by calling snd_play_refill() */
play_callback(play_queue[play_consume], play_user);
void snd_isr_dmaw()
{
+ irq_ack(IRQ_AC97DMAW);
+
asm volatile( /* Invalidate Level-1 data cache */
"wcsr DCC, r0\n"
"nop\n"
void time_isr()
{
+ irq_ack(IRQ_TIMER0);
sec++;
time_tick();
}
void time_get(struct timestamp *ts)
{
unsigned int oldmask = 0;
- unsigned int ctl, counter, sec2;
+ unsigned int pending, counter, sec2;
oldmask = irq_getmask();
irq_setmask(oldmask & ~(IRQ_TIMER0));
counter = CSR_TIMER0_COUNTER;
- ctl = CSR_TIMER0_CONTROL;
+ pending = irq_pending() & IRQ_TIMER0;
sec2 = sec;
irq_setmask(oldmask);
* the overflow was already present when we read the counter
* value.
*/
- if(ctl & TIMER_MATCH) {
+ if(pending) {
if(counter < (brd_desc->clk_frequency/2))
ts->sec++;
}
void tmu_isr()
{
+ irq_ack(IRQ_TMU);
if(queue[consume]->callback)
queue[consume]->callback(queue[consume]);
if(queue[consume]->profile) {