Split implementation for unix/baremetal

The differences will be significant, so a separation via compilation
unit is better than a thousands of #ifdef
This commit is contained in:
Steve Schnepp 2023-08-30 21:45:44 +02:00
parent 816a75e7d9
commit 251bb311f4
12 changed files with 32 additions and 6 deletions

View file

@ -16,6 +16,7 @@ CC = gcc
CFLAGS = -g -O2 -I./src/ -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DPATCHLEVEL=$(PATCHLEVEL) -DCOMPILE_VERSION=$(COMPILE_VERSION)
LIBS = -lm
OS_TYPE=unix
ifeq ($(GUI), x11)
CFLAGS += $(shell pkg-config --cflags x11 xext) -D_GNU_SOURCE=1 -DGUI_IS_X11=1
LIBS += $(shell pkg-config --libs x11 xext)
@ -24,25 +25,33 @@ ifeq ($(GUI), sdl1)
CFLAGS += $(shell pkg-config --cflags SDL_gfx sdl12_compat) -DGUI_IS_SDL1=1
LIBS += $(shell pkg-config --libs SDL_gfx sdl12_compat)
endif
ifeq ($(GUI), baremetal)
CC = riscv64-unknown-elf-gcc
CFLAGS += -march=rv32e -mabi=ilp32e --specs=picolibc.specs -DGUI_IS_BAREMETAL=1
LIBS += -Wl,--print-memory-usage
LIBS +=-T baremetal.ld
OS_TYPE=baremetal
WITH_DEBUGGER=no
endif
FULL_WARNINGS = no
ifeq ($(FULL_WARNINGS), yes)
CFLAGS += -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-unused-function -Wconversion -Wdouble-promotion -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap
endif
DOTOS = src/main.o \
DOTOS = src/main_$(OS_TYPE).o \
src/hp48_device.o \
src/hp48_emulate.o \
src/hp48_init.o \
src/hp48_serial.o \
src/hp48_init_$(OS_TYPE).o \
src/hp48_serial_$(OS_TYPE).o \
src/hp48emu_actions.o \
src/hp48emu_memory.o \
src/hp48emu_register.o \
src/romio.o \
src/timer.o \
src/timer_$(OS_TYPE).o \
src/x48_errors.o \
src/x48_resources.o \
src/x48.o
src/x48_$(OS_TYPE).o
ifeq ($(WITH_DEBUGGER), yes)
DOTOS += src/x48_debugger.o \
@ -54,7 +63,10 @@ endif
.PHONY: all clean clean-all pretty-code install
all: dist/mkcard dist/checkrom dist/dump2rom dist/x48ng
all: dist/x48ng
ifneq ($(GUI), baremetal)
all: dist/mkcard dist/checkrom dist/dump2rom
endif
# Binaries
dist/mkcard: src/tools/mkcard.o

8
baremetal.ld Normal file
View file

@ -0,0 +1,8 @@
__flash = 0x00000000;
__flash_size = 1M;
/* __ram = 0x01000000; */
__ram_size = 256k;
__stack_size = 256;
INCLUDE picolibc.ld

View file

View file

6
src/main_baremetal.c Normal file
View file

@ -0,0 +1,6 @@
int main() {
init_emulator();
serial_init();
init_display();
emulate();
}

0
src/timer_baremetal.c Normal file
View file

0
src/x48_baremetal.c Normal file
View file