Đang chuẩn bị liên kết để tải về tài liệu:
linux device drivers 2nd edition phần 3
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Có nhiều thay đổi với Linux kể từ khi ấn bản đầu tiên của cuốn sách này xuất hiện. Linux chạy trên bộ xử lý nhiều hơn nữa và hỗ trợ một loạt rộng lớn hơn nhiều của phần cứng. Nhiều người trong số các giao diện lập trình nội bộ đã thay đổi đáng kể. Vì vậy, ấn bản thứ hai. | Debugging by Querying says that proc entries associated with device drivers should go in the subdirectory driver scull could place its entry there simply by giving its name as driver scullmem. Entries in proc of course should be removed when the module is unloaded. remove_proc_entry is the function that undoes what create_proc_read_entry did remove_proc_entry scullmem NULL parent dir The alternative method for creating a proc entry is to create and initialize a proc_dir_entry structure and pass it to proc_register_dynamic version 2.0 or proc_register version 2.2 which assumes a dynamic file if the inode number in the structure is 0 . As an example consider the following code that scull uses when compiled against 2.0 headers static int scull_get_info char buf char start off_t offset int len int unused int eof 0 return scull_read_procmem buf start offset len eof NULL struct proc_dir_entry scull_proc_entry namelen 8 name scullmem mode S_IFREG S_IRUGO nlink 1 get_info scull_get_info static void scull_create_proc proc_register_dynamic proc_root scull_proc_entry static void scull_remove_proc proc_unregister proc_root scull_proc_entry.low_ino The code declares a function using the get_info interface and fills in a proc_dir_entry structure that is registered with the filesystem. This code provides compatibility across the 2.0 and 2.2 kernels with a little support from macro definitions in sysdep.h. It uses the get_info interface because the 2.0 kernel did not support read_proc. Some more work with ifdef could have made it use read_proc with Linux 2.2 but the benefits would be minor. 107 Chapter 4 Debugging Techniques The ioctl Method ioctl which we show you how to use in the next chapter is a system call that acts on a file descriptor it receives a number that identifies a command to be performed and optionally another argument usually a pointer. As an alternative to using the proc filesystem you can implement a few ioctl commands tailored for debugging. These commands can