1:orphan: 2 3========================================== 4loongson3 virt generic platform (``virt``) 5========================================== 6 7The ``virt`` machine use gpex host bridge, and there are some 8emulated devices on virt board, such as loongson7a RTC device, 9IOAPIC device, ACPI device and so on. 10 11Supported devices 12----------------- 13 14The ``virt`` machine supports: 15- Gpex host bridge 16- Ls7a RTC device 17- Ls7a IOAPIC device 18- ACPI GED device 19- Fw_cfg device 20- PCI/PCIe devices 21- Memory device 22- CPU device. Type: la464. 23 24CPU and machine Type 25-------------------- 26 27The ``qemu-system-loongarch64`` provides emulation for virt 28machine. You can specify the machine type ``virt`` and 29cpu type ``la464``. 30 31Boot options 32------------ 33 34We can boot the LoongArch virt machine by specifying the uefi bios, 35initrd, and linux kernel. And those source codes and binary files 36can be accessed by following steps. 37 38(1) Build qemu-system-loongarch64: 39 40.. code-block:: bash 41 42 ./configure --disable-rdma --prefix=/usr \ 43 --target-list="loongarch64-softmmu" \ 44 --disable-libiscsi --disable-libnfs --disable-libpmem \ 45 --disable-glusterfs --enable-libusb --enable-usb-redir \ 46 --disable-opengl --disable-xen --enable-spice \ 47 --enable-debug --disable-capstone --disable-kvm \ 48 --enable-profiler 49 make -j8 50 51(2) Set cross tools: 52 53.. code-block:: bash 54 55 wget https://github.com/loongson/build-tools/releases/download/2022.09.06/loongarch64-clfs-6.3-cross-tools-gcc-glibc.tar.xz 56 57 tar -vxf loongarch64-clfs-6.3-cross-tools-gcc-glibc.tar.xz -C /opt 58 59 export PATH=/opt/cross-tools/bin:$PATH 60 export LD_LIBRARY_PATH=/opt/cross-tools/lib:$LD_LIBRARY_PATH 61 export LD_LIBRARY_PATH=/opt/cross-tools/loongarch64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH 62 63Note: You need get the latest cross-tools at https://github.com/loongson/build-tools 64 65(3) Build BIOS: 66 67 See: https://github.com/tianocore/edk2-platforms/tree/master/Platform/Loongson/LoongArchQemuPkg#readme 68 69Note: To build the release version of the bios, set --buildtarget=RELEASE, 70 the bios file path: Build/LoongArchQemu/RELEASE_GCC5/FV/QEMU_EFI.fd 71 72(4) Build kernel: 73 74.. code-block:: bash 75 76 git clone https://github.com/loongson/linux.git 77 78 cd linux 79 80 git checkout loongarch-next 81 82 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- loongson3_defconfig 83 84 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- -j32 85 86Note: The branch of linux source code is loongarch-next. 87 the kernel file: arch/loongarch/boot/vmlinuz.efi 88 89(5) Get initrd: 90 91 You can use busybox tool and the linux modules to make a initrd file. Or you can access the 92 binary files: https://github.com/yangxiaojuan-loongson/qemu-binary 93 94.. code-block:: bash 95 96 git clone https://github.com/yangxiaojuan-loongson/qemu-binary 97 98Note: the initrd file is ramdisk 99 100(6) Booting LoongArch: 101 102.. code-block:: bash 103 104 $ ./build/qemu-system-loongarch64 -machine virt -m 4G -cpu la464 \ 105 -smp 1 -bios QEMU_EFI.fd -kernel vmlinuz.efi -initrd ramdisk \ 106 -serial stdio -monitor telnet:localhost:4495,server,nowait \ 107 -append "root=/dev/ram rdinit=/sbin/init console=ttyS0,115200" \ 108 --nographic 109