diff --git a/Languages/Python3/library/Marionette.md b/Languages/Python3/library/Marionette.md new file mode 100644 index 0000000..ce7ed7a --- /dev/null +++ b/Languages/Python3/library/Marionette.md @@ -0,0 +1,29 @@ +#### 简介 + +这是一个远程协议,可用于控制浏览器。 + +Marionette由两部分组成:服务端在浏览器内部,用于接收请求并执行它们。客户端用于发送命令。 + +#### 构建 + +#### Mn Python测试 + +#### 协议 + +#### 贡献 + +#### 新贡献者 + +#### 提交补丁 + +#### 调试 + +#### 使用一键loaner进行测试 + +#### 类型概览 + +#### Selenium atoms + +#### 偏好 + +#### 内部 \ No newline at end of file diff --git a/Languages/Rust/attribute/attribute.md b/Languages/Rust/attribute/attribute.md new file mode 100644 index 0000000..d3bbda6 --- /dev/null +++ b/Languages/Rust/attribute/attribute.md @@ -0,0 +1,47 @@ +#### 属性 + +语法: + +```rust +#![Attr] // 内部属性,作用于声明属性的地方 +#[Attr] // 外部属性,作用于属性之后的东西 +``` + +分类: + +- 内建属性 +- 宏属性 +- 派生宏辅助属性 +- 工具属性 + +可应用于: + +##### 元条目属性语法 + +##### 活跃的或内部的 + +##### 工具属性 + +##### 内建属性 + +```rust +// 条件编译 +// 测试 +// 派生 +// 宏 +macro_use // 扩展宏的可见性,或从其它crate导入宏。 +// 诊断 +// ABI,链接,符号,FFI +no_main // 不会加载"main"标记 +// 代码生成 +// 文档 +// 预加载 +no_std // 不会预加载std +// 模块 +// 限制 +// 运行时 +// 性质 +feature // 使能开发中的,或实验性的编译器属性。 +// 类型系统 +``` + diff --git a/Languages/Rust/attribute/feature.md b/Languages/Rust/attribute/feature.md new file mode 100644 index 0000000..6b19d86 --- /dev/null +++ b/Languages/Rust/attribute/feature.md @@ -0,0 +1,32 @@ +详见[the unstable book](https://doc.rust-lang.org/stable/unstable-book/index.html) + +#### 编译器标志 + +#### 语言属性 + +#### 库属性 + +##### global_asm + +`global_asm!`宏使得程序员可以在函数体之外写汇编,通过rustc和llvm传递给汇编器。这个宏是[llvm模块级内联汇编](http://llvm.org/docs/LangRef.html#module-level-inline-assembly)的简单接口。 + +如果不需要`global_asm!`的强大和灵活,且仅在函数体内使用内联汇编,应使用`asm`属性。 + +##### llvm_asm + +`llvm_asm!`宏支持内联汇编,格式如下: + +```rust +llvm_asm!(assembly template + : output operands + : input operands + : clobbers + : options + ); +``` + +详细的格式请参考[LLVM's inline assembler expressions](http://llvm.org/docs/LangRef.html#inline-assembler-expressions) + +相比于`global_asm`,它能力会弱一点,但有更精细的控制。 + +##### panic_info_message \ No newline at end of file diff --git a/Languages/Rust/core_library/mod_fmt.md b/Languages/Rust/core_library/mod_fmt.md new file mode 100644 index 0000000..8956319 --- /dev/null +++ b/Languages/Rust/core_library/mod_fmt.md @@ -0,0 +1,21 @@ +#### 简介 + +格式化字符串或打印字符串的工具。 + +#### 宏 + +Debug + +#### 结构体 + +#### 枚举类型 + +#### 特性 + +#### 函数 + +write + +#### 类型定义 + +Result \ No newline at end of file diff --git a/Languages/Rust/crate/embedded_hal.md b/Languages/Rust/crate/embedded_hal.md new file mode 100644 index 0000000..27aa763 --- /dev/null +++ b/Languages/Rust/crate/embedded_hal.md @@ -0,0 +1,25 @@ +#### 简介 + +适用于嵌入式系统的硬件抽象层。 + +#### 模块 + +- serial - 串行接口 + + ```rust + /* + * 特性 + */ + // Read - 串行接口的读取 + type Error // Read error + fn try_read(&mut self) -> Result + // Write - 串行接口的写入 + type Error // Write error + fn try_write(&mut self, word: Word) -> Result<(), Self::Error> + // 写一个word到串行接口 + fn try_flush(&mut self) -> Result<(), Self::Error> + // 确保之前的写操作都已完成 + ``` + + + diff --git a/Languages/Rust/crate/k210_hal.md b/Languages/Rust/crate/k210_hal.md new file mode 100644 index 0000000..34f6c7f --- /dev/null +++ b/Languages/Rust/crate/k210_hal.md @@ -0,0 +1,22 @@ +#### 简介 + +K210 SoC 对embedded-hal特性的实现。 + +#### 模块 + +serial - 串行接口 + +```rust +UARTHS +UART1 +UART2 +UART3 +// 结构体 +// 特性 +``` + + + +#### 结构体 + +Peripherals - 所有的外设 \ No newline at end of file diff --git a/Languages/Rust/crate/nb.md b/Languages/Rust/crate/nb.md new file mode 100644 index 0000000..cc55d30 --- /dev/null +++ b/Languages/Rust/crate/nb.md @@ -0,0 +1,3 @@ +#### 简介 + +一个最小化和可重用的非阻塞I/O层。 \ No newline at end of file diff --git a/Languages/Rust/std_library/mod_io.md b/Languages/Rust/std_library/mod_io.md new file mode 100644 index 0000000..17f5b70 --- /dev/null +++ b/Languages/Rust/std_library/mod_io.md @@ -0,0 +1,29 @@ +#### 简介 + +关于核心I/O功能的特性、helpers和类型定义。 + +#### Read和Write + +Read和Write是特性,大量的其它类型实现了它们,你也可以对自己的类型实现它们。 + +#### 模块 + +prelude + +#### 结构体 + +Stdout - 当前进程标准输出流的句柄。 + +#### 枚举类型 + +#### 特性 + +Read + +Write + +#### 函数 + +#### 类型 + +Result \ No newline at end of file diff --git a/OS/Rcore/ch1_print.md b/OS/Rcore/ch1_print.md new file mode 100644 index 0000000..79a7d52 --- /dev/null +++ b/OS/Rcore/ch1_print.md @@ -0,0 +1,58 @@ +#### 概述 + +从C与Rust、Rcore与其它OS对比的角度,描述Rcore。 + +- Rcore:用Rust编写,运行于qemu和k210。 +- Ucore:用C编写,运行于qemu。系统的结构应是最接近Rcore的。 +- xv6-riscv:用C编写,运行于qemu。 +- RT-Thread:用C编写,运行于k210。 + +第一节的目标是在屏幕上打印一些字符串。要实现此目标需要做以下的事: + +- os成功从CPU手中接管控制权。 +- os成功控制uart设备。 + +#### 从CPU手中接管控制权 + +##### Rcore + +要从CPU手中正确接管管控权,os就需要放在内存中合适的位置,这是由链接脚本控制的。 + +对于Rcore来说,它的链接脚本是linker-\.ld。两个平台唯一的差别就是`BASE_ADDRESS`不一样,k210是`0x80020000`,而qemu是`0x80200000`。 + +硬件会从`0x80000000`开始执行代码,由于Rcore设置了bootloader,所以bootloader会先从`0x80000000`开始执行,再把控制权转交给os。k210只有6M的内存,在bootloader目录下可以查到rustsbi-k210.bin是78K,所以rustsbi-k210设定从它后面128K开始执行os是合适的。qemu默认的内存就达到了128M,rustsbi_qemu.bin是107K,所以rustsbi-qemu设定从它后面2M开始执行os也是没问题的。 + +##### Ucore + +Ucore的链接脚本和Rcore是一样的。 + +##### xv6-riscv + +与Rcore不一样,xv6-riscv的链接脚本设定os是从`0x80000000`开始的,这是因为xv6没有使用bootloader,不用给它留位置。 + +##### TR-Tread + +RT-Thread针对K210的链接脚本是bsp/k210/link.lds,它和xv6-riscv一样,也是从`0x80000000`开始的,因为它没有使用像rustsbi这样的bootloader,而自己直接控制了所有的硬件。 + +#### 控制uart设备 + +##### Rcore + +os通过K210上的uart设备向主机发送信息,主机接收到信息后打印出来。 + +Rcore通过宏`println!`打印出"Hello world"。这个宏在src/console.rs里定义,最终调用了`console_putchar()`。`console_putchar()`定义在src/sbi.rs,最终使用`ecall`指令调用了机器态的rustsbi,传递的参数是`SBI_CONSOLE_PUTCHAR`。 + +上面通过`ecall`进到rustsbi的中断处理入口`_start_trap`,保存寄存器的值然后调用`_start_trap_rust`,即`start_trap_rust`函数。通过`match`运算匹配到`SupervisorEnvCall`,调用到`rustsbi::ecall()`执行具体的处理。从lib.rs可见`ecall()`即`handle_ecall()`,`handle_ecall()`在ecall.rs。在`handle_ecall()`里通过`match`运算匹配到`LEGACY_CONSOLE_PUTCHAR`,进而执行`legacy::console_putchar()`。在ecall/legacy.rs可见`console_putchar()`调用的是`legacy_stdio_putchar()`,从legacy_stdio.rs可见`legacy_stdio_putchar()`的定义,最终使用的crate:`k210_pac`提供的`try_write()`和`try_flush()`两个函数。可以从[docs.rs](docs.rs)网站得到`k210_pac`的详细介绍(包括源码)。 + +##### Ucore + +Ucore也是通过`ecall`指令进到rustsbi,来实现`printf()`函数。从而打印"Hello world"。 + +##### xv6-riscv + +xv6-riscv有自己定义对UART的驱动,详见kernel/uart.c文件。比如,通过`Reg(THR)`即可定位到UART设备的传输保持寄存器(transmit holding register),只要向这个内存地址写入数据即可实现通过串口输出的功能。 + +##### RT-Thread + +RT-Thread也有定义对K210的驱动,在bsp/k210/driver。比如drv_uart.c即为UART的驱动,其中`_uarths`即为UARTHS寄存器组的起始地址,在`drv_uarths_putc()`函数就实现了向UARTHS的传输保持寄存器`txdata`写入数据的功能。 + diff --git a/OS/Rcore/ch2_batch.md b/OS/Rcore/ch2_batch.md new file mode 100644 index 0000000..442e5f5 --- /dev/null +++ b/OS/Rcore/ch2_batch.md @@ -0,0 +1,3 @@ +#### 概述 + +本章的目标是让用户态的程序可以批量执行。 \ No newline at end of file diff --git a/Software/builtin命令/function.md b/Software/builtin命令/function.md new file mode 100644 index 0000000..52733c1 --- /dev/null +++ b/Software/builtin命令/function.md @@ -0,0 +1,7 @@ +作用:定义shell函数。 + +```bash +fuction name {commands;} +fuction name () {commands;} +``` + diff --git a/Software/crontab.md b/Software/crontab.md index 73ec8e6..5c3306e 100644 --- a/Software/crontab.md +++ b/Software/crontab.md @@ -33,9 +33,9 @@ crontab [-u user] [选项] # week取值范围0~7,这里0和7都代表星期日 # command是要执行的命令 # 星号(*)代表所有可能的值 -# 逗号(,)用来隔开值,所有被隔开的值代表一个取值范围 -# 横杠(-)表示两个值之间的取值范围 -# 斜杠(/)指定时间的频率 +# 逗号(,)用来隔开值,或隔开取值范围。如"1,2,5"或"1-3,7-9"。 +# 横杠(-)表示两个值之间的取值范围。如"8-10"代表"8,9,10"。 +# 斜杠(/)指定时间的频率。如"0-23/2"代表"0,2,4,6,8,10,12,14,16,18,20,22",也相当于"*/2"。 # 举例:每周一早上5点备份home目录 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ diff --git a/Software/find.md b/Software/find.md index 8b09380..6df85db 100644 --- a/Software/find.md +++ b/Software/find.md @@ -24,6 +24,12 @@ 作用于命令行中所有位置的Tests和Actions操作,总是返回true。 +```bash +-maxdepth # 指定要查找的文件夹的层数 +``` + + + ##### Tests 基于文件的属性返回true或false。 diff --git a/Software/flatbuffers.md b/Software/flatbuffers.md new file mode 100644 index 0000000..cca6125 --- /dev/null +++ b/Software/flatbuffers.md @@ -0,0 +1,89 @@ +##### flatc + +```bash +# 编译flatc +git clone https://github.com/google/flatbuffers.git +export CC=/usr/bin/clang +export CXX=/usr/bin/clang++ +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -B build +cd build && make + +# 用法 +flatc [options] [-- files] + --cpp, -c # 生成C++头文件 + --python, -p # 生成Python文件 + --gen-mutable # 生成可以改变缓冲区的访问器。(缓冲区默认是不可改变的) +``` + +##### schema语言 + +`namespace ;`定义命名空间NameSpace。 + +`enum : {}`定义枚举类型。 + +`union {}`定义联合类型。 + +`struct {}`定义结构体。 + +`table {}`定义列表。列表里的字段不可删除,但可以使用`deprecated`来阻止生成代码访问这个字段。 + +`root_type`用来声明序列化数据的根列表。 + +详见如下文档: + +- [writing a schema](https://google.github.io/flatbuffers/flatbuffers_guide_writing_schema.html) + +- [grammar of the schema language](https://google.github.io/flatbuffers/flatbuffers_grammar.html) + +##### 用C++读写FlatBuffers + +```cpp +// #include生成的文件并using namespace +// 使用FlatBufferBuilder实例化一个缓冲区 +// 在序列化一个对象前,先要序列化其中包含的任何对象 +// 最后,调用finish方法结束序列化。 +// 保存缓冲区,注意要保存为二进制格式。 +// 使用g++或clang++编译器 + +/* 把buffer写入文件示例代码 */ + std::ofstream outfile; + outfile.open("csample.bat", std::ios::binary | std::ios::out); + outfile.write((const char *)builder.GetBufferPointer(), builder.GetSize()); + outfile.close(); + +/* 从文件读入buffer示例代码 */ + std::ifstream infile; + infile.open("csample.bat", std::ios::binary | std::ios::in); + infile.seekg(0, std::ios::end); + int length = infile.tellg(); + infile.seekg(0, std::ios::beg); + char *data = new char[length]; + infile.read(data, length); + infile.close(); +``` + +详见如下文档: + +- [tutorial](https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html) +- [use cpp](https://google.github.io/flatbuffers/flatbuffers_guide_use_cpp.html) +- [api](https://google.github.io/flatbuffers/group__flatbuffers__cpp__api.html) + +##### 用Python读写FlatBuffers + +```python +# 把buffer写入文件示例代码 + file = open('psample.bat','wb'); + file.write(builder.Output()); + file.close; + +# 从文件读入buffer示例代码 + file = open('psample.bat','rb'); + buf = file.read(); + buf = bytearray(buf); + file.close; +``` + +详见如下文档: + +- [use python](https://google.github.io/flatbuffers/flatbuffers_guide_use_python.html) + diff --git a/Software/git命令/git-clone.md b/Software/git命令/git-clone.md index 12b6080..e8db0bf 100644 --- a/Software/git命令/git-clone.md +++ b/Software/git命令/git-clone.md @@ -6,5 +6,6 @@ git clone [options] [directory] ``` -b, --branch # 指向name所代表的分支 +--origin , -o # 不用origin,而用追踪远程仓库 ``` diff --git a/Software/编译工具/clang.md b/Software/编译工具/clang.md new file mode 100644 index 0000000..2f664b7 --- /dev/null +++ b/Software/编译工具/clang.md @@ -0,0 +1,14 @@ +```bash +clang [options] +``` + +#### 选项 + +``` +-c # 只执行预处理、编译、汇编这几个阶段。 +-MD # 写一个depfile,包含用户和系统头文件 +-MT # 指定depfile输出到的文件的名称 +-MF # 把从-MMD, -MD, -MM或-M的depfile输出写入 +-o # 把输出写入 +``` + diff --git a/Software/编译工具/cmake.md b/Software/编译工具/cmake.md new file mode 100644 index 0000000..64a9c0b --- /dev/null +++ b/Software/编译工具/cmake.md @@ -0,0 +1,31 @@ +#### 用法 + +```bash +cmake [options] +cmake [options] +cmake [options] -S -B +``` + +#### 选项 + +```bash +-S # 指定源码目录 +-B # 指定构建目录 +-G # 指定生成器 + +-E # cmake命令模式 + +--help # 打印帮助信息 +--help-command # 打印命令的帮助信息。 +``` + +#### 生成器 + +- Unix Makefiles - 生成标准的UNIX makefiles。 + +#### cmake命令 + +``` + +``` + diff --git a/Software/编译工具/make.md b/Software/编译工具/make.md index 0e0acf8..18e5da7 100644 --- a/Software/编译工具/make.md +++ b/Software/编译工具/make.md @@ -20,7 +20,7 @@ #### OPTIONS -``` +```bash -b, -m -B, --always-make -C dir, --directory=dir # 更改目录为dir @@ -42,8 +42,8 @@ -q, --question # 不运行任何命令,也不打印任何东西,只返回一个退出的状态。如果编译目标已经更新则返回0,否则返回其它数字。 -r -R --s --S +-s, --silent, --quiet # 静默选项。不把正在运行的命令打印出来。 +-S, --no-keep-going, --stop # 取消-k选项的效果。 -t, --touch # 更新文件的日期,从而不执行它所依赖的命令。这实际上就是假装命令已经执行过了,以便make将来调用的时候欺骗它。 --trace -v