linux - 使用 libraw1394 进行内存访问

标签 linux linux-kernel firewire

我发现 Linux 不支持我的尼康 LS-9000 ED 扫描仪 SANE并决定使用 Linux Firewire 内核 API 制作我自己的驱动程序 libraw1394 .

Library Programs and Command API Specifications扫描仪最近由尼康发布。扫描仪使用 Serial Bus Protocol 2 (SBP-2) 和 IEEE Std 1394-1995标准。

我用 libraw1394 制作了一个简单的测试程序,发现我无法读取(或写入)大多数 特定于串行总线的寄存器。阅读测试程序如下:

// gcc -Wall -o read read.c -l raw1394
#include <stdio.h>
#include <libraw1394/csr.h>
#include <libraw1394/raw1394.h>


int main()
{

    raw1394handle_t handle;

    handle = raw1394_new_handle_on_port(0);

    printf("node: %X\n", raw1394_get_local_id(handle));


    quadlet_t read;

    for (int i = 0; i <= 1048576; i++)  // 0 to 0x100000
    {
        int result = raw1394_read(handle, 
                                  raw1394_get_local_id(handle), 
                                  CSR_REGISTER_BASE + (i*4), 
                                  sizeof(quadlet_t), 
                                  &read);

        if (result == 0)
            printf("%X\n", i*4);            
    }

    raw1394_destroy_handle(handle);

}

输出(缩写形式)是:

$ sudo ./read
node: FFC1
0
4
8
18
1C
200
204
210
218
21C
220
224
228
230
234
400 - 7FC
1000 - 13FC

这些偏移量不包括最重要的 MANAGEMENT_AGENT 寄存器,对于尼康 LS9000 ED,该寄存器位于 0x30000。我也无法写入到这个寄存器。

内核中一定有一种内存访问限制。如何将命令写入 MANAGEMENT_AGENT 寄存器,例如查询登录 ORB?

连接扫描仪之前:

$ lsmod | grep firewire
firewire_ohci          40960  0
firewire_core          65536  1 firewire_ohci
crc_itu_t              16384  1 firewire_core

$ dmesg | grep firewire
[    0.776039] firewire_ohci 0000:03:00.0: added OHCI v1.10 device as card  0, 4 IR + 8 IT contexts, quirks 0x2
[    1.276095] firewire_core 0000:03:00.0: created device fw0: GUID 000000000000017e, S400

扫描仪连接后:

$ lsmod | grep firewire
firewire_sbp2          24576  0
firewire_ohci          40960  0
firewire_core          65536  2 firewire_ohci,firewire_sbp2
crc_itu_t              16384  1 firewire_core

$ dmesg | grep firewire
[    0.776039] firewire_ohci 0000:03:00.0: added OHCI v1.10 device as card 0, 4 IR + 8 IT contexts, quirks 0x2
[    1.276095] firewire_core 0000:03:00.0: created device fw0: GUID 000000000000017e, S400
[ 3289.660782] firewire_core 0000:03:00.0: rediscovered device fw0
[ 3292.688185] firewire_core 0000:03:00.0: created device fw1: GUID 0090b54003ffffff, S400
[ 3292.688190] firewire_core 0000:03:00.0: phy config: new root=ffc0, gap_count=5
[ 3292.922459] firewire_sbp2 fw1.0: logged in to LUN 0000 (0 retries)

似乎内核模块 firewire_sbp2 在扫描仪连接时启动并且显然进行了登录。 firewire_sbp2 中的功能是否可以从应用程序中使用?

最佳答案

SBP2是一种通过 FireWire 传输 SCSI 命令的协议(protocol)。

在 Linux 中,您可以使用 SCSI Generic driver (sg) 向此类设备发送 SCSI 命令。

关于linux - 使用 libraw1394 进行内存访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47421031/

相关文章:

linux - 将时间跨度(以秒为单位)转换为 shell 中的格式化时间

linux - 文件名按循环顺序排列

unix - 如何确定特定模块是否加载到 linux 内核中

linux - 如何使脚本在 init 后作为启动脚本在 buildroot 中运行

python - 在 python 中与 Firewire 端口通信

opencv - 无法使用 OpenCV 从 FireWire cam 捕获图像

linux - 我如何通过命令知道我使用的是哪种 linux 版本

linux:如何在没有root权限的情况下获取无线ssid?

Linux 内核 dentry 和 inode

c++ - 更新固件\SDK 后无法在 PTGRey 相机(Dragonfly express)上开始捕获