From b11bb1b25676f528ec1b0e1da0af82b4652f70c4 Mon Sep 17 00:00:00 2001 From: login Date: Sun, 7 May 2023 22:20:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E7=BC=96=E8=AF=91=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E9=93=BE=E3=80=81=E4=BF=AE=E5=A4=8D=E7=94=B1=E4=BA=8E?= =?UTF-8?q?=E6=96=B0=E7=89=88rust=E7=BC=96=E8=AF=91=E5=99=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=AF=BC=E8=87=B4=E7=9A=84=E6=8A=A5=E9=94=99=E3=80=82?= =?UTF-8?q?=20(#258)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 固定编译工具链、修复由于新版rust编译器问题导致的报错。 * 完善github workflow环境配置 --- .github/workflows/makefile.yml | 2 +- kernel/src/driver/uart/uart.rs | 12 ++++++------ rust-toolchain.toml | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index b07393e8..8cfa3de3 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -44,7 +44,7 @@ jobs: - if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }} name: Install toolchain continue-on-error: true - run: sudo apt install -y llvm-dev libclang-dev clang gcc-multilib && cargo install cargo-binutils && rustup toolchain install nightly && rustup default nightly && rustup component add rust-src && rustup component add llvm-tools-preview && rustup target add x86_64-unknown-none + run: sudo apt install -y llvm-dev libclang-dev clang gcc-multilib && cargo install cargo-binutils && rustup toolchain install nightly && rustup default nightly && rustup component add rust-src && rustup component add llvm-tools-preview && rustup target add x86_64-unknown-none && rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu - name: build the DragonOS run: bash -c "source ~/.cargo/env && export DragonOS_GCC=$HOME/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin && make -j $(nproc) " diff --git a/kernel/src/driver/uart/uart.rs b/kernel/src/driver/uart/uart.rs index 95e7de36..0f21484b 100644 --- a/kernel/src/driver/uart/uart.rs +++ b/kernel/src/driver/uart/uart.rs @@ -156,10 +156,10 @@ impl UartDriver { /// @param str 发送字符切片 /// @return None #[allow(dead_code)] - fn uart_send(uart_port: &UartPort, str: &str) { + fn uart_send(uart_port: &UartPort, s: &str) { let port = uart_port.to_u16(); while UartDriver::is_transmit_empty(port) == false { - for c in str.bytes() { + for c in s.bytes() { unsafe { io_out8(port, c); } @@ -202,11 +202,11 @@ pub extern "C" fn c_uart_read(port: u16) -> u8 { ///@param port 串口端口 ///@param str 字符串S #[no_mangle] -pub extern "C" fn c_uart_send_str(port: u16, str: *const u8) { +pub extern "C" fn c_uart_send_str(port: u16, s: *const u8) { unsafe { - let mut i = 0; - while *offset(str, i) != '\0' as u8 { - c_uart_send(port, *offset(str, i)); + let mut i = 0isize; + while *offset(s, i) != '\0' as u8 { + c_uart_send(port, *offset(s, i)); i = i + 1; } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..3d808158 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2023-01-21" +components = ["rust-src"] \ No newline at end of file