telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | 93e4898 | 2018-09-05 13:05:09 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #define LOG_TAG "ArmnnDriver" |
| 7 | |
| 8 | #include "ArmnnDriver.hpp" |
| 9 | |
| 10 | #include <hidl/LegacySupport.h> |
| 11 | #include <log/log.h> |
| 12 | |
| 13 | #include <string> |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 14 | |
| 15 | using namespace armnn_driver; |
| 16 | using namespace std; |
| 17 | |
| 18 | int main(int argc, char** argv) |
| 19 | { |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 20 | android::sp<ArmnnDriver> driver; |
Kevin May | abc95d0 | 2020-05-15 15:34:03 +0100 | [diff] [blame] | 21 | DriverOptions driverOptions(argc, argv); |
Mike Kelly | 6df71fd | 2020-10-13 17:50:05 +0100 | [diff] [blame^] | 22 | |
| 23 | if (driverOptions.ShouldExit()) |
| 24 | { |
| 25 | return driverOptions.GetExitCode(); |
| 26 | } |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 27 | try |
| 28 | { |
| 29 | driver = new ArmnnDriver(DriverOptions(argc, argv)); |
| 30 | } |
| 31 | catch (const std::exception& e) |
| 32 | { |
| 33 | ALOGE("Could not create driver: %s", e.what()); |
Mike Kelly | 6df71fd | 2020-10-13 17:50:05 +0100 | [diff] [blame^] | 34 | std::cout << "Unable to start:" << std::endl |
| 35 | << "Could not create driver: " << e.what() << std::endl; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 36 | return EXIT_FAILURE; |
| 37 | } |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 38 | |
| 39 | android::hardware::configureRpcThreadpool(1, true); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 40 | android::status_t status = android::UNKNOWN_ERROR; |
| 41 | try |
| 42 | { |
Kevin May | abc95d0 | 2020-05-15 15:34:03 +0100 | [diff] [blame] | 43 | status = driver->registerAsService(driverOptions.GetServiceName()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 44 | } |
| 45 | catch (const std::exception& e) |
| 46 | { |
| 47 | ALOGE("Could not register service: %s", e.what()); |
Mike Kelly | 6df71fd | 2020-10-13 17:50:05 +0100 | [diff] [blame^] | 48 | std::cout << "Unable to start:" << std::endl |
| 49 | << "Could not register service: " << e.what() << std::endl; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 50 | return EXIT_FAILURE; |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 51 | } |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 52 | |
Mike Kelly | 6df71fd | 2020-10-13 17:50:05 +0100 | [diff] [blame^] | 53 | if (status != android::OK) |
| 54 | { |
| 55 | ALOGE("Could not register service"); |
| 56 | std::cout << "Unable to start:" << std::endl |
| 57 | << "Could not register service" << std::endl; |
| 58 | return EXIT_FAILURE; |
| 59 | } |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 60 | android::hardware::joinRpcThreadpool(); |
Mike Kelly | 6df71fd | 2020-10-13 17:50:05 +0100 | [diff] [blame^] | 61 | ALOGW("Service exited!"); |
| 62 | return EXIT_SUCCESS; |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 63 | } |