diff options
Diffstat (limited to 'en/devices/architecture/hidl/converting.html')
-rw-r--r-- | en/devices/architecture/hidl/converting.html | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/en/devices/architecture/hidl/converting.html b/en/devices/architecture/hidl/converting.html deleted file mode 100644 index d4dbacea..00000000 --- a/en/devices/architecture/hidl/converting.html +++ /dev/null @@ -1,87 +0,0 @@ -<html devsite> - <head> - <title>Converting HAL Modules</title> - <meta name="project_path" value="/_project.yaml" /> - <meta name="book_path" value="/_book.yaml" /> - </head> - <body> - <!-- - Copyright 2017 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<p>You can update pre-existing HAL modules to HIDL HAL modules by converting the -header in <code>hardware/libhardware/include/hardware</code>.</p> - -<h2 id=c2hal>Using c2hal</h2> -<p>The -<code><a href="https://android.googlesource.com/platform/system/tools/hidl/+/master/c2hal/">c2hal</code></a> -tool handles most of the conversion work, reducing the number of required manual -changes. For example, to generate a HIDL <code>.hal</code> file for the NFC -HAL:</p> -<pre class="devsite-click-to-copy"> -<code class="devsite-terminal">make c2hal</code> -c2hal -r android.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport -p android.hardware.nfc@1.0 hardware/libhardware/include/hardware/nfc.h -</pre> - -<p>These commands add files in <code>hardware/interfaces/nfc/1.0/</code>. Running -<code>hardware/interfaces/update-makefiles.sh</code> from the $ANDROID_BUILD_TOP -directory will also add the required makefile to the HAL. From here, you can -make manual changes to fully convert the HAL.</p> - -<h2 id=activities>c2hal activities</h2> -<p>When you run <code>c2hal</code>, everything in the header file is transferred -to <code>.hal</code> files.</p> - -<p><code>c2hal</code> identifies structs that contain function pointers in the -provided header file and converts each struct into a separate interface file. -For example, <code>alloc_device_t</code> is converted to the -<code>IAllocDevice</code> HAL module (in the file -<code>IAllocDevice.hal</code>).</p> - -<p>All other data types are copied over into a <code>types.hal</code> file. -Pound-defines are moved into enums, and items not a part of HIDL or not -convertible (such as static-function declarations) are copied into comments -marked with the text "<code>NOTE</code>".</p> - -<h2 id=manual>Manual activities</h2> -<p>The <code>c2hal</code> tool does not know what to do when it encounters -certain constructs. For example, HIDL has no concept of raw pointers; because of -this, when <code>c2hal</code> encounters a pointer in header files, it doesn't -know whether the pointer should be interpreted as an array or as a reference to -another object. Void pointers are also similarly opaque.</p> - -<p>Field such as <code>int reserved[7]</code> must be manually removed during -the transition to HIDL. Items such as the name of the return value should be -updated to something more meaningful; for example, converting the return -parameter of methods such as <code>write</code> in NFC from the autogenerated -<code>int32_t write_ret</code> to <code>Status status</code> (where -<code>Status</code> is a new enum containing possible NFC statuses).</p> - -<h2 id=implement>Implementing the HAL</h2> -<p>After you have created <code>.hal</code> files to represent your HAL, you -must generate the makefiles (Make or Soong) that create the language support in -C++ and Java (unless the HAL uses a feature unsupported in Java). The -<code>./hardware/interfaces/update-makefiles.sh</code> script can automatically -generate makefiles for HALs located in the <code>hardware/interfaces</code> -directory (for HALs in other locations, simply update the script).</p> - -<p>When the makefiles are up to date, you are ready to generate header files and -implement methods. For details on implementing the generated interface, see -<a href="/devices/architecture/hidl-cpp/index.html">HIDL C++</a> (for C++ -implementations) or <a href="/devices/architecture/hidl-java/index.html">HIDL -Java</a> (for Java implementations).</p> - - </body> -</html> |