diff --git a/part12-wgt/Makefile b/part12-wgt/Makefile index 9e49e59..4e43900 100644 --- a/part12-wgt/Makefile +++ b/part12-wgt/Makefile @@ -8,11 +8,17 @@ all: clean kernel8.img boot/boot.o: boot/boot.S $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@ +bin/wgt1pal.o: bin/wgt1.pal + $(LLVMPATH)/llvm-objcopy -I binary -O elf64-littleaarch64 -B aarch64 $< $@ + +bin/wgt1blk.o: bin/wgt1.blk + $(LLVMPATH)/llvm-objcopy -I binary -O elf64-littleaarch64 -B aarch64 $< $@ + %.o: %.c $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@ -kernel8.img: boot/boot.o $(OFILES) - $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot/boot.o $(OFILES) -T boot/link.ld -o kernel8.elf +kernel8.img: boot/boot.o $(OFILES) bin/wgt1pal.o bin/wgt1blk.o + $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot/boot.o $(OFILES) bin/wgt1pal.o bin/wgt1blk.o -T boot/link.ld -o kernel8.elf $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img clean: diff --git a/part12-wgt/bin/wgt1.blk b/part12-wgt/bin/wgt1.blk new file mode 100644 index 0000000..cc8cb21 Binary files /dev/null and b/part12-wgt/bin/wgt1.blk differ diff --git a/part12-wgt/bin/wgt1.pal b/part12-wgt/bin/wgt1.pal new file mode 100644 index 0000000..1d8c8f1 Binary files /dev/null and b/part12-wgt/bin/wgt1.pal differ diff --git a/part12-wgt/examples/wgt11.c b/part12-wgt/examples/wgt11.c new file mode 100644 index 0000000..60ef1e4 --- /dev/null +++ b/part12-wgt/examples/wgt11.c @@ -0,0 +1,81 @@ +#include "wgt.h" +#include "include/mem.h" +#include "include/mb.h" + +// ######## REQUIRED FUNCTIONS ######## + +unsigned long state0 = 1000; +unsigned long state1 = 2000; + +unsigned long rand(void) +{ + unsigned long s1 = state0; + unsigned long s0 = state1; + + state0 = s0; + s1 ^= s1 << 23; + s1 ^= s1 >> 17; + s1 ^= s0; + s1 ^= s0 >> 26; + state1 = s1; + + return state0 + state1; +} + +void wait_msec(unsigned int n) +{ + register unsigned long f, t, r; + + // Get the current counter frequency + asm volatile ("mrs %0, cntfrq_el0" : "=r"(f)); + // Read the current counter + asm volatile ("mrs %0, cntpct_el0" : "=r"(t)); + // Calculate expire value for counter + t+=((f/1000)*n)/1000; + do{asm volatile ("mrs %0, cntpct_el0" : "=r"(r));}while(r 12) + { + ptr = malloc (size); + if (ptr == NULL) + return NULL; + orig = ptr; + + /* store width and height */ + *ptr++ = width; + *ptr++ = height; + for (int i=0;i