فهرست منبع

更新系统调用号 (#15)

LoGin 1 سال پیش
والد
کامیت
29f2a1e928
3فایلهای تغییر یافته به همراه110 افزوده شده و 82 حذف شده
  1. 35 34
      src/lib.rs
  2. 59 41
      src/macros.rs
  3. 16 7
      src/platform/x86_64/nr.rs

+ 35 - 34
src/lib.rs

@@ -1,72 +1,73 @@
 //! # dsc - DragonOS Raw Syscall Binding
-//! 
+//!
 //! This is a raw syscall binding for DragonOS. It is not meant to be used directly, but rather as a dependency for other crates.
-//! 
+//!
 //! ## Usage
-//! 
+//!
 //! Add this to your `Cargo.toml`:
-//! 
+//!
 //! ```toml
 //! [dependencies]
 //! dsc = { git = "https://github.com/DragonOS-Community/dsc.git" , rev = "The Git Commit You Want" }
 //! ```
-//! 
+//!
 //! ## 其他
-//! 
+//!
 //! 如果您正在开发dsc,请您在引入dsc的库的`Cargo.toml`中添加如下内容,而不是使用上述的代码:
-//! 
+//!
 //! ```toml
 //! [dependencies]
 //! dsc = { path = "您本地存放dsc的源代码的路径" }
 //! ```
-//! 
+//!
 //! ## How to build
-//! 
+//!
 //! ```bash
-//! ARCH=x86_64 && cargo build -Zbuild-std --release --target src/platform/$ARCH/target.json 
+//! ARCH=x86_64 && cargo build -Zbuild-std --release --target src/platform/$ARCH/target.json
 //! ```
-//! 
+//!
 //! ## How to build docs
-//! 
+//!
 //! ```bash
-//! ARCH=x86_64 && cargo doc -Zbuild-std --release --target src/platform/$ARCH/target.json 
+//! ARCH=x86_64 && cargo doc -Zbuild-std --release --target src/platform/$ARCH/target.json
 //! ```
-//! 
+//!
 //! ## What is DragonOS?
-//! 
-//! DragonOS is an opensource operating system developed for the server field. 
+//!
+//! DragonOS is an opensource operating system developed for the server field.
 //! Its kernel and user mode environment are developed from scratch, and provides Linux compatibility.
-//! 
+//!
 //! - [DragonOS Website](https://dragonos.org)
 //! - [DragonOS Github](https://github.com/DragonOS-Community)
-//! 
+//!
 //! ## License
-//! 
-//! Licensed under 
+//!
+//! Licensed under
 //!   * MIT license (<http://opensource.org/licenses/MIT>)
 
 #![allow(deprecated)] // llvm_asm!
 #![deny(warnings)]
 #![no_std]
-#![cfg_attr(any(
-    target_arch = "arm",
-    target_arch = "mips",
-    target_arch = "mips64",
-    target_arch = "powerpc",
-    target_arch = "powerpc64",
-    target_arch = "sparc64",
-    target_arch = "x86"
-), feature(llvm_asm))]
+#![cfg_attr(
+    any(
+        target_arch = "arm",
+        target_arch = "mips",
+        target_arch = "mips64",
+        target_arch = "powerpc",
+        target_arch = "powerpc64",
+        target_arch = "sparc64",
+        target_arch = "x86"
+    ),
+    feature(llvm_asm)
+)]
 
 #[cfg(test)]
 extern crate std;
 
 pub use platform::*;
 
-pub (crate) mod macros;
+pub(crate) mod macros;
 
-
-#[cfg(all(any(target_os = "dragonos"),
-          target_arch = "x86_64"))]
-#[path="platform/x86_64/mod.rs"]
+#[cfg(all(any(target_os = "dragonos"), target_arch = "x86_64"))]
+#[path = "platform/x86_64/mod.rs"]
 pub mod platform;

+ 59 - 41
src/macros.rs

@@ -9,60 +9,78 @@
 // except according to those terms.
 
 /// The macro to invoke a syscall.
-/// 
+///
 /// # Examples
-/// 
+///
 /// The following code will print `Hello, world!` to the screen with black background and white foreground.
 /// ```
 /// syscall!(SYS_PUTSTRING, "Hello, world!\n", 0x00ffffff, 0x00000000);
 /// ```
-/// 
+///
 /// # Note
-/// 
+///
 /// This macro is not meant to be used directly, but rather as a dependency for other crates.
 #[macro_export]
 macro_rules! syscall {
-    ($nr:ident)
-        => ( ::dsc::syscall0(
-                ::dsc::nr::$nr) );
+    ($nr:ident) => {
+        ::dsc::syscall0(::dsc::nr::$nr)
+    };
 
-    ($nr:ident, $a1:expr)
-        => ( ::dsc::syscall1(
-                ::dsc::nr::$nr,
-                $a1 as usize) );
+    ($nr:ident, $a1:expr) => {
+        ::dsc::syscall1(::dsc::nr::$nr, $a1 as usize)
+    };
 
-    ($nr:ident, $a1:expr, $a2:expr)
-        => ( ::dsc::syscall2(
-                ::dsc::nr::$nr,
-                $a1 as usize, $a2 as usize) );
+    ($nr:ident, $a1:expr, $a2:expr) => {
+        ::dsc::syscall2(::dsc::nr::$nr, $a1 as usize, $a2 as usize)
+    };
 
-    ($nr:ident, $a1:expr, $a2:expr, $a3:expr)
-        => ( ::dsc::syscall3(
-                ::dsc::nr::$nr,
-                $a1 as usize, $a2 as usize, $a3 as usize) );
+    ($nr:ident, $a1:expr, $a2:expr, $a3:expr) => {
+        ::dsc::syscall3(::dsc::nr::$nr, $a1 as usize, $a2 as usize, $a3 as usize)
+    };
 
-    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr)
-        => ( ::dsc::syscall4(
-                ::dsc::nr::$nr,
-                $a1 as usize, $a2 as usize, $a3 as usize,
-                $a4 as usize) );
+    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => {
+        ::dsc::syscall4(
+            ::dsc::nr::$nr,
+            $a1 as usize,
+            $a2 as usize,
+            $a3 as usize,
+            $a4 as usize,
+        )
+    };
 
-    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr)
-        => ( ::dsc::syscall5(
-                ::dsc::nr::$nr,
-                $a1 as usize, $a2 as usize, $a3 as usize,
-                $a4 as usize, $a5 as usize) );
+    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr) => {
+        ::dsc::syscall5(
+            ::dsc::nr::$nr,
+            $a1 as usize,
+            $a2 as usize,
+            $a3 as usize,
+            $a4 as usize,
+            $a5 as usize,
+        )
+    };
 
-    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr)
-        => ( ::dsc::syscall6(
-                ::dsc::nr::$nr,
-                $a1 as usize, $a2 as usize, $a3 as usize,
-                $a4 as usize, $a5 as usize, $a6 as usize) );
+    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr) => {
+        ::dsc::syscall6(
+            ::dsc::nr::$nr,
+            $a1 as usize,
+            $a2 as usize,
+            $a3 as usize,
+            $a4 as usize,
+            $a5 as usize,
+            $a6 as usize,
+        )
+    };
 
-    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr, $a7:expr)
-        => ( ::dsc::syscall7(
-                ::dsc::nr::$nr,
-                $a1 as usize, $a2 as usize, $a3 as usize,
-                $a4 as usize, $a5 as usize, $a6 as usize,
-                $a7 as usize) );
-}
+    ($nr:ident, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr, $a7:expr) => {
+        ::dsc::syscall7(
+            ::dsc::nr::$nr,
+            $a1 as usize,
+            $a2 as usize,
+            $a3 as usize,
+            $a4 as usize,
+            $a5 as usize,
+            $a6 as usize,
+            $a7 as usize,
+        )
+    };
+}

+ 16 - 7
src/platform/x86_64/nr.rs

@@ -2,19 +2,23 @@ pub const SYS_READ: usize = 0;
 pub const SYS_WRITE: usize = 1;
 pub const SYS_OPEN: usize = 2;
 pub const SYS_CLOSE: usize = 3;
-
+pub const SYS_STAT: usize = 4;
 pub const SYS_FSTAT: usize = 5;
+
+pub const SYS_POLL: usize = 7;
 pub const SYS_LSEEK: usize = 8;
 pub const SYS_MMAP: usize = 9;
 pub const SYS_MPROTECT: usize = 10;
 pub const SYS_MUNMAP: usize = 11;
 pub const SYS_BRK: usize = 12;
 pub const SYS_SIGACTION: usize = 13;
-
+pub const SYS_RT_SIGPROCMASK: usize = 14;
 pub const SYS_RT_SIGRETURN: usize = 15;
-
+pub const SYS_IOCTL: usize = 16;
 pub const SYS_WRITEV: usize = 20;
 
+pub const SYS_MADVISE: usize = 28;
+
 pub const SYS_DUP: usize = 32;
 pub const SYS_DUP2: usize = 33;
 
@@ -34,7 +38,7 @@ pub const SYS_BIND: usize = 49;
 pub const SYS_LISTEN: usize = 50;
 pub const SYS_GETSOCKNAME: usize = 51;
 pub const SYS_GETPEERNAME: usize = 52;
-
+pub const SYS_SOCKET_PAIR: usize = 53;
 pub const SYS_SETSOCKOPT: usize = 54;
 pub const SYS_GETSOCKOPT: usize = 55;
 pub const SYS_CLONE: usize = 56;
@@ -58,23 +62,28 @@ pub const SYS_MKDIR: usize = 83;
 
 pub const SYS_GETTIMEOFDAY: usize = 96;
 
-pub const SYS_REBOOT: usize = 169;
-
 pub const SYS_GETPPID: usize = 110;
 pub const SYS_GETPGID: usize = 121;
-
+pub const SYS_SIGALTSTACK: usize = 131;
 pub const SYS_MKNOD: usize = 133;
 
 pub const SYS_ARCH_PRCTL: usize = 158;
 
+pub const SYS_REBOOT: usize = 169;
+
+pub const SYS_GETTID: usize = 186;
+
 pub const SYS_FUTEX: usize = 202;
 
+pub const SYS_GET_DENTS_64: usize = 217;
 pub const SYS_SET_TID_ADDR: usize = 218;
 
 pub const SYS_UNLINK_AT: usize = 263;
 
 pub const SYS_PIPE: usize = 293;
 
+pub const SYS_GET_RANDOM: usize = 318;
+
 // 与linux不一致的调用,在linux基础上累加
 // 独立系统调用号大于100000
 pub const SYS_PUT_STRING: usize = 100000;