From 4ba6e5cc6f942d0bebc04ad5f1f20b07c00eb7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Sat, 30 Jan 2016 16:00:02 +0000 Subject: [PATCH] avoid FireTOS hang on boot --- BaS_gcc/BaS_gcc.files | 1 + BaS_gcc/Makefile | 8 +++---- BaS_gcc/include/version.h | 2 +- BaS_gcc/mcf5474.gdb | 4 ++-- BaS_gcc/memory_map.txt | 8 +++++++ BaS_gcc/pci/pci.c | 4 ++-- BaS_gcc/sys/BaS.c | 45 +++++++++++++++++++++++++++++++++------ BaS_gcc/sys/exceptions.S | 2 +- BaS_gcc/sys/sysinit.c | 6 +++--- 9 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 BaS_gcc/memory_map.txt diff --git a/BaS_gcc/BaS_gcc.files b/BaS_gcc/BaS_gcc.files index 2c483f2..00dfc0c 100644 --- a/BaS_gcc/BaS_gcc.files +++ b/BaS_gcc/BaS_gcc.files @@ -609,3 +609,4 @@ tos/pci_test/include/MCF5475_USB.h tos/pci_test/include/MCF5475_XLB.h tos/pci_test/include/MCF5475.h tos/pci_test/include/pci.h +memory_map.txt diff --git a/BaS_gcc/Makefile b/BaS_gcc/Makefile index 1172d54..b2272a7 100644 --- a/BaS_gcc/Makefile +++ b/BaS_gcc/Makefile @@ -10,7 +10,7 @@ # can be either "Y" or "N" (without quotes). "Y" for using the m68k-elf-, "N" for using the m68k-atari-mint # toolchain -COMPILE_ELF=N +COMPILE_ELF=Y ifeq (Y,$(COMPILE_ELF)) TCPREFIX=m68k-elf- @@ -51,7 +51,7 @@ CFLAGS_OPTIMIZED = -mcpu=5474 \ -Wa,--register-prefix-optional LDFLAGS= -TRGTDIRS= ./firebee ./m5484lite ./m54455 +TRGTDIRS= ./firebee ./m5484lite OBJDIRS=$(patsubst %, %/objs,$(TRGTDIRS)) TOOLDIR=util @@ -266,7 +266,7 @@ $(1)_MAPFILE=$(1)/$$(basename $$(FLASH_EXEC)).map $(1)/$$(FLASH_EXEC): $(1)/$(LIBBAS) $(LDCSRC) $(CPP) $(INCLUDE) -DOBJDIR=$(1)/objs -P -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCSRC) -o $(1)/$$(LDCFILE) #$(LD) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE) --cref -T $(1)/$$(LDCFILE) $(LDLIBS) -o $$@ - $(CC) -nostdlib -Wl,--oformat -Wl,$$(FORMAT) -Wl,-Map -Wl,$$($(1)_MAPFILE) -Wl,--cref -Wl,-T -Wl,$(1)/$$(LDCFILE) $(LDLIBS) -o $$@ + $(CC) $$(CFLAGS) -nostdlib -Wl,--oformat -Wl,$$(FORMAT) -Wl,-Map -Wl,$$($(1)_MAPFILE) -Wl,--cref -Wl,-T -Wl,$(1)/$$(LDCFILE) $(LDLIBS) -o $$@ ifeq ($(COMPILE_ELF),Y) $(OBJCOPY) -O srec $$@ $$(basename $$@).s19 else @@ -278,7 +278,7 @@ $(1)_MAPFILE_RAM=$(1)/$$(basename $$(RAM_EXEC)).map $(1)/$$(RAM_EXEC): $(1)/$(LIBBAS) $(LDCSRC) $(CPP) $(INCLUDE) -DCOMPILE_RAM -DOBJDIR=$(1)/objs -P -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCSRC) -o $(1)/$$(LDRFILE) #$(LD) $(LDFLAGS) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE_RAM) --cref -T $(1)/$$(LDRFILE) $(LDLIBS) -o $$@ - $(CC) -nostdlib -Wl,--oformat -Wl,$$(FORMAT) -Wl,-Map -Wl,$$($(1)_MAPFILE) -Wl,--cref -Wl,-T -Wl,$(1)/$$(LDRFILE) $(LDLIBS) -o $$@ + $(CC) $$(CFLAGS) -nostdlib -Wl,--oformat -Wl,$$(FORMAT) -Wl,-Map -Wl,$$($(1)_MAPFILE) -Wl,--cref -Wl,-T -Wl,$(1)/$$(LDRFILE) $(LDLIBS) -o $$@ ifeq ($(COMPILE_ELF),Y) $(OBJCOPY) -O srec $$@ $$(basename $$@).s19 else diff --git a/BaS_gcc/include/version.h b/BaS_gcc/include/version.h index 53f03ab..75a1b92 100644 --- a/BaS_gcc/include/version.h +++ b/BaS_gcc/include/version.h @@ -29,7 +29,7 @@ */ #define MAJOR_VERSION 0 -#define MINOR_VERSION 87 +#define MINOR_VERSION 88 #endif /* VERSION_H_ */ diff --git a/BaS_gcc/mcf5474.gdb b/BaS_gcc/mcf5474.gdb index 08d77f3..a7cf98b 100644 --- a/BaS_gcc/mcf5474.gdb +++ b/BaS_gcc/mcf5474.gdb @@ -65,7 +65,7 @@ define run continue end -tbtr +tr ib -add-symbol-file ../emutos/emutos2.img 0xe00000 +#add-symbol-file ../emutos/emutos2.img 0xe00000 #load firebee/ram.elf diff --git a/BaS_gcc/memory_map.txt b/BaS_gcc/memory_map.txt new file mode 100644 index 0000000..58acb8b --- /dev/null +++ b/BaS_gcc/memory_map.txt @@ -0,0 +1,8 @@ +Firebee memory map +================== + + Virt. Start Virt. End Phys. Start Phys. End +ST-RAM 0x00000000 0x00dfffff 0x60000000 0x60dfffff +TOS 0x00e00000 0x00efffff 0x00e00000 0x00efffff +ST I/O area 0x00f00000 0x01000000 0xfff00000 0xffffffff +TT-RAM 0x01000000 0x20ffffff 0x00000000 0x1fffffff diff --git a/BaS_gcc/pci/pci.c b/BaS_gcc/pci/pci.c index 23a0d6d..aa0dbae 100644 --- a/BaS_gcc/pci/pci.c +++ b/BaS_gcc/pci/pci.c @@ -33,7 +33,7 @@ #include "interrupts.h" #include "wait.h" -#define DEBUG_PCI +//#define DEBUG_PCI #ifdef DEBUG_PCI #define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0) #else @@ -1131,7 +1131,7 @@ void init_eport(void) MCF_EPORT_EPDDR = 0; /* clear data direction register. All pins as input */ MCF_EPORT_EPFR = -1; /* clear all EPORT interrupt flags */ - // MCF_EPORT_EPIER = 0xfe; /* enable all EPORT interrupts (for now) */ + MCF_EPORT_EPIER = 0xfe; /* enable all EPORT interrupts (for now) */ } void init_xlbus_arbiter(void) diff --git a/BaS_gcc/sys/BaS.c b/BaS_gcc/sys/BaS.c index edfdc70..7b07469 100644 --- a/BaS_gcc/sys/BaS.c +++ b/BaS_gcc/sys/BaS.c @@ -423,16 +423,17 @@ void BaS(void) xprintf("finished\r\n"); xprintf("enable video: "); + /* * video setup (25MHz) */ - * (volatile uint32_t *) (0xf0000410 + 0) = 0x032002ba; /* horizontal 640x480 */ - * (volatile uint32_t *) (0xf0000410 + 4) = 0x020c020a; /* vertical 640x480 */ - * (volatile uint32_t *) (0xf0000410 + 8) = 0x0190015d; /* horizontal 320x240 */ - * (volatile uint32_t *) (0xf0000410 + 12) = 0x020C020A; /* vertical 320x230 */ + * (volatile uint32_t *) 0xf0000410 = 0x032002ba; /* horizontal 640x480 */ + * (volatile uint32_t *) 0xf0000414 = 0x020c020a; /* vertical 640x480 */ + * (volatile uint32_t *) 0xf0000418 = 0x0190015d; /* horizontal 320x240 */ + * (volatile uint32_t *) 0xf000041c = 0x020c020a; /* vertical 320x230 */ /* fifo on, refresh on, ddrcs and cke on, video dac on */ - * (volatile uint32_t *) (0xf0000410 - 0x20) = 0x01070002; + * (volatile uint32_t *) 0xf0000400 = 0x01070082; xprintf("finished\r\n"); #endif /* MACHINE_FIREBEE */ @@ -442,7 +443,7 @@ void BaS(void) /* * memory setup */ - memset((void *) 0x400, 0, 0x400); + memset((void *) 0x200, 0, 0x400); #if defined(MACHINE_FIREBEE) /* set Falcon bus control register */ @@ -483,6 +484,7 @@ void BaS(void) enable_coldfire_interrupts(); MCF_INTC_IMRH = 0; MCF_INTC_IMRL = 0; + dma_irq_enable(); fec_irq_enable(0, 5, 1); @@ -495,6 +497,37 @@ void BaS(void) set_ipl(7); /* disable interrupts */ + /* + * start FireTOS if DIP switch is set accordingly + */ + if (!(DIP_SWITCH & (1 << 6))) + { + extern uint8_t _FIRETOS[]; +#define FIRETOS ((uint32_t)_FIRETOS) /* where FireTOS is stored in flash */ + + /* make sure MMU is disabled */ + MCF_MMU_MMUCR = 0; /* MMU off */ + NOP(); /* force pipeline sync */ + + /* ST RAM */ + + * (uint32_t *) 0x42e = STRAM_END; /* phystop TOS system variable */ + * (uint32_t *) 0x420 = 0x752019f3; /* memvalid TOS system variable */ + * (uint32_t *) 0x43a = 0x237698aa; /* memval2 TOS system variable */ + * (uint32_t *) 0x51a = 0x5555aaaa; /* memval3 TOS system variable */ + + /* TT-RAM */ + + * (uint32_t *) 0x5a4 = FASTRAM_END; /* ramtop TOS system variable */ + * (uint32_t *) 0x5a8 = 0x1357bd13; /* ramvalid TOS system variable */ + + xprintf("call FireTOS\r\n"); + /* Jump into FireTOS */ + typedef void void_func(void); + void_func* FireTOS = (void_func*) FIRETOS; + FireTOS(); // Should never return + } + xprintf("call EmuTOS\r\n"); struct rom_header *os_header = (struct rom_header *) TOS; os_header->initial_pc(); diff --git a/BaS_gcc/sys/exceptions.S b/BaS_gcc/sys/exceptions.S index d8ae2f7..caebf09 100644 --- a/BaS_gcc/sys/exceptions.S +++ b/BaS_gcc/sys/exceptions.S @@ -144,7 +144,7 @@ subq.l #8,sp movem.l d0/a5,(sp) // save registers - lea MCF_EPORT_EPFR,a5 + lea MCF_EPORT_EPFR,a5 move.b #\clr_int,(a5) // clear int pending movem.l (sp),d0/a5 // restore registers diff --git a/BaS_gcc/sys/sysinit.c b/BaS_gcc/sys/sysinit.c index 1ca6645..1153453 100644 --- a/BaS_gcc/sys/sysinit.c +++ b/BaS_gcc/sys/sysinit.c @@ -561,8 +561,7 @@ static void init_video_ddr(void) { _VRAM = 0000070022; /* load MR dll on */ NOP(); - * (uint32_t *) 0xf0000400 = 0x01070002; /* fifo on, refresh on, ddrcs und cke on, video dac on */ -// * (uint32_t *) 0xf0000400 = 0x0107820b; /* fifo on, refresh on, ddrcs und cke on, video dac on */ + * (uint32_t *) 0xf0000400 = 0x01070082; /* fifo on, refresh on, ddrcs und cke on, video dac on, Falcon shift mode on */ xprintf("finished\r\n"); } @@ -940,7 +939,7 @@ static void clear_bss_segment(void) void initialize_hardware(void) { /* Test for FireTOS switch: DIP switch #5 up */ -#if defined(MACHINE_FIREBEE) +#ifdef _NOT_USED_ // #if defined(MACHINE_FIREBEE) if (!(DIP_SWITCH & (1 << 6))) { /* Minimal hardware initialization */ init_gpio(); @@ -958,6 +957,7 @@ void initialize_hardware(void) /* TT-RAM */ + xprintf("FASTRAM_END = %p\r\n", FASTRAM_END); * (uint32_t *) 0x5a4 = FASTRAM_END; /* ramtop TOS system variable */ * (uint32_t *) 0x5a8 = 0x1357bd13; /* ramvalid TOS system variable */