Skip to content

Commit bce529f

Browse files
committed
add [web3 与量化](/2023/09/web3_and_quantitative_trading.md)
1 parent f94e0d0 commit bce529f

10 files changed

+264
-14
lines changed

2023/08/jyy_operate_system_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ In C, adjacent string literals are concatenated, so "1" "2" "3" is equivalent to
6464
htop 的 load 表示在一段时间内待处理的任务数量,通常以三个数值表示,如"0.71 0.36 0.20"。这些数值对应于最近1分钟、5分钟和15分钟
6565

6666
gdb 确定到 Segmentation Fault 的位置,而它恰好是一条 SSE 指令 则很可能原因是没对齐(如果是 SIGILL 大概率是不支持 SSE 指令集)
67+
68+
pthread 线程默认是 “joinable” 的。joinable 的线程只要没有 join 过,资源就一直不会释放(produces a "zombie thread") 除非设置成 detach

2023/08/learning_os.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ OS 课缺失的 lecture7 可以看学堂在线公开课的版本
1515
||||
1616
|---|---|---|
1717
|CSAPP| 看完了 |
18+
|程序员的自我修养链接装载库| 看完了 |
1819
|计算机组成与设计 RISC-V edition| ch2.3.2 | 常数 |
1920
|OS Three easy pieces| 看完了 |
2021
|rCore Tutorial Book| 看完了 |
22+
|rust raspberrypi OS| 06_uart_chainloader |
2123
|uCore Tutorial Book| ch4 | SV39 实现 |
22-
|程序员的自我修养链接装载库| 看完了 |
2324
|清华 os_lecture 2022| 看完了|
2425
|清华操作系统(RISC-V) 学堂在线| 看完了+通过慕课考试 |
2526
|南京大学操作系统 jyy 2022|lecture06 7min||

2023/08/link_load_and_lib_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ C 语言用 __attribute__((section("foo")))
7171
|`__attribute__((aligned(32)))`|#[repr(align(32))]|
7272
|`__attribute__((always_inline))`|#[inline(always)]|
7373
|`__attribute__((naked))`|#[naked]|
74+
|`__attribute__ ((warn_unused_result))`|#[unused_must_use]|
7475
|C++: extern "C"|#[no_mangle]|
7576
|__thread|#[thread_local]|
7677
|gcc -nostdlib|#![no_std]|

2023/08/ptr_addr_of.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22

33
addr_of! 宏除了读取 repr(packed) 的结构体我还没想到有什么用
44

5-
对应 C 语言类似的是 **container_of** 还有一个相关的 **offset_of**
5+
对应 C 语言类似的是 **offset_of**
6+
7+
## container_of
8+
9+
obtain a pointer to the parent structure given a pointer to one of its members
10+
11+
常用于 linux 源码例如 watchdog_context 里面有个 watchdog_devicewatchdog_ops
12+
13+
**Rust for Linux 源码中实现了这两个 C 的宏** <https://rust-for-linux.github.io/docs/kernel/macro.container_of.html>

2023/09/automotive_gateway.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@ Telematics Box车载远程通信模块继承蜂窝网络、WiFi、蓝牙等
2929
## BSP
3030
Board Support Package
3131

32+
## 新能源汽车产商
33+
- BBA: 宝马奔驰奥迪
34+
3235
## Reference
3336
- <https://www.arrow.cn/blog/post/gateway.html>

2023/09/bst_chip_arm_linux_cross_compile.md

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ ld.lld --version
134134

135135
`make ARCH=arm64 LLVM=1 WERROR=0 O=build -j$nproc` 就这样正常编译就行了
136136

137+
注意"环境变量"要写到make后面,如果写到make的前面的话效果就不一样了
138+
137139
## 不加 O=build 会出现一堆奇怪编译报错
138140

139141
```
@@ -163,13 +165,13 @@ Command 'mkimage' not found, but can be installed with:
163165
apt install u-boot-tools
164166
165167
# O=build would generate build/.config, not .config
166-
make ARCH=arm64 LLVM=1 bsta1000b_defconfig O=build
167-
make ARCH=arm64 LLVM=1 bsta1000b_defconfig
168+
make ARCH=arm64 LLVM=1 O=build bsta1000b_defconfig
168169
169-
make ARCH=arm64 LLVM=1 WERROR=0 O=build -j$nproc
170+
# ubuntu 上编译不用加 WERROR=0
171+
make ARCH=arm64 LLVM=1 O=build -j$nproc
170172
171173
# make modules_install 不会修改内核
172-
make ARCH=arm64 LLVM=1 O=build modules_install INSTALL_MOD_PATH=modules_install INSTALL_MOD_STRIP=1
174+
make ARCH=arm64 LLVM=1 O=build INSTALL_MOD_PATH=modules_install INSTALL_MOD_STRIP=1 modules_install
173175
174176
# 看门狗驱动内嵌在内核中,似乎 NOC 要手动 insmod
175177
tree build/modules_install/lib/modules/6.1.12+2-rt7/kernel/ | grep noc
@@ -210,6 +212,22 @@ make ARCH=arm64 && make defconfig && make rust-analyzer
210212

211213
bear + O=build 的编译倒是没有特别困难
212214

215+
```
216+
make[1]: Entering directory '/home/wuaoxiang/linux-rust/build'
217+
Traceback (most recent call last):
218+
File "../scripts/generate_rust_analyzer.py", line 141, in <module>
219+
main()
220+
File "../scripts/generate_rust_analyzer.py", line 134, in main
221+
"crates": generate_crates(args.srctree, args.objtree, args.sysroot_src),
222+
File "../scripts/generate_rust_analyzer.py", line 107, in generate_crates
223+
if f"{name}.o" not in open(path.parent / "Makefile").read():
224+
FileNotFoundError: [Errno 2] No such file or directory: '../drivers/block/nvme_mq/Makefile'
225+
make[2]: *** [../rust/Makefile:392: rust-analyzer] Error 1
226+
make[1]: *** [/home/wuaoxiang/linux-rust/Makefile:1850: rust-analyzer] Error 2
227+
```
228+
229+
touch drivers/block/nvme_mq/Makefile 就解决这个报错
230+
213231
## 一个内核模块报错
214232
我搜索 drivers/soc 下面 module_init 找到 NOC 芯片的驱动代码? 的入口函数
215233

@@ -297,3 +315,50 @@ USB协议也支持一种特殊的模式,即On-The-Go(OTG)模式。在OTG
297315

298316
## MTD=Memory Technology Device
299317
为原始闪存设备(例如NAND,OneNAND,NOR 等)提供了一个抽象层。 这些不同类型的Flash都可以使用相同的API
318+
319+
## platform device
320+
321+
Linux源码学习之platform_driver
322+
323+
按照驱动probe用的结构体的不同去分类驱动
324+
驱动可分为usb_serial_driver,platform_driver等等
325+
基本上各种不同的驱动结构体都"继承"了device,device_driver
326+
327+
platform_driver适用于特定硬件平台
328+
如图中所示树莓派的GPIO名字跟树莓派官网下载的dtb设备树文件中完全一致
329+
330+
```
331+
[w@ww rpi_linux]$ git remote -v
332+
origin https://github.com/raspberrypi/linux.git (fetch)
333+
origin https://github.com/raspberrypi/linux.git (push)
334+
[w@ww rpi_linux]$ dtc bcm2711-rpi-4-b.dtb -o rpi4.dtc 2>/dev/null
335+
[w@ww rpi_linux]$ grep gpiomem rpi4.dtc
336+
gpiomem {
337+
compatible = "brcm,bcm2835-gpiomem";
338+
[w@ww rpi_linux]$ grep -n -r "brcm,bcm2835-gpiomem" drivers/
339+
drivers/char/broadcom/bcm2835-gpiomem.c:237: {.compatible = "brcm,bcm2835-gpiomem",},
340+
[w@ww rpi_linux]$ grep -B1 -A12 -n -H -h -r "brcm,bcm2835-gpiomem" drivers/
341+
236-static const struct of_device_id bcm2835_gpiomem_of_match[] = {
342+
237: {.compatible = "brcm,bcm2835-gpiomem",},
343+
238- { /* sentinel */ },
344+
239-};
345+
240-
346+
241-MODULE_DEVICE_TABLE(of, bcm2835_gpiomem_of_match);
347+
242-
348+
243-static struct platform_driver bcm2835_gpiomem_driver = {
349+
244- .probe = bcm2835_gpiomem_probe,
350+
245- .remove = bcm2835_gpiomem_remove,
351+
246- .driver = {
352+
247- .name = DRIVER_NAME,
353+
248- .owner = THIS_MODULE,
354+
249- .of_match_table = bcm2835_gpiomem_of_match,
355+
```
356+
357+
##
358+
359+
Linux源码学习之bindings_helpers
360+
361+
C函数签名带static的不会暴露在动态库/静态库的符号中,约等于"私有函数"
362+
363+
例如ioremap只好创建一个非static的rust_helper_ioremap函数当作wrapper把私有函数包一层
364+
另外一种办法是static inline函数内一般都是调用一个公开的函数,要不就直接调里面的函数也行

2023/09/sloppy_counter.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ gpt 的一句话点醒了我 **缺点是近似的计数方法**
1414

1515
但 OSTEP 书中更聪明,维护一个所有线程ID->counter的映射数组,每次线程想增加计数器时,先从数组找到自己线程的局部计数器去自增,这样就不用改CPU调度的亲和性了
1616

17+
OSTEP ch29 Locked Data Structures
18+
1719
<https://twitter.com/ospopen/status/1700119320091910306>

0 commit comments

Comments
 (0)