Fixes
authorlekernel <sebastien.bourdeauducq@lekernel.net>
Fri, 13 Nov 2009 18:23:28 +0000 (19:23 +0100)
committerlekernel <sebastien.bourdeauducq@lekernel.net>
Fri, 13 Nov 2009 18:23:28 +0000 (19:23 +0100)
cores/sysctl/rtl/sysctl.v
software/demo/cpustats.c
software/demo/isr.c
software/include/hw/sysctl.h
software/libbase/uart-async.c
software/libhal/pfpu.c
software/libhal/ps2.c
software/libhal/slowout.c
software/libhal/snd.c
software/libhal/time.c
software/libhal/tmu.c

index 1736e43..cca95b2 100644 (file)
@@ -68,7 +68,6 @@ end
  * Dual timer
  */
 
-reg trig0, trig1;
 reg en0, en1;
 reg ar0, ar1;
 reg [31:0] counter0, counter1;
@@ -97,8 +96,6 @@ always @(posedge sys_clk) begin
                en1 <= 1'b0;
                ar0 <= 1'b0;
                ar1 <= 1'b0;
-               trig0 <= 1'b0;
-               trig1 <= 1'b0;
                counter0 <= 32'd0;
                counter1 <= 32'd0;
                compare0 <= 32'hFFFFFFFF;
@@ -109,19 +106,13 @@ always @(posedge sys_clk) begin
 
                /* 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;
        
@@ -137,18 +128,16 @@ always @(posedge sys_clk) begin
                                        
                                        /* 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;
@@ -163,12 +152,12 @@ always @(posedge sys_clk) begin
                                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;
                                
index 8bc70a5..361bea5 100644 (file)
@@ -15,6 +15,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <stdio.h>
 #include <irq.h>
 
 #include <hal/time.h>
@@ -44,6 +45,11 @@ void cpustats_tick()
        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);
index cad0d9e..42968a1 100644 (file)
@@ -65,10 +65,10 @@ void isr()
        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();
 }
index 1d03808..56b92b8 100644 (file)
@@ -32,9 +32,8 @@
 #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)
 
index 578d631..1c061c4 100644 (file)
@@ -36,6 +36,7 @@ static volatile unsigned int rx_consume;
 
 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;
 }
@@ -67,6 +68,7 @@ static int force_sync;
 
 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;
index 445051f..d5b51c4 100644 (file)
@@ -102,6 +102,7 @@ static void pfpu_start(struct pfpu_td *td)
 
 void pfpu_isr()
 {
+       irq_ack(IRQ_PFPU);
        if(queue[consume]->update)
                update_registers(queue[consume]->registers);
        if(queue[consume]->invalidate) {
index 43d0500..eee3dfc 100644 (file)
@@ -49,6 +49,7 @@ void ps2_init()
 
 void ps2_isr()
 {
+       irq_ack(IRQ_PS2);
        if(level >= QSIZE) {
                printf("PS2: queue overflow\n");
                return;
index a2cd749..ad42bcf 100644 (file)
@@ -68,6 +68,7 @@ static void slowout_start(struct slowout_operation *op)
 
 void slowout_isr()
 {
+       irq_ack(IRQ_TIMER1);
        consume = (consume + 1) & OPQ_MASK;
        level--;
        if(level > 0)
index 8a31c64..b0c4231 100644 (file)
@@ -76,13 +76,15 @@ void snd_init()
 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)
@@ -129,6 +131,7 @@ static void play_start(short *buffer)
 
 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);
 
@@ -241,6 +244,8 @@ static void record_start(short *buffer)
 
 void snd_isr_dmaw()
 {
+       irq_ack(IRQ_AC97DMAW);
+
        asm volatile( /* Invalidate Level-1 data cache */
                "wcsr DCC, r0\n"
                "nop\n"
index 7844e92..93aba81 100644 (file)
@@ -46,6 +46,7 @@ void time_init()
 
 void time_isr()
 {
+       irq_ack(IRQ_TIMER0);
        sec++;
        time_tick();
 }
@@ -53,12 +54,12 @@ void time_isr()
 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);
 
@@ -70,7 +71,7 @@ void time_get(struct timestamp *ts)
         * 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++;
        }
index 721970f..c91f2f7 100644 (file)
@@ -73,6 +73,7 @@ static void tmu_start(struct tmu_td *td)
 
 void tmu_isr()
 {
+       irq_ack(IRQ_TMU);
        if(queue[consume]->callback)
                queue[consume]->callback(queue[consume]);
        if(queue[consume]->profile) {