source: trunk/softs/tsar_boot/Makefile @ 701

Last change on this file since 701 was 701, checked in by cfuguet, 10 years ago

tsar_boot:

  • Important optimization in the reset_elf_loader function.
  • Implementation of pread function which uses bytes addressing to read disk.
  • pread function alternates between direct tranfer from disk to memory and from disk to a memory cache block based on alignment of byte address, i.e., when file offset is aligned to disk block (512 bytes), pread uses DMA capacity of disk to transfer directly to memory, otherwise it passes before by a memory cache block and then performs a memcpy to transfer data to final destination.
  • the cache block used by pread function, allows to treat succeeding reads on the same block without accessing the disk.
File size: 3.8 KB
Line 
1# let the user have a default configuration (ie for PLATFORM_DIR and SOCLIB)
2-include ./build.mk
3
4MAKECMDGOALS ?= none
5RAMDISK      ?= 0
6SOCLIB       ?= 0
7
8ifneq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),clean distclean clean-doc doc))
9  ifndef PLATFORM_DIR
10    $(error please define PLATFORM_DIR 'make PLATFORM_DIR=foo')
11  else
12    ifeq ($(SOCLIB),1)
13      ifeq ($(RAMDISK),1)
14        DEFS+= -DUSE_RDK
15      else
16        DEFS+= -DUSE_BDV
17      endif
18      DTS=platform_soclib.dts
19      $(info Make for $(PLATFORM_DIR), SocLib variant)
20    else
21      DEFS+= -DUSE_SPI
22      DTS=platform_fpga.dts
23      $(info Make for $(PLATFORM_DIR), FPGA variant)
24    endif
25  endif
26endif
27
28LD         := mipsel-unknown-elf-ld
29CC         := mipsel-unknown-elf-gcc
30AS         := mipsel-unknown-elf-as
31DU         := mipsel-unknown-elf-objdump
32RM         := rm -rf
33ECHO       := @echo
34MKDIR      := mkdir
35DTC        := dtc
36HEXDUMP    := hexdump
37DOXYGEN    := doxygen
38
39BUILD_DIR  := build
40SRCS_DIR   := src
41INCS_DIR   := include
42
43# =============================================================================
44# Include files paths
45# =============================================================================
46
47INCLUDE    += -I. -I$(INCS_DIR) -I$(PLATFORM_DIR)
48
49# =============================================================================
50# Paths of sources in another directories
51# =============================================================================
52
53VPATH      += $(SRCS_DIR)
54VPATH      += $(PLATFORM_DIR)
55
56# =============================================================================
57# Object files
58# =============================================================================
59
60CFLAGS     := -Wall                \
61              -mno-gpopt           \
62              -ffreestanding       \
63              -fomit-frame-pointer \
64              -mips32              \
65              -ggdb                \
66              -mlong-calls         \
67              -O2                  \
68              -Werror
69
70C_SRCS     := reset_elf_loader.c \
71              reset_ioc.c        \
72              reset_utils.c      \
73              reset_tty.c        \
74              reset_exception.c
75
76ifeq ($(SOCLIB),0)
77  C_SRCS   += sdcard.c spi.c
78endif
79
80S_SRCS     := reset.S
81
82OBJS       := $(subst .c,.o, $(notdir $(C_SRCS)))
83OBJS       += $(subst .S,.o, $(notdir $(S_SRCS)))
84OBJS       := $(addprefix $(BUILD_DIR)/, $(OBJS))
85
86TARGET     := preloader.elf
87
88USE_DT     ?= 1
89
90all: $(TARGET)
91
92$(BUILD_DIR)/version.o: $(BUILD_DIR) $(OBJS) version version.sh
93        $(ECHO) "[version.sh]"
94        ./version.sh > $(BUILD_DIR)/version.c
95        $(ECHO) "[   CC    ]     $(BUILD_DIR)/version.c"
96        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $(BUILD_DIR)/version.c
97        $(DU) -D $@ > $@.txt
98
99$(TARGET): $(BUILD_DIR) $(BUILD_DIR)/version.o $(OBJS) $(PLATFORM_DIR)/ldscript $(BUILD_DIR)/platform.ld
100        $(ECHO) "[   LD    ]     $@"
101        $(LD) -o $@ -T $(PLATFORM_DIR)/ldscript $(OBJS) $(BUILD_DIR)/version.o
102        $(DU) -D $@ > $@.txt
103
104ifeq ($(USE_DT), 1)
105$(BUILD_DIR)/platform.ld: $(BUILD_DIR)/platform.dtb
106        $(ECHO) "[ HEXDUMP ]     $(notdir $<)"
107        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
108else
109$(BUILD_DIR)/platform.ld:
110        $(ECHO) "[  TOUCH  ]     $(notdir $@)"
111        touch $@
112endif
113
114$(BUILD_DIR)/platform.dtb: $(DTS)
115        $(ECHO) "[   DTC   ]     $(notdir $<)"
116        ${DTC} -O dtb -o $@ $< &> /dev/null
117
118$(BUILD_DIR):
119        $(MKDIR) $@
120
121doc: Doxyfile
122        $(DOXYGEN) Doxyfile
123
124clean:
125        $(RM) $(TARGET).txt $(TARGET) *~ $(BUILD_DIR)
126
127clean-doc:
128        $(RM) doc
129
130distclean: clean clean-doc
131
132# =============================================================================
133# Implicit makefile rules
134
135$(BUILD_DIR)/%.o: %.c
136        $(ECHO) "[   CC    ]     $(notdir $<)"
137        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
138        $(DU) -D $@ > $@.txt
139
140$(BUILD_DIR)/%.o: %.S
141        $(ECHO) "[   AS    ]     $(notdir $<)"
142        $(CC) $(DEFS) ${INCLUDE} -g -mips32 -c -o $@ $<
143        $(DU) -D $@ > $@.txt
144
145.SILENT:
Note: See TracBrowser for help on using the repository browser.