to be compiled and used stand-alone. sdram initialisation is disabled.
the general idea here is to make this a useful mini-BIOS bootloader,
focussing initially on verilator start-up. to that end, the first
addition is a SYS_REG_BRAM_BOOTADDR addition to syscon which is the
location where the chain-loading continues (if SPI and SDRAM are not
available, where SDRAM is definitely out at this point)
#define LETH_CSR_BASE 0xc8020000 /* LiteEth CSR registers */
#define LETH_SRAM_BASE 0xc8030000 /* LiteEth MMIO space */
#define SPI_FLASH_BASE 0xf0000000 /* SPI Flash memory map */
+#ifdef STANDALONE_MINI_BIOS
+#define DRAM_INIT_BASE 0x00000000 /* alternative, for verilator simulation */
+#else
#define DRAM_INIT_BASE 0xff000000 /* Internal DRAM init firmware */
+#endif
/*
* Interrupt numbers
#define SYS_REG_UART0_INFO 0x40
#define SYS_REG_UART1_INFO 0x48
#define SYS_REG_UART_IS_16550 (1ull << 32)
+#define SYS_REG_BRAM_BOOTADDR 0x50
/*
#### Directories
-include variables.mak
+# check for variables.mak and if not, allow stand-alone BIOS to be compiled
+# (disables SDRAM)
+ifeq ("$(wildcard variables.mak)","")
+ include variables.mak
+ NO_SDRAM=
+else
+ BUILD_DIR=.
+ SRC_DIR=.
+ GENINC_DIR=.
+ NO_SDRAM=true
+ EXTRA_CFLAGS=-DSTANDALONE_MINI_BIOS
+endif
+
OBJ = $(BUILD_DIR)/obj
LXINC_DIR=$(LXSRC_DIR)/include
PROGRAM = sdram_init
+ifeq ($(NO_SDRAM), true)
+OBJECTS = $(OBJ)/head.o $(OBJ)/main.o $(OBJ)/console.o
+else
OBJECTS = $(OBJ)/head.o $(OBJ)/main.o $(OBJ)/sdram.o $(OBJ)/memtest.o $(OBJ)/console.o
+endif
#### Compiler
CPPFLAGS += -I$(LXSRC_DIR) -I$(LXINC_DIR) -I$(LXINC_DIR)/base -I$(LXSRC_DIR)/liblitedram
CPPFLAGS += -isystem $(shell $(CC) -print-file-name=include)
-CFLAGS = -Os -g -Wall -std=c99 -m64 -mabi=elfv2 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -fno-delete-null-pointer-checks
+CFLAGS = -Os -g -Wall -std=c99 -m64 -mabi=elfv2 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -fno-delete-null-pointer-checks
ASFLAGS = $(CPPFLAGS) $(CFLAGS)
LDFLAGS = -static -nostdlib -T $(OBJ)/$(PROGRAM).lds --gc-sections
* limitations under the License.
*/
-#define STACK_TOP 0xff006000
+#include "microwatt_soc.h"
+#define STACK_TOP (0x00006000 + DRAM_INIT_BASE)
#define FIXUP_ENDIAN \
tdi 0,0,0x48; /* Reverse endian of b . + 8 */ \
#include <stdarg.h>
#include <stdio.h>
+#ifndef STANDALONE_MINI_BIOS
#include <generated/git.h>
+#endif
#include "console.h"
#include "microwatt_soc.h"
#include "io.h"
+#ifndef STANDALONE_MINI_BIOS
#include "sdram.h"
+#endif
#include "elf64.h"
#define FLASH_LOADER_USE_MAP
}
printf("\n");
if (ftr & SYS_REG_INFO_HAS_DRAM) {
+#ifndef STANDALONE_MINI_BIOS
printf("LiteDRAM built from Migen %s and LiteX %s\n",
MIGEN_GIT_SHA1, LITEX_GIT_SHA1);
sdrinit();
+#endif
}
if (ftr & SYS_REG_INFO_HAS_BRAM) {
- printf("Booting from BRAM...\n");
- return 0;
+ // allow a jump to a config-specified address (just like DRAM can)
+ val = readq(SYSCON_BASE + SYS_REG_BRAM_BOOTADDR);
+ printf("Booting from BRAM at %lx...\n", val);
+ return val;
}
if (try_flash) {
val = boot_flash(fl_off);