diff --git a/playground/openEuler-Exp/KADC2024/Code/helloworld.cpp b/playground/openEuler-Exp/KADC2024/Code/helloworld.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0194844e7ce21c476413f1fdf459053a8978df65 --- /dev/null +++ b/playground/openEuler-Exp/KADC2024/Code/helloworld.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + QLabel *label = new QLabel("Hello, world!"); + label->show(); + + return app.exec(); +} \ No newline at end of file diff --git a/playground/openEuler-Exp/KADC2024/Images/TigerVNC-Viewer.png b/playground/openEuler-Exp/KADC2024/Images/TigerVNC-Viewer.png new file mode 100644 index 0000000000000000000000000000000000000000..75de96fec1ff435ca1c1058f5603fd32be451018 Binary files /dev/null and b/playground/openEuler-Exp/KADC2024/Images/TigerVNC-Viewer.png differ diff --git a/playground/openEuler-Exp/KADC2024/Images/VNC-Viewer-Connection.png b/playground/openEuler-Exp/KADC2024/Images/VNC-Viewer-Connection.png new file mode 100644 index 0000000000000000000000000000000000000000..134fed7ef5044c89694cddb962debf5b7567c91a Binary files /dev/null and b/playground/openEuler-Exp/KADC2024/Images/VNC-Viewer-Connection.png differ diff --git a/playground/openEuler-Exp/KADC2024/Images/VNC-authentication.png b/playground/openEuler-Exp/KADC2024/Images/VNC-authentication.png new file mode 100644 index 0000000000000000000000000000000000000000..c465f898ac2d45e9d38bfb6ae75d4028f97e1587 Binary files /dev/null and b/playground/openEuler-Exp/KADC2024/Images/VNC-authentication.png differ diff --git a/playground/openEuler-Exp/KADC2024/Images/hello-world.png b/playground/openEuler-Exp/KADC2024/Images/hello-world.png new file mode 100644 index 0000000000000000000000000000000000000000..cea656e3ea48544f7cc0dd519ae41e36db706803 Binary files /dev/null and b/playground/openEuler-Exp/KADC2024/Images/hello-world.png differ diff --git a/playground/openEuler-Exp/KADC2024/Images/yum-install-qt5.png b/playground/openEuler-Exp/KADC2024/Images/yum-install-qt5.png new file mode 100644 index 0000000000000000000000000000000000000000..db19c44d03bd8e062e85cb0525ccb2a7b61c9fc3 Binary files /dev/null and b/playground/openEuler-Exp/KADC2024/Images/yum-install-qt5.png differ diff --git a/playground/openEuler-Exp/KADC2024/KADC2024.md b/playground/openEuler-Exp/KADC2024/KADC2024.md index ba79d909b2c5a54022cd67d62b7b49f97823ff9a..eab83236559a132ef44c39a9680d0dd13b27a0ac 100644 --- a/playground/openEuler-Exp/KADC2024/KADC2024.md +++ b/playground/openEuler-Exp/KADC2024/KADC2024.md @@ -8,27 +8,30 @@ 华为公司副总裁、ICT产品与解决方案总裁马海旭正式发布Kunpeng Pro。Kunpeng Pro是一块面向开发者的鲲鹏开发板,具有鲲鹏主板的完整能力,内置openEuler开源操作系统、openGauss开源数据库和鲲鹏开发套件DevKit,外置丰富接口,易于扩展,帮助开发者更快速、便捷的进行各种实践和创新。 -## I. 实验设备 -本次大会以**鲲鹏开发板**为平台进行实验。 + +## I 实验设备及其连接 + +本次大会以**[鲲鹏开发板](http://www.orangepi.cn/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-kunpeng.html)**为平台进行实验。 ![kdb-connection](./Images/kdb-connection.png) 如上图所示,开发板与其他实验设备之间的连接方式有三: - PC通过以太网和开发板相连 -- PC通过串口和开发板相连 + - 利用PC机中的Console命令行终端通过以太网+TCP/IP+SSH登录系统(用`ssh`命令) + - 通过VNC(Virtual Network Computing)登录系统 + +- PC通过串口(Serial)和开发板相连 + - 注意鲲鹏开发板串口的波特(Baud,symbol/s)为115200bps + - 开发板+显示器+键盘+鼠标相连 -## II. 登录系统 -登录到开发板(操作系统)的方式亦有三: -- 通过本地终端登录系统,这里的本地终端包括键盘、鼠标(物理输入设备)和显示器(物理输出设备)。 -- 通过串口登录系统。 -- 利用PC机中的Console命令行终端通过以太网+TCP/IP+SSH登录系统(用`ssh`命令)。 +## II 登录系统 -本实验以**ssh**命令登录系统。 +本实验在PC上以**ssh**命令通过“以太网+TCP/IP”登录系统。 🤚 *动手操作* @@ -36,19 +39,188 @@ - 按“![Windows-Key](./Images/Windows-Key.png) +X, i”打开Terminal(PowerShell),或者 - 通过![xterm_logo](./Images/xterm_logo.png)[“MobaXterm”软件](https://mobaxterm.mobatek.net/)选择使用SSH协议登录系统 -然后输入以下`ssh`命令: +输入以下`ssh`命令: ```shell -ssh openEuler@192.168.1.102 +ssh openEuler@192.168.1.105 ``` -这里“openEuler”是用户名,*192.168.1.102*是开发板的IP地址,登录时要输入密码,密码也是“openEuler”。 +这里“openEuler”是用户名,*192.168.1.105*是开发板的IP地址,登录时要输入密码,密码也是“openEuler”。 🔒 *安全* 为系统安全起见,进行应用编程实验时,我们一般以非root用户登录,进行内核模块编程时,我们以root身份登录。 -## III. 进行实验 + + +## III 进行实验 请根据实验指南进行实验。 + + +## 附录A 安装Qt + +如何在开发板上安装Qt开发环境?不妨假设您通过“以太网+TCP/IP”在一台PC上登录到开发板上的openEuler操作系统进行Qt GUI程式开发。在这种情形下,我们需要: +- 安装Qt +- 安装VNC + +### 一、安装Qt + +可以以以下命令安装Qt及其开发组件(以Qt5为例): +```shell +yum install qt5 qt5-devel +``` +安装完成后在鲲鹏开发板上“Applications”中会有如下显示(注意有关Qt的图标): + +![yum-install-qt5](./Images/yum-install-qt5.png) + +以下命令适合更全面的安装: +```shell +yum install qt5* # Total download size: 2.3 G; Installed size: 8.7 G +``` + +### 二、安装VNC + +安装VNC(Virtual Network Console)是为了让PC通过“以太网+TCP/IP”登录到开发板的桌面系统。 + +由于openEuler操作系统的repo源中有tigervnc与tigervnc-server,因此就安装它们: +```shell +yum install -y tigervnc tigervnc-server +``` + +安装完毕后启动VNC Server: +```shell +vncserver +``` +注意:如果是第一次启动,则需要设置和再次输入密码,按照提示设置和再次输入即可: +``` + +You will require a password to access your desktops. + +Password: +Verify: +Would you like to enter a view-only password (y/n)? y +Password: +Verify: +``` + +可以确认是否启动: +```shell +vncserver -list +``` + +可能的输出如下: +``` +TigerVNC server sessions: + +X DISPLAY # PROCESS ID +:1 2593 +``` + +在用客户端进行连接之前需要检查VNC服务器(即开发板)上的防护墙是否开启: +```shell +systemctl status firewalld +``` + +如果防护墙处于开启状态则可以直接关闭防护墙: +```shell +systemctl stop firewalld +``` + +注意:由于是学生实验,所以可以简单关闭防火墙。若其他安全性比较高的场景,请参照如下命令: +```shell +firewall-cmd --zone=public --add-port=5900/tcp +``` +VNC的默认端口是5900,远程桌面连接端口则是5900+n(n是vncserver命令指定的)。如果使用“vncserver”命令启动后“X DISPLAY”的端口号为“:1”,则其相应VNC Server端口号为则5901,其余以此类推。 + +最后请在Windows终端安装TigerVNC客户端并启动之: + +![TigerVNC-Viewer](./Images/TigerVNC-Viewer.png) + +![VNC-Viewer-Connection](./Images/VNC-Viewer-Connection.png) + +在本例中假设开发板的IP地址为“192.168.1.105”,VNC Server端口号为5901(如果使用两位端口号格式,则在客户端输入的是“01”),然后点击“Connect”按钮。 + +然后输入先前在服务器(即开发板)上第一次运行`vncserver`命令时所设置的密码并按“OK”按钮进行连接: + +![VNC-authentication](./Images/VNC-authentication.png) + +如果没有出什么差错,则会在PC上显示开发板上openEuler操作系统的桌面。 + +### 三、Hello, world! + +现在是以一个简单的例子验证我们安装的Qt开发环境的时候了。 + +步骤1:创建工作目录并进入 +```shell +mkdir -p ~/qt/helloworld/ && cd $_ +``` + +步骤2:准备源代码 +请参考本例所附helloworld.cpp源代码进行准备: + +```shell +vim helloworld.cpp +``` + +步骤3:产生工程文件 +```shell +qmake-qt5 -project +echo "QT += widgets" >> helloworld.pro +``` + +步骤4:编译源文件 +```shell +qmake-qt5 +make +``` + +步骤5:在桌面环境中运行 +```shell +~/qt/helloworld/helloworld +``` +![hello-world](./Images/hello-world.png) + +步骤6:清理文件 +```shell +cd ~/qt/helloworld/ +find * | grep -v helloworld.cpp | xargs rm +``` + + + +## 附录B 软件包安装汇总 + +在开发板上进行一次比较全面的软件包安装以支持内核模块编程、系统环境实验以及Qt软件开发,可以参考以下命令: +```shell +yum group install "Development Tools" +yum install bc +yum install openssl-devel + +yum install mlocate # for locate command + +yum install qt5* +``` + +注意:如果在安装的过程中出现“Error: GPG check FAILED”错误则可在`yum install`命令后增加`--nogpgcheck`选项,例如: +```shell +yum group install -y "Development Tools" --nogpgcheck +``` + + + +## 附录C 术语表 + +本实验中所用术语列表如下: + +🏷*术语表* + +- PC + - Personal Computer,个人电脑 +- SSH + - Secure Shell,安全外壳。一种网络安全协议,通过加密和认证机制实现安全的访问和文件传输等业务。 +- VNC + - Virtual Network Console,虚拟网络控制台 +- TCP/IP + - Transmission Control Protocol/Internet Protocol,传输控制协议/网际协议。其不仅仅指的是TCP和IP两个协议,而是指一个由TCP、IP、ARP(Address Resolution Protocol)、UDP(User Datagram Protocol)、HTTP(Hypertext Transfer Protocol)、FTP(File Transfer Protocol)、SMTP(Simple Mail Transfer Protocol)、Telnet等协议构成的协议簇,而尤其以TCP和IP最具代表性。 \ No newline at end of file diff --git a/playground/openEuler-Exp/openEuler-KMPE/openEuler-KMPE.md b/playground/openEuler-Exp/openEuler-KMP/openEuler-KMP.md similarity index 77% rename from playground/openEuler-Exp/openEuler-KMPE/openEuler-KMPE.md rename to playground/openEuler-Exp/openEuler-KMP/openEuler-KMP.md index 1a0b09eba3ceb6e7b225f09bdf2a1276a619ee9f..524d0ddb9df89e65f8dd9b7aa203b7b15606e428 100644 --- a/playground/openEuler-Exp/openEuler-KMPE/openEuler-KMPE.md +++ b/playground/openEuler-Exp/openEuler-KMP/openEuler-KMP.md @@ -1,6 +1,6 @@ -# openEuler内核模块编程实验 +# openEuler内核模块编程 -**openEuler Kernel Module Programming Experiments** +**openEuler Kernel Module Programming** 内核模块是一种可以扩展运行时内核功能的目标文件(Object File)。大多数类Unix及Windows系统均使用模块,这种机制使得允许内核在运行过程中动态地插入或者移除代码。 @@ -16,7 +16,9 @@ -## I. 内核的编译与安装 +## I 内核编译 + +### 一、内核编译与安装 #### 1. 准备环境 @@ -27,6 +29,10 @@ yum group install -y "Development Tools" yum install -y bc yum install -y openssl-devel ``` +注意:如果在安装的过程中出现“Error: GPG check FAILED”错误则可在`yum install`命令后增加`--nogpgcheck`选项,例如: +```shell +yum group install -y "Development Tools" --nogpgcheck +``` #### 2. 备份 @@ -111,7 +117,7 @@ make modules_install ``` ...... INSTALL sound/soundcore.ko -DEPMOD 4.19.154 +DEPMOD 4.19.90 ``` 安装内核: @@ -123,37 +129,63 @@ make install 最后的输出类似这样: ``` -/bin/sh ./arch/arm64/boot/install.sh 4.19.154 \ +/bin/sh ./arch/arm64/boot/install.sh 4.19.90 \ arch/arm64/boot/Image System.map "/boot" dracut-install: Failed to find module 'xen-blkfront' -dracut: FAILED: /usr/lib/dracut/dracut-install -D /var/tmp/dracut.tlIdPu/initramfs --kerneldir /lib/modules/4.19.154/ -m virtio_gpu xen-blkfront xen-netfront virtio_blk virtio_scsi virtio_net virtio_pci virtio_ring virtio +dracut: FAILED: /usr/lib/dracut/dracut-install -D /var/tmp/dracut.tlIdPu/initramfs --kerneldir /lib/modules/4.19.90/ -m virtio_gpu xen-blkfront xen-netfront virtio_blk virtio_scsi virtio_net virtio_pci virtio_ring virtio ``` 注意:这里出现的“dracut: FAILED”错误可以忽略之。 -#### 6. 重启系统 +#### 6. 重启系统并以新的内核引导 + +通常,我们需要借助VNC(Virtual Network Computing)窗口在GRUB菜单显示时用上下光标键选择新编译出来的内核来启动系统。或者,对于本实验而言,也可以使用以下方法: +首先查看新编译出来的内核GRUB菜单: ```shell -reboot +cat /etc/grub2-efi.cfg +``` + +我们应该可以找到类似这样的菜单项: +``` +menuentry 'openEuler (4.19.90) 20.03 (LTS)' +``` +这就是本例中我们新编译出来的内核版本菜单项(请留意前述编译内核时的一些命令行输出信息)。这时我们可以对默认启动项进行设置: +```shell +grub2-set-default 'openEuler (4.19.90) 20.03 (LTS)' ``` -然后我们需要借助VNC窗口在GRUB菜单显示时用上下光标键选择新编译出来的内核来启动系统。 +确认: +```shell +grub2-editenv list +``` -我们以新的内核引导系统后,可以继续在VNC窗口中登录系统,也可以以ssh终端登录,然后在并在shell中输入如下命令查看内核版本: +应该类似如下所示的输出: +``` +saved_entry=openEuler (4.19.90) 20.03 (LTS) +boot_success=0 +``` +随后重启系统: ```shell -uname -r # For instance: 4.19.154 +reboot ``` -可以看出内核版本已更新。 +登录并验证: +```shell +uname -r # Desire 4.19.90 +``` +可以看出内核版本已更新。我们可以通过如下命令查看新内核的一些信息: +```shell +ls /lib/modules/`uname -r` +``` 🔔 *注意* 您编译出来的新内核版本通常会与此不同。 - -## II. Hello, world! +### 二、验证:Hello, world! #### 1. 准备源代码 @@ -234,8 +266,6 @@ Linux的内核模块(Module)是一种具有独立功能的程序,它可以 ```C #include //包含了对模块的结构定义 -MODULE_LICENSE("GPL"); //声明版权 - static __init my_module_init(void) { //加载模块 } @@ -246,31 +276,45 @@ static __exit my_module_exit(void) { module_init(my_module_init); //指定初始化函数 module_exit(my_module_exit); //指定卸载函数 + +MODULE_LICENSE("GPL"); //声明版权 ``` -# III. 术语表 -本实验中所用术语列表如下: +## II 两个模块的内核编程 -🏷*术语表* +🔔 *说明* -- KMP - - Kernel Module Programming,内核模块编程。 -- KECS - - Kunpeng Elastic Cloud Server,鲲鹏弹性云服务器 -- VNC - - Virtual Network Console,虚拟网络控制台 -- GRUB - - Grand Unified Boot Loader,大一统引导装载程序 +这里简单编写了两个内核模块作为示例,更深入的内核模块编程请参考其他相关资料。 + +这两个模块分别实现以下功能: + +- 模块1:支持数组参数,加载时读入并打印。 +- 模块2:在/proc目录下创建只读文件。 + +需要注意以下问题: + +- 模块可以写在一个C文件中,模块参数传递参考宏定义`module_param(name, type, perm)`,需要用到头文件linux/moduleparam.h。 +- 编写Makefile文件将C源码编译成.ko模块。 + +🎵 *准备代码* + +请参考所附源代码文件(module_1.c、module_2.c以及Makefile)准备您的文件。 +🤚 *动手操作* +请参考命令行文件cmdline.sh进行实验。 -# IV. 附:在x64平台上编译内核 + + +## 附录A 在x64平台上编译内核 除了鲲鹏平台,openEuler操作系统也支持x86_64、RISC-V等架构。兹列出在x86_64平台上的openEuler编译内核的步骤以供参考。 +### 一、内核编译与安装 + #### 1. 查看系统信息 先查看当前的系统信息: @@ -432,3 +476,26 @@ uname -r # For instance: 4.19.208 🔔 *注意* 您编译出来的新内核版本通常会与此不同。 + + +### 二、验证 + +从略。 + + + +## 附录B 术语表 + +本实验中所用术语列表如下: + +🏷*术语表* + +- KMP + - Kernel Module Programming,内核模块编程。 +- KECS + - Kunpeng Elastic Cloud Server,鲲鹏弹性云服务器 +- VNC + - Virtual Network Console,虚拟网络控制台 +- GRUB + - Grand Unified Boot Loader,大一统引导装载程序 + diff --git a/playground/openEuler-Exp/openEuler-KMPE/hello-world/Makefile b/playground/openEuler-Exp/openEuler-KMP/src/hello-world/Makefile similarity index 100% rename from playground/openEuler-Exp/openEuler-KMPE/hello-world/Makefile rename to playground/openEuler-Exp/openEuler-KMP/src/hello-world/Makefile diff --git a/playground/openEuler-Exp/openEuler-KMPE/hello-world/cmdline.sh b/playground/openEuler-Exp/openEuler-KMP/src/hello-world/cmdline.sh similarity index 62% rename from playground/openEuler-Exp/openEuler-KMPE/hello-world/cmdline.sh rename to playground/openEuler-Exp/openEuler-KMP/src/hello-world/cmdline.sh index e0171a4c97b69b0841004e886ec01d02e48857d0..1b964fcc064edb353df1fe5e3d0c7c549b0050f7 100644 --- a/playground/openEuler-Exp/openEuler-KMPE/hello-world/cmdline.sh +++ b/playground/openEuler-Exp/openEuler-KMP/src/hello-world/cmdline.sh @@ -1,10 +1,15 @@ + make -insmod hello_world.ko guy="Dinu" year=2013 + +insmod hello_world.ko guy="Andy" year=2024 lsmod | grep hello #hello_world 262144 0 + rmmod hello_world + dmesg | tail -n3 #[ 6228.122161] Init module. -#[ 6228.122433] Hello, Dinu, 2013! +#[ 6228.122433] Hello, Andy, 2024! #[ 6254.880206] Exit module. + make clean diff --git a/playground/openEuler-Exp/openEuler-KMPE/hello-world/hello_world.c b/playground/openEuler-Exp/openEuler-KMP/src/hello-world/hello_world.c similarity index 80% rename from playground/openEuler-Exp/openEuler-KMPE/hello-world/hello_world.c rename to playground/openEuler-Exp/openEuler-KMP/src/hello-world/hello_world.c index 75786548b140caddd86d54d03a8f47240efc7d11..835d698a831a16385110d28ab5ab3f4179392613 100644 --- a/playground/openEuler-Exp/openEuler-KMPE/hello-world/hello_world.c +++ b/playground/openEuler-Exp/openEuler-KMP/src/hello-world/hello_world.c @@ -1,12 +1,14 @@ /* Hello from Kernel! */ -#include +#include +#include +#include -static char* guy = "Kernel"; +static char* guy = "Dinu"; module_param(guy, charp, 0644); MODULE_PARM_DESC(guy, "char* param\n"); -static int year = 2021; +static int year = 2013; module_param(year, int, 0644); MODULE_PARM_DESC(year, "int param\n"); diff --git a/playground/openEuler-Exp/openEuler-KMP/src/m2/Makefile b/playground/openEuler-Exp/openEuler-KMP/src/m2/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..a717a00982cdfd2fb27c52f472d9d7e300476e2f --- /dev/null +++ b/playground/openEuler-Exp/openEuler-KMP/src/m2/Makefile @@ -0,0 +1,9 @@ +# Build modules + +obj-m := module_1.o module_2.o +KDIR := /lib/modules/$(shell uname -r)/build +PWD := $(shell pwd) +all: + make -C $(KDIR) M=$(PWD) modules +clean: + rm -f *.ko *.mod.c *.o *.order *.symvers diff --git a/playground/openEuler-Exp/openEuler-KMP/src/m2/cmdline.sh b/playground/openEuler-Exp/openEuler-KMP/src/m2/cmdline.sh new file mode 100644 index 0000000000000000000000000000000000000000..eddd65f4165e5aa9e0bc9e41bd1204aefa8a6074 --- /dev/null +++ b/playground/openEuler-Exp/openEuler-KMP/src/m2/cmdline.sh @@ -0,0 +1,20 @@ + +# Step 1: Compile the source code +make clean +make + +# Step 2: Install the module and test +insmod module_1.ko my_array=1,2,3,4,5,6,7 +insmod module_2.ko + +lsmod | grep module + +cat /proc/hello_proc + +# Step 3: Uninstall the module +rmmod module_2.ko +rmmod module_1.ko + +# Step 4: Review the system log information +clear +dmesg | tail -n80 diff --git a/playground/openEuler-Exp/openEuler-KMP/src/m2/module_1.c b/playground/openEuler-Exp/openEuler-KMP/src/m2/module_1.c new file mode 100644 index 0000000000000000000000000000000000000000..7a3ac4c53d06c420dd1010e8e8e9a7e9e294bedf --- /dev/null +++ b/playground/openEuler-Exp/openEuler-KMP/src/m2/module_1.c @@ -0,0 +1,33 @@ +// Module that support for array parameter + +#include +#include +#include + +#define MAX_LENGTH 7 + +static int my_array[MAX_LENGTH]; +int array_num; + +module_param_array(my_array, int, &array_num, 0644); +MODULE_PARM_DESC(my_array, "A integer array"); + +static int __init my_module_init(void) { + int i; + printk("module 1 is loaded!\n"); + + for(i = 0; i < array_num; i++){ + printk("%d\n", my_array[i]); + } + + return 0; +} + +static void __exit my_module_exit(void) { + printk("module 1 is removed!\n"); +} + +module_init(my_module_init); +module_exit(my_module_exit); + +MODULE_LICENSE("GPL"); diff --git a/playground/openEuler-Exp/openEuler-KMP/src/m2/module_2.c b/playground/openEuler-Exp/openEuler-KMP/src/m2/module_2.c new file mode 100644 index 0000000000000000000000000000000000000000..4cccd385cf4d522c9cce0d6a12aaf30e4810fef0 --- /dev/null +++ b/playground/openEuler-Exp/openEuler-KMP/src/m2/module_2.c @@ -0,0 +1,38 @@ +// Read-only proc file + +#include +#include +#include + +static int hello_proc_show(struct seq_file *m, void *v) { + seq_printf(m, "This is a proc message!\n"); + return 0; +} + +static int hello_proc_open(struct inode *inode, struct file *file) { + return single_open(file, hello_proc_show, NULL); +} + +static const struct file_operations hello_proc_fops = { + .owner = THIS_MODULE, + .open = hello_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int __init hello_proc_init(void) { + printk("module 2 is loaded!\n"); + proc_create("hello_proc", 0, NULL, &hello_proc_fops); + return 0; +} + +static void __exit hello_proc_exit(void) { + printk("module 2 is removed!\n"); + remove_proc_entry("hello_proc", NULL); +} + +module_init(hello_proc_init); +module_exit(hello_proc_exit); + +MODULE_LICENSE("GPL"); diff --git a/playground/openEuler-Exp/openEuler-SEE/openEuler-SEE.md b/playground/openEuler-Exp/openEuler-SEE/openEuler-SEE.md index 301fa15400d45ff7e878f369cd1e80d9761eebda..58fdbfd34e9d7988b89d9e3d784c67305c4c58b7 100644 --- a/playground/openEuler-Exp/openEuler-SEE/openEuler-SEE.md +++ b/playground/openEuler-Exp/openEuler-SEE/openEuler-SEE.md @@ -4,7 +4,7 @@ -## I. 什么是系统环境实验 +## I 什么是系统环境实验 所谓**系统环境**,是指运行在一定硬件系统之上的操作系统所提供的软件运行环境,在本实验中特指运行于**鲲鹏处理器**之上的**openEuler操作系统 **向上层软件提供的运行环境。 @@ -34,7 +34,7 @@ -## II. 实验设备与实验流程 +## II 实验设备与实验流程 ```mermaid flowchart TD @@ -64,7 +64,7 @@ flowchart TD - SEE - System Environment Experiments,系统环境实验 -## 一、实验设备 +### 一、实验设备 目前有三种鲲鹏平台可供选择: @@ -72,7 +72,7 @@ flowchart TD - 鲲鹏ECS:即基于鲲鹏处理器的华为云ECS(弹性云服务器,Elastic Cloud Server)。 - 鲲鹏开发板:类似于树莓派但是以鲲鹏处理器为CPU的开发板。 -## 二、实验流程 +### 二、实验流程 实验流程如下: @@ -90,7 +90,7 @@ flowchart TD 为系统安全起见,进行应用编程实验时,我们一般以非root用户登录。 -## III. openEuler系统环境实验 +## III openEuler系统环境实验 ### 一、查看系统信息 @@ -191,7 +191,7 @@ C是一种“强类型、弱检查”的系统级通用编程语言,我们通 本节实验所用源代码在“`code`”目录中。 -### 1. 检查GCC版本 +#### 1. 检查GCC版本 🤚 *动手操作* @@ -201,7 +201,7 @@ gcc --version # ...... 推荐使用gcc7.3.0及以上版本(不低于4.8.5)。 -### 2. 准备C程序源代码 +#### 2. 准备C程序源代码 🎵 *准备代码* @@ -211,7 +211,7 @@ gcc --version # ...... cd ~/code ``` -### 3. 编译并执行 +#### 3. 编译并执行 在鲲鹏开发板上编译并执行: @@ -238,7 +238,7 @@ unsigned char ch = ff, +255, positive - 由于计算机中的整数用补码表示的原因,`-1`在内存中的数值是`0xff` - 在鲲鹏平台上`char`的默认数据类型与`unsigned char`同 -### 4. 在x64平台上进行同样的实验 +#### 4. 在x64平台上进行同样的实验 🤲 *与x64平台比较* @@ -267,7 +267,7 @@ unsigned char ch = ff, +255, positive 你可以举出另外一些“信息就是上下文”的例子吗? -### 5. 编译时指定char的类型 +#### 5. 编译时指定char的类型 🤚 *动手操作* @@ -294,7 +294,7 @@ gcc -fsigned-char ch.c 由于鲲鹏处理器是基于aarch64架构的,故其采用的是精简指令集。 -### 1. 准备源代码 +#### 1. 准备源代码 🎵 *准备代码* @@ -304,7 +304,7 @@ gcc -fsigned-char ch.c cd ~/code ``` -### 2. 编译然后反汇编 +#### 2. 编译然后反汇编 编译源文件并进行反汇编: @@ -459,9 +459,9 @@ Disassembly of section .fini: 观察两者的机器码,你能说出精简指令集和复杂指令集各自的特点吗? -## 四、C代码中的汇编语句 +### 四、C代码中的汇编语句 -### 1. 准备源代码 +#### 1. 准备源代码 🎵 *准备代码* @@ -471,7 +471,7 @@ Disassembly of section .fini: cd ~/code ``` -### 2. 编译并执行 +#### 2. 编译并执行 🤚 *动手操作* @@ -484,9 +484,9 @@ gcc -o add add.c 试着将代码中32位的寄存器Wn换成64位的寄存器Xn再重新编译运行一遍。 -## 五、纯汇编程序 +### 五、纯汇编程序 -### 1. 准备汇编代码 +#### 1. 准备汇编代码 🎵 *准备代码* @@ -496,7 +496,7 @@ gcc -o add add.c cd ~/code ``` -### 2. 编译、链接 +#### 2. 编译、链接 🤚 *动手操作* @@ -505,7 +505,7 @@ as -o hello.o hello.s ld -o hello hello.o ``` -### 3. 执行 +#### 3. 执行 🤚 *动手操作* @@ -519,7 +519,7 @@ ld -o hello hello.o -# IV. 术语表 +## IV 术语表 本实验中所用术语列表如下: