From 5eec5618b438caa50296c26b1852f946b5fc3064 Mon Sep 17 00:00:00 2001 From: Guofeng Wang Date: Thu, 20 Jun 2024 09:09:42 +0800 Subject: [PATCH] add loongarch support Signed-off-by: Guofeng Wang Signed-off-by: Xiaotian Wu --- OAT.xml | 5 + loongarch64_virt/BUILD.gn | 31 +++++ loongarch64_virt/linux/BUILD.gn | 36 ++++++ loongarch64_virt/linux/README.md | 45 ++++++++ loongarch64_virt/linux/README_zh.md | 107 ++++++++++++++++++ loongarch64_virt/linux/chipset/BUILD.gn | 27 +++++ .../chipset/etc/fstab.qemu.loongarch64.linux | 7 ++ .../linux/chipset/etc/fstab.updater | 6 + loongarch64_virt/linux/images/BUILD.gn | 23 ++++ .../linux/images/system_image_conf.txt | 32 ++++++ .../linux/images/updater_image_conf.txt | 5 + .../linux/images/userdata_image_conf.txt | 33 ++++++ .../linux/images/vendor_image_conf.txt | 33 ++++++ loongarch64_virt/linux/ohos.build | 10 ++ loongarch64_virt/linux/rootfs/BUILD.gn | 56 +++++++++ loongarch64_virt/linux/rootfs/default.para | 16 +++ .../rootfs/init.qemu.loongarch64.linux.cfg | 28 +++++ .../init.qemu.loongarch64.linux.usb.cfg | 51 +++++++++ .../rootfs/qemu.loongarch64.linux.updater.cfg | 10 ++ loongarch64_virt/ohos.build | 10 ++ 20 files changed, 571 insertions(+) create mode 100644 loongarch64_virt/BUILD.gn create mode 100644 loongarch64_virt/linux/BUILD.gn create mode 100644 loongarch64_virt/linux/README.md create mode 100755 loongarch64_virt/linux/README_zh.md create mode 100644 loongarch64_virt/linux/chipset/BUILD.gn create mode 100644 loongarch64_virt/linux/chipset/etc/fstab.qemu.loongarch64.linux create mode 100644 loongarch64_virt/linux/chipset/etc/fstab.updater create mode 100644 loongarch64_virt/linux/images/BUILD.gn create mode 100644 loongarch64_virt/linux/images/system_image_conf.txt create mode 100644 loongarch64_virt/linux/images/updater_image_conf.txt create mode 100644 loongarch64_virt/linux/images/userdata_image_conf.txt create mode 100644 loongarch64_virt/linux/images/vendor_image_conf.txt create mode 100644 loongarch64_virt/linux/ohos.build create mode 100644 loongarch64_virt/linux/rootfs/BUILD.gn create mode 100644 loongarch64_virt/linux/rootfs/default.para create mode 100644 loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.cfg create mode 100644 loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.usb.cfg create mode 100644 loongarch64_virt/linux/rootfs/qemu.loongarch64.linux.updater.cfg create mode 100644 loongarch64_virt/ohos.build diff --git a/OAT.xml b/OAT.xml index c1182cf..0866ed7 100644 --- a/OAT.xml +++ b/OAT.xml @@ -64,6 +64,11 @@ + + + + + diff --git a/loongarch64_virt/BUILD.gn b/loongarch64_virt/BUILD.gn new file mode 100644 index 0000000..543cb4c --- /dev/null +++ b/loongarch64_virt/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +group("loongarch64_virt") { +} diff --git a/loongarch64_virt/linux/BUILD.gn b/loongarch64_virt/linux/BUILD.gn new file mode 100644 index 0000000..0ecd2d8 --- /dev/null +++ b/loongarch64_virt/linux/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors may be used +# to endorse or promote products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +group("qemu-loongarch64-linux-group") { + deps = [ + "//device/qemu/loongarch64_virt/linux/chipset:chipset_files", + "//device/qemu/loongarch64_virt/linux/images:all_image_conf", + "//device/qemu/loongarch64_virt/linux/rootfs:rootfs_files", + ] +} diff --git a/loongarch64_virt/linux/README.md b/loongarch64_virt/linux/README.md new file mode 100644 index 0000000..43bfd08 --- /dev/null +++ b/loongarch64_virt/linux/README.md @@ -0,0 +1,45 @@ +# QEMU LoongArch64 Virt for Standard System Tutorial + +## 1. Overview + +The `loongarch64_virt/linux` directory contains code that has been verified on the QEMU LoongArch64 Virt platform for adapting to Linux kernel. The code includes the driver and board configurations. + +The LoongArch64 Virt platform is a `qemu-system-loongarch64` target device that simulates a general-purpose board running on the LoongArch64 architecture. +The board whose **machine** is **virt** in QEMU is configurable. For example, you can select the core type and quantity, memory size, and security extensions when configuring the board. + +This tutorial guides you through the configuration of a board based on the LoongArch 64 architecture, with one CPU, extended secure features, Generic Interrupt Controller versions 2 (GICv2), and 1 GB memory. +The system memory is hardcoded to 1024 MB. + +## 2. Setting Up the Environment + +For details, see [Environment Setup](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/Readme-EN.md) + +## 3. Obtaining the Source Code + +For details, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). + +## 4. Building the Source Code + +In the root directory of the obtained source code, run the following command: + +``` +./build.sh --product-name qemu-loongarch64-linux-min --ccache --jobs 4 +``` + +After this command is executed, the image files for standard system are generated in out/qemu-loongarch64-linux/packages/phone/images/ directory. +qemu-loongarch64-linux-min means product with minimum set of components. + +## 5. Running an Image in QEMU + +a) If `qemu-system-loongarch64` has not been installed, install it. For details, see [Qemu Installation](https://gitee.com/openharmony/device_qemu/blob/HEAD/README.md). + +Note: The introduced functions have been tested on the target machine of virt-5.1, but are not available for all QEMU versions. Therefore, you must ensure that the qemu-system-loongarch64 version is 8.0 or later. + + +b) Run the images. + +After the source code is built, run the `./vendor/ohemu/qemu_loongarch64_linux_min/qemu_run.sh` or `./vendor/ohemu/qemu_loongarch64_linux_headless/qemu_run.sh` command, the images built in step 4 will be started. + +c) Exit QEMU. + +Press `Ctrl-A + x` to exit the QEMU virtual environment. diff --git a/loongarch64_virt/linux/README_zh.md b/loongarch64_virt/linux/README_zh.md new file mode 100755 index 0000000..fd0099f --- /dev/null +++ b/loongarch64_virt/linux/README_zh.md @@ -0,0 +1,107 @@ +# Qemu LoongArch64 Virt 标准系统教程 + +## 1. 简介 + +`loongarch64_virt/linux` 子目录包含部分Qemu LoongArch 64虚拟化平台验证的Linux kernel的适配代码,含驱动配置、板端配置等。 + +LoongArch64 虚拟化平台是一个 `qemu-system-loongarch64` 的目标设备,通过它来模拟一个通用的、基于龙架构的单板。 + +Qemu中machine为 **virt** 的单板就是这种可配置的,例如:选择核的类型、核的个数、内存的大小和安全特性等,单板设备的配置。 + +这次模拟的配置是:LoongArch 64架构,1个CPU,带安全扩展,1G内存。 + +提示: 系统内存硬编码为1024MB。 + +## 2. 环境搭建 + +参考链接: [环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/Readme-CN.md) + +## 3. 获取源码 + +参考链接: [代码获取](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/get-code/sourcecode-acquire.md) + +## 4. 源码构建 + +在已经获取的源码根目录,请输入: + +``` +./build.sh --product-name qemu-loongarch64-linux-min --ccache --jobs 4 +``` + +在构建完成之后,对应的镜像文件在out/qemu-loongarch64-linux/packages/phone/images/目录下。 + +`qemu-loongarch64-linux-min` 表示部件最小集合的产品。 + + +## 5. 在Qemu中运行镜像 + +a) 如果没有安装 `qemu-system-loongarch64` ,安装请参考链接 [Qemu installation](https://gitee.com/openharmony/device_qemu/blob/HEAD/README_zh.md) + +提示:当前引入的功能在virt-8.0的目标machine已经完成测试,不保证所有的Qemu版本都能够运行成功,因此需要保证你的qemu-system-loongarch64 版本尽可能在8.0及以上。 + +b) 运行镜像 + +执行`./vendor/ohemu/qemu_loongarch64_linux_min/qemu_run.sh`或`./vendor/ohemu/qemu_loongarch64_linux_headless/qemu_run.sh`即可运行步骤4生成的镜像。 + +c) 退出qemu环境 + +按下`Ctrl-A + x`可退出qemu虚拟环境。 + +### 5.1 qemu_run.sh使用说明 + +```C +Usage: qemu-run [OPTION]... +Run a OHOS image in qemu according to the options. + -e, --exec image_path images path, including: zImage-dtb, ramdisk.img, system.img, vendor.img, userdata.img + -g, --gdb enable gdb for kernel. + -n, --network auto setup network for qemu (sudo required). + -i, --instance id start qemu images with specified instance id (from 01 to 99). + it will also setup network when running in multiple instance mode. + -f force override instance image with a new copy. + -h, --help print this help info. + + If no image_path specified, it will find OHOS image in current working directory; then try . + + When setting up network, it will create br0 on the host PC with the following information: + IP address: 192.168.100.1 + netmask: 255.255.255.0 + + The default qemu device MAC address is [00:22:33:44:55:66], default serial number is [0023456789]. + When running in multiple instances mode, the MAC address and serial number will increase with specified instance ID as follow: + MAC address: {instanceID}:22:33:44:55:66 + Serial number: {instanceID}23456789 +``` + +qemu_run.sh默认会启动当前工作目录或out/qemu-loongarch64-linux/packages/phone/images目录下的系统镜像。 + +默认的qemu虚拟机没有网络连接。如果需要使能网络连接,可以添加-n选项。此选项会完成以下几个事物: + +- 主机侧创建虚拟网桥 + + 主机侧会创建br0的网桥,用于与qemu ram虚拟机设备进行网络通信。 + + br0默认IP地址为192.168.100.1,子网掩码为255.255.255.0。 + + 由于主机侧创建虚拟网桥需要管理员权限,因此,需要通过sudo命令执行qemu_run.sh。 + + +- 虚拟机侧创建虚拟网卡 + + 启动qemu loongarch64虚拟机时会为虚拟机设备创建一个网卡,该网卡的默认MAC地址是12:22:33:44:55:66,在虚拟机的网络接口名称是eth0。 + + 虚拟机启动后,可以通过ifconfig eth0 192.168.100.2给虚拟机设置上IP地址(其它IP地址都可以,只要在同一个网段内)。 + + 通过此设置,主机就可以和虚拟机进行网络通信。可以使用hdc与虚拟机交互。 + +正常的OHOS设备都有一个唯一的设备序列号,该序列号会用于各个业务进行设备唯一标识。使用qemu虚拟机启动时,默认的序列号是0123456789。 + +### 5.2 qemu_run.sh多实例运行 + +有时需要运行多个qemu loongarch64虚拟机实例,用于验证分布式组网场景。此时,可以在调用qemu_run.sh时传入-i指定不同实例号。每个不同实例号运行多虚拟机设备都有不同的MAC地址和SN号,以此来模拟多个虚拟设备。MAC地址和SN号的分配规则如下: + + MAC address: {instanceID}:22:33:44:55:66 + Serial number: {instanceID}23456789 + +instanceID的取值格式为两个数字字符:范围为01到99。 + +当镜像输出目录中已存在该instanceID的实例时,默认不重新拷贝镜像。若要重新拷贝镜像可在调用qemu_run.sh时传入-f选项将原镜像覆盖。 diff --git a/loongarch64_virt/linux/chipset/BUILD.gn b/loongarch64_virt/linux/chipset/BUILD.gn new file mode 100644 index 0000000..82efa56 --- /dev/null +++ b/loongarch64_virt/linux/chipset/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2020 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//build/ohos.gni") + +ohos_prebuilt_etc("fstab.qemu.loongarch64.linux") { + source = "etc/fstab.qemu.loongarch64.linux" + module_install_dir = "etc" + part_name = "qemu_loongarch64_linux_chipset" + install_images = [ chipset_base_dir ] +} + +group("chipset_files") { + deps = [ + ":fstab.qemu.loongarch64.linux", + "//kernel/linux/build:linux_kernel", + ] +} diff --git a/loongarch64_virt/linux/chipset/etc/fstab.qemu.loongarch64.linux b/loongarch64_virt/linux/chipset/etc/fstab.qemu.loongarch64.linux new file mode 100644 index 0000000..81af05a --- /dev/null +++ b/loongarch64_virt/linux/chipset/etc/fstab.qemu.loongarch64.linux @@ -0,0 +1,7 @@ +# fstab file. +# fstab file. +# +/dev/block/vdb /usr ext4 ro,barrier=1 wait,required +/dev/block/vdc /vendor ext4 ro,barrier=1 wait,required +/dev/block/vdd /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 +/dev/block/vda /misc none none wait diff --git a/loongarch64_virt/linux/chipset/etc/fstab.updater b/loongarch64_virt/linux/chipset/etc/fstab.updater new file mode 100644 index 0000000..24386a1 --- /dev/null +++ b/loongarch64_virt/linux/chipset/etc/fstab.updater @@ -0,0 +1,6 @@ +# +/dev/block/platform/soc/10100000.himci.eMMC/by-name/system /system ext4 ro,barrier=1 wait +/dev/block/platform/soc/10100000.himci.eMMC/by-name/vendor /vendor ext4 ro,barrier=1 wait +/dev/block/platform/soc/10100000.himci.eMMC/by-name/userdata /data ext4 nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc wait,reservedsize=104857600 +/dev/block/platform/soc/10100000.himci.eMMC/by-name/misc /misc none none wait +/dev/block/platform/soc/100f0000.himci.SD/mmcblk1p1 /sdcard ext4 rw wait diff --git a/loongarch64_virt/linux/images/BUILD.gn b/loongarch64_virt/linux/images/BUILD.gn new file mode 100644 index 0000000..0653db5 --- /dev/null +++ b/loongarch64_virt/linux/images/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//build/ohos.gni") + +ohos_copy("all_image_conf") { + sources = [ + "system_image_conf.txt", + "updater_image_conf.txt", + "userdata_image_conf.txt", + "vendor_image_conf.txt", + ] + outputs = [ "${product_output_dir}/imagesconf/{{source_file_part}}" ] +} diff --git a/loongarch64_virt/linux/images/system_image_conf.txt b/loongarch64_virt/linux/images/system_image_conf.txt new file mode 100644 index 0000000..bb74eb9 --- /dev/null +++ b/loongarch64_virt/linux/images/system_image_conf.txt @@ -0,0 +1,32 @@ + # Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + # Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved. + # + # Redistribution and use in source and binary forms, with or without modification, + # are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, this list of + # conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright notice, this list + # of conditions and the following disclaimer in the documentation and/or other materials + # provided with the distribution. + # + # 3. Neither the name of the copyright holder nor the names of its contributors may be used + # to endorse or promote products derived from this software without specific prior written + # permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/ +104857600 +--fs_type=ext4 +--dac_config ../../build/ohos/images/mkimage/dac.txt diff --git a/loongarch64_virt/linux/images/updater_image_conf.txt b/loongarch64_virt/linux/images/updater_image_conf.txt new file mode 100644 index 0000000..3c4ff5f --- /dev/null +++ b/loongarch64_virt/linux/images/updater_image_conf.txt @@ -0,0 +1,5 @@ +/updater +67108864 +--fs_type=ext4 +--dac_config ../../build/ohos/images/mkimage/dac.txt +--file_context obj/base/security/selinux_adapter/file_contexts.bin diff --git a/loongarch64_virt/linux/images/userdata_image_conf.txt b/loongarch64_virt/linux/images/userdata_image_conf.txt new file mode 100644 index 0000000..d6ac1c3 --- /dev/null +++ b/loongarch64_virt/linux/images/userdata_image_conf.txt @@ -0,0 +1,33 @@ + # Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + # Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved. + # + # Redistribution and use in source and binary forms, with or without modification, + # are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, this list of + # conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright notice, this list + # of conditions and the following disclaimer in the documentation and/or other materials + # provided with the distribution. + # + # 3. Neither the name of the copyright holder nor the names of its contributors may be used + # to endorse or promote products derived from this software without specific prior written + # permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/data +104857600 +--fs_type=ext4 +--dac_config ../../build/ohos/images/mkimage/dac.txt diff --git a/loongarch64_virt/linux/images/vendor_image_conf.txt b/loongarch64_virt/linux/images/vendor_image_conf.txt new file mode 100644 index 0000000..cc3520a --- /dev/null +++ b/loongarch64_virt/linux/images/vendor_image_conf.txt @@ -0,0 +1,33 @@ + # Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + # Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved. + # + # Redistribution and use in source and binary forms, with or without modification, + # are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, this list of + # conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright notice, this list + # of conditions and the following disclaimer in the documentation and/or other materials + # provided with the distribution. + # + # 3. Neither the name of the copyright holder nor the names of its contributors may be used + # to endorse or promote products derived from this software without specific prior written + # permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/vendor +104857600 +--fs_type=ext4 +--dac_config ../../build/ohos/images/mkimage/dac.txt diff --git a/loongarch64_virt/linux/ohos.build b/loongarch64_virt/linux/ohos.build new file mode 100644 index 0000000..8419fa2 --- /dev/null +++ b/loongarch64_virt/linux/ohos.build @@ -0,0 +1,10 @@ +{ + "subsystem": "device_loongarch64_virt", + "parts": { + "qemu_loongarch64_linux_chipset": { + "module_list": [ + "//device/qemu/loongarch64_virt/linux:qemu-loongarch64-linux-group" + ] + } + } +} diff --git a/loongarch64_virt/linux/rootfs/BUILD.gn b/loongarch64_virt/linux/rootfs/BUILD.gn new file mode 100644 index 0000000..74dbc4e --- /dev/null +++ b/loongarch64_virt/linux/rootfs/BUILD.gn @@ -0,0 +1,56 @@ +# Copyright (c) 2020 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//base/startup/init/services/etc/param/param_fixer.gni") +import("//build/ohos.gni") + +ohos_prebuilt_etc("qemu.loongarch64.linux.init.cfg") { + source = "init.qemu.loongarch64.linux.cfg" + if (!enable_ramdisk) { + install_images = [ "system" ] + } else { + install_images = [ chipset_base_dir ] + } + part_name = "qemu_loongarch64_linux_chipset" +} + +ohos_prebuilt_etc("qemu.loongarch64.linux.usb.cfg") { + source = "init.qemu.loongarch64.linux.usb.cfg" + if (!enable_ramdisk) { + install_images = [ "system" ] + } else { + install_images = [ chipset_base_dir ] + } + part_name = "qemu_loongarch64_linux_chipset" +} + +ohos_prebuilt_etc("qemu.loongarch64.linux.updater.cfg") { + source = "qemu.loongarch64.linux.updater.cfg" + install_images = [ "updater" ] + part_name = "qemu_loongarch64_linux_chipset" +} + +ohos_prebuilt_para("default_param") { + source = "default.para" + install_images = [ chipset_base_dir ] + module_install_dir = "etc/param" + part_name = "qemu_loongarch64_linux_chipset" +} + +group("rootfs_files") { + deps = [ + ":default_param", + ":qemu.loongarch64.linux.init.cfg", + ":qemu.loongarch64.linux.updater.cfg", + ":qemu.loongarch64.linux.usb.cfg", + ] +} diff --git a/loongarch64_virt/linux/rootfs/default.para b/loongarch64_virt/linux/rootfs/default.para new file mode 100644 index 0000000..cb7544f --- /dev/null +++ b/loongarch64_virt/linux/rootfs/default.para @@ -0,0 +1,16 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +persist.hdc.mode=tcp +persist.hdc.port=5555 + diff --git a/loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.cfg b/loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.cfg new file mode 100644 index 0000000..b254ca8 --- /dev/null +++ b/loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.cfg @@ -0,0 +1,28 @@ +{ + "import" : [ + "init.qemu.loongarch64.linux.usb.cfg" + ], + "jobs" : [{ + "name" : "pre-init", + "cmds" : [ + "write /proc/sys/vm/min_free_kbytes 10240" + ] + }, { + "name" : "init", + "cmds" : [ + "mount debugfs /sys/kernel/debug /sys/kernel/debug mode=755" + ] + }, { + "name" : "fs", + "cmds" : [ + ] + }, { + "name" : "boot", + "cmds" : [ + "chmod 777 /dev/ttyS0", + "chmod 0440 /proc/interrupts", + "chmod 0440 /proc/stat" + ] + } + ] +} diff --git a/loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.usb.cfg b/loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.usb.cfg new file mode 100644 index 0000000..a6df325 --- /dev/null +++ b/loongarch64_virt/linux/rootfs/init.qemu.loongarch64.linux.usb.cfg @@ -0,0 +1,51 @@ +{ + "jobs" : [{ + "name" : "boot", + "cmds" : [ + "mkdir /dev/usb-ffs 0770 shell shell", + "mkdir /dev/usb-ffs/hdc 0770 shell shell", + "mount configfs none /config", + "mkdir /config/usb_gadget/g1 0770 shell shell", + "write /config/usb_gadget/g1/idVendor 0x12D1", + "write /config/usb_gadget/g1/idProduct 0x5000", + "write /config/usb_gadget/g1/os_desc/use 1", + "write /config/usb_gadget/g1/bcdDevice 0x0223", + "write /config/usb_gadget/g1/bcdUSB 0x0200", + "mkdir /config/usb_gadget/g1/strings/0x409 0770", + "copy /sys/block/mmcblk0/device/cid /config/usb_gadget/g1/strings/0x409/serialnumber", + "write /config/usb_gadget/g1/strings/0x409/manufacturer HISILICON", + "write /config/usb_gadget/g1/strings/0x409/product \"HDC Device\"", + "mkdir /config/usb_gadget/g1/functions/ffs.hdc", + "mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell", + "mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell", + "write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1", + "write /config/usb_gadget/g1/os_desc/qw_sign MSFT100", + "write /config/usb_gadget/g1/configs/b.1/MaxPower 500", + "symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1", + "mount functionfs hdc /dev/usb-ffs/hdc uid=2000,gid=2000", + "setparam sys.usb.configfs 1", + "setparam sys.usb.controller 100e0000.hidwc3_0" + ] + }, { + "name" : "param:sys.usb.config=none && param:sys.usb.configfs=1", + "condition" : "sys.usb.config=none && sys.usb.configfs=1", + "cmds" : [ + "write /config/usb_gadget/g1/os_desc/use 0", + "setparam sys.usb.ffs.ready 0" + ] + }, { + "name" : "param:init.svc.hdcd=stopped", + "condition" : "init.svc.hdcd=stopped", + "cmds" : [ + "setparam sys.usb.ffs.ready 0" + ] + }, { + "name" : "param:sys.usb.config=hdc && param:sys.usb.configfs=1", + "condition" : "sys.usb.config=hdc && sys.usb.configfs=1", + "cmds" : [ + "write /config/usb_gadget/g1/idProduct 0x5000", + "write /config/usb_gadget/g1/os_desc/use 1" + ] + } + ] +} diff --git a/loongarch64_virt/linux/rootfs/qemu.loongarch64.linux.updater.cfg b/loongarch64_virt/linux/rootfs/qemu.loongarch64.linux.updater.cfg new file mode 100644 index 0000000..746be03 --- /dev/null +++ b/loongarch64_virt/linux/rootfs/qemu.loongarch64.linux.updater.cfg @@ -0,0 +1,10 @@ +{ + "jobs" : [ + { + "name" : "init", + "cmds" : [ + + ] + } + ] +} diff --git a/loongarch64_virt/ohos.build b/loongarch64_virt/ohos.build new file mode 100644 index 0000000..6182536 --- /dev/null +++ b/loongarch64_virt/ohos.build @@ -0,0 +1,10 @@ +{ + "subsystem": "device_loongarch64_virt", + "parts": { + "device_loongarch64_virt": { + "module_list": [ + "//device/qemu/loongarch64_virt:loongarch64_virt" + ] + } + } +} -- Gitee