test: Update so it builds with LLVM
This commit is contained in:
parent
652a6d2575
commit
04c4c42779
@ -3,17 +3,18 @@ CFLAGS = -O2
|
||||
LD = cc
|
||||
QEMU = qemu-system-x86_64
|
||||
QEMUFLAGS = -m 1G -enable-kvm -cpu host
|
||||
LDINTERNALFLAGS := -Tlinker.ld -nostdlib -pie -static-pie -fno-pic -fpie -z max-page-size=0x1000
|
||||
INTERNALCFLAGS := -I../stivale -I. -ffreestanding -fno-stack-protector \
|
||||
-fno-pic -fpie -fomit-frame-pointer -mno-red-zone -mgeneral-regs-only -masm=intel
|
||||
LDINTERNALFLAGS := -Tlinker.ld -nostdlib -fno-pic -fpie -z max-page-size=0x1000 \
|
||||
-Wl,-static,-pie,--no-dynamic-linker,-ztext -static-pie
|
||||
INTERNALCFLAGS := -I../stivale -I. -ffreestanding -fno-stack-protector \
|
||||
-fno-pic -fpie -mno-red-zone -mno-80387 -mno-mmx -mno-3dnow -mno-sse -mno-sse2
|
||||
|
||||
all: test.elf
|
||||
|
||||
test.elf: stivale.o stivale2.o e9print.o
|
||||
$(LD) $(LDINTERNALFLAGS) stivale.o stivale2.o e9print.o -o test.elf
|
||||
test.elf: stivale.o stivale2.o e9print.o memory.o
|
||||
$(LD) $(LDINTERNALFLAGS) $^ -o test.elf
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf test.elf stivale.o stivale2.o e9print.o
|
||||
rm -rf test.elf stivale.o stivale2.o e9print.o memory.o
|
||||
|
@ -8,7 +8,7 @@ static const char CONVERSION_TABLE[] = "0123456789abcdef";
|
||||
void e9_putc(char c) {
|
||||
if (stivale2_print != NULL)
|
||||
stivale2_print(&c, 1);
|
||||
asm volatile ("out dx, al" :: "a" (c), "d" (0xE9) : "memory");
|
||||
asm volatile ("outb %0, %1" :: "a" (c), "Nd" (0xe9) : "memory");
|
||||
}
|
||||
|
||||
void e9_print(const char *msg) {
|
||||
|
52
test/memory.c
Normal file
52
test/memory.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t n) {
|
||||
uint8_t *pdest = dest;
|
||||
const uint8_t *psrc = src;
|
||||
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
pdest[i] = psrc[i];
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *memset(void *s, int c, size_t n) {
|
||||
uint8_t *p = s;
|
||||
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
p[i] = (uint8_t)c;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t n) {
|
||||
uint8_t *pdest = dest;
|
||||
const uint8_t *psrc = src;
|
||||
|
||||
if (src > dest) {
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
pdest[i] = psrc[i];
|
||||
}
|
||||
} else if (src < dest) {
|
||||
for (size_t i = n; i > 0; i--) {
|
||||
pdest[i-1] = psrc[i-1];
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t n) {
|
||||
const uint8_t *p1 = s1;
|
||||
const uint8_t *p2 = s2;
|
||||
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (p1[i] != p2[i])
|
||||
return p1[i] < p2[i] ? -1 : 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user