代码之家  ›  专栏  ›  技术社区  ›  Kimvais

从哪里开始学习Linux DMA/设备驱动程序/内存分配

  •  6
  • Kimvais  · 技术社区  · 15 年前

    我正在移植/调试一个设备驱动程序(由另一个内核模块使用),并面临一个死胡同,因为dma_sync_single_for_device()会因内核故障而失败。

    我不知道这个功能应该做什么,谷歌也没有真正的帮助,所以我可能需要了解更多关于这方面的东西。

    问题是,从哪里开始?

    哦,是的,如果相关的话,代码应该在PowerPC上运行(Linux是OpenWRT)

    编辑: 可优先使用在线资源(书籍需要几天时间才能交付:)

    3 回复  |  直到 15 年前
        1
  •  9
  •   Robert S. Barnes Antoni    15 年前

    在线:

    Anatomy of the Linux slab allocator

    Understanding the Linux Virtual Memory Manager

    Linux Device Drivers, Third Edition

    The Linux Kernel Module Programming Guide

    Writing device drivers in Linux: A brief tutorial

    书:

    Linux Kernel Development (2nd Edition)

    Essential Linux Device Drivers (只有前4-5章)

    有用资源:

    the Linux Cross Reference (所有内核的可搜索内核源)

    API changes in the 2.6 kernel series


    dma_sync_single_for_device 电话 dma_sync_single_range_for_cpu 在文件中再向上一点,这是源文档(我假设即使这是用于ARM的,接口和行为也是相同的):

    /**
     380 * dma_sync_single_range_for_cpu
     381 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
     382 * @handle: DMA address of buffer
     383 * @offset: offset of region to start sync
     384 * @size: size of region to sync
     385 * @dir: DMA transfer direction (same as passed to dma_map_single)
     386 *
     387 * Make physical memory consistent for a single streaming mode DMA
     388 * translation after a transfer.
     389 *
     390 * If you perform a dma_map_single() but wish to interrogate the
     391 * buffer using the cpu, yet do not wish to teardown the PCI dma
     392 * mapping, you must call this function before doing so.  At the
     393 * next point you give the PCI dma address back to the card, you
     394 * must first the perform a dma_sync_for_device, and then the
     395 * device again owns the buffer.
     396 */
    
        2
  •  5
  •   Matthew Flaschen    15 年前
        3
  •  3
  •   Robert Christie    15 年前

    的章节 Linux Device Drivers book(与理解Linux内核在同一系列中,由@matthew flashen推荐)可能很有用。

    您可以从下载独立章节 LWN Website . Chapter 16 处理DMA。

    推荐文章