Initial AMD64 support (bootloader)

This commit is contained in:
Furkan Mudanyali 2023-11-24 09:13:03 +03:00
parent 47232020b1
commit aafa37ad06
15 changed files with 530 additions and 82 deletions

6
.gitignore vendored
View File

@ -41,4 +41,8 @@ yukari.bin
yukari.uimg
asagiri.img
drive.img
boot.scr
boot.scr
# Toolchain files
binutils-*.tar.gz
gcc-*.tar.gz

View File

@ -1,57 +1,52 @@
include toolchain-aarch64.mk
override MAKEFLAGS += -rR
override IMAGE_NAME := asagiri
override KERNEL := yukari
override ARCH ?= aarch64
.PHONY: all
all: $(IMAGE_NAME).img
ifeq ($(ARCH),aarch64)
include toolchain-aarch64.mk
else ifeq ($(ARCH),x86_64)
include toolchain-x86_64.mk
else
$(error Unknown target architecture $(ARCH))
endif
.PHONY: run
run: $(IMAGE_NAME).img
if [ "$$(uname -a | grep -i 'microsoft')" ]; then \
export IMAGE_PATH=$$(wslpath -wa build/$(IMAGE_NAME).img); \
else \
export IMAGE_PATH=build/$(IMAGE_NAME).img; \
fi; \
qemu-system-aarch64 -M raspi3b -kernel u-boot/u-boot.bin -drive file=$$IMAGE_PATH,if=sd,format=raw -serial null -serial stdio
uboot:
git clone https://github.com/u-boot/u-boot.git --branch=v2023.10 --depth=1 2>/dev/null | true
sed -i '/panic("FDT and ATAGS support not compiled in\\n");/c\' u-boot/arch/arm/lib/bootm.c
SOURCE_DATE_EPOCH=0 $(MAKE) -C u-boot rpi_3_defconfig ARCH=arm CROSS_COMPILE=aarch64-none-elf-
SOURCE_DATE_EPOCH=0 $(MAKE) -C u-boot all ARCH=arm CROSS_COMPILE=aarch64-none-elf-
asagiri: build/bin/$(KERNEL)
override CFLAGS += \
-Iarch/$(ARCH) \
-Ilibc/include \
-Iyukari/include
-I$(KERNEL)/include
override LDFLAGS += \
-T arch/$(ARCH)/linker.ld
export ARCH
## KERNEL
override KCFILES := $(shell find -L arch/$$ARCH/* -type f -name '*.c')
override KCFILES := $(shell find -L arch/$(ARCH)/* -type f -name '*.c')
override KCFILES += $(shell find -L libc/* -type f -name '*.c')
override KCFILES += $(shell find -L yukari/* -type f -name '*.c')
override KASFILES := $(shell find -L arch/$$ARCH/* -type f -name '*.S')
override KOBJ := $(addprefix build/kern/obj/,$(KCFILES:.c=.c.o) $(KASFILES:.S=.S.o))
override KCFILES += $(shell find -L $(KERNEL)/* -type f -name '*.c')
override KASFILES := $(shell find -L arch/$(ARCH)/* -type f -name '*.S')
override KOBJ := $(addprefix build/$(KERNEL)/obj/,$(KCFILES:.c=.c.o) $(KASFILES:.S=.S.o))
# Compilation rules for kern *.c files.
build/kern/obj/%.c.o: %.c
build/$(KERNEL)/obj/%.c.o: %.c
mkdir -p "$$(dirname $@)"
$(CC) $(CFLAGS) -D_IS_KLIBC -c $< -o $@
# Compilation rules for kern *.S files.
build/kern/obj/%.S.o: %.S
build/$(KERNEL)/obj/%.S.o: %.S
mkdir -p "$$(dirname $@)"
$(CC) $(CFLAGS) -D_IS_KLIBC -c $< -o $@
# Linking the kernel
build/bin/$(KERNEL): $(KOBJ)
mkdir -p "$$(dirname $@)"
$(LD) $(KOBJ) $(LDFLAGS) -o $@
#### Userspace
override CFILES += $(shell find -L libc/* -type f -name '*.c')
override OBJ := $(addprefix build/obj/,$(CFILES:.c=.c.o) $(ASFILES:.S=.S.o))
override CFILES := $(shell find -L libc/* -type f -name '*.c')
override OBJ := $(addprefix build/obj/,$(CFILES:.c=.c.o))
# Compilation rules for *.c files.
build/obj/%.c.o: %.c
@ -63,22 +58,31 @@ build/obj/%.S.o: %.S
mkdir -p "$$(dirname $@)"
$(CC) $(CFLAGS) -c $< -o $@
# Linking the kernel
build/bin/$(KERNEL): $(KOBJ)
mkdir -p "$$(dirname $@)"
$(LD) $(KOBJ) $(LDFLAGS) -o $@
asagiri: build/bin/$(KERNEL)
$(IMAGE_NAME).img: asagiri
# Create directory
mkdir -p "$$(dirname $@)"
$(OBJCOPY) -O binary build/bin/yukari build/yukari.bin
SOURCE_DATE_EPOCH=0 ./u-boot/tools/mkimage -A arm64 -C none -O linux -T kernel -d build/yukari.bin -a 0x1000000 -e 0x1000000 build/yukari.uimg
# Create uboot image from the kernel elf if AARCH64
ifeq ($(ARCH),aarch64)
$(OBJCOPY) -O binary build/bin/$(KERNEL) build/$(KERNEL).bin
SOURCE_DATE_EPOCH=0 ./u-boot/tools/mkimage -A arm64 -C none -O linux -T kernel -d build/$(KERNEL).bin -a 0x1000000 -e 0x1000000 build/$(KERNEL).uimg
SOURCE_DATE_EPOCH=0 ./u-boot/tools/mkimage -A arm64 -C none -T script -n "Boot script" -d "arch/aarch64/res/boot.cmd" build/boot.scr
endif
# Create disk drive
qemu-img create build/$(IMAGE_NAME).img 4M
mformat -N 7777777 -i build/$(IMAGE_NAME).img ::
faketime "1970-01-01 00:00:00" mcopy -p -m -i build/$(IMAGE_NAME).img build/yukari.uimg ::
# Add files to disk drive
ifeq ($(ARCH),aarch64)
faketime "1970-01-01 00:00:00" mcopy -p -m -i build/$(IMAGE_NAME).img build/$(KERNEL).uimg ::
faketime "1970-01-01 00:00:00" mcopy -p -m -i build/$(IMAGE_NAME).img build/boot.scr ::
else
faketime "1970-01-01 00:00:00" mcopy -p -m -i build/$(IMAGE_NAME).img build/bin/$(KERNEL) ::
faketime "1970-01-01 00:00:00" mmd -i build/$(IMAGE_NAME).img ::/EFI
faketime "1970-01-01 00:00:00" mmd -i build/$(IMAGE_NAME).img ::/EFI/BOOT
faketime "1970-01-01 00:00:00" mcopy -p -m -i build/$(IMAGE_NAME).img build/bin/BOOTX64.EFI ::/EFI/BOOT
endif
.PHONY: clean
clean:

View File

@ -1,3 +1,21 @@
/**
* stdarg.h implementation of Asagiri
* Copyright (C) 2023 Asagiri contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)

View File

@ -72,8 +72,8 @@ void fb_init() {
mbox[2] = MBOX_TAG_SETPHYWH;
mbox[3] = 8; // Value size in bytes
mbox[4] = 0;
mbox[5] = 1920; // Width, hardcoded for now
mbox[6] = 1080; // Height, hardcoded for now
mbox[5] = 640; // Width, hardcoded for now
mbox[6] = 480; // Height, hardcoded for now
mbox[7] = MBOX_TAG_SETVIRTWH;
mbox[8] = 8;

View File

@ -0,0 +1,55 @@
/**
* alltypes.h implementation of Asagiri
* Copyright (C) 2023 Asagiri contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _ASAGIRI_ALLTYPES_H
#define _ASAGIRI_ALLTYPES_H
#define _Addr long
#define _Int64 long
#define _Reg long
#define __CHAR_MAX 0x7f
#define __UCHAR_MAX 0xff
#define __SHRT_MAX 0x7fff
#define __USHRT_MAX 0xffff
#define __INT_MAX 0x7fffffff
#define __UINT_MAX 0xffffffff
#define __LONG_MAX 0x7fffffffffffffffL
#define __ULONG_MAX 0xffffffffffffffffUL
#define __LLONG_MAX 0x7fffffffffffffffLL
#define __ULLONG_MAX 0xffffffffffffffffULL
typedef unsigned wint_t;
typedef int blksize_t;
typedef unsigned int nlink_t;
typedef float float_t;
typedef double double_t;
typedef int size_t;
typedef char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef long int64_t;
typedef unsigned long uint64_t;
typedef long intptr_t;
typedef unsigned long uintptr_t;
#endif

25
arch/x86_64/bits/stdarg.h Normal file
View File

@ -0,0 +1,25 @@
/**
* stdarg.h implementation of Asagiri
* Copyright (C) 2023 Asagiri contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#define va_copy(d,s) __builtin_va_copy(d,s)
typedef __builtin_va_list va_list;
typedef __builtin_va_list __isoc_va_list;

33
arch/x86_64/hal.c Normal file
View File

@ -0,0 +1,33 @@
/**
* HAL implementation for x86_64 of asagiri
* Copyright (C) 2023 Furkan Mudanyali
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <hal.h>
void hcf() {
asm("hlt");
}
void outb(uint16_t port, uint8_t val) {
asm("outb %0, %1" : : "a"(val), "Nd"(port));
}
uint8_t inb(uint16_t port) {
uint8_t ret;
asm("inb %1, %0" : "=a"(ret) : "Nd"(port));
return ret;
}

30
arch/x86_64/hal.h Normal file
View File

@ -0,0 +1,30 @@
/**
* HAL implementation for x86_64 of asagiri
* Copyright (C) 2023 Furkan Mudanyali
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _ASAGIRI_HAL_H
#define _ASAGIRI_HAL_H
#include <bits/alltypes.h>
#define asm __asm__ __volatile__
void hcf();
void outb(uint16_t, uint8_t);
uint8_t inb(uint16_t);
#endif

28
arch/x86_64/linker.ld Normal file
View File

@ -0,0 +1,28 @@
ENTRY(_start)
SECTIONS
{
. = 2M;
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
}

View File

@ -19,25 +19,30 @@
#include <stdio.h>
#ifdef _IS_KLIBC
#if ARCH == aarch64
#if _ARCH_AARCH64
#include <uart.h>
#else
// TODO: other arch implementation
#endif
#else
// TODO: Userspace implementation
#endif
int putchar(int ic) {
// aarch64 print function
#ifdef _IS_KLIBC
#if ARCH == aarch64
#ifdef _IS_KLIBC
#if _ARCH_AARCH64
uart_putc((char)ic);
#else
#else
// TODO: other arch implementation
#endif
#else
#endif
#else
// TODO: Userspace implementation
#endif
#endif
return ic;
}

View File

@ -0,0 +1,81 @@
#!/bin/bash
set -euo pipefail
export PREFIX="$HOME/cross-x86_64"
export TARGET="x86_64-none-elf"
export TARGET2="x86_64-none-pe"
export PATH="$PREFIX/bin:$PATH"
# Get thread count
if [ "$(uname)" == "Darwin" ]; then
export NPROC="sysctl -n hw.physicalcpu"
else
export NPROC="nproc"
fi
existGCC=0
existBIN=0
if [ -e binutils-2.41.tar.gz ]; then
existBIN=1
fi
if [ -e gcc-13.2.0.tar.gz ]; then
existGCC=1
fi
if [[ "${existBIN}" != "1" ]]; then
wget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.gz
fi
if [[ "${existGCC}" != "1" ]]; then
wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz
fi
startLoc=$(pwd)
# Create prefix path
mkdir -p $PREFIX
# Create compilation directory
cd /tmp
rm -rf toolchain
mkdir -p toolchain
cd toolchain
cp "${startLoc}/binutils-2.41.tar.gz" .
cp "${startLoc}/gcc-13.2.0.tar.gz" .
# Build binutils for aarch64
# might need texinfo
mkdir -p binutils-src
tar -xvf binutils-2.41.tar.gz -C binutils-src/
mkdir -p binutils
cd binutils
../binutils-src/*/configure --target=$TARGET --enable-targets=$TARGET,$TARGET2 --prefix=$PREFIX --libexecdir=$PREFIX/lib \
--enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-plugin \
--disable-linker-build-id --enable-lto --enable-install-libiberty --with-linker-hash-style=gnu --with-gnu-ld\
--enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie \
--enable-default-ssp --enable-gnu-unique-object --with-zstd=no
make -j$($NPROC)
make install
# Build gcc for aarch64
cd ..
mkdir -p gcc-src
tar -xvf gcc-13.2.0.tar.gz -C gcc-src/
cd gcc-src/*/
./contrib/download_prerequisites
cd ../../
mkdir -p gcc
cd gcc
../gcc-src/*/configure --target=$TARGET --prefix=$PREFIX --disable-shared --disable-nls --disable-threads --disable-tls \
--enable-checking=release --enable-languages=c,c++ --with-newlib --with-gnu-as --with-gnu-ld --without-headers
make -j$($NPROC) all-gcc
make install-gcc
make -j$($NPROC) all-target-libgcc
make install-target-libgcc
cd
rm -rf /tmp/toolchain
echo "Toolchain installation is complete!"
echo "Please add this to your bashrc or zshrc or whatever"
echo "export PATH=\"$PREFIX/bin:\$PATH\""

35
shinobu/shinobu.c Normal file
View File

@ -0,0 +1,35 @@
/**
* AMD64 Bootloader of Asagiri
* Copyright (C) 2023 Asagiri contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <efi/efi.h>
#include <efi/efilib.h>
EFI_STATUS
EFIAPI
efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
// Store SystemTable
ST = SystemTable;
// Print string
uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"Hello world from the UEFI!\r\n");
// Busy-loop wait for keystroke
while(uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, NULL));
// Exit boot services
uefi_call_wrapper(ST->BootServices->Exit, 4, ImageHandle, EFI_SUCCESS, NULL, NULL);
return EFI_SUCCESS;
}

View File

@ -1,26 +1,45 @@
override ARCH := aarch64
override CC := aarch64-none-elf-gcc
override LD := aarch64-none-elf-ld
override OBJCOPY := aarch64-none-elf-objcopy
override CFLAGS := -g -O3 -pipe
override CFLAGS := \
-O3 \
-pipe \
-Wall \
-Wextra \
-std=c99 \
-ffreestanding \
-fno-stack-protector \
-fno-stack-check \
-fno-lto \
-fPIE \
-march=armv8-a \
-D_ARCH_AARCH64
override CFLAGS += \
-Wall \
-Wextra \
-std=c99 \
-ffreestanding \
-fno-stack-protector \
-fno-stack-check \
-fno-lto \
-fPIE \
-march=armv8-a
override LDFLAGS += \
-m aarch64elf \
-nostdlib \
-static \
-pie \
--no-dynamic-linker \
override LDFLAGS := \
-m aarch64elf \
-nostdlib \
-static \
-pie \
--no-dynamic-linker \
-z noexecstack --no-warn-rwx-segments
.PHONY: all
all: $(IMAGE_NAME).img
.PHONY: run
run: $(IMAGE_NAME).img
if [ "$$(uname -a | grep -i 'microsoft')" ]; then \
export IMAGE_PATH=$$(wslpath -wa build/$(IMAGE_NAME).img); \
else \
export IMAGE_PATH=build/$(IMAGE_NAME).img; \
fi; \
qemu-system-aarch64 -M raspi3b -kernel u-boot/u-boot.bin -drive file=$$IMAGE_PATH,if=sd,format=raw -serial null -serial stdio
### Bootloader
uboot:
git clone https://github.com/u-boot/u-boot.git --branch=v2023.10 --depth=1 2>/dev/null | true
sed -i '/panic("FDT and ATAGS support not compiled in\\n");/c\' u-boot/arch/arm/lib/bootm.c
SOURCE_DATE_EPOCH=0 $(MAKE) -C u-boot rpi_3_defconfig ARCH=arm CROSS_COMPILE=aarch64-none-elf-
SOURCE_DATE_EPOCH=0 $(MAKE) -C u-boot all ARCH=arm CROSS_COMPILE=aarch64-none-elf-

99
toolchain-x86_64.mk Normal file
View File

@ -0,0 +1,99 @@
override CC := x86_64-none-elf-gcc
override LD := x86_64-none-elf-ld
override OBJCOPY := x86_64-none-elf-objcopy
override BOOTLOADER := shinobu
override OVMF_CODE := /usr/share/OVMF/OVMF_CODE.fd
override OVMF_VARS := /usr/share/OVMF/OVMF_VARS.fd
override CFLAGS := \
-g \
-O3 \
-pipe \
-Wall \
-Wextra \
-std=c99 \
-ffreestanding \
-fno-stack-protector \
-fno-stack-check \
-fno-lto \
-mno-red-zone \
-fshort-wchar \
-fPIE \
-march=x86-64 \
-D_ARCH_AMD64
override LDFLAGS := \
-m elf_x86_64 \
-nostdlib \
-static \
--no-dynamic-linker \
-z noexecstack --no-warn-rwx-segments
.PHONY: all
all: shinobu $(IMAGE_NAME).img
.PHONY: run
run: shinobu $(IMAGE_NAME).img
if [ "$$(uname -a | grep -i 'microsoft')" ]; then \
export IMAGE_PATH=$$(wslpath -wa build/$(IMAGE_NAME).img); \
export OVMF_CODE=$$(wslpath -wa $(OVMF_CODE)); \
export OVMF_VARS=$$(wslpath -wa $(OVMF_VARS)); \
else \
export IMAGE_PATH=build/$(IMAGE_NAME).img; \
export OVMF_CODE=$(OVMF_CODE); \
export OVMF_VARS=$(OVMF_VARS); \
fi; \
qemu-system-x86_64 -cpu qemu64 -net none \
-drive if=pflash,format=raw,unit=0,file=$$OVMF_CODE,readonly=on \
-drive if=pflash,format=raw,unit=1,file=$$OVMF_VARS,readonly=on \
-drive if=ide,format=raw,file=$$IMAGE_PATH
### Bootloader
shinobu: build/bin/shinobu
override BCFILES := $(shell find -L $(BOOTLOADER)/* -type f -name '*.c')
override BOBJ := $(addprefix build/$(BOOTLOADER)/obj/,$(BCFILES:.c=.c.o))
override INC := /usr/include
override GNUEFICRT0 := /usr/lib/crt0-efi-x86_64.o
override GNUEFILDS := /usr/lib/elf_x86_64_efi.lds
override LIBS := /usr/lib
# Compilation rules for bootloader *.c files.
build/$(BOOTLOADER)/obj/%.c.o: %.c
mkdir -p "$$(dirname $@)"
$(CC) $(CFLAGS) \
-I$(INC) \
-DEFI_FUNCTION_WRAPPER \
-c $< -o $@
# Linking the bootloader
build/bin/$(BOOTLOADER): $(BOBJ)
mkdir -p "$$(dirname $@)"
$(LD) $(BOBJ) \
$(GNUEFICRT0) \
-T $(GNUEFILDS) \
-L $(LIBS) \
-l:libgnuefi.a \
-l:libefi.a \
-nostdlib \
-znocombreloc \
-shared \
-Bsymbolic \
-o $@
$(OBJCOPY) \
-j .text \
-j .sdata \
-j .data \
-j .dynamic \
-j .dynsym \
-j .rel \
-j .rela \
-j .reloc \
--target=efi-app-x86_64 \
$@ $$(dirname $@)/BOOTX64.EFI

View File

@ -16,32 +16,44 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <hal.h>
#if _ARCH_AARCH64
#include <fdt.h>
#include <uart.h>
#include <fb.h>
#else
//
#endif
#include <hal.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#ifdef _ARCH_AARCH64
void __attribute__((section (".text.boot"))) _start() {
#else
void kernel_main() {
#endif
#if _ARCH_AARCH64
fdt_init();
uart_init();
uart_puts("Selamunaleykum.\n");
uart_puts("Asagiri version pre-alpha\n");
uart_puts("UART initialized.\n");
uint32_t test = 0xDEADBEEF;
char teststr[10];
uitoa(test, teststr, 16);
print_fdt();
#endif
printf(
"Testing printf:\n"
"char: %c\n"
"str: %s\n"
"int: %d\n"
"hex: 0x%x\n"
, 'A', teststr, 747474, 0xDEADBABE
"Selamunaleykum.\n"
"Asagiri version pre-alpha\n"
"UART initialized.\n"
);
#if _ARCH_AARCH64
print_fdt();
fb_init();
#endif
hcf();
}