LINUX DEVICE DRIVERS 3rd edition phần 2

bao gồm cả chương mẫu và các ví dụ mã. là trang web hàng đầu cho nền tảng web mã nguồn mở: Linux, Apache, MySQL, và hoặc là Perl, Python, hoặc PHP O'Reilly mang lại sáng tạo đa dạng với nhau để nuôi dưỡng những ý tưởng tia lửa các ngành công nghiệp cách mạng. Chúng tôi chuyên trong tài liệu công cụ mới nhất | The above functions allocate device numbers for your driver s use but they do not tell the kernel anything about what you will actually do with those numbers. Before a user-space program can access one of those device numbers your driver needs to connect them to its internal functions that implement the device s operations. We will describe how this connection is accomplished shortly but there are a couple of necessary digressions to take care of first. Dynamic Allocation of Major Numbers Some major device numbers are statically assigned to the most common devices. A list of those devices can be found in Documentation within the kernel source tree. The chances of a static number having already been assigned for the use of your new driver are small however and new numbers are not being assigned. So as a driver writer you have a choice you can simply pick a number that appears to be unused or you can allocate major numbers in a dynamic manner. Picking a number may work as long as the only user of your driver is you once your driver is more widely deployed a randomly picked major number will lead to conflicts and trouble. Thus for new drivers we strongly suggest that you use dynamic allocation to obtain your major device number rather than choosing a number randomly from the ones that are currently free. In other words your drivers should almost certainly be using alloc_chrdev_region rather than register_chrdev_region. The disadvantage of dynamic assignment is that you can t create the device nodes in advance because the major number assigned to your module will vary. For normal use of the driver this is hardly a problem because once the number has been assigned you can read it from Iprocldevices. To load a driver using a dynamic major number therefore the invocation of insmod can be replaced by a simple script that after calling insmod reads Iprocldevices in order to create the special file s . A typical proc devices file looks like the following .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.