#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
#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
#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 */
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
$(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
+++ /dev/null
-SECTIONS
-{
- . = 0xffff0000;
- start = .;
- .head : {
- KEEP(*(.head))
- }
- . = 0xffff1000;
- .text : { *(.text*) *(.sfpr) *(.rodata*) }
- .data : { *(.data*) }
- .bss : { *(.bss*) }
-}
--- /dev/null
+#include "microwatt_soc.h"
+
+SECTIONS
+{
+ . = DRAM_INIT_BASE;
+ start = .;
+ .head : {
+ KEEP(*(.head))
+ }
+ . = DRAM_INIT_BASE | 0x1000;
+ .text : { *(.text*) *(.sfpr) *(.rodata*) }
+ .data : { *(.data*) }
+ .bss : { *(.bss*) }
+}
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)