Linux Device Drivers-Chapter 10 :Judicious Use of Data Types

Tham khảo tài liệu 'linux device drivers-chapter 10 :judicious use of data types', 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 10 Judicious Use of Data Types Before we go on to more advanced topics we need to stop for a quick note on portability issues. Modern versions of the Linux kernel are highly portable running on several very different architectures. Given the multiplatform nature of Linux drivers intended for serious use should be portable as well. But a core issue with kernel code is being able both to access data items of known length for example filesystem data structures or registers on device boards and to exploit the capabilities of different processors 32-bit and 64-bit architectures and possibly 16 bit as well . Several of the problems encountered by kernel developers while porting x86 code to new architectures have been related to incorrect data typing. Adherence to strict data typing and compiling with the - Wall -Wstrict-prototypes flags can prevent most bugs. Data types used by kernel data are divided into three main classes standard C types such as int explicitly sized types such as u32 and types used for specific kernel objects such as pid_t. We are going to see when and how each of the three typing classes should be used. The final sections of the chapter talk about some other typical problems you might run into when porting driver code from the x86 to other platforms and introduce the generalized support for linked lists exported by recent kernel headers. If you follow the guidelines we provide your driver should compile and run even on platforms on which you are unable to test it. Use of Standard C Types Although most programmers are accustomed to freely using standard types like int and long writing device drivers requires some care to avoid typing conflicts and obscure bugs. The problem is that you can t use the standard types when you need a two-byte filler or something representing a four-byte string because the normal C data types are not the same size on all architectures. To show the data size of the various C types the datasize program has been .

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
476    17    1    28-11-2024
Đã 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.