Browse Source

Disable device tree filter when load a dts from file (#219)

* add device tree in elf, using --with-dts to add the absolute path of device tree

* Disable device tree filter

* Remove *.dtb dependence, when the --with-dts option is not used
pull/220/head
Yan 5 years ago
committed by GitHub
parent
commit
a4d4298ca1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Makefile.in
  2. 2
      bbl/bbl.c
  3. 1
      bbl/bbl.lds
  4. 29
      configure
  5. 5
      machine/machine.ac
  6. 7
      machine/machine.mk.in
  7. 13
      machine/mentry.S

4
Makefile.in

@ -116,6 +116,10 @@ ifneq (@BBL_PAYLOAD@,no)
CFLAGS := $(CFLAGS) -DBBL_PAYLOAD=\"bbl_payload\"
endif
BBL_PAYLOAD := @BBL_PAYLOAD@
ifneq (@CUSTOM_DTS@,no)
CFLAGS := $(CFLAGS) -DCUSTOM_DTS=\"custom_dts\"
endif
CUSTOM_DTS := @CUSTOM_DTS@
COMPILE := $(CC) -MMD -MP $(CFLAGS) \
$(sprojs_include)
# Linker

2
bbl/bbl.c

@ -41,11 +41,13 @@ static void filter_dtb(uintptr_t source)
uint32_t size = fdt_size(source);
memcpy((void*)dest, (void*)source, size);
#ifndef CUSTOM_DTS
// Remove information from the chained FDT
filter_harts(dest, &disabled_hart_mask);
filter_plic(dest);
filter_compat(dest, "riscv,clint0");
filter_compat(dest, "riscv,debug-013");
#endif
}
static void protect_memory(void)

1
bbl/bbl.lds

@ -67,6 +67,7 @@ SECTIONS
*(.srodata*)
*(.gnu.linkonce.d.*)
*(.comment)
*(.dtb)
}
/* End of initialized data segment */

29
configure

@ -590,6 +590,7 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
subprojects_enabled
subprojects
CUSTOM_DTS
BBL_LOGO_FILE
BBL_PAYLOAD
BBL_ENABLE_LOGO
@ -648,6 +649,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@ -683,6 +685,7 @@ with_payload
with_logo
enable_boot_machine
enable_fp_emulation
with_dts
'
ac_precious_vars='build_alias
host_alias
@ -737,6 +740,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -989,6 +993,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1126,7 +1139,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@ -1279,6 +1292,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@ -1331,6 +1345,7 @@ Optional Packages:
--with-mem-start Set physical memory start address
--with-payload Set ELF payload for bbl
--with-logo Specify a better logo
--with-dts Specify a customize dts
Some influential environment variables:
CC C compiler command
@ -4469,6 +4484,18 @@ $as_echo "#define PK_ENABLE_FP_EMULATION /**/" >>confdefs.h
fi
# Check whether --with-dts was given.
if test "${with_dts+set}" = set; then :
withval=$with_dts; CUSTOM_DTS=$with_dts
else
CUSTOM_DTS=no
fi

5
machine/machine.ac

@ -4,3 +4,8 @@ AC_ARG_ENABLE([fp-emulation], AS_HELP_STRING([--disable-fp-emulation], [Disable
AS_IF([test "x$enable_fp_emulation" != "xno"], [
AC_DEFINE([PK_ENABLE_FP_EMULATION],,[Define if floating-point emulation is enabled])
])
AC_ARG_WITH([dts], AS_HELP_STRING([--with-dts], [Specify a customize dts]),
[AC_SUBST([CUSTOM_DTS], $with_dts, [customize dts])],
[AC_SUBST([CUSTOM_DTS], [no], [customize dts])]
)

7
machine/machine.mk.in

@ -37,3 +37,10 @@ machine_c_srcs = \
machine_asm_srcs = \
mentry.S \
fp_asm.S \
ifneq (@CUSTOM_DTS@,no)
mentry.o: custom.dtb
custom.dtb: $(CUSTOM_DTS)
dtc -O dtb $^ -o $@
endif

13
machine/mentry.S

@ -281,6 +281,10 @@ do_reset:
#endif
# Boot on the first hart
#ifdef CUSTOM_DTS
csrr a0, mhartid
la a1, dtb_start
#endif
j init_first_hart
.LmultiHartInit:
@ -313,6 +317,15 @@ do_reset:
wfi
j .LmultiHart
#ifdef CUSTOM_DTS
.section .dtb
.align 3
.global dtb_start, dtb_end
dtb_start:
.incbin "custom.dtb"
dtb_end:
#endif
.bss
.align RISCV_PGSHIFT
stacks:

Loading…
Cancel
Save