-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Major improvements from evaluation (#10)"
This reverts commit 2a9dabc.
- Loading branch information
1 parent
2a9dabc
commit 045d14e
Showing
90 changed files
with
2,636 additions
and
2,910 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
.POSIX: | ||
.SECONDARY: | ||
export ROOT=${abspath .} | ||
|
||
PROJECTS:=projects/hello \ | ||
projects/trapped \ | ||
projects/ping-pong \ | ||
projects/demonstrator | ||
|
||
all: ${PROJECTS} | ||
PROJECTS:=projects/hello projects/trapped projects/ping-pong | ||
PLATFORM?=qemu_virt | ||
|
||
include tools.mk | ||
include common/plat/${PLATFORM}.mk | ||
|
||
${PROJECTS}: common | ||
all: ${PROJECTS} | ||
|
||
common ${PROJECTS}: | ||
@${MAKE} -C $@ all | ||
make -C $@ all PLATFORM=${PLATFORM} | ||
|
||
clean: | ||
@for i in common ${PROJECTS}; do \ | ||
${MAKE} -C $$i clean; \ | ||
for i in ${PROJECTS}; do \ | ||
make -C $$i clean PLATFORM=${PLATFORM}; \ | ||
done | ||
|
||
docs: | ||
doxygen | ||
|
||
format: | ||
clang-format -i $$(find * -type f -name '*.[hc]') | ||
clang-format -i $(shell find -name '*.[hc]' -not -path '*/.*') | ||
|
||
.PHONY: all clean format common ${PROJECTS} | ||
.PHONY: all docs clean common ${PROJECTS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,57 @@ | ||
.POSIX: | ||
.SECONDARY: | ||
|
||
PLATFORM?=${patsubst plat/%.mk, %, ${wildcard plat/*.mk}} | ||
include plat/${PLATFORM}.mk | ||
|
||
all: ${addsuffix .all, ${PLATFORM}} | ||
clean: ${addsuffix .clean, ${PLATFORM}} | ||
include ${ROOT}/tools.mk | ||
|
||
%.all: | ||
${MAKE} -f build.mk PLATFORM=${@:.all=} all | ||
# CFLAGS | ||
CFLAGS:=-march=${ARCH} -mabi=${ABI} -mcmodel=${CMODEL} \ | ||
-DPLATFORM_${PLATFORM} \ | ||
-Os -flto -ffat-lto-objects \ | ||
-nostdlib -Iinc \ | ||
|
||
%.clean: | ||
${MAKE} -f build.mk PLATFORM=${@:.clean=} clean | ||
BUILD :=build/${PLATFORM} | ||
SRCS2OBJS=${patsubst src/%.S, ${BUILD}/%.o, ${filter %.S, ${1}}} \ | ||
${patsubst src/%.c, ${BUILD}/%.o, ${filter %.c, ${1}}} | ||
|
||
ALTC_SRCS :=${wildcard src/altc/*.[cS]} | ||
S3K_SRCS :=${wildcard src/s3k/*.[cS]} | ||
START_SRCS:=${wildcard src/start/*.S} | ||
|
||
PLAT_OBJS :=${call SRCS2OBJS, ${PLAT_SRCS}} | ||
ALTC_OBJS :=${call SRCS2OBJS, ${ALTC_SRCS}} | ||
S3K_OBJS :=${call SRCS2OBJS, ${S3K_SRCS}} | ||
START_OBJS:=${call SRCS2OBJS, ${START_SRCS}} | ||
|
||
TARGETS:=${BUILD}/libplat.a \ | ||
${BUILD}/libaltc.a \ | ||
${BUILD}/libs3k.a \ | ||
${START_OBJS} | ||
|
||
|
||
all: ${TARGETS} | ||
|
||
clean: | ||
rm -rf ${TARGETS} | ||
|
||
${BUILD}/libplat.a: ${PLAT_OBJS} | ||
@mkdir -p ${@D} | ||
${AR} cr $@ $^ | ||
|
||
${BUILD}/libaltc.a: ${ALTC_OBJS} | ||
@mkdir -p ${@D} | ||
${AR} cr $@ $^ | ||
|
||
${BUILD}/libs3k.a: ${S3K_OBJS} | ||
@mkdir -p ${@D} | ||
${AR} cr $@ $^ | ||
|
||
${BUILD}/%.o: src/%.c | ||
@mkdir -p ${@D} | ||
${CC} -o $@ $< -c ${CFLAGS} | ||
|
||
${BUILD}/%.o: src/%.S | ||
@mkdir -p ${@D} | ||
${CC} -o $@ $< -c ${CFLAGS} | ||
|
||
.PHONY: all clean |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
#pragma once | ||
#include <stdarg.h> | ||
#include <stddef.h> | ||
|
||
int alt_getchar(void); | ||
int alt_putchar(char c); | ||
int alt_putstr(const char *str); | ||
int alt_puts(const char *str); | ||
int alt_gets(char *str); | ||
int alt_printf(const char *fmt, ...); | ||
int alt_snprintf(char *restrict s, size_t n, const char *restrict fmt, ...); | ||
int alt_vsnprintf(char *restrict s, size_t n, const char *restrict fmt, | ||
va_list ap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.globl memchr | ||
.type memchr,@function | ||
|
||
.section .text.libaltc | ||
|
||
// void *memchr(const void *s, int c, size_t n); | ||
memchr: | ||
beqz a2,2f // if (n == 0) goto exit1; | ||
add a2,a2,a0 // char *a2 = s + n; | ||
andi a1,a1,0xFF // c = c & 0xFF; | ||
// do { | ||
1: lb t0,(a0) // t0 = *s; | ||
addi a0,a0,1 // ++s; | ||
beq t0,a1,3f // if (t0 == c) goto exit2; | ||
bne a0,a1,1b // } while (s != a2); | ||
2: li a0,0 // exit1: return NULL; | ||
3: ret // exit2: return s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.globl memcmp | ||
.type memcmp,@function | ||
|
||
.section .text.libaltc | ||
|
||
// int memcmp(const void *s1, const void *s2, size_t n); | ||
memcmp: | ||
beqz a2,2f // if (n == 0) goto eq; | ||
add a2,a2,a0 // char *a2 = s + n; | ||
// do { | ||
1: lb t0,(a0) // char t0 = *s1; | ||
lb t1,(a1) // char t1 = *s2; | ||
addi a0,a0,1 // ++s1; | ||
addi a1,a1,1 // ++s2; | ||
bne t0,t1,3f // if (t0 != t1) goto neq; | ||
bne a0,a2,1b // } while (s1 != a2); | ||
2: li a0,1 // eq: return 1; | ||
ret | ||
3: li a0,0 // neq: return 0; | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.globl memcpy | ||
.type memcpy,@function | ||
|
||
.section .text.libaltc | ||
|
||
// void *memcpy(void *dst, const void *src, size_t n); | ||
memcpy: | ||
beqz a2,2f // if (n == 0) goto exit; | ||
mv t0,a0 // t0 = dst; | ||
add a2,a2,a0 // a2 = dst + n; | ||
// do { | ||
1: lb t1,(a1) // t1 = *src; | ||
addi a1,a1,1 // ++src; | ||
addi t0,t0,1 // ++t0; | ||
sb t1,-1(t0) // *(t0-1) = t1; | ||
bne t0,a2,1b // } while (t0 != a2); | ||
2: ret // exit: return dst; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.globl memmove | ||
.type memmove,@function | ||
|
||
.section .text.libaltc | ||
|
||
// void *memmove(void *dst, const void *src, size_t n); | ||
memmove: | ||
beq a0,a1,2f // if (dst == src) goto exit; | ||
beqz a2,2f // if (n == 0) goto exit; | ||
bltu a0,a1,memcpy // if (dst < src) memcpy(dst, src, n); | ||
add a2,a2,a0 // a2 = dst + n; | ||
add a1,a1,a0 // src = src + n; | ||
// do { | ||
1: lb t1,(a1) // t1 = *src; | ||
addi a1,a1,-1 // --src; | ||
addi a2,a2,-1 // --a2; | ||
sb t1,1(a2) // *(a2+1) = t1; | ||
bne a2,a0,1b // } while (a2 != dst); | ||
2: ret // exit: return dst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.globl memset | ||
.type memset,@function | ||
|
||
.section .text.libaltc | ||
|
||
// void *memset(void *s, int c, size_t n); | ||
memset: | ||
beqz a2,2f // if (n == 0) goto exit; | ||
mv t0,a0 // char *t0 = s; | ||
add a2,a2,a0 // char *a2 = s + n; | ||
// do { | ||
1: sb a1,(t0) // *t0 = c; | ||
addi t0,t0,1 // ++t0; | ||
bne t0,a2,1b // } while (t0 != a2); | ||
2: ret // exit: return s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.