我是裸机和内核编程的新手,还有什么比打招呼世界更好的方式开始我的旅程!
不幸的是,当涉及到我选择的体系结构PPC64(使用QEMU和OpenFirmware)时,我很难找到有关如何使用固件制作Hello World程序的相关信息或代码示例。
到目前为止,我一直在努力使最简单的东西正常工作,到目前为止,我已经尝试使用此start
作为我的主要功能和此链接描述文件:
.section .boot, "aw"
.global start
start:
b start # Basically halt the machine.
ENTRY(start)
SECTIONS
{
. = 1M;
.text : {
*(.boot)
*(.text*)
}
.data : {
*(.data*)
*(.rodata*)
}
.bss : {
*(COMMON)
*(.bss)
}
}
我已经测试过:
clang --target=ppc64-unknown-elf -c <asm_file> -o <asm_file>.o
ld.lld --oformat elf_ppc64 --nostdlib -T <linkscript> <asm_file>.o -o output.elf
qemu-system-ppc64 -kernel output.elf -serial stdio
但是到目前为止,我尝试的唯一结果是QEMU仿真中SLOF的输出:
Detected RAM kernel at 400000 (4 bytes)
Welcome to Open Firmware
Copyright (c) 2004, 2017 IBM Corporation All rights reserved.
This program and the accompanying materials are made available
under the terms of the BSD License available at
http://www.opensource.org/licenses/bsd-license.php
Booting from memory...
( 700 ) Program Exception [ 1dbf04c4 ]
R0 .. R7 R8 .. R15 R16 .. R23 R24 .. R31
8000000000002000 000000001e478200 0000000000000000 0000000000000000
000000001dc71000 8000000000000000 0000000000000000 0000000000000000
0000000000000000 000000001e477010 0000000000000000 0000000000000000
0000000000000000 0000000000000030 0000000000000000 0000000000000000
0000000000000000 000000000000005b 0000000000000000 0000000000000000
000000001dbf04c4 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000
我如何让这个小片段起作用?我可以使用任何文档来完成完整的hello world程序吗?预先感谢!
在此处查看micropython powerpc端口README:https://github.com/micropython/micropython/tree/master/ports/powerpc
它显示了如何运行qemu并直接将打开的固件跳过到测试程序中。您需要剥离的二进制文件而不是elf(请参见Makefile中的objcopy)
在该目录中有一个链接描述文件和一个head.S,向您显示了基础知识。
祝你好运!