Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 1 | #include "config.h" |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame^] | 2 | |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 3 | #include "host_state_manager.hpp" |
| 4 | |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame^] | 5 | #include <sdbusplus/bus.hpp> |
| 6 | |
| 7 | #include <cstdlib> |
| 8 | #include <exception> |
| 9 | #include <experimental/filesystem> |
| 10 | #include <iostream> |
| 11 | |
Andrew Geissler | 769a62f | 2019-12-06 13:36:08 -0600 | [diff] [blame] | 12 | int main() |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 13 | { |
Dhruvaraj Subhashchandran | 3f47524 | 2017-07-12 00:44:27 -0500 | [diff] [blame] | 14 | namespace fs = std::experimental::filesystem; |
| 15 | |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 16 | auto bus = sdbusplus::bus::new_default(); |
| 17 | |
Andrew Geissler | 1cb8b70 | 2016-12-13 13:33:06 -0600 | [diff] [blame] | 18 | // For now, we only have one instance of the host |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 19 | auto objPathInst = std::string{HOST_OBJPATH} + '0'; |
Andrew Geissler | 1cb8b70 | 2016-12-13 13:33:06 -0600 | [diff] [blame] | 20 | |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 21 | // Add sdbusplus ObjectManager. |
Andrew Geissler | 1cb8b70 | 2016-12-13 13:33:06 -0600 | [diff] [blame] | 22 | sdbusplus::server::manager::manager objManager(bus, objPathInst.c_str()); |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 23 | |
Andrew Geissler | 769a62f | 2019-12-06 13:36:08 -0600 | [diff] [blame] | 24 | phosphor::state::manager::Host manager(bus, objPathInst.c_str()); |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 25 | |
Dhruvaraj Subhashchandran | 3f47524 | 2017-07-12 00:44:27 -0500 | [diff] [blame] | 26 | auto dir = fs::path(HOST_STATE_PERSIST_PATH).parent_path(); |
| 27 | fs::create_directories(dir); |
| 28 | |
Andrew Geissler | a90a31a | 2016-12-13 16:16:28 -0600 | [diff] [blame] | 29 | bus.request_name(HOST_BUSNAME); |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 30 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 31 | while (true) |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 32 | { |
| 33 | bus.process_discard(); |
| 34 | bus.wait(); |
| 35 | } |
| 36 | return 0; |
| 37 | } |