User:Columbus/OR1K BareBones
Jump to navigation
Jump to search
Here a conversion of the Bare Bones tutorial to or1k.
Sources
boot.asm
# Declare constants for multiboot header. .set ALIGN, 1<<0 .set MEMINFO, 1<<1 .set FLAGS, ALIGN | MEMINFO .set MAGIC, 0x1BADB002 .set CHECKSUM, -(MAGIC + FLAGS) .section .multiboot .align 4 .long MAGIC .long FLAGS .long CHECKSUM .section .bootstrap_stack, "aw", @nobits stack_bottom: .skip 16384 # 16 KiB stack_top: .section .text .global _start .type _start, @function _start: # I think/hope, this sets the stack pointer l.movhi r3, hi(stack_top) l.ori r3, r3, lo(stack_top) l.sw 0(r3), r1 # I hope this calls kernel_main l.jal kernel_main .Lhang: l.nop l.j .Lhang .size _start, . - _start
main.c
Can be the same, as in Bare Bones.
linker.ld
Can be the same, as in Bare Bones.
Compilation
or1k-elf-as boot.asm -o boot.o
or1k-elf-g++ -c main.c -o main.o -ffreestanding -O2 -Wall -Wextra -fno-exceptions -fno-rtti
or1k-elf-gcc -T linker.ld -o kernel -ffreestanding -O2 -nostdlib boot.o main.o -lgcc
Execution
Honestly, I don't know, if anything was right about the compilation, or boot.asm, and I also have no idea how to execute it. On my machine everything worked fine, until the execution.