/* * \brief Pin-state service * \author Norman Feske * \date 2021-04-20 */ /* * Copyright (C) 2021 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. */ #ifndef _INCLUDE__PIN_STATE_SESSION__COMPONENT_H_ #define _INCLUDE__PIN_STATE_SESSION__COMPONENT_H_ #include #include #include namespace Pin_state { template class Session_component; template struct Root : Pin::Root, Pin::Direction::IN> { using Pin::Root, Pin::Direction::IN>::Root; }; } template class Pin_state::Session_component : public Session_object { private: Pin::Assignment _assignment; public: using Pin_id = ID; Session_component(Entrypoint &ep, Resources const &resources, Label const &label, Diag &diag, Pin::Driver &driver) : Session_object(ep, resources, label, diag), _assignment(driver) { update_assignment(); } /** * Pin_state::Session interface */ bool state() const override { if (!_assignment.target.constructed()) return false; return _assignment.driver.pin_state(_assignment.target->id); } void update_assignment() { _assignment.update(label(), Pin::Direction::IN); } }; #endif /* _INCLUDE__PIN_STATE_SESSION__COMPONENT_H_ */