diff --git a/ddk/build/build_rust_drv.sh b/ddk/build/build_rust_drv.sh index 0297031..88ef0a1 100755 --- a/ddk/build/build_rust_drv.sh +++ b/ddk/build/build_rust_drv.sh @@ -24,7 +24,7 @@ cur_dir=$(cd "$(dirname "$0")"; pwd) echo "build_rust_drv.sh is at dir: $cur_dir" name=$1 std=$2 -features=$4 +features=$3 function clean() { rm -rf ./target @@ -44,7 +44,7 @@ function build_rust_drv() { rust_so="$release_path/lib$name.so" combile_so="$release_path/libcombine.so" case "$std" in - "core") cargo +$os build $features -Z build-std=core --target=$target --release + "core") cargo +$os build $features --target=$target --release ;; "std") cargo +$os build $features --target=$target --release ;; diff --git a/ddk/rust_drv_apis/src/lib.rs b/ddk/rust_drv_apis/src/lib.rs index b8bd0c8..f9b8a8d 100644 --- a/ddk/rust_drv_apis/src/lib.rs +++ b/ddk/rust_drv_apis/src/lib.rs @@ -19,6 +19,7 @@ pub mod hwi_api; pub mod io_api; pub mod map_api; pub mod mem_copy_api; +pub mod reg_api; pub mod share_mem_api; pub use framework::tee_defines::TeeResult; diff --git a/ddk/rust_drv_apis/src/reg_api/mod.rs b/ddk/rust_drv_apis/src/reg_api/mod.rs new file mode 100644 index 0000000..27943ab --- /dev/null +++ b/ddk/rust_drv_apis/src/reg_api/mod.rs @@ -0,0 +1,20 @@ +// Copyright (C) 2023 Huawei Technologies Co., Ltd. +// Licensed under the Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. +mod reg_api_ffi; + +#[repr(C)] +pub struct RegApi {} + +impl RegApi { + pub fn read_mpidr_el1() -> i64 { + unsafe { reg_api_ffi::drv_read_mpidr_el1() } + } +} diff --git a/ddk/rust_drv_apis/src/reg_api/reg_api_ffi.rs b/ddk/rust_drv_apis/src/reg_api/reg_api_ffi.rs new file mode 100644 index 0000000..2e97eae --- /dev/null +++ b/ddk/rust_drv_apis/src/reg_api/reg_api_ffi.rs @@ -0,0 +1,22 @@ +// Copyright (C) 2023 Huawei Technologies Co., Ltd. +// Licensed under the Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + +extern "C" { + /// + /// read mpidr el1 for cpu + /// + /// # Parameters + /// None + /// + /// # Return + /// mpidr el1 + pub fn drv_read_mpidr_el1() -> i64; +} diff --git a/sdk/build/pack-TA/build_rust_ta.sh b/sdk/build/pack-TA/build_rust_ta.sh index 35dd62c..0b07b1e 100755 --- a/sdk/build/pack-TA/build_rust_ta.sh +++ b/sdk/build/pack-TA/build_rust_ta.sh @@ -46,7 +46,7 @@ function build_rust_ta() { rust_so="$release_path/lib$name.so" combile_so="$release_path/libcombine.so" case "$std" in - "core") cargo +$os build $features -Z build-std=core --target=$target --release + "core") cargo +$os build $features --target=$target --release ;; "std") cargo +$os build $features --target=$target --release ;;