linux device drivers 2nd edition phần 2

Nhưng cuốn sách này cũng là hạt nhân Linux làm việc và làm thế nào để thích nghi với hoạt động của mình với nhu cầu hoặc sở thích của bạn. Linux là một hệ thống mở, với cuốn sách này, chúng tôi hy vọng, nó sẽ rộng mở hơn và dễ tiếp cận với một cộng đồng lớn hơn của các nhà phát triển. | Backward Compatibility If you do need to export symbols from your module you will need to create a symbol table structure describing these symbols. Filling a Linux symbol table structure is a tricky task but kernel developers have provided header files to simplify things. The following lines of code show how a symbol table is declared and exported using the facilities offered by the headers of Linux static struct symbol_table skull_syms include linux X skull_fn1 X skull_fn2 X skull_variable include linux register_symtab skull_syms Writing portable code that controls symbol visibility takes an explicit effort from the device driver programmer. This is a case where it is not sufficient to define a few compatibility macros instead portability requires a fair amount of conditional preprocessor code but the concepts are simple. The first step is to identify the kernel version in use and to define some symbols accordingly. What we chose to do in is define a macro REGISTER_SYMTAB that expands to nothing on version and later and expands to register_symtab on version . Also USE_OLD_SYMTAB_is defined if the old code must be used. By making use of this code a module that exports symbols may now do so portably. In the sample code is a module called misc-modules that does nothing except export one symbol. The module covered in more detail in Version Control in Modules in Chapter 11 includes the following lines to export the symbol portably ifdef USE_OLD_SYMTAB__ static struct symbol_table export_syms include linux X export_function include linux else EXPORT_SYMBOL export_function endif int export_init void REGISTER_SYMTAB export_syms return 0 49 Chapter 2 Building and Running Modules If__USE_OLD_SYMTAB_is set meaning that you are dealing with a ker- nel the symbol_table structure is defined as needed otherwise EXPORT_SYMBOL is used to export the symbol directly. Then in .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
12    263    1    30-06-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.