<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                結構體hw_module_t和hw_device_t及其相關的其他結構體定義在文件`hardware/libhardware/include/hardware/hardware.h`中。下面我們就分別介紹這些結構體的定義。 **struct hw_module_t** **hardware/libhardware/include/hardware/hardware.h** ~~~ /* * Value for the hw_module_t.tag field */ #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') /** * Name of the hal_module_info */ #define HAL_MODULE_INFO_SYM HMI /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ typedef struct hw_module_t { /** tag must be initialized to HARDWARE_MODULE_TAG */ uint32_t tag; /** major version number for the module */ uint16_t version_major; /** minor version number of the module */ uint16_t version_minor; /** Identifier of module */ const char *id; /** Name of this module */ const char *name; /** Author/owner/implementor of the module */ const char *author; /** Modules methods */ struct hw_module_methods_t* methods; /** module's dso */ void* dso; /** padding to 128 bytes, reserved for future use */ uint32_t reserved[32-7]; } hw_module_t; ~~~ 結構體hw_module_t中的每一個成員變量在代碼中都有詳細的解釋,這里不再重復。不過,有五點是需要注意的。 (1)在結構體hw_module_t的定義前面有一段注釋,意思是,硬件抽象層中的每一個模塊都必須自定義一個硬件抽象層模塊結構體,而且它的第一個成員變量的類型必須為hw_module_t。 (2)硬件抽象層中的每一個模塊都必須存在一個導出符號HAL_MODULE_IFNO_SYM,即“HMI”,它指向一個自定義的硬件抽象層模塊結構體。后面我們在分析硬件抽象層模塊的加載過程時,將會看到這個導出符號的意義。 (3)結構體hw_module_t的成員變量tag的值必須設置為HARDWARE_MODULE_TAG,即設置為一個常量值('H'<<24 | 'W'<<16 | 'M'<<8 | 'T'),用來標志這是一個硬件抽象層模塊結構體。 (4)結構體hw_module_t的成員變量dso用來保存加載硬件抽象層模塊后得到的句柄值。前面提到,每一個硬件抽象層模塊都對應有一個動態鏈接庫文件。加載硬件抽象層模塊的過程實際上就是調用dlopen函數來加載與其對應的動態鏈接庫文件的過程。在調用dlclose函數來卸載這個硬件抽象層模塊時,要用到這個句柄值,因此,我們在加載時需要將它保存起來。 (5)結構體hw_module_t的成員變量methods定義了一個硬件抽象層模塊的操作方法列表,它的類型為hw_module_methods_t,接下來我們就介紹它的定義。 **struct hw_module_methods_t** **hardware/libhardware/include/hardware/hardware.h** ~~~ typedef struct hw_module_methods_t { /** Open a specific device */ int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device); } hw_module_methods_t; ~~~ 結構體hw_module_methods_t只有一個成員變量,它是一個函數指針,用來打開硬件抽象層模塊中的硬件設備。其中,參數module表示要打開的硬件設備所在的模塊;參數id表示要打開的硬件設備的ID;參數device是一個輸出參數,用來描述一個已經打開的硬件設備。由于一個硬件抽象層模塊可能會包含多個硬件設備,因此,在調用結構體hw_module_methods_t的成員變量open來打開一個硬件設備時,我們需要指定它的ID。硬件抽象層中的硬件設備使用結構體hw_device_t來描述,接下來我們就介紹它的定義。 **struct hw_device_t** **hardware/libhardware/include/hardware/hardware.h** ~~~ #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct hw_device_t { /** tag must be initialized to HARDWARE_DEVICE_TAG */ uint32_t tag; /** version number for hw_device_t */ uint32_t version; /** reference to the module this device belongs to */ struct hw_module_t* module; /** padding reserved for future use */ uint32_t reserved[12]; /** Close this device */ int (*close)(struct hw_device_t* device); } hw_device_t; ~~~ 結構體hw_device_t中的每一個成員變量在代碼中都有詳細的解釋,這里不再重復。不過,有三點是需要注意的。 (1)硬件抽象層模塊中的每一個硬件設備都必須自定義一個硬件設備結構體,而且它的第一個成員變量的類型必須為hw_device_t。 (2)結構體hw_device_t的成員變量tag的值必須設置為HARDWARE_DEVICE_TAG,即設置為一個常量值('H'<<24 | 'W'<<16 | 'D'<<8 | 'T'),用來標志這是一個硬件抽象層中的硬件設備結構體。 (3)結構體hw_device_t的成員變量close是一個函數指針,它用來關閉一個硬件設備。 注意:硬件抽象層中的硬件設備是由其所在的模塊提供接口來打開的,而關閉則是由硬件設備自身提供接口來完成的。 至此,硬件抽象層模塊接口的編寫規范就介紹完了。接下來,我們就可以為虛擬硬件設備freg編寫硬件抽象層模塊接口了。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看