Browse Source

添加cargo doc,并完善编译命令

longjin 1 year ago
parent
commit
943c158aa5
5 changed files with 122 additions and 3 deletions
  1. 5 1
      Cargo.toml
  2. 26 1
      README.md
  3. 48 1
      src/lib.rs
  4. 12 0
      src/macros.rs
  5. 31 0
      src/platform/x86_64/target.json

+ 5 - 1
Cargo.toml

@@ -1,8 +1,12 @@
 [package]
 name = "dsc"
-version = "0.1.0"
+version = "0.0.1"
 edition = "2021"
 authors = ["longjin <[email protected]>"]
+description = "DragonOS Raw Syscall Binding"
+readme = "README.md"
+license = "MIT"
+repository = "https://github.com/DragonOS-Community/dsc"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 [lib]

+ 26 - 1
README.md

@@ -11,7 +11,7 @@ Add this to your `Cargo.toml`:
 dsc = { git = "https://github.com/DragonOS-Community/dsc.git" }
 ```
 
-## 其他
+## Development
 
 如果您正在开发dsc,请您在引入dsc的库的`Cargo.toml`中添加如下内容,而不是使用上述的代码:
 
@@ -19,3 +19,28 @@ dsc = { git = "https://github.com/DragonOS-Community/dsc.git" }
 [dependencies]
 dsc = { path = "您本地存放dsc的源代码的路径" }
 ```
+
+## How to build
+
+```bash
+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 
+```
+
+## What is DragonOS?
+
+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 
+  * MIT license ([LICENSE-MIT](LICENSE) or http://opensource.org/licenses/MIT)

+ 48 - 1
src/lib.rs

@@ -1,3 +1,50 @@
+//! # 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 
+//! ```
+//! 
+//! ## How to build docs
+//! 
+//! ```bash
+//! 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. 
+//! 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 
+//!   * MIT license (<http://opensource.org/licenses/MIT>)
+
 #![allow(deprecated)] // llvm_asm!
 #![deny(warnings)]
 #![no_std]
@@ -16,7 +63,7 @@ extern crate std;
 
 pub use platform::*;
 
-pub mod macros;
+pub (crate) mod macros;
 
 
 #[cfg(all(any(target_os = "dragonos"),

+ 12 - 0
src/macros.rs

@@ -8,6 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // 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)

+ 31 - 0
src/platform/x86_64/target.json

@@ -0,0 +1,31 @@
+{    "arch": "x86_64",
+    "code-model": "kernel",
+    "cpu": "x86-64",
+    "os": "dragonos",
+    "target-endian": "little",
+    "target-pointer-width": "64",
+    "target-c-int-width": "32",
+    "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
+    "disable-redzone": true,
+    "features": "-3dnow,-3dnowa,-avx,-avx2",
+    "linker": "rust-lld",
+    "linker-flavor": "ld.lld",
+    "llvm-target": "x86_64-unknown-none",
+    "max-atomic-width": 64,
+    "panic-strategy": "abort",
+    "position-independent-executables": true,
+    "relro-level": "full",
+    "stack-probes": {
+      "kind": "inline-or-call",
+      "min-llvm-version-for-inline": [
+        16,
+        0,
+        0
+      ]
+    },
+    "static-position-independent-executables": true,
+    "supported-sanitizers": [
+      "kcfi"
+    ],
+    "target-pointer-width": "64"
+}