i have been reading Linux source code ported on to a propriety platform based on ARM Cortex -A7 MPCore - NEON Architecture
我一直在阅读基于ARM Cortex -A7 MPCore的适当平台上的Linux源代码 - NEON Architecture
The code below shows how a control register of a module is modified up on calling an API
下面的代码显示了在调用API时如何修改模块的控制寄存器
drivers\module\module-specific_file.c
static inline void API(....)
{
if (set)
__raw_writel(msk, (void *)((u32) (reg) + 0x1000));
else
{
__raw_writel(msk, (void *)((u32) (reg) + 0x2000));
}
}
in the above code reg
is actually a virtual address and msk
is a mask lets say x7FF
and set
is a parameter passed which conveys request of set/clear
在上面的代码中,reg实际上是一个虚拟地址,而msk是一个掩码,让我们说x7FF和set是传递的参数,它传达了set / clear的请求
but actually my doubt is how does modifying the control register address is modifying the value to be written to register ... ?? further if i look at the api which is been called it looks like below
但实际上我怀疑的是修改控制寄存器地址是如何修改要写入寄存器的值... ??进一步,如果我看看被称为api,它看起来像下面
arch\arm\include\asm\Io.h
static inline void __raw_writel(u32 val, volatile void __iomem *addr)
{
asm volatile("str %1, %0"
: "+Qo" (*(volatile u32 __force *)addr)
: "r" (val));
}
if any one have come across this kind of accessing control registers please let me know how actually content of registers are modified by modifying the virtual address.
如果有人遇到过这种访问控制寄存器,请通过修改虚拟地址告诉我实际上寄存器的内容是如何修改的。
1 个解决方案
#1
0
As I know, registers are mapped in virtual address space. Have a look at /proc/iomem for example, you'll see mapped registers addresses and what hardware they are belong. The addresses of registers are strictly determined by hardware developers. Typically, to map register address one should call ioremap function. It returns the address. Often this address is the base address, where the register addresses begin. To write something in register you just need to write the data in this address plus the resister offset. E.g.: On ARM PXA320, there is a set of LCD registers. Somewhere ion driver code one may see - ioremap(BASE_ADDR, SIZE_OF_ADDR_SET); In order to write __raw_write(value, base_addr + offset) function is used.
据我所知,寄存器映射在虚拟地址空间中。以/ proc / iomem为例,您将看到映射的寄存器地址以及它们所属的硬件。寄存器的地址严格由硬件开发人员决定。通常,要映射寄存器地址,应调用ioremap函数。它返回地址。通常,该地址是寄存器地址开始的基址。要在寄存器中写入内容,您只需要在此地址中写入数据加上resister offset。例如:在ARM PXA320上,有一组LCD寄存器。某人可能会看到离子驱动程序代码 - ioremap(BASE_ADDR,SIZE_OF_ADDR_SET);为了写__raw_write(value,base_addr + offset)函数被使用。
#1
0
As I know, registers are mapped in virtual address space. Have a look at /proc/iomem for example, you'll see mapped registers addresses and what hardware they are belong. The addresses of registers are strictly determined by hardware developers. Typically, to map register address one should call ioremap function. It returns the address. Often this address is the base address, where the register addresses begin. To write something in register you just need to write the data in this address plus the resister offset. E.g.: On ARM PXA320, there is a set of LCD registers. Somewhere ion driver code one may see - ioremap(BASE_ADDR, SIZE_OF_ADDR_SET); In order to write __raw_write(value, base_addr + offset) function is used.
据我所知,寄存器映射在虚拟地址空间中。以/ proc / iomem为例,您将看到映射的寄存器地址以及它们所属的硬件。寄存器的地址严格由硬件开发人员决定。通常,要映射寄存器地址,应调用ioremap函数。它返回地址。通常,该地址是寄存器地址开始的基址。要在寄存器中写入内容,您只需要在此地址中写入数据加上resister offset。例如:在ARM PXA320上,有一组LCD寄存器。某人可能会看到离子驱动程序代码 - ioremap(BASE_ADDR,SIZE_OF_ADDR_SET);为了写__raw_write(value,base_addr + offset)函数被使用。