Initial version

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
This commit is contained in:
David Abdurachmanov 2019-08-25 11:49:05 -07:00
commit 24652ffd18
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
3 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,59 @@
diff --git a/Makefile b/Makefile
index b7204ed..c69639e 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ CC=${CROSSCOMPILE}gcc
LD=${CROSSCOMPILE}ld
OBJCOPY=${CROSSCOMPILE}objcopy
OBJDUMP=${CROSSCOMPILE}objdump
-CFLAGS=-I. -O2 -ggdb -march=rv64imafdc -mabi=lp64d -Wall -mcmodel=medany -mexplicit-relocs
+CFLAGS=-I. -O2 -ggdb -march=rv64imafdc -mabi=lp64d -Wall -mcmodel=medany -mexplicit-relocs -Wno-main
CCASFLAGS=-I. -mcmodel=medany -mexplicit-relocs
LDFLAGS=-nostdlib -nostartfiles
@@ -52,7 +52,7 @@ asm: zsbl.asm fsbl.asm
lib/version.c: .git/HEAD .git/index
echo "const char *gitid = \"$(shell git describe --always --dirty)\";" > lib/version.c
- echo "const char *gitdate = \"$(shell git log -n 1 --date=short --format=format:"%ad.%h" HEAD)\";" >> lib/version.c
+ echo "const char *gitdate = \"$(shell git log -n 1 --date=short --format=format:"%ad.%h" --no-show-signature HEAD)\";" >> lib/version.c
echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" >> lib/version.c
# echo "const char *gitstatus = \"$(shell git status -s )\";" >> lib/version.c
@@ -73,7 +73,7 @@ fsbl/dtb.o: fsbl/ux00_fsbl.dtb
zsbl/start.o: zsbl/ux00_zsbl.dtb
%.bin: %.elf
- $(OBJCOPY) -O binary $^ $@
+ $(OBJCOPY) -S -R .comment -R .note.gnu.build-id -O binary $^ $@
%.asm: %.elf
$(OBJDUMP) -S $^ > $@
diff --git a/lib/strlen.c b/lib/strlen.c
index 565955f..3d6addf 100644
--- a/lib/strlen.c
+++ b/lib/strlen.c
@@ -17,6 +17,14 @@
#include <string.h>
#include <stdint.h>
+static __inline unsigned long detect_null(unsigned long w)
+{
+ unsigned long mask = 0x7f7f7f7f;
+ if (sizeof (long) == 8)
+ mask = ((mask << 16) << 16) | mask;
+ return ~(((w & mask) + mask) | w | mask);
+}
+
size_t strlen(const char *str)
{
const char *start = str;
@@ -35,7 +43,7 @@ size_t strlen(const char *str)
} while ((uintptr_t)str & (sizeof (long) - 1));
unsigned long *ls = (unsigned long *)str;
- while (!__libc_detect_null (*ls++))
+ while (!detect_null (*ls++))
;
asm volatile ("" : "+r"(ls)); /* prevent "optimization" */

Binary file not shown.

View File

@ -0,0 +1,52 @@
# No need for debuginfo or stripping
%global debug_package %{nil}
%global __strip /bin/true
Name: freedom-u540-c000-bootloader
Version: 2019.08.25.128f282
Release: 1%{?dist}
Summary: SiFive FU540 ZSBL and FSBL
License: Apache-2.0 | GPLv2+
URL: https://github.com/sifive/freedom-u540-c000-bootloader
# This is a full git clone copy (incl. git), --depth 1 should be enough
# This allows Makefile to extract version information from .git
Source0: %{name}-%{version}.tar.xz
Patch0: drop-unneeded-sectiosn-fix-string.patch
# We depend on kernel for a new DTB
BuildRequires: kernel-core
# Needed to generate version information
BuildRequires: git
# Needed to compile DTB ( ZSBL and FSBL)
BuildRequires: dtc
BuildRequires: gcc
BuildRequires: binutils
%description
Provides booloaders for SiFive (FU540) HiFive Unleashed board:
- Zeroth Stage Boot Loader (ZSBL)
- First Stage Boot Loader (FSBL)
%prep
%autosetup -p1
%build
make CROSSCOMPILE=
%install
install -d %{buildroot}/boot/freedom-u540-c000-bootloader/unstable/
install -m 755 zsbl.bin %{buildroot}/boot/freedom-u540-c000-bootloader/unstable/
install -m 755 fsbl.bin %{buildroot}/boot/freedom-u540-c000-bootloader/unstable/
%files
%license LICENSE
/boot/freedom-u540-c000-bootloader/unstable/{zsbl,fsbl}.bin
%changelog
* Sun Aug 25 2019 David Abdurachmanov <david.abdurachmanov@sifive.com> 2019.08.25.128f282-1
- Add initial version