diff --git a/kernel/Makefile b/kernel/Makefile index 5471cb91..db95c26a 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -3,7 +3,7 @@ CC = $(ARCH)-gcc LD = $(ARCH)-ld OBJCOPY = $(ARCH)-objcopy -CFLAGS = -g -O0 -nostdlib -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Wall -Wextra -mcpu=cortex-a72 -I. -I../shared -I../user +CFLAGS = -g -O0 -std=c17 -nostdlib -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Wall -Wextra -mcpu=cortex-a72 -I. -I../shared -I../user LDFLAGS = -T $(shell ls *.ld) C_SRC = $(shell find . -name '*.c') diff --git a/kernel/exceptions/exception_handler.c b/kernel/exceptions/exception_handler.c index 3f34039b..712b9e66 100644 --- a/kernel/exceptions/exception_handler.c +++ b/kernel/exceptions/exception_handler.c @@ -8,6 +8,10 @@ #include "theme/theme.h" #include "std/string.h" +#ifndef asm +#define asm __asm__ +#endif + static bool panic_triggered = false; void set_exception_vectors(){ diff --git a/kernel/fw/fw_cfg.c b/kernel/fw/fw_cfg.c index 8b730c8d..6a29dd9a 100644 --- a/kernel/fw/fw_cfg.c +++ b/kernel/fw/fw_cfg.c @@ -14,6 +14,7 @@ #define FW_LIST_DIRECTORY 0x19 + static bool checked = false; struct fw_cfg_dma_access { diff --git a/run b/run index 5dc8ca7a..26e3bfd4 100755 --- a/run +++ b/run @@ -1,4 +1,4 @@ -#/!bin/sh +#!/bin/sh echo "Running emulator" @@ -15,19 +15,33 @@ if echo "$XHCI_CAPABILITIES" | grep -q "msi "; then MSI_CAPABILITIES="msi=on,msix=off," fi +OS_TYPE="$(uname)" + +if [[ "$OS_TYPE" == "Darwin" ]]; then + NETARG="vmnet-bridged,id=net0,ifname=en0" + +elif [[ "$OS_TYPE" == "Linux" ]]; then + NETARG="user,id=net0" + +else + echo "Unknown OS: $OS_TYPE" >&2 + exit 1 +fi + + qemu-system-aarch64 \ --M virt \ --cpu cortex-a72 \ --m 512M \ --kernel kernel.elf \ --device virtio-gpu-pci \ --display sdl \ --netdev vmnet-bridged,id=net0,ifname=en0 \ --device virtio-net-pci,netdev=net0 \ --serial mon:stdio \ --drive file=disk.img,if=none,format=raw,id=hd0 \ --device virtio-blk-pci,drive=hd0 \ --device qemu-xhci,${MSI_CAPABILITIES}id=usb \ --device usb-kbd,bus=usb.0 \ --d guest_errors \ -$ARGS + -M virt \ + -cpu cortex-a72 \ + -m 512M \ + -kernel kernel.elf \ + -device virtio-gpu-pci \ + -display sdl \ + -netdev ${NETARG} \ + -device virtio-net-pci,netdev=net0 \ + -serial mon:stdio \ + -drive file=disk.img,if=none,format=raw,id=hd0 \ + -device virtio-blk-pci,drive=hd0 \ + -device qemu-xhci,${MSI_CAPABILITIES}id=usb \ + -device usb-kbd,bus=usb.0 \ + -d guest_errors \ + $ARGS diff --git a/shared/Makefile b/shared/Makefile index 7f3ebf38..fb7390db 100644 --- a/shared/Makefile +++ b/shared/Makefile @@ -3,7 +3,7 @@ CC = $(ARCH)-gcc AR = $(ARCH)-ar OBJCOPY = $(ARCH)-objcopy -CFLAGS = -g -O0 -nostdlib -nolibc -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Wall -Wextra -mcpu=cortex-a72 -I. -I../kernel -Wno-unused-parameter +CFLAGS = -g -O0 -std=c17 -nostdlib -nolibc -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Wall -Wextra -mcpu=cortex-a72 -I. -I../kernel -Wno-unused-parameter C_SRC = $(shell find . -name '*.c') CPP_SRC = $(shell find . -name '*.cpp') diff --git a/shared/types.h b/shared/types.h index 0b58af56..0b6dc865 100644 --- a/shared/types.h +++ b/shared/types.h @@ -1,9 +1,15 @@ #pragma once +#ifndef asm +#define asm __asm__ +#endif + #ifdef __cplusplus extern "C" { #endif + + typedef unsigned int uint32_t; typedef long unsigned int size_t; typedef unsigned long uint64_t; diff --git a/user/Makefile b/user/Makefile index 48042a7d..fb6b8328 100644 --- a/user/Makefile +++ b/user/Makefile @@ -3,7 +3,7 @@ CC = $(ARCH)-gcc LD = $(ARCH)-ld OBJCOPY = $(ARCH)-objcopy -CFLAGS = -g -O0 -nostdlib -ffreestanding -Wall -Wextra -mcpu=cortex-a72 -I. -I../shared -Wno-unused-parameter +CFLAGS = -g -O0 -std=c17 -nostdlib -ffreestanding -Wall -Wextra -mcpu=cortex-a72 -I. -I../shared -Wno-unused-parameter LDFLAGS = -T $(shell ls *.ld) C_SRC = $(shell find . -name '*.c')