如何在Linux内核驱动程序中读取64位寄存器

发布于 2025-02-02 00:01:26 字数 721 浏览 2 评论 0原文

我想在Linux内核驱动程序中阅读64位寄存器的值 我尝试了以下代码,但我总是得到0。

    reg_addr = ioremap(0xffe602000, 0x20000); 
    if (!reg_addr) {
        printk(KERN_ALERT " ioremap failed \n");
    }else{
        printk(KERN_ALERT "  ioremap success reg_addr[0x%X]\n", reg_addr);
    }

IOREMAP在上述代码中取得了成功。

在IOREMAP之后,我呼叫如下:

    unsigned long long val;
    val = ioread64(reg_addr+0x300);
    printk(KERN_ALERT " ### REG READ returning [%lx] ###\n",val);

上面使用Trace32检查的上述代码打印

### REG READ returning [0] ###

,寄存器的值不是0,寄存器的实际值为0x00000000E506A904

我想念什么吗?

内核版本:

4.19.33 #12 SMP ppc64 GNU/Linux

I want to read the value of a 64bit register in the Linux Kernel driver
I tried the below code, but I get 0 always.

    reg_addr = ioremap(0xffe602000, 0x20000); 
    if (!reg_addr) {
        printk(KERN_ALERT " ioremap failed \n");
    }else{
        printk(KERN_ALERT "  ioremap success reg_addr[0x%X]\n", reg_addr);
    }

the ioremap was successful in the above code.

after the ioremap, I call read as below:

    unsigned long long val;
    val = ioread64(reg_addr+0x300);
    printk(KERN_ALERT " ### REG READ returning [%lx] ###\n",val);

the above code prints

### REG READ returning [0] ###

I checked using Trace32, the value of register is not 0, the real value of the register is 0x00000000e506a904.

did I miss something?

kernel version:

4.19.33 #12 SMP ppc64 GNU/Linux

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文