diff options
-rw-r--r-- | kernel/cpu/irq.c | 16 | ||||
-rw-r--r-- | kernel/drivers/uart.c | 4 | ||||
-rw-r--r-- | usr/main.c | 3 | ||||
-rw-r--r-- | usr/timed.c | 6 |
4 files changed, 18 insertions, 11 deletions
diff --git a/kernel/cpu/irq.c b/kernel/cpu/irq.c index 286f78d..09b3346 100644 --- a/kernel/cpu/irq.c +++ b/kernel/cpu/irq.c @@ -17,6 +17,7 @@ static unsigned long counter = 0; unsigned long c_irq_handler(void) { unsigned long source = load32(CORE0_IRQ_SOURCE); + unsigned long scheduled = 0; // Check if GPU Interrupt if (source & (1 << 8)) { // Check if UART Interrupt @@ -38,7 +39,7 @@ unsigned long c_irq_handler(void) if (irqs[UART_IRQ].handler != 0) { struct UartInfo* uart_info = irqs[UART_IRQ].handler_info; add_thread(irqs[UART_IRQ].handler, (void*)data, uart_info->priority); - return 1; + scheduled = 1; } } } @@ -47,6 +48,7 @@ unsigned long c_irq_handler(void) if (*GPEDS0 & g->pin) { add_thread(irqs[GPIO_BANK_1_IRQ].handler, 0, g->priority); *GPEDS0 = g->pin; + scheduled = 1; } } // Check if System Time Compare 0 Triggered the Interrupt @@ -58,7 +60,7 @@ unsigned long c_irq_handler(void) add_thread(irqs[SYS_TIMER_0_IRQ].handler, stinfo->arg, stinfo->priority); *nexttime = *timer_chi + stinfo->tick_rate; *timer_cs = SYS_TIMER_SC_M0; - return 1; + scheduled = 1; } // Check if System Time Compare 1 Triggered the Interrupt if (*(volatile unsigned long*)SYS_TIMER_CS & SYS_TIMER_SC_M1 && irqs[SYS_TIMER_1_IRQ].handler != 0) { @@ -69,7 +71,7 @@ unsigned long c_irq_handler(void) add_thread(irqs[SYS_TIMER_1_IRQ].handler, stinfo->arg, stinfo->priority); *nexttime = *timer_chi + stinfo->tick_rate; *timer_cs = SYS_TIMER_SC_M1; - return 1; + scheduled = 1; } // Check if System Time Compare 2 Triggered the Interrupt if (*(volatile unsigned long*)SYS_TIMER_CS & SYS_TIMER_SC_M2 && irqs[SYS_TIMER_2_IRQ].handler != 0) { @@ -80,7 +82,7 @@ unsigned long c_irq_handler(void) add_thread(irqs[SYS_TIMER_2_IRQ].handler, stinfo->arg, stinfo->priority); *nexttime = *timer_chi + stinfo->tick_rate; *timer_cs = SYS_TIMER_SC_M2; - return 1; + scheduled = 1; } // Check if System Time Compare 3 Triggered the Interrupt if (*(volatile unsigned long*)SYS_TIMER_CS & SYS_TIMER_SC_M3 && irqs[SYS_TIMER_3_IRQ].handler != 0) { @@ -91,7 +93,7 @@ unsigned long c_irq_handler(void) add_thread(irqs[SYS_TIMER_3_IRQ].handler, stinfo->arg, stinfo->priority); *nexttime = *timer_chi + stinfo->tick_rate; *timer_cs = SYS_TIMER_SC_M3; - return 1; + scheduled = 1; } } // Check if CNTV triggered the interrupt @@ -102,7 +104,7 @@ unsigned long c_irq_handler(void) if (counter % 0x6000 == 0) counter = 0; } - return 0; + return scheduled; } unsigned long c_fiq_handler(void) @@ -161,7 +163,7 @@ void subscribe_irq(unsigned long irq_num, void* handler, void* handler_info) case GPIO_BANK_1_IRQ: store32((1 << (49-32)), IRQ_ENABLE2); struct GPIOInfo* g = irqs[irq_num].handler_info; - *GPREN0 = g->pin; + *GPAREN0 = g->pin; break; } } diff --git a/kernel/drivers/uart.c b/kernel/drivers/uart.c index 68c70d6..2107a6f 100644 --- a/kernel/drivers/uart.c +++ b/kernel/drivers/uart.c @@ -31,8 +31,8 @@ void uart_init(void) // Clear pending interrupts store32(0x7FF, UART0_ICR); // Set to 3Mhz - store32(1, UART0_IBRD); - store32(40, UART0_FBRD); + store32(10, UART0_IBRD); + store32(20, UART0_FBRD); // Enable FIFO and 8 bit transmission store32((1<<4)|(1<<5)|(1<<6), UART0_LCRH); // Mask all interrupts @@ -35,7 +35,7 @@ static struct UartInfo UART_INFO = { }; static struct GPIOInfo gpinfo = { - .pin = (1<<16), + .pin = (1<<16 | 1<<12), .priority = 0, }; @@ -59,4 +59,5 @@ void main(void) subscribe_irq(GPIO_BANK_1_IRQ, gptest, &gpinfo); add_thread(loop, 0, 8); add_thread(consumer, 0, 3); + uart_string("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); } diff --git a/usr/timed.c b/usr/timed.c index fd4f923..5f3b52e 100644 --- a/usr/timed.c +++ b/usr/timed.c @@ -28,6 +28,8 @@ void consumer(void) void loop(void) { + unsigned long long ti, tf; + sys0_64(SYS_TIME, &ti); static char str[13]; static unsigned long previous = 0; char* start; @@ -49,8 +51,10 @@ void loop(void) // draw_hex32(0, 17, count++); // add_thread(producer, 0, 4); //} + sys0_64(SYS_TIME, &tf); + draw_hex32(0, 13, tf-ti); wait_msec(30000); - add_thread(loop, 0, 3); + //add_thread(loop, 0, 3); } void loopt(void) |