From 8d64090a68a47fbcfea162b488542fd325b7c2b8 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 15 May 2020 17:43:51 +1000 Subject: [PATCH] sw: Add full memory map to .h and use it for litedram .lds Signed-off-by: Benjamin Herrenschmidt --- include/microwatt_soc.h | 24 +++++++++++++------ litedram/gen-src/sdram_init/Makefile | 6 +++-- .../{sdram_init.lds => sdram_init.lds.S} | 8 ++++--- soc.vhdl | 2 +- 4 files changed, 27 insertions(+), 13 deletions(-) rename litedram/gen-src/sdram_init/{sdram_init.lds => sdram_init.lds.S} (63%) diff --git a/include/microwatt_soc.h b/include/microwatt_soc.h index 16871a4..b0dab83 100644 --- a/include/microwatt_soc.h +++ b/include/microwatt_soc.h @@ -2,9 +2,21 @@ #define __MICROWATT_SOC_H /* - * Definitions for the syscon registers + * Microwatt SoC memory map + */ + +#define MEMORY_BASE 0x00000000 /* "Main" memory alias, either BRAM or DRAM */ +#define DRAM_BASE 0x40000000 /* DRAM if present */ +#define SYSCON_BASE 0xc0000000 /* System control regs */ +#define UART_BASE 0xc0002000 /* UART */ +#define XICS_BASE 0xc0004000 /* Interrupt controller */ +#define DRAM_CTRL_BASE 0xc0100000 /* LiteDRAM control registers */ +#define BRAM_BASE 0xf0000000 /* Internal BRAM */ +#define DRAM_INIT_BASE 0xffff0000 /* Internal DRAM init firmware */ + +/* + * Register definitions for the syscon registers */ -#define SYSCON_BASE 0xc0000000 #define SYS_REG_SIGNATURE 0x00 #define SYS_REG_INFO 0x08 @@ -18,9 +30,9 @@ #define SYS_REG_CTRL_CORE_RESET (1ull << 1) #define SYS_REG_CTRL_SOC_RESET (1ull << 2) -/* Definition for the "Potato" UART */ -#define UART_BASE 0xc0002000 - +/* + * Register definitions for the potato UART + */ #define POTATO_CONSOLE_TX 0x00 #define POTATO_CONSOLE_RX 0x08 #define POTATO_CONSOLE_STATUS 0x10 @@ -31,7 +43,5 @@ #define POTATO_CONSOLE_CLOCK_DIV 0x18 #define POTATO_CONSOLE_IRQ_EN 0x20 -/* Definition for the LiteDRAM control registers */ -#define DRAM_CTRL_BASE 0xc0100000 #endif /* __MICROWATT_SOC_H */ diff --git a/litedram/gen-src/sdram_init/Makefile b/litedram/gen-src/sdram_init/Makefile index 4bc3e7b..420072e 100644 --- a/litedram/gen-src/sdram_init/Makefile +++ b/litedram/gen-src/sdram_init/Makefile @@ -26,7 +26,7 @@ CPPFLAGS += -I$(SRC_DIR)/libc/include -I$(LXSRC_DIR) -I$(LXINC_DIR) -I$(GENINC_D 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 ASFLAGS = $(CPPFLAGS) $(CFLAGS) -LDFLAGS = -static -nostdlib -Ttext-segment=0xffff0000 -T $(SRC_DIR)/$(PROGRAM).lds --gc-sections +LDFLAGS = -static -nostdlib -T $(OBJ)/$(PROGRAM).lds --gc-sections #### Pretty print @@ -58,13 +58,15 @@ $(OBJ)/%.o : $(SRC_DIR)/%.S $(call Q,AS, $(CC) $(ASFLAGS) -c $< -o $@, $@) $(OBJ)/%.o : $(SRC_DIR)/libc/src/%.c $(call Q,CC, $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@, $@) +$(OBJ)/%.lds : $(SRC_DIR)/%.lds.S + $(call Q,CC, $(CC) $(CPPFLAGS) -P -E $< -o $@, $@) LIBC_SRC := $(wildcard $(SRC_DIR)/libc/src/*.c) LIBC_OBJ := $(patsubst $(SRC_DIR)/libc/src/%.c, $(OBJ)/%.o,$(LIBC_SRC)) $(OBJ)/libc.o: $(LIBC_OBJ) $(call Q,LD, $(LD) -r -o $@ $^, $@) -$(OBJ)/$(PROGRAM).elf: $(OBJECTS) $(OBJ)/libc.o +$(OBJ)/$(PROGRAM).elf: $(OBJECTS) $(OBJ)/libc.o $(OBJ)/$(PROGRAM).lds $(call Q,LD, $(LD) $(LDFLAGS) -o $@ $^, $@) $(OBJ)/$(PROGRAM).bin: $(OBJ)/$(PROGRAM).elf diff --git a/litedram/gen-src/sdram_init/sdram_init.lds b/litedram/gen-src/sdram_init/sdram_init.lds.S similarity index 63% rename from litedram/gen-src/sdram_init/sdram_init.lds rename to litedram/gen-src/sdram_init/sdram_init.lds.S index f76e77f..f1bc291 100644 --- a/litedram/gen-src/sdram_init/sdram_init.lds +++ b/litedram/gen-src/sdram_init/sdram_init.lds.S @@ -1,11 +1,13 @@ +#include "microwatt_soc.h" + SECTIONS { - . = 0xffff0000; + . = DRAM_INIT_BASE; start = .; .head : { KEEP(*(.head)) - } - . = 0xffff1000; + } + . = DRAM_INIT_BASE | 0x1000; .text : { *(.text*) *(.sfpr) *(.rodata*) } .data : { *(.data*) } .bss : { *(.bss*) } diff --git a/soc.vhdl b/soc.vhdl index caa62cd..a42e071 100644 --- a/soc.vhdl +++ b/soc.vhdl @@ -10,7 +10,7 @@ use work.common.all; use work.wishbone_types.all; --- Memory map: +-- Memory map. *** Keep include/microwatt_soc.h updated on changes *** -- -- 0x00000000: Block RAM (MEMORY_SIZE) or DRAM depending on syscon -- 0x40000000: DRAM (when present)