Merge pull request #942 from zyp/external_software_packages
Allow external software packages to be linked into the BIOS
This commit is contained in:
commit
b0e6851150
|
@ -46,9 +46,6 @@ soc_software_packages = [
|
|||
"libliteeth",
|
||||
"liblitesdcard",
|
||||
"liblitesata",
|
||||
|
||||
# BIOS.
|
||||
"bios"
|
||||
]
|
||||
|
||||
# Builder ------------------------------------------------------------------------------------------
|
||||
|
@ -105,16 +102,25 @@ class Builder:
|
|||
# Documentation
|
||||
self.generate_doc = generate_doc
|
||||
|
||||
# List software packages.
|
||||
# List software packages and libraries.
|
||||
self.software_packages = []
|
||||
self.software_libraries = []
|
||||
|
||||
for name in soc_software_packages:
|
||||
self.add_software_package(name)
|
||||
|
||||
if name == "libbase":
|
||||
name += "-nofloat"
|
||||
self.add_software_library(name)
|
||||
|
||||
def add_software_package(self, name, src_dir=None):
|
||||
if src_dir is None:
|
||||
src_dir = os.path.join(soc_directory, "software", name)
|
||||
self.software_packages.append((name, src_dir))
|
||||
|
||||
def add_software_library(self, name):
|
||||
self.software_libraries.append(name)
|
||||
|
||||
def _generate_includes(self):
|
||||
# Generate Include/Generated directories.
|
||||
_create_dir(self.include_dir)
|
||||
|
@ -123,12 +129,18 @@ class Builder:
|
|||
# Generate BIOS files when the SoC uses it.
|
||||
with_bios = self.soc.cpu_type not in [None, "zynq7000"]
|
||||
if with_bios:
|
||||
self.add_software_package("bios")
|
||||
|
||||
# Generate Variables to variables.mak.
|
||||
variables_contents = []
|
||||
def define(k, v):
|
||||
variables_contents.append("{}={}".format(k, _makefile_escape(v)))
|
||||
|
||||
# Define packages and libraries.
|
||||
define("PACKAGES", " ".join(name for name, src_dir in self.software_packages))
|
||||
define("PACKAGE_DIRS", " ".join(src_dir for name, src_dir in self.software_packages))
|
||||
define("LIBS", " ".join(self.software_libraries))
|
||||
|
||||
# Define the CPU variables.
|
||||
for k, v in export.get_cpu_mak(self.soc.cpu, self.compile_software):
|
||||
define(k, v)
|
||||
|
|
|
@ -54,28 +54,17 @@ endif
|
|||
|
||||
bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS)
|
||||
|
||||
vpath %.a $(PACKAGES:%=../%)
|
||||
|
||||
%.elf: ../libbase/crt0.o \
|
||||
../libcompiler_rt/libcompiler_rt.a \
|
||||
../libbase/libbase-nofloat.a \
|
||||
../liblitedram/liblitedram.a \
|
||||
../libliteeth/libliteeth.a \
|
||||
../liblitespi/liblitespi.a \
|
||||
../libfatfs/libfatfs.a \
|
||||
../liblitesdcard/liblitesdcard.a \
|
||||
../liblitesata/liblitesata.a
|
||||
%.elf: ../libbase/crt0.o $(LIBS:%=%.a)
|
||||
$(CC) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \
|
||||
../libbase/crt0.o \
|
||||
$(OBJECTS) \
|
||||
-L../libcompiler_rt \
|
||||
-L../libbase \
|
||||
-L../liblitedram \
|
||||
-L../libliteeth \
|
||||
-L../liblitespi \
|
||||
-L../libfatfs \
|
||||
-L../liblitesdcard \
|
||||
-L../liblitesata \
|
||||
-llitedram -lliteeth -llitespi -lfatfs -llitesdcard -llitesata -lbase-nofloat -lcompiler_rt
|
||||
$(PACKAGES:%=-L../%) \
|
||||
-Wl,--whole-archive \
|
||||
-Wl,--gc-sections \
|
||||
$(LIBS:lib%=-l%) \
|
||||
|
||||
|
||||
ifneq ($(OS),Windows_NT)
|
||||
chmod -x $@
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "readline.h"
|
||||
#include "helpers.h"
|
||||
#include "command.h"
|
||||
#include "init.h"
|
||||
|
||||
extern unsigned int _ftext, _edata_rom;
|
||||
|
||||
|
@ -126,3 +127,10 @@ struct command_struct *command_dispatcher(char *command, int nb_params, char **p
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void init_dispatcher(void)
|
||||
{
|
||||
for (const init_func* fp = __bios_init_start; fp != __bios_init_end; fp++) {
|
||||
(*fp)();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,6 @@ void dump_bytes(unsigned int *ptr, int count, unsigned long addr);
|
|||
void crcbios(void);
|
||||
int get_param(char *buf, char **cmd, char **params);
|
||||
struct command_struct *command_dispatcher(char *command, int nb_params, char **params);
|
||||
void init_dispatcher(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
typedef void (*init_func)(void);
|
||||
|
||||
extern init_func const __bios_init_start[];
|
||||
extern init_func const __bios_init_end[];
|
||||
|
||||
#define define_init_func(f) \
|
||||
const init_func __bios_init_##f __attribute__((__used__)) \
|
||||
__attribute__((__section__(".bios_init"))) = f
|
|
@ -41,6 +41,13 @@ SECTIONS
|
|||
PROVIDE_HIDDEN (__bios_cmd_end = .);
|
||||
} > rom
|
||||
|
||||
.init :
|
||||
{
|
||||
PROVIDE_HIDDEN (__bios_init_start = .);
|
||||
KEEP(*(.bios_init))
|
||||
PROVIDE_HIDDEN (__bios_init_end = .);
|
||||
} > rom
|
||||
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
|
|
|
@ -173,6 +173,8 @@ int main(int i, char **c)
|
|||
video_framebuffer_dma_enable_write(1);
|
||||
#endif
|
||||
|
||||
init_dispatcher();
|
||||
|
||||
if(sdr_ok) {
|
||||
printf("--============== \e[1mBoot\e[0m ==================--\n");
|
||||
boot_sequence();
|
||||
|
|
Loading…
Reference in New Issue