1 /*
2 *
3 * SPDX-License-Identifier: GPL-2.0
4 *
5 * Copyright (C) 2011-2018 ARM or its affiliates
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20 #include "acamera_fw.h"
21 #include "monitor_fsm.h"
22
23
24 /* Use static memory here to make it cross-platform */
25 static monitor_fsm_t monitor_fsm_ctxs[FIRMWARE_CONTEXT_NUMBER];
26
monitor_get_fsm_common(uint8_t ctx_id)27 fsm_common_t *monitor_get_fsm_common( uint8_t ctx_id )
28 {
29 monitor_fsm_t *p_fsm_ctx = NULL;
30
31 if ( ctx_id >= FIRMWARE_CONTEXT_NUMBER ) {
32 LOG( LOG_CRIT, "Invalid ctx_id: %d, greater than max: %d.", ctx_id, FIRMWARE_CONTEXT_NUMBER - 1 );
33 return NULL;
34 }
35
36 p_fsm_ctx = &monitor_fsm_ctxs[ctx_id];
37
38 p_fsm_ctx->cmn.ctx_id = ctx_id;
39 p_fsm_ctx->cmn.p_fsm = (void *)p_fsm_ctx;
40
41 p_fsm_ctx->cmn.ops.init = monitor_fsm_init;
42 p_fsm_ctx->cmn.ops.deinit = NULL;
43 p_fsm_ctx->cmn.ops.run = NULL;
44 p_fsm_ctx->cmn.ops.get_param = monitor_fsm_get_param;
45 p_fsm_ctx->cmn.ops.set_param = monitor_fsm_set_param;
46 p_fsm_ctx->cmn.ops.proc_event = (FUN_PTR_PROC_EVENT)monitor_fsm_process_event;
47 p_fsm_ctx->cmn.ops.proc_interrupt = (FUN_PTR_PROC_INT)monitor_fsm_process_interrupt;
48
49 return &( p_fsm_ctx->cmn );
50 }
51