move the gecko upload client out of irq context

This commit is contained in:
dhewg 2010-08-05 18:11:16 +02:00
parent 37cee63ed9
commit a7b9770cbf
5 changed files with 15 additions and 21 deletions

19
gecko.c
View File

@ -24,6 +24,7 @@ Copyright (C) 2009 Andre Heider "dhewg" <dhewg@wiibrew.org>
#include "powerpc_elf.h"
#include "gecko.h"
static u8 gecko_found = 0;
static u8 gecko_console_enabled = 0;
static u32 _gecko_command(u32 command)
@ -207,13 +208,12 @@ void gecko_init(void)
write32(EXI0_CSR, 0);
write32(EXI1_CSR, 0);
write32(EXI2_CSR, 0);
write32(EXI0_CSR, 0x2000);
write32(EXI0_CSR, 3<<10);
write32(EXI1_CSR, 3<<10);
if (!gecko_isalive())
return;
gecko_found = 1;
gecko_flush();
gecko_console_enabled = 1;
}
@ -269,17 +269,12 @@ static u32 _gecko_receive_left = 0;
static u32 _gecko_receive_len = 0;
static u8 *_gecko_receive_buffer = NULL;
void gecko_timer_initialize(void)
{
if (!gecko_isalive())
return;
irq_set_alarm(20, 1);
}
void gecko_timer(void) {
void gecko_process(void) {
u8 b;
if (!gecko_found)
return;
if (_gecko_cmd_start_time && read32(HW_TIMER) >
(_gecko_cmd_start_time + IRQ_ALARM_MS2REG(5000)))
goto cleanup;

View File

@ -27,14 +27,13 @@ u8 gecko_enable_console(const u8 enable);
int gecko_printf(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
#endif
void gecko_timer_initialize(void);
void gecko_timer(void);
void gecko_process(void);
#else
#define gecko_init(...) do { } while(0)
#define gecko_enable_console(...) do { } while(0)
#define gecko_printf(...) do { } while(0)
#define gecko_timer_initialize(...) do { } while(0)
#define gecko_process(...) do { } while(0)
#define gecko_timer(...) do { } while(0)
#endif

2
ipc.c
View File

@ -343,6 +343,8 @@ u32 ipc_process_slow(void)
if (!vector)
{
gecko_process();
u32 cookie = irq_kill();
if(slow_queue_head == slow_queue_tail)
irq_wait();

6
irq.c
View File

@ -54,11 +54,9 @@ void irq_handler(void)
flags = flags & enabled;
if(flags & IRQF_TIMER) {
if (_alarm_frequency) {
// currently we use the alarm timer only for lame usbgecko polling
gecko_timer();
if (_alarm_frequency)
write32(HW_ALARM, read32(HW_TIMER) + _alarm_frequency);
}
write32(HW_ARMIRQFLAG, IRQF_TIMER);
}
if(flags & IRQF_NAND) {

4
main.c
View File

@ -55,11 +55,11 @@ u32 _main(void *base)
read32(0xffffff0c), read32(0xffffff10), read32(0xffffff14));
irq_initialize();
irq_enable(IRQ_TIMER);
// irq_enable(IRQ_GPIO1B);
irq_enable(IRQ_GPIO1);
irq_enable(IRQ_RESET);
gecko_timer_initialize();
irq_enable(IRQ_TIMER);
irq_set_alarm(20, 1);
gecko_printf("Interrupts initialized\n");
crypto_initialize();