QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
egon
Posts: 2
Joined: Sat Mar 16, 2024 2:27 pm

QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Post 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
egon
Posts: 2
Joined: Sat Mar 16, 2024 2:27 pm

QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Post 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

nullplan
Member
Member
Posts: 1780
Joined: Wed Aug 30, 2017 8:24 am

Re: QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Post by nullplan »

I moved this to the OS Development board. Didn't have anything to do with the Wiki.
Carpe diem!
nullplan
Member
Member
Posts: 1780
Joined: Wed Aug 30, 2017 8:24 am

Re: QEMU AArch64 Virt Bare Bones with Kernel in Assembly

Post by nullplan »

Dito here. BTW, I doubt this works, as kmain is missing the ret.
Carpe diem!
Post Reply