blob: 5191fbfea849b5ccc72a1038d831fda839b524fe [file] [log] [blame]
telsoa015307bc12018-03-09 13:51:08 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beck93e48982018-09-05 13:05:09 +01003// SPDX-License-Identifier: MIT
telsoa015307bc12018-03-09 13:51:08 +00004//
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>
telsoa015307bc12018-03-09 13:51:08 +000014
15using namespace armnn_driver;
16using namespace std;
17
18int main(int argc, char** argv)
19{
surmeh0149b9e102018-05-17 14:11:25 +010020 android::sp<ArmnnDriver> driver;
Kevin Mayabc95d02020-05-15 15:34:03 +010021 DriverOptions driverOptions(argc, argv);
Mike Kelly6df71fd2020-10-13 17:50:05 +010022
23 if (driverOptions.ShouldExit())
24 {
25 return driverOptions.GetExitCode();
26 }
surmeh0149b9e102018-05-17 14:11:25 +010027 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 Kelly6df71fd2020-10-13 17:50:05 +010034 std::cout << "Unable to start:" << std::endl
35 << "Could not create driver: " << e.what() << std::endl;
surmeh0149b9e102018-05-17 14:11:25 +010036 return EXIT_FAILURE;
37 }
telsoa015307bc12018-03-09 13:51:08 +000038
39 android::hardware::configureRpcThreadpool(1, true);
surmeh0149b9e102018-05-17 14:11:25 +010040 android::status_t status = android::UNKNOWN_ERROR;
41 try
42 {
Kevin Mayabc95d02020-05-15 15:34:03 +010043 status = driver->registerAsService(driverOptions.GetServiceName());
surmeh0149b9e102018-05-17 14:11:25 +010044 }
45 catch (const std::exception& e)
46 {
47 ALOGE("Could not register service: %s", e.what());
Mike Kelly6df71fd2020-10-13 17:50:05 +010048 std::cout << "Unable to start:" << std::endl
49 << "Could not register service: " << e.what() << std::endl;
surmeh0149b9e102018-05-17 14:11:25 +010050 return EXIT_FAILURE;
telsoa015307bc12018-03-09 13:51:08 +000051 }
surmeh0149b9e102018-05-17 14:11:25 +010052
Mike Kelly6df71fd2020-10-13 17:50:05 +010053 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 }
telsoa015307bc12018-03-09 13:51:08 +000060 android::hardware::joinRpcThreadpool();
Mike Kelly6df71fd2020-10-13 17:50:05 +010061 ALOGW("Service exited!");
62 return EXIT_SUCCESS;
telsoa015307bc12018-03-09 13:51:08 +000063}