Inseob Kim | bdca047 | 2023-07-28 19:20:56 +0900 | [diff] [blame] | 1 | // Copyright 2023 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | //! Android VfioHandler |
| 16 | |
| 17 | mod aidl; |
| 18 | |
| 19 | use crate::aidl::VfioHandler; |
| 20 | use android_logger::Config; |
| 21 | use android_system_virtualizationservice_internal::aidl::android::system::virtualizationservice_internal::IVfioHandler::{ |
| 22 | BnVfioHandler, |
| 23 | BpVfioHandler, |
| 24 | IVfioHandler, |
| 25 | }; |
| 26 | use binder::{register_lazy_service, BinderFeatures, ProcessState}; |
| 27 | use log::{info, Level}; |
| 28 | |
| 29 | const LOG_TAG: &str = "VfioHandler"; |
| 30 | |
| 31 | fn main() { |
| 32 | android_logger::init_once( |
| 33 | Config::default() |
| 34 | .with_tag(LOG_TAG) |
| 35 | .with_min_level(Level::Info) |
| 36 | .with_log_id(android_logger::LogId::System), |
| 37 | ); |
| 38 | |
| 39 | let service = VfioHandler::init(); |
| 40 | let service = BnVfioHandler::new_binder(service, BinderFeatures::default()); |
| 41 | register_lazy_service(<BpVfioHandler as IVfioHandler>::get_descriptor(), service.as_binder()) |
| 42 | .unwrap(); |
| 43 | info!("Registered Binder service, joining threadpool."); |
| 44 | ProcessState::join_thread_pool(); |
| 45 | } |