powerpc - 裸机 hello world PPC64 (QEMU + OFW) 不工作
问题描述
我是裸机和内核编程的新手,还有什么比使用 hello world 更好的方式来开始我的旅程!
可悲的是,当谈到我选择的架构 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 端口自述文件: https ://github.com/micropython/micropython/tree/master/ports/powerpc
它向您展示了如何运行 qemu 并将打开的固件直接跳过到您的测试程序中。您需要一个剥离的二进制文件而不是精灵(请参阅 Makefile 中的 objcopy)
在该目录中有一个链接器脚本和一个 head.S,它向您展示了基础知识。
祝你好运!
推荐阅读
- python - 在matplotlib python中过滤掉一个圆形边界
- python-3.x - 如果删除了语句错误,这怎么可能?
- python - 如何将字符串转换为二进制
- mysql - Node.js - 从 MySQL 获取一个值并将其分配给一个变量
- wordpress - 带有子域的 Wordpress 永久链接问题
- node.js - TypeError:无法读取未定义的属性“查找”(8:38)
- python - TypeError: UserCreateForm() 得到了一个意外的关键字参数“初始”
- python - 由于未知原因导致的 jupyter 笔记本错误
- java - 使用 dagger 2 在 android 中注入嵌套的 Recyclerview 适配器时遇到问题
- java - 单元测试 GraphQL 的 DataFetchingEnvironment 问题