xref: /openbmc/qemu/target/loongarch/README (revision 44602af8)
1- Introduction
2
3  LoongArch is the general processor architecture of Loongson.
4
5  The following versions of the LoongArch core are supported
6    core: 3A5000
7    https://github.com/loongson/LoongArch-Documentation/releases/download/2021.08.17/LoongArch-Vol1-v1.00-EN.pdf
8
9  We can get the latest loongarch documents at https://github.com/loongson/LoongArch-Documentation/tags.
10
11
12- System emulation
13
14  Mainly emulate a virt 3A5000 board and ls7a bridge that is not exactly the same as the host.
15  3A5000 support multiple interrupt cascading while here we just emulate the extioi interrupt
16  cascading. LS7A1000 host bridge support multiple devices, such as sata, gmac, uart, rtc
17  and so on. But we just realize the rtc. Others use the qemu common devices. It does not affect
18  the general use. We also introduced the emulation of devices at docs/system/loongarch/loongson3.rst.
19
20  This version only supports running binary files in ELF format, and does not depend on BIOS and kernel file.
21  You can compile the test program with 'make & make check-tcg' and run the test case with the following command:
22
23  1. Install LoongArch cross-tools on X86 machines.
24
25    Download cross-tools.
26
27      wget https://github.com/loongson/build-tools/releases/download/2022.05.29/loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz
28
29      tar -vxf loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz -C /opt
30
31    Config cross-tools env.
32
33      . setenv.sh
34
35      setenv.sh:
36
37          #!/bin/sh
38          set -x
39          CC_PREFIX=/opt/cross-tools
40
41          export PATH=$CC_PREFIX/bin:$PATH
42          export LD_LIBRARY_PATH=$CC_PREFIX/lib:$LD_LIBRARY_PATH
43          export LD_LIBRARY_PATH=$CC_PREFIX/loongarch64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH
44          set +x
45
46  2. Test tests/tcg/multiarch.
47
48    ./configure --disable-rdma --disable-pvrdma --prefix=/usr  \
49            --target-list="loongarch64-softmmu"  \
50            --disable-libiscsi --disable-libnfs --disable-libpmem \
51            --disable-glusterfs --enable-libusb --enable-usb-redir \
52            --disable-opengl --disable-xen --enable-spice --disable-werror \
53            --enable-debug --disable-capstone --disable-kvm --enable-profiler
54
55    cd  build/
56
57    make && make check-tcg
58
59    or
60
61    ./build/qemu-system-loongarch64 -machine virt -m 4G -cpu Loongson-3A5000 -smp 1 -kernel build/tests/tcg/loongarch64-softmmu/hello -monitor none -display none -chardev file,path=hello.out,id=output -serial chardev:output
62
63- Linux-user emulation
64
65  We already support Linux user emulation. We can use LoongArch cross-tools to build LoongArch executables on X86 machines,
66  and We can also use qemu-loongarch64 to run LoongArch executables.
67
68  1. Config cross-tools env.
69
70     see System emulation.
71
72  2. Test tests/tcg/multiarch.
73
74     ./configure  --static  --prefix=/usr  --disable-werror --target-list="loongarch64-linux-user" --enable-debug
75
76     cd build
77
78     make && make check-tcg
79
80  3. Run LoongArch system basic command with loongarch-clfs-system.
81
82     - Config clfs env.
83
84       wget https://github.com/loongson/build-tools/releases/download/2022.05.29/loongarch64-clfs-system-5.0.tar.bz2
85
86       tar -vxf loongarch64-clfs-system-5.0.tar.bz2 -C /opt/clfs
87
88       cp /opt/clfs/lib64/ld-linux-loongarch-lp64d.so.1  /lib64
89
90       export LD_LIBRARY_PATH="/opt/clfs/lib64"
91
92     - Run LoongArch system basic command.
93
94       ./qemu-loongarch64  /opt/clfs/usr/bin/bash
95       ./qemu-loongarch64  /opt/clfs/usr/bin/ls
96       ./qemu-loongarch64  /opt/clfs/usr/bin/pwd
97
98- Note.
99  We can get the latest LoongArch documents or LoongArch tools at https://github.com/loongson/
100