Skip to content

Commit

Permalink
make it work on RISCV
Browse files Browse the repository at this point in the history
  • Loading branch information
hansfbaier committed Feb 27, 2023
1 parent 9db62b3 commit 9711158
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DiskImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2821,7 +2821,7 @@ bool unpack_td0(unsigned char *data, long &size)
td0_src = end_packed_data;
}
}
size = unsigned(td0_dst) - unsigned(data);
size = (unsigned long)td0_dst - (unsigned long)data;
delete snbuf;
return true;
}
Expand Down
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SHELL = /bin/bash -o pipefail

# using gcc version 10.2.1

BASE = arm-linux-gnueabihf
BASE = riscv64-unknown-linux-gnu

CC = $(BASE)-gcc
LD = $(BASE)-ld
Expand Down Expand Up @@ -32,12 +32,12 @@ C_SRC = $(wildcard *.c) \
$(wildcard ./lib/md5/*.c) \
$(wildcard ./lib/lzma/*.c) \
$(wildcard ./lib/flac/src/*.c) \
$(wildcard ./lib/libchdr/*.c) \
lib/libco/arm.c
$(wildcard ./lib/libchdr/*.c) # \
# lib/libco/arm.c

CPP_SRC = $(wildcard *.cpp) \
$(wildcard ./lib/serial_server/library/*.cpp) \
$(wildcard ./support/*/*.cpp)
$(wildcard ./support/*/*.cpp)

IMG = $(wildcard *.png)

Expand All @@ -47,16 +47,16 @@ OBJ = $(C_SRC:.c=.c.o) $(CPP_SRC:.cpp=.cpp.o) $(IMG:.png=.png.o)
DEP = $(C_SRC:.c=.c.d) $(CPP_SRC:.cpp=.cpp.d)

DFLAGS = $(INCLUDE) -D_7ZIP_ST -DPACKAGE_VERSION=\"1.3.3\" -DFLAC_API_EXPORTS -DFLAC__HAS_OGG=0 -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H -DHAVE_SYS_PARAM_H -DENABLE_64_BIT_WORDS=0 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\"
CFLAGS = $(DFLAGS) -w -Wextra -Wno-strict-aliasing -Wno-stringop-overflow -Wno-stringop-truncation -Wno-format-truncation -Wno-psabi -Wno-restrict -c -O3
LFLAGS = -lc -lstdc++ -lm -lrt $(IMLIB2_LIB) -Llib/bluetooth -lbluetooth -lpthread
CFLAGS = $(DFLAGS) -w -Wextra -Wno-strict-aliasing -Wno-stringop-overflow -Wno-stringop-truncation -Wno-format-truncation -Wno-psabi -Wno-restrict -c -O3 -march=rv64gc -mabi=lp64d
LFLAGS = -lc -lstdc++ -lm -lrt $(IMLIB2_LIB) -Llib/bluetooth -lbluetooth -lpthread -mabi=lp64d

ifeq ($(PROFILING),1)
DFLAGS += -DPROFILING
endif

$(PRJ): $(OBJ)
$(Q)$(info $@)
$(Q)$(CC) -o $@ $+ $(LFLAGS)
$(Q)$(CC) -o $@ $+ $(LFLAGS)
$(Q)cp $@ $@.elf
$(Q)$(STRIP) $@

Expand All @@ -77,6 +77,8 @@ clean:
%.png.o: %.png
$(Q)$(info $<)
$(Q)$(LD) -r -b binary -o $@ $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'
# change the flags to double flow RV64 (it's just data and the linker does not want to do it)
$(Q)printf '\x05' | dd of=$@ bs=1 seek=48 count=1 conv=notrunc

ifneq ($(MAKECMDGOALS), clean)
-include $(DEP)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions fpga_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int fpgamgr_program_init(void)
/* Write the RBF data to FPGA Manager */
static void fpgamgr_program_write(const void *rbf_data, unsigned long rbf_size)
{
uint32_t src = (uint32_t)rbf_data;
// uint32_t src = (uint32_t)rbf_data;
// TODO
}

Expand Down Expand Up @@ -125,7 +125,7 @@ static int socfpga_load(const void *rbf_data, size_t rbf_size)
{
unsigned long status;

if ((uint32_t)rbf_data & 0x3) {
if ((uint64_t)rbf_data & 0x3) {
printf("FPGA: Unaligned data, realign to 32bit boundary.\n");
return -EINVAL;
}
Expand Down
2 changes: 1 addition & 1 deletion scheduler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SCHEDULER_H
#define SCHEDULER_H

#define USE_SCHEDULER
//#define USE_SCHEDULER

void scheduler_init(void);
void scheduler_run(void);
Expand Down
2 changes: 1 addition & 1 deletion shmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int shmem_unmap(void* map, uint32_t size)
{
if (munmap(map, size) < 0)
{
printf("Error: Unable to unmap(0x%X, %d)!\n", (uint32_t)map, size);
printf("Error: Unable to unmap(0x%X, %d)!\n", (uint64_t)map, size);
return 0;
}

Expand Down

0 comments on commit 9711158

Please sign in to comment.