c - printk 格式中 %pa[p] 中 p 的含义

标签 c linux linux-kernel linux-device-driver device-driver

问题是关于 printk 格式的。我正在阅读的文档位于 here

以下是我要问的摘录:

Physical addresses types phys_addr_t:

    %pa[p]  0x01234567 or 0x0123456789abcdef

    For printing a phys_addr_t type (and its derivatives, such as
    resource_size_t) which can vary based on build options, regardless of
    the width of the CPU data path. Passed by reference.

[p] 中的 %pa[p] 代表什么?这是什么意思?

最佳答案

p 中的 [p]phys_addr_t 中使用时代表 %pap 。这类似于 d 中的 %pad 代表 dma_addr_t ,如引用的文档中所示:

DMA addresses types dma_addr_t:

    %pad    0x01234567 or 0x0123456789abcdef

    For printing a dma_addr_t type which can vary based on build options,
    regardless of the width of the CPU data path. Passed by reference.

由于它没有提供 %pa%pap 之间的差异记录,这意味着它们的行为相同。括号内的内容表示可选修饰符。这可以在文档后面的 %*pE 定义中看到:

Raw buffer as an escaped string:

    %*pE[achnops]
...
    The conversion rules are applied according to an optional combination
    of flags (see string_escape_mem() kernel documentation for the
    details):
        a - ESCAPE_ANY
        c - ESCAPE_SPECIAL
        h - ESCAPE_HEX
        n - ESCAPE_NULL
        o - ESCAPE_OCTAL
        p - ESCAPE_NP
        s - ESCAPE_SPACE
    By default ESCAPE_ANY_NP is used.

关于c - printk 格式中 %pa[p] 中 p 的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39005601/

相关文章:

c - 当用户空间程序调用系统调用时,执行如何转移回内核空间?

c - Netfilter 内核模块拦截数据包并记录它们

c - 我如何在 (GNU) C 中编写一个代理函数来连接两个不同的调用约定?

c - 替换 linux 内核模块中的 sys/socket.h?

c++ - Ubuntu 中的 OpenCV 不显示窗口

linux - Ansible - 未安装 winrm 或请求

linux - 确定模块加载状态

c - linux 中的内存管理 : implementing first fit

c - C中的参数传递

c - 需要知道 fork 是如何工作的吗?