Skip to content

Commit

Permalink
Reorganize userland libraries, improves naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Karlsson committed Oct 15, 2023
1 parent 7b6f4e2 commit 96857b7
Show file tree
Hide file tree
Showing 48 changed files with 477 additions and 542 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECTS=projects/hello projects/ping-pong
PROJECTS=projects/hello projects/ping-pong projects/trapped projects/demonstrator
all:
@for i in $(PROJECTS); do \
make -C $$i all; \
Expand Down
16 changes: 0 additions & 16 deletions common/inc/drivers/uart.h

This file was deleted.

41 changes: 0 additions & 41 deletions common/src/drivers/fu540-uart.c

This file was deleted.

43 changes: 0 additions & 43 deletions common/src/drivers/ns16550a.c

This file was deleted.

28 changes: 0 additions & 28 deletions common/src/drivers/timer.c

This file was deleted.

32 changes: 0 additions & 32 deletions plat/hifive-u/config.h

This file was deleted.

4 changes: 0 additions & 4 deletions plat/hifive-u/platform.ld

This file was deleted.

4 changes: 0 additions & 4 deletions plat/hifive-u/platform.mk

This file was deleted.

4 changes: 0 additions & 4 deletions plat/virt/platform.ld

This file was deleted.

5 changes: 0 additions & 5 deletions plat/virt/platform.mk

This file was deleted.

3 changes: 3 additions & 0 deletions plat64/config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARCH=rv64imac_zicsr
ABI=lp64
CMODEL=medany
9 changes: 9 additions & 0 deletions plat64/inc/plat/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#if defined(PLATFORM_VIRT)
#include "plat/virt.h"
#elif defined(PLATFORM_HIFIVE_UNLEASHED)
#include "plat/hifive_unleashed.h"
#else
#error "Unsupported platform or platform not found"
#endif
39 changes: 39 additions & 0 deletions plat64/inc/plat/hifive_unleashed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#define UART_SIFIVE
#define UART0_BASE_ADDR (0x10010000ull)

#define MTIME_BASE_ADDR 0x200bff8ull
#define MTIMECMP_BASE_ADDR 0x2004000ull

// Min and max usable hart ID.
#define S3K_MIN_HART 1
#define S3K_MAX_HART 4

// Total number of usable harts.
#define S3K_HART_CNT (S3K_MAX_HART - S3K_MIN_HART + 1ul)

// Number of PMP slots.
#define S3K_PMP_CNT 8

// RTC ticks per second
#define S3K_RTC_HZ 1000000ull

/// Stack size of 1024 KiB
#define S3K_LOG_STACK_SIZE 10

#define UART_SIFIVE

#define INIT_CAPS \
{ \
[0] = cap_mk_pmp(0x20005fff, MEM_RWX), \
[1] = cap_mk_memory(0x80020000, 0x80100000, MEM_RWX), \
[2] = cap_mk_memory(0x10010000, 0x10011000, MEM_RW), \
[3] = cap_mk_memory(0x200b000, 0x200c000, MEM_R), \
[4] = cap_mk_time(1, 0, S3K_SLOT_CNT), \
[5] = cap_mk_time(2, 0, S3K_SLOT_CNT), \
[6] = cap_mk_time(3, 0, S3K_SLOT_CNT), \
[7] = cap_mk_time(4, 0, S3K_SLOT_CNT), \
[8] = cap_mk_monitor(0, S3K_PROC_CNT), \
[9] = cap_mk_channel(0, S3K_CHAN_CNT), \
}
14 changes: 10 additions & 4 deletions plat/virt/plat_conf.h → plat64/inc/plat/virt.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#ifndef __PLAT_CONF_H__
#define __PLAT_CONF_H__
/**
* Platform configuration for QEMU virt
*/
#pragma once

#define UART_NS16550A
#define UART0_BASE_ADDR (0x10000000ull)

#define MTIME_BASE_ADDR 0x200bff8ull
#define MTIMECMP_BASE_ADDR 0x2004000ull

// Min and max usable hart ID.
#define S3K_MIN_HART 0
Expand Down Expand Up @@ -30,5 +38,3 @@
[8] = cap_mk_monitor(0, S3K_PROC_CNT), \
[9] = cap_mk_channel(0, S3K_CHAN_CNT), \
}

#endif /* __PLAT_CONF_H__ */
69 changes: 3 additions & 66 deletions projects/hello/app0/Makefile
Original file line number Diff line number Diff line change
@@ -1,68 +1,5 @@
BUILD?=build
PROGRAM?=app0
PROGRAM=app0

ROOT=../../..
COMMON=${ROOT}/common
PLATFORM=${ROOT}/plat/virt
SRCS=start/start.S main.c s3k/s3k.c s3klib/altio.c

include ${ROOT}/tools.mk
include ${PLATFORM}/platform.mk

vpath %.c src ${COMMON}/src
vpath %.S src ${COMMON}/src

SRCS=init/start.S init/common.S altio/altio.c s3k/s3k.c
SRCS+=${DRIVERS}
SRCS+=main.c

OBJS=${patsubst %, ${BUILD}/${PROGRAM}/%.o, ${SRCS}}
DEPS=${patsubst %, ${BUILD}/${PROGRAM}/%.d, ${SRCS}}

CFLAGS+=-march=${ARCH} -mabi=${ABI} -mcmodel=${CMODEL}
CFLAGS+=-nostartfiles -nostdlib
CFLAGS+=-DSTACK_SIZE=1024
CFLAGS+=-T${PLATFORM}/platform.ld -Tlinker.ld
CFLAGS+=-Wl,--no-warn-rwx-segments
CFLAGS+=-O2

INC=-Iinc -I${COMMON}/inc -include ${S3K_CONF_H} -include ${PLAT_CONF_H}

ELF=${BUILD}/${PROGRAM}.elf
BIN=${ELF:.elf=.bin}
DA=${ELF:.elf=.da}

all: ${ELF} ${BIN} ${DA}

elf: ${ELF}
bin: ${BIN}
da: ${DA}

${BUILD}/${PROGRAM}/%.S.o: %.S
@mkdir -p ${@D}
@echo "CC $@"
@${CC} ${CFLAGS} ${INC} -MMD -c -o $@ $<

${BUILD}/${PROGRAM}/%.c.o: %.c
@mkdir -p ${@D}
@echo "CC $@"
@${CC} ${CFLAGS} ${INC} -MMD -c -o $@ $<

${ELF}: ${OBJS}
@mkdir -p ${@D}
@echo "CC $@"
@${CC} ${CFLAGS} -MMD ${INC} -o $@ ${OBJS}

${BIN}: ${ELF}
@echo "OBJCOPY $@"
@${OBJCOPY} -O binary $< $@

${DA}: ${ELF}
@echo "OBJDUMP $@"
@${OBJDUMP} -D $< > $@

clean:
rm -f ${ELF} ${BIN} ${DA} ${OBJS} ${DEPS}

.PHONY: all elf bin da clean

-include ${DEPS}
include ../default.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "altio/altio.h"
#include "s3k/s3k.h"
#include "s3klib/altio.h"

#define APP0_PID 0
#define APP1_PID 1
Expand Down
Loading

0 comments on commit 96857b7

Please sign in to comment.