Tham khảo tài liệu 'linux device drivers-chapter 13 :mmap and dma', công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 13 mmap and DMA This chapter delves into the area of Linux memory management with an emphasis on techniques that are useful to the device driver writer. The material in this chapter is somewhat advanced and not everybody will need a grasp of it. Nonetheless many tasks can only be done through digging more deeply into the memory management subsystem it also provides an interesting look into how an important part of the kernel works. The material in this chapter is divided into three sections. The first covers the implementation of the mmapsystem call which allows the mapping of device memory directly into a user process s address space. We then cover the kernel kiobuf mechanism which provides direct access to user memory from kernel space. The kiobuf system may be used to implement raw I O for certain kinds of devices. The final section covers direct memory access DMA I O operations which essentially provide peripherals with direct access to system memory. Of course all of these techniques require an understanding of how Linux memory management works so we start with an overview of that subsystem. Memory Management in Linux Rather than describing the theory of memory management in operating systems this section tries to pinpoint the main features of the Linux implementation of the theory. Although you do not need to be a Linux virtual memory guru to implement mmap a basic overview of how things work is useful. What follows is a fairly lengthy description of the data structures used by the kernel to manage memory. Once the necessary background has been covered we can get into working with these structures. Address Types Linux is of course a virtual memory system meaning that the addresses seen by user programs do not directly correspond to the physical addresses used by the hardware. Virtual memory introduces a layer of indirection which allows a number of nice things. With virtual memory programs running on the system can allocate far more memory than is .