replace hw access with system command on boot seq.

This commit is contained in:
optixx 2009-10-18 10:27:09 +02:00
parent 596a26323a
commit a9a366895a
8 changed files with 53 additions and 23 deletions

View File

@ -16,7 +16,7 @@
# Author: Christian Starkjohann
# =====================================================================================
DEBUG = 0
DEBUG = 1
TTY = /dev/tty.PL2303-00002126
DEVICE = atmega644
F_CPU = 20000000

View File

@ -31,6 +31,8 @@
#include "usbdrv.h"
#include "rle.h"
#include "loader.h"
#include "system.h"
extern usb_transaction_t usb_trans;
@ -93,13 +95,9 @@ void boot_startup_rom(uint16_t init_delay)
{
uint8_t i;
uint32_t addr = 0x000000;
info_P(PSTR("Fetch loader rom\n"));
info_P(PSTR("Activate AVR bus\n"));
avr_bus_active();
info_P(PSTR("IRQ off\n"));
snes_irq_lo();
snes_irq_off();
snes_lorom();
system_set_bus_avr();
system_snes_irq_off();
system_set_rom_lorom();
for (i=0; i<ROM_BUFFER_CNT; i++){
addr += rle_decode(_rom[i], _rom_size[i], addr);
}
@ -112,14 +110,9 @@ void boot_startup_rom(uint16_t init_delay)
info(PSTR("crc=%x\n"),crc);
#endif
snes_irq_lo();
snes_irq_off();
snes_hirom();
snes_wr_disable();
snes_bus_active();
info_P(PSTR("Activate SNES bus\n"));
send_reset();
system_set_rom_hirom();
system_set_bus_snes();
system_send_snes_reset();
_delay_ms(init_delay);
}

View File

@ -1,6 +1,6 @@
/*
File: qd16boot01.smc
Time: Sat, 17 Oct 2009 16:53:02
Time: Sun, 18 Oct 2009 09:40:40
*/
#ifndef __FIFO_H__
#define __FIFO_H__

View File

@ -245,6 +245,7 @@ void globals_init(){
int main(void)
{
#ifndef NO_DEBUG
uart_init();
stdout = &uart_stdout;
@ -260,7 +261,7 @@ int main(void)
pwm_stop();
usbInit();
usb_connect();
sei();
while (1) {
avr_bus_active();
info_P(PSTR("Activate AVR bus\n"));

View File

@ -86,6 +86,19 @@ void system_send_snes_irq()
snes_irq_off();
}
void system_snes_irq_off()
{
snes_irq_off();
system.irq_line = IRQ_OFF;
}
void system_snes_irq_on()
{
snes_irq_on();
system.irq_line = IRQ_ON;
}
void system_set_bus_avr()
{
avr_bus_active();
@ -104,8 +117,6 @@ void system_set_bus_snes()
snes_bus_active();
system.bus_mode = MODE_SNES;
info_P(PSTR("Activate SNES bus\n"));
irq_stop();
}
void system_set_rom_mode(usb_transaction_t *usb_trans)
@ -113,7 +124,7 @@ void system_set_rom_mode(usb_transaction_t *usb_trans)
if (usb_trans->req_bank_size == 0x8000) {
snes_lorom();
system.rom_mode = LOROM;
info_P(PSTR("Set SNES lowrom \n"));
info_P(PSTR("Set SNES lorom \n"));
} else {
snes_hirom();
system.rom_mode = HIROM;
@ -121,3 +132,17 @@ void system_set_rom_mode(usb_transaction_t *usb_trans)
}
}
void system_set_rom_lorom()
{
snes_lorom();
system.rom_mode = LOROM;
info_P(PSTR("Set SNES lorom \n"));
}
void system_set_rom_hirom()
{
snes_hirom();
system.rom_mode = HIROM;
info_P(PSTR("Set SNES hirom \n"));
}

View File

@ -23,6 +23,8 @@
#ifndef __SYSTEM_H__
#define __SYSTEM_H__
#include "requests.h"
typedef struct system_t {
@ -38,6 +40,15 @@ typedef struct system_t {
} system_t;
void system_init(void);
void system_init(void);
void system_send_snes_reset(void);
void system_send_snes_irq(void);
void system_set_bus_avr(void);
void system_set_bus_snes(void);
void system_set_rom_mode(usb_transaction_t *usb_trans);
void system_set_rom_hirom(void);
void system_set_rom_lorom(void);
void system_snes_irq_off(void);
#endif

View File

@ -35,6 +35,7 @@ if huffman == True:
os.unlink("/tmp/loader.rle")
os.unlink("/tmp/loader.rle.hfm")
cfile = open("/tmp/loader.c","w")
hfile = open("/tmp/loader.h","w")
@ -83,7 +84,6 @@ const char _rom%02i[ROM_BUFFER_SIZE%02i] PROGMEM = {
l = addr
h = addr + parts[idx]
addr+= parts[idx]
print l,h
for idx,c in enumerate(data[l:h]):
c = ord(c)
if idx<len(data)-1: