tailieunhanh - linux device drivers 2nd edition phần 5

Tùy chọn cuối cùng để phân bổ các khu vực bộ nhớ tiếp giáp lãnh hải, và có thể là đơn giản nhất là đặt một khu vực bộ nhớ ở phần cuối của bộ nhớ vật lý (trong khi bigphysar ea dự trữ nó vào đầu của bộ nhớ vật lý). Để mục đích này, bạn cần phải vượt qua một lựa chọn dòng lệnh hạt nhân | Backward Compatibility Reserving High RAM Addresses The last option for allocating contiguous memory areas and possibly the easiest is reserving a memory area at the end of physical memory whereas bigphysarea reserves it at the beginning of physical memory . To this aim you need to pass a command-line option to the kernel to limit the amount of memory being managed. For example one of your authors uses mem 12 6M to reserve 2 megabytes in a system that actually has 128 megabytes of RAM. Later at runtime this memory can be allocated and used by device drivers. The allocator module part of the sample code released on the O Reilly FTP site offers an allocation interface to manage any high memory not used by the Linux kernel. The module is described in more detail in Do-it-yourself allocation in Chapter 13. The advantage of allocator over the bigphysarea patch is that there s no need to modify official kernel sources. The disadvantage is that you must change the command-line option to the kernel whenever you change the amount of RAM in the system. Another disadvantage which makes allocator unsuitable in some situations is that high memory cannot be used for some tasks such as DMA buffers for ISA devices. Backward Compatibility The Linux memory management subsystem has changed dramatically since the kernel came out. Happily however the changes to its programming interface have been much smaller and easier to deal with. kmalloc and kfree have remained essentially constant between Linux and . Access to high memory and thus the_GFP_HIGHMEM flag was added starting with kernel fills the gaps and allows for semantics to be used in and . The lookaside cache functions were introduced in Linux and were simply not available in the kernel. Code that must be portable back to Linux should stick with kmalloc and kfree. Moreover kmem_destroy_cache was introduced during development and has only been backported to as of .