Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zCore使用qemu测试时无法使用pci #393

Closed
fish4terrisa-MSDSM opened this issue Oct 16, 2022 · 14 comments
Closed

zCore使用qemu测试时无法使用pci #393

fish4terrisa-MSDSM opened this issue Oct 16, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@fish4terrisa-MSDSM
Copy link

log在此:
`[ INFO]: src/main.rs@043: bootloader is running
[ INFO]: src/main.rs@159: opening file: \EFI\Boot\rboot.conf
[ INFO]: src/main.rs@181: loading file to memory
[ INFO]: src/main.rs@211: switching graphic mode
[ INFO]: src/main.rs@052: config: Config {
[ INFO]: src/main.rs@052: kernel_stack_address: 0xffffff0100000000,
[ INFO]: src/main.rs@052: kernel_stack_size: 0x200,
[ INFO]: src/main.rs@052: physical_memory_offset: 0xffff800000000000,
[ INFO]: src/main.rs@052: kernel_path: "\EFI\zCore\zcore.elf",
[ INFO]: src/main.rs@052: resolution: Some(
[ INFO]: src/main.rs@052: (
[ INFO]: src/main.rs@052: 0x320,
[ INFO]: src/main.rs@052: 0x258,
[ INFO]: src/main.rs@052: ),
[ INFO]: src/main.rs@052: ),
[ INFO]: src/main.rs@052: initramfs: None,
[ INFO]: src/main.rs@052: cmdline: "LOG=warn",
[ INFO]: src/main.rs@052: }
[ INFO]: src/main.rs@060: acpi2: 0x3fbfa014
[ INFO]: src/main.rs@068: smbios: 0x3fbcc000
[ INFO]: src/main.rs@159: opening file: \EFI\zCore\zcore.elf
[ INFO]: src/main.rs@181: loading file to memory
[ INFO]: src/page_table.rs@012: mapping ELF
[DEBUG]: src/page_table.rs@056: mapping segment: Ph64(
[DEBUG]: src/page_table.rs@056: ProgramHeader64 {
[DEBUG]: src/page_table.rs@056: type_: Ok(
[DEBUG]: src/page_table.rs@056: Load, [DEBUG]: src/page_table.rs@056: ), [DEBUG]: src/page_table.rs@056: flags: Flags( [DEBUG]: src/page_table.rs@056: 0x5, [DEBUG]: src/page_table.rs@056: ),
[DEBUG]: src/page_table.rs@056: offset: 0x1000,
[DEBUG]: src/page_table.rs@056: virtual_addr: 0xffffff0000000000,
[DEBUG]: src/page_table.rs@056: physical_addr: 0xffffff0000000000,
[DEBUG]: src/page_table.rs@056: file_size: 0xeea8b,
[DEBUG]: src/page_table.rs@056: mem_size: 0xeea8b,
[DEBUG]: src/page_table.rs@056: align: 0x1000,
[DEBUG]: src/page_table.rs@056: },
[DEBUG]: src/page_table.rs@056: )
[DEBUG]: src/page_table.rs@056: mapping segment: Ph64(
[DEBUG]: src/page_table.rs@056: ProgramHeader64 {
[DEBUG]: src/page_table.rs@056: type_: Ok(
[DEBUG]: src/page_table.rs@056: Load,
[DEBUG]: src/page_table.rs@056: ),
[DEBUG]: src/page_table.rs@056: flags: Flags(
[DEBUG]: src/page_table.rs@056: 0x4,
[DEBUG]: src/page_table.rs@056: ),
[DEBUG]: src/page_table.rs@056: offset: 0xf0000,
[DEBUG]: src/page_table.rs@056: virtual_addr: 0xffffff00000ef000,
[DEBUG]: src/page_table.rs@056: physical_addr: 0xffffff00000ef000,
[DEBUG]: src/page_table.rs@056: file_size: 0x2d5dc,
[DEBUG]: src/page_table.rs@056: mem_size: 0x2d5dc,
[DEBUG]: src/page_table.rs@056: align: 0x1000,
[DEBUG]: src/page_table.rs@056: },
[DEBUG]: src/page_table.rs@056: )
[DEBUG]: src/page_table.rs@056: mapping segment: Ph64(
[DEBUG]: src/page_table.rs@056: ProgramHeader64 {
[DEBUG]: src/page_table.rs@056: type_: Ok(
[DEBUG]: src/page_table.rs@056: Load,
[DEBUG]: src/page_table.rs@056: ),
[DEBUG]: src/page_table.rs@056: flags: Flags(
[DEBUG]: src/page_table.rs@056: 0x6,
[DEBUG]: src/page_table.rs@056: ),
[DEBUG]: src/page_table.rs@056: offset: 0x11e000,
[DEBUG]: src/page_table.rs@056: virtual_addr: 0xffffff000011d000,
[DEBUG]: src/page_table.rs@056: physical_addr: 0xffffff000011d000,
[DEBUG]: src/page_table.rs@056: file_size: 0x10090,
[DEBUG]: src/page_table.rs@056: mem_size: 0x10090,
[DEBUG]: src/page_table.rs@056: align: 0x1000,
[DEBUG]: src/page_table.rs@056: },
[DEBUG]: src/page_table.rs@056: )
[DEBUG]: src/page_table.rs@056: mapping segment: Ph64(
[DEBUG]: src/page_table.rs@056: ProgramHeader64 {
[DEBUG]: src/page_table.rs@056: type_: Ok(
[DEBUG]: src/page_table.rs@056: Load,
[DEBUG]: src/page_table.rs@056: ),
[DEBUG]: src/page_table.rs@056: flags: Flags(
[DEBUG]: src/page_table.rs@056: 0x6,
[DEBUG]: src/page_table.rs@056: ),
[DEBUG]: src/page_table.rs@056: offset: 0x12f000,
[DEBUG]: src/page_table.rs@056: virtual_addr: 0xffffff000012e000,
[DEBUG]: src/page_table.rs@056: physical_addr: 0xffffff000012e000,
[DEBUG]: src/page_table.rs@056: file_size: 0x0,
[DEBUG]: src/page_table.rs@056: mem_size: 0x1223038,
[DEBUG]: src/page_table.rs@056: align: 0x1000,
[DEBUG]: src/page_table.rs@056: },
[DEBUG]: src/page_table.rs@056: )
[ INFO]: src/page_table.rs@026: mapping stack at 0xffffff0100000000
[ INFO]: src/page_table.rs@160: mapping physical memory
[ INFO]: src/main.rs@127: exit boot services
[ 0.905347 WARN 0 0:0 zcore_drivers::bus::pci] NoResources, failed to initialize PCI device: 8086:29c0
[ 0.906437 WARN 0 0:0 zcore_drivers::bus::pci] NoResources, failed to initialize PCI device: 1234:1111
[ 0.907250 WARN 0 0:0 zcore_drivers::bus::pci] BAR0 set from 0xc1060000 to 0xc1060000
[ 0.907574 WARN 0 0:0 zcore_drivers::bus::pci] pci device enable done
[ 0.908796 WARN 0 0:0 zcore_drivers::bus::pci] NoResources, failed to initialize PCI device: 8086:2918
[ 0.909220 WARN 0 0:0 zcore_drivers::bus::pci] NotSupported, failed to initialize PCI device: 8086:2922
[ 0.909510 WARN 0 0:0 zcore_drivers::bus::pci] NoResources, failed to initialize PCI device: 8086:2930

panic cpu=0
panicked at 'cannot read block 0 offset 0 from device', /home/fish4terrisa/.cargo/git/checkouts/rcore-fs-7fdf258332f6146d/1a3246b/rcore-fs-sfs/src/lib.rs:40:18
[ 1.892844 ERROR 0 0:0 zcore::lang]

panicked at 'cannot read block 0 offset 0 from device', /home/fish4terrisa/.cargo/git/checkouts/rcore-fs-7fdf258332f6146d/1a3246b/rcore-fs-sfs/src/lib.rs:40:18`

@fish4terrisa-MSDSM
Copy link
Author

我所运行的qemu命令为:
qemu-system-x86_64 -smp 1 -machine q35 -cpu Haswell,+smap,-check,-fsgsbase -m 1G -serial mon:stdio -serial file:serial.out -drive format=raw,if=pflash,readonly=on,file=/storage/emulated/0/OVMF.fd -drive format=raw,file=fat:rw:/storage/emulated/0/xinhao/windows/esp -nic none -netdev user,id=net1,hostfwd=tcp::8000-:80,hostfwd=tcp::2222-:2222,hostfwd=udp::6969-:6969 -device e1000e,netdev=net1 -display none

@YdrMaster
Copy link
Collaborator

x86 我不怎么了解,不过可能提供一下你怎么编译的镜像会有帮助,有一些跟 pci 有关的 feature

@fish4terrisa-MSDSM
Copy link
Author

Kernel:
cd ./zCore
make build ARCH=x86_64 LINUX=1

@fish4terrisa-MSDSM
Copy link
Author

rootfs&image:
cargo rootfs --arch x86_64
cargo image --arch x86_64

@YdrMaster YdrMaster added the bug Something isn't working label Oct 17, 2022
@shzhxh
Copy link
Contributor

shzhxh commented Oct 17, 2022

make build ARCH=x86_64 LINUX=1

可以使用make run ARCH=x86_64 LINUX=1试试,可以检查一下对应的esp目录下是否有x86_64.img文件

@fish4terrisa-MSDSM
Copy link
Author

有x86_64.img文件,我用的是那个命令,不过因为我编译服务器上没有qemu所以是复制了那个命令在电脑上执行

@shzhxh
Copy link
Contributor

shzhxh commented Oct 17, 2022

请提供一下相关的文件,包括/storage/emulated/0/xinhao/windows/esp/storage/emulated/0/OVMF.fd

@fish4terrisa-MSDSM
Copy link
Author

esp.zip

OVMF.fd.tar.gz

@fish4terrisa-MSDSM
Copy link
Author

就是这两个诶

@shzhxh
Copy link
Contributor

shzhxh commented Oct 18, 2022

你的esp/EFI/Boot/rboot.conf文件里initramfs=\EFI\zCore\ini.img给注释掉了,把它取消注释应该就好了。

@fish4terrisa-MSDSM
Copy link
Author

抱歉。发错了,那个是我之前的一个错误,后来我已经解决了。
esp.tar.gz
因为一个是zip一个是tar所以拖动错了,抱歉

@fish4terrisa-MSDSM
Copy link
Author

要么你把我那个解压了然后用qemu试一下应该就能看到了

@shzhxh
Copy link
Contributor

shzhxh commented Oct 19, 2022

rboot.confinitramfs=\\EFI\\zCore\\x86_64.img应改为initramfs=\EFI\zCore\x86_64.img

@fish4terrisa-MSDSM
Copy link
Author

ok,解决了,多谢(这一错误是在反复编译中诞生的)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants