Page 1 of 1

QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Posted: Sat Mar 16, 2024 2:39 pm
by egon
Hello,

I am starting my OSDev journey and I was really happy to find the barebones for the QEmu virt platform, so thank you very much for that.

I myself am trying to build a basic OS for ARMv8 AArch64 using assembly only so I spent some time porting the code you provided for the kernel.c file to assembly.

Here is the result, feel free to add it to the page if you believe it might be a nice addition.

Kind regards.

Code: Select all

.global kmain

.data

uartdr:     .quad   0x9000000
message:     .asciz  "Hello, World!"

.text

print:
    ldr     x2,    [x0]
    cmp     x2,     #0
    beq     end
    strb    w2,    [x1]
    add     x0,     x0,     #1
    bl      print

end:
    ret

kmain:
    ldr     x0,     =message
    ldr     x1,     uartdr
    bl      print

QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Posted: Sun Mar 17, 2024 12:22 am
by egon
Hello,

I have ported the C code from the QEmu virt barebones article (https://wiki.osdev.org/QEMU_AArch64_Virt_Bare_Bones) to assembly in case anyone needs it.

Feel free to add it to the article if you find it useful.

Code: Select all

.global kmain

.data

uartdr:     .quad   0x9000000
msg:        .asciz  "Hello, World!\n"

.text

print:
    ldr     x2,    [x0]
    cmp     x2,     #0
    beq     end
    strb    w2,    [x1]
    add     x0,     x0,     #1
    bl      print

end:
    ret

kmain:
    ldr     x0,     =msg
    ldr     x1,     uartdr
    bl      print


Re: QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Posted: Tue Jun 11, 2024 11:03 am
by nullplan
I moved this to the OS Development board. Didn't have anything to do with the Wiki.

Re: QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Posted: Tue Jun 11, 2024 11:07 am
by nullplan
Dito here. BTW, I doubt this works, as kmain is missing the ret.