Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kabirz committed Nov 1, 2022
1 parent 89ea0a9 commit 22e6796
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 6 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ scp -r name@ip:GIT_ROOT/linux/out/_modules/lib/modules/linuxxxx/extra .
### kgdb
patch: patches/kdb_arm64.patch
config: patches/kdb_config.diff
1. [arm64 kgdb1](https://blog.csdn.net/qq_35712169/article/details/108217641) [arm64 kgdb2](https://zhuanlan.zhihu.com/p/197545583)
1. [arm64 kgdb1](https://blog.csdn.net/qq_35712169/article/details/108217641) [arm64 kgdb2](https://zhuanlan.zhihu.com/p/197545583)

### earlycon
1. [earlycon](https://blog.csdn.net/ooonebook/article/details/52654191)
1. [earlycon](https://blog.csdn.net/ooonebook/article/details/52654191)


### [device tree](./doc/devicetree_cn.md)
### [device tree](./doc/devicetree_cn.md)
### [softirq tasklet](./doc/softirq_cn.md)
### [rwsem-读写信号量](./doc/rwsem_cn.md)

#### 参考:
[Linux内核中的pinctrl子系统应用实例](https://blog.csdn.net/u012719256/article/details/76070339)
[Linux - 使用V4L2(总结)](https://blog.csdn.net/weixin_43707799/article/details/107821189)
[Linux V4L2之camera](https://www.cnblogs.com/vedic/p/10763838.html)
[深入学习Linux摄像头(二)v4l2驱动框架](https://blog.csdn.net/weixin_42462202/article/details/99680969)
[一文让你读懂Linux五大模块内核源码,内核整体架构设计(超详细)](https://zhuanlan.zhihu.com/p/474337723)
[linux系统调度之时间](https://blog.csdn.net/eleven_xiy/article/details/71175347)

[mtk linux](https://gitlab.com/mediatek/aiot/bsp/linux)

### 面试题
[知乎1](https://zhuanlan.zhihu.com/p/161100568)
[Linux内核知识点---线程、锁、中断下半部、定时器](https://blog.csdn.net/baidu_19348579/article/details/126222242)
211 changes: 211 additions & 0 deletions doc/devicetree_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,214 @@
[设备树处理之——device_node转换成platform_device](https://www.cnblogs.com/downey-blog/p/10486568.html)
[Linux 驱动开发 十六:设备树在系统中的体现 1](https://blog.csdn.net/OnlyLove_/article/details/121987183)
[Linux 驱动开发 十六:设备树在系统中的体现 2](https://www.cnblogs.com/multimicro/p/11905647.html)

## devicetree加载resource流程
of_platform_sync_state_init -> of_platform_default_populate -> of_platform_populate -> of_platform_bus_create -> of_platform_device_create_pdata ->


of_platform_sync_state_init ->
```c
// drivers/of/platform.c

static int __init of_platform_default_populate_init(void)
{
struct device_node *node;

device_links_supplier_sync_state_pause();

if (!of_have_populated_dt())
return -ENODEV;

if (IS_ENABLED(CONFIG_PPC)) {
...
} else {
...
/* Populate everything else. */
of_platform_default_populate(NULL, NULL, NULL);
}

return 0;
}
arch_initcall_sync(of_platform_default_populate_init);

```
of_platform_default_populate ->
```c
// drivers/of/platform.c
int of_platform_default_populate(struct device_node *root, const struct of_dev_auxdata *lookup, struct device *parent)
{
return of_platform_populate(root, of_default_bus_match_table, lookup, parent);
}
```

of_platform_populate -> of_platform_bus_create
```c
// drivers/of/platform.c
int of_platform_populate(struct device_node *root, const struct of_device_id *matches, const struct of_dev_auxdata *lookup, struct device *parent)
{
struct device_node *child;
int rc = 0;

root = root ? of_node_get(root) : of_find_node_by_path("/");
if (!root)
return -EINVAL;

pr_debug("%s()\n", __func__);
pr_debug(" starting at: %pOF\n", root);

device_links_supplier_sync_state_pause();
for_each_child_of_node(root, child) {
rc = of_platform_bus_create(child, matches, lookup, parent, true);
if (rc) {
of_node_put(child);
break;
}
}
device_links_supplier_sync_state_resume();

of_node_set_flag(root, OF_POPULATED_BUS);

of_node_put(root);
return rc;
}
```
of_platform_bus_create -> of_platform_device_create_pdata
```c
// drivers/of/platform.c
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
const struct of_dev_auxdata *lookup,
struct device *parent, bool strict)
{
const struct of_dev_auxdata *auxdata;
struct device_node *child;
struct platform_device *dev;
const char *bus_id = NULL;
void *platform_data = NULL;
int rc = 0;
...
dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %pOF\n", child);
rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);
if (rc) {
of_node_put(child);
break;
}
}
of_node_set_flag(bus, OF_POPULATED_BUS);
return rc;
}
```
of_platform_device_create_pdata -> of_device_alloc
```c
// drivers/of/platform.c
struct platform_device *of_device_alloc(struct device_node *np, const char *bus_id, struct device *parent)
{
struct platform_device *dev;
int rc, i, num_reg = 0;
struct resource *res, temp_res;

dev = platform_device_alloc("", PLATFORM_DEVID_NONE);
if (!dev)
return NULL;

/* count the io resources */
while (of_address_to_resource(np, num_reg, &temp_res) == 0)
num_reg++;

/* Populate the resource table */
if (num_reg) {
res = kcalloc(num_reg, sizeof(*res), GFP_KERNEL);
if (!res) {
platform_device_put(dev);
return NULL;
}

dev->num_resources = num_reg;
dev->resource = res;
for (i = 0; i < num_reg; i++, res++) {
rc = of_address_to_resource(np, i, res);
WARN_ON(rc);
}
}

dev->dev.of_node = of_node_get(np);
dev->dev.fwnode = &np->fwnode;
dev->dev.parent = parent ? : &platform_bus;

if (bus_id)
dev_set_name(&dev->dev, "%s", bus_id);
else
of_device_make_bus_id(&dev->dev);

return dev;
}
```
of_address_to_resource
```c
// drivers/of/address.c
int of_address_to_resource(struct device_node *dev, int index,
struct resource *r)
{
return __of_address_to_resource(dev, index, -1, r);
}
static int __of_address_to_resource(struct device_node *dev, int index, int bar_no,
struct resource *r)
{
u64 taddr;
const __be32 *addrp;
u64 size;
unsigned int flags;
const char *name = NULL;
addrp = __of_get_address(dev, index, bar_no, &size, &flags);
if (addrp == NULL)
return -EINVAL;
/* Get optional "reg-names" property to add a name to a resource */
if (index >= 0)
of_property_read_string_index(dev, "reg-names", index, &name);
if (flags & IORESOURCE_MEM)
taddr = of_translate_address(dev, addrp);
else if (flags & IORESOURCE_IO)
taddr = of_translate_ioport(dev, addrp, size);
else
return -EINVAL;
if (taddr == OF_BAD_ADDR)
return -EINVAL;
memset(r, 0, sizeof(struct resource));
if (of_mmio_is_nonposted(dev))
flags |= IORESOURCE_MEM_NONPOSTED;
r->start = taddr;
r->end = taddr + size - 1;
r->flags = flags;
r->name = name ? name : dev->full_name;
return 0;
}
```












6 changes: 6 additions & 0 deletions doc/rwsem_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
code: kernel/locking/rwsem.c

##参考

* [深入讲解读写信号量(上)](https://zhuanlan.zhihu.com/p/578510398)
* [深入讲解读写信号量(下)](https://zhuanlan.zhihu.com/p/578543055)
10 changes: 10 additions & 0 deletions doc/softirq_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


## 参考

[Linux内核中的下半部机制之tasklet](https://zhuanlan.zhihu.com/p/88746106)
[linux网络软中断softirq底层机制及并发优化](https://developer.aliyun.com/article/557121)
[linux 下半部机制 - softirq使用](https://zhuanlan.zhihu.com/p/363245257)
[Linux内核中断处理“下半部”机制(上)(超详细~](https://zhuanlan.zhihu.com/p/510834583)
[Linux内核之tasklet使用](https://blog.csdn.net/u010299133/article/details/100177713)

32 changes: 32 additions & 0 deletions doc/v4l2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#### V4l2:
[V4L2框架概述](https://blog.csdn.net/u013904227/article/details/80718831)

[Linux - 使用V4L2(总结)](https://blog.csdn.net/weixin_43707799/article/details/107821189)
[Linux V4L2之camera](https://www.cnblogs.com/vedic/p/10763838.html)
[深入学习Linux摄像头(二)v4l2驱动框架](https://blog.csdn.net/weixin_42462202/article/details/99680969)
[v4l2系列](https://blog.csdn.net/cqxcool66/category_11276218.html)
[V4L2驱动框架详解-非常有用 v4l2.pdf](https://blog.csdn.net/weixin_42203498/article/details/126753239)
[V4L2控制接口](https://blog.csdn.net/zzsxyl/article/details/124478369)


编译v4l-utils

```shell
git clone https://github.com/karbirz/v4l-utils
# 在Makefile.am中找到contrib并删除
./bootstrap.sh

./configure --host=aarch64-linux-gnu --disable-libdvbv5 --without-libudev --disable-qv4l2 --disable-dyn-libv4l --disable-qvidcap

make
```

编译yavta
```shell
git clone https://github.com/kabirz/yavta
cd yavta
aarch64-linux-gnu-gcc yavta.c -o yavta
```


Binary file added doc/v4l2.pdf
Binary file not shown.

0 comments on commit 22e6796

Please sign in to comment.