1 /* 2 * Copyright (C) 2020 Intel Corporation 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #ifndef _USFSTL_SCHEDCTRL_H_ 7 #define _USFSTL_SCHEDCTRL_H_ 8 #include <stdint.h> 9 #include <inttypes.h> 10 #include "loop.h" 11 #include "sched.h" 12 13 struct usfstl_sched_ctrl { 14 struct usfstl_scheduler *sched; 15 uint64_t ack_time; 16 int64_t offset; 17 uint32_t nsec_per_tick; 18 int fd; 19 unsigned int waiting:1, acked:1, frozen:1, started:1; 20 uint32_t expected_ack_seq; 21 }; 22 23 void usfstl_sched_ctrl_start(struct usfstl_sched_ctrl *ctrl, 24 const char *socket, 25 uint32_t nsec_per_tick, 26 uint64_t client_id, 27 struct usfstl_scheduler *sched); 28 void usfstl_sched_ctrl_sync_to(struct usfstl_sched_ctrl *ctrl); 29 void usfstl_sched_ctrl_sync_from(struct usfstl_sched_ctrl *ctrl); 30 void usfstl_sched_ctrl_stop(struct usfstl_sched_ctrl *ctrl); 31 32 /** 33 * usfstl_sched_ctrl_set_frozen - freeze/thaw scheduler interaction 34 * @ctrl: scheduler control 35 * @frozen: whether or not the scheduler interaction is frozen 36 * 37 * When the scheduler control connection is frozen, then any remote 38 * updates will not reflect in the local scheduler, but instead will 39 * just modify the offset vs. the remote. 40 * 41 * This allows scheduling repeatedly at "time zero" while the remote 42 * side is actually running, e.g. to ensure pre-firmware boot hardware 43 * simulation doesn't affect the firmware simulation time. 44 */ 45 void usfstl_sched_ctrl_set_frozen(struct usfstl_sched_ctrl *ctrl, bool frozen); 46 47 #endif // _USFSTL_SCHEDCTRL_H_ 48