changeset 230:baa738eeb842

FCBM code implemented in first pass
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 01 May 2021 10:05:53 +0000
parents 7ec0ae23ce76
children 7b71cbbc140b
files components/fcbm src/cs/services/fcbm/fcbm_charging.c src/cs/services/fcbm/fcbm_display_ctrl.c src/cs/services/fcbm/fcbm_env.c src/cs/services/fcbm/fcbm_env.h src/cs/services/fcbm/fcbm_func_i.h src/cs/services/fcbm/fcbm_kpd_if.c src/cs/services/fcbm/fcbm_life_cycle.h src/cs/services/fcbm/fcbm_messages.c src/cs/services/fcbm/fcbm_messages.h src/cs/services/fcbm/fcbm_phone_on.c src/cs/services/fcbm/fcbm_pool_size.h src/cs/services/fcbm/fcbm_powerkey_if.c src/cs/services/fcbm/fcbm_send_msg.c src/cs/services/fcbm/fcbm_send_msg.h src/cs/services/fcbm/fcbm_task.c src/cs/services/fcbm/fcbm_timer_i.h
diffstat 17 files changed, 613 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/fcbm	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,46 @@
+# Building FCBM SWE - an original FreeCalypso addition
+
+CFLAGS="-mn -mt -o -x -mw -me -pw2"
+CPPFLAGS="-DTOOL_CHOICE=0 -D_TMS470"
+
+# Includes
+
+CPPFLAGS="$CPPFLAGS -I$SRC/nucleus"
+CPPFLAGS="$CPPFLAGS -I.."
+CPPFLAGS="$CPPFLAGS -I../config"
+CPPFLAGS="$CPPFLAGS -I$SRC/gpf/inc"
+CPPFLAGS="$CPPFLAGS -I$SRC/gpf/frame/cust_os"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/system"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/riviera"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/riviera/rv"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/abb"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/armio"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/clkm"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/conf"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/dma"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/dsp_dwnld"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/inth"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/memif"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/rhea"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/security"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/spi"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/timer"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/uart"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_core/ulpd"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/drivers/drv_app"
+CPPFLAGS="$CPPFLAGS -I$SRC/cs/services"
+
+# Source modules
+
+SRCDIR=$SRC/cs/services/fcbm
+
+cfile_plain $SRCDIR/fcbm_charging.c
+cfile_plain $SRCDIR/fcbm_display_ctrl.c
+cfile_plain $SRCDIR/fcbm_env.c
+cfile_plain $SRCDIR/fcbm_kpd_if.c
+cfile_plain $SRCDIR/fcbm_messages.c
+cfile_plain $SRCDIR/fcbm_phone_on.c
+cfile_plain $SRCDIR/fcbm_powerkey_if.c
+cfile_plain $SRCDIR/fcbm_send_msg.c
+cfile_plain $SRCDIR/fcbm_task.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_charging.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,68 @@
+/*
+ * In this module we are going to implement FCBM functions
+ * related specifically to charging mode, as opposed to other
+ * special boot modes.
+ */
+
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+#include "fcbm/fcbm_func_i.h"
+#include "fcbm/fcbm_life_cycle.h"
+#include "fcbm/fcbm_timer_i.h"
+#include "fchg/fchg_api.h"
+#include "r2d/r2d_blrr_api.h"
+#include "abb/abb.h"
+
+void fcbm_process_msg_chg_mode(void)
+{
+	if (fcbm_life_cycle_state != FCBM_STATE_INACTIVE) {
+		rvf_send_trace("FCBM got charging mode request in wrong state",
+				45, fcbm_life_cycle_state,
+				RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
+		return;
+	}
+	rvf_send_trace("Entering charging boot mode", 27, NULL_PARAM,
+			RV_TRACE_LEVEL_DEBUG_HIGH, FCBM_USE_ID);
+	fcbm_subscribe_kpd();
+	fcbm_setup_long_pwon();
+	/* TODO: display charging boot mode info on the LCD */
+	blrr_display_ctrl(BLRR_DISPLAY_CHG_BOOT);
+	rvf_start_timer(FCBM_TIMER_DSPL_OFF,
+			RVF_SECS_TO_TICKS(FCBM_DISPLAY_SECS), FALSE);
+	rvf_start_timer(FCBM_TIMER_CHG_UPD,
+			RVF_MS_TO_TICKS(FCBM_CHG_UPD_INTERVAL), TRUE);
+	fcbm_life_cycle_state = FCBM_STATE_ACTIVE;
+}
+
+static void charging_info_update(void)
+{
+	/* to be filled */
+}
+
+static void power_off_check(void)
+{
+	SYS_UWORD16 abb_status;
+
+	abb_status = ABB_Read_Status();
+	if (abb_status & CHGPRES)
+		return;
+	rvf_send_trace("Charger unplug, powering off", 28, NULL_PARAM,
+			RV_TRACE_LEVEL_DEBUG_HIGH, FCBM_USE_ID);
+	/* TODO: display appropriate message on the LCD */
+	blrr_display_ctrl(BLRR_DISPLAY_CHG_BOOT);
+	rvf_delay(RVF_MS_TO_TICKS(50));
+	ABB_Power_Off();
+}
+
+void fcbm_chg_periodic_timer(void)
+{
+	if (fcbm_life_cycle_state != FCBM_STATE_ACTIVE) {
+		rvf_send_trace("Charging mode periodic timer in wrong state",
+				43, fcbm_life_cycle_state,
+				RV_TRACE_LEVEL_WARNING, FCBM_USE_ID);
+		return;
+	}
+	power_off_check();
+	charging_info_update();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_display_ctrl.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,43 @@
+/*
+ * In this module we are going to implement our functions
+ * for controlling display on/off state during charging boot mode.
+ */
+
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+#include "fcbm/fcbm_func_i.h"
+#include "fcbm/fcbm_timer_i.h"
+#include "fcbm/fcbm_life_cycle.h"
+#include "kpd/kpd_api.h"
+#include "r2d/r2d_blrr_api.h"
+
+void fcbm_display_off_timer(void)
+{
+	if (fcbm_life_cycle_state != FCBM_STATE_ACTIVE) {
+		rvf_send_trace("FCBM display off timer in wrong state", 37,
+				fcbm_life_cycle_state, RV_TRACE_LEVEL_WARNING,
+				FCBM_USE_ID);
+		return;
+	}
+	blrr_display_ctrl(BLRR_DISPLAY_OFF);
+}
+
+void fcbm_process_kpd_msg(T_KPD_KEY_EVENT_MSG *msg)
+{
+	if (fcbm_life_cycle_state != FCBM_STATE_ACTIVE) {
+		rvf_send_trace("FCBM keypad message in wrong state", 34,
+				fcbm_life_cycle_state, RV_TRACE_LEVEL_WARNING,
+				FCBM_USE_ID);
+		return;
+	}
+	switch (msg->key_info.state) {
+	case KPD_KEY_PRESSED:
+		blrr_display_ctrl(BLRR_DISPLAY_CHG_BOOT);
+		return;
+	case KPD_KEY_RELEASED:
+		rvf_start_timer(FCBM_TIMER_DSPL_OFF,
+				RVF_SECS_TO_TICKS(FCBM_DISPLAY_SECS), FALSE);
+		return;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_env.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,86 @@
+/*
+ * This module provides the glue to the RiViera environment
+ * for our FCBM SWE.
+ */
+
+#include "fcbm/fcbm_env.h"
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_priorities.h"
+#include "rvm/rvm_api.h"
+#include "rvm/rvm_use_id_list.h"
+#include <string.h>
+
+/* Global variables for FCBM addr_id and prim_id */
+T_RVF_ADDR_ID fcbm_addr_id;
+T_RVF_MB_ID fcbm_prim_id;
+
+T_RVM_RETURN fcbm_get_info (T_RVM_INFO_SWE  *infoSWE)
+{
+   /* SWE info */
+
+   infoSWE->swe_type = RVM_SWE_TYPE_4;
+   infoSWE->type_info.type4.swe_use_id = FCBM_USE_ID;
+   memcpy( infoSWE->type_info.type4.swe_name, "FCBM", 5 );
+
+   infoSWE->type_info.type4.stack_size = FCBM_STACK_SIZE;
+   infoSWE->type_info.type4.priority   = RVM_FCBM_TASK_PRIORITY;
+
+   /* memory bank info */
+   infoSWE->type_info.type4.nb_mem_bank = 1;
+
+   memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "FCBM_PRIM", 10);
+   infoSWE->type_info.type4.mem_bank[0].initial_params.size          = FCBM_MB_PRIM_SIZE;
+   infoSWE->type_info.type4.mem_bank[0].initial_params.watermark     = FCBM_MB_PRIM_WATERMARK;
+
+   /* linked SWE info: we depend on FCHG, R2D, KPD */
+   infoSWE->type_info.type4.nb_linked_swe    = 3;
+   infoSWE->type_info.type4.linked_swe_id[0] = FCHG_USE_ID;
+   infoSWE->type_info.type4.linked_swe_id[1] = R2D_USE_ID;
+   infoSWE->type_info.type4.linked_swe_id[2] = KPD_USE_ID;
+
+   /* generic functions */
+   infoSWE->type_info.type4.set_info = fcbm_set_info;
+   infoSWE->type_info.type4.init     = fcbm_init;
+   infoSWE->type_info.type4.core     = fcbm_core;
+   infoSWE->type_info.type4.stop     = fcbm_stop;
+   infoSWE->type_info.type4.kill     = fcbm_kill;
+
+   /* Set the return path */
+   infoSWE->type_info.type4.return_path.callback_func = NULL;
+   infoSWE->type_info.type4.return_path.addr_id	      = 0;
+
+   return RV_OK;
+}
+
+T_RVM_RETURN fcbm_set_info(T_RVF_ADDR_ID   addr_id,
+                           T_RV_RETURN     return_path[],
+                           T_RVF_MB_ID     mbId[],
+                           T_RVM_RETURN  (*callBackFct) (T_RVM_NAME SWEntName,
+                                                         T_RVM_RETURN errorCause,
+                                                         T_RVM_ERROR_TYPE errorType,
+                                                         T_RVM_STRING errorMsg))
+{
+    /* Store the addr id */
+    fcbm_addr_id = addr_id;
+
+    /* Store the memory bank id */
+    fcbm_prim_id = mbId[0];
+
+    return RV_OK;
+}
+
+T_RVM_RETURN fcbm_init(void)
+{
+   return RV_OK;
+}
+
+T_RVM_RETURN fcbm_stop(void)
+{
+   return RV_OK;
+}
+
+T_RVM_RETURN fcbm_kill(void)
+{
+   return RV_OK;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_env.h	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,41 @@
+/*
+ * RiViera environment boilerplate header for the FCBM SWE
+ */
+
+#ifndef __FCBM_ENV_H__
+#define __FCBM_ENV_H__
+
+#include "rvm/rvm_gen.h"
+#include "fcbm/fcbm_pool_size.h"
+
+#define	FCBM_MAILBOX		RVF_TASK_MBOX_0
+
+/* memory bank size and watermark */
+#define FCBM_MB_PRIM_SIZE            FCBM_MB1_SIZE
+#define FCBM_MB_PRIM_WATERMARK 	    (FCBM_MB_PRIM_SIZE)
+
+#define FCBM_MB_PRIM_INC_SIZE        0
+#define FCBM_MB_PRIM_INC_WATERMARK   0
+
+/* Prototypes */
+
+T_RVM_RETURN fcbm_get_info (T_RVM_INFO_SWE  *infoSWE);
+
+T_RVM_RETURN fcbm_set_info(T_RVF_ADDR_ID  addr_id,
+                           T_RV_RETURN    return_path[],
+                           T_RVF_MB_ID    mbId[],
+                           T_RVM_RETURN   (*callBackFct) (T_RVM_NAME SWEntName,
+                           T_RVM_RETURN errorCause,
+                           T_RVM_ERROR_TYPE errorType,
+                           T_RVM_STRING errorMsg));
+
+T_RVM_RETURN fcbm_init (void);
+T_RVM_RETURN fcbm_core (void);
+T_RVM_RETURN fcbm_stop (void);
+T_RVM_RETURN fcbm_kill (void);
+
+/* global variables */
+extern T_RVF_ADDR_ID fcbm_addr_id;
+extern T_RVF_MB_ID fcbm_prim_id;
+
+#endif	/* include guard */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_func_i.h	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,24 @@
+/*
+ * Declarations of internal functions live here.
+ */
+
+#ifndef __FCBM_FUNC_I
+#define __FCBM_FUNC_I
+
+#include "rv/rv_general.h"
+#include "kpd/kpd_api.h"
+
+T_RV_RET fcbm_subscribe_kpd(void);
+T_RV_RET fcbm_unsubscribe_kpd(void);
+void fcbm_setup_long_pwon(void);
+
+void fcbm_process_message(T_RV_HDR *msg_ptr);
+void fcbm_process_msg_chg_mode(void);
+void fcbm_process_msg_phone_on(void);
+
+void fcbm_chg_periodic_timer(void);
+void fcbm_display_off_timer(void);
+
+void fcbm_process_kpd_msg(T_KPD_KEY_EVENT_MSG *msg);
+
+#endif	/* include guard */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_kpd_if.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,76 @@
+/*
+ * This module implements the interface to KPD for FCBM.
+ */
+
+#include "fcbm/fcbm_env.h"
+#include "fcbm/fcbm_func_i.h"
+#include "kpd/kpd_api.h"
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+
+static T_KPD_SUBSCRIBER fcbm_kpd_sub;
+
+T_RV_RET fcbm_subscribe_kpd(void)
+{
+	T_RV_RET rc;
+	T_RV_RETURN return_path;
+	T_KPD_VIRTUAL_KEY_TABLE notified_keys;
+
+	return_path.callback_func = 0;
+	return_path.addr_id = fcbm_addr_id;
+
+	notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
+	notified_keys.notified_keys[0] = KPD_KEY_0;
+	notified_keys.notified_keys[1] = KPD_KEY_1;
+	notified_keys.notified_keys[2] = KPD_KEY_2;
+	notified_keys.notified_keys[3] = KPD_KEY_3;
+	notified_keys.notified_keys[4] = KPD_KEY_4;
+	notified_keys.notified_keys[5] = KPD_KEY_5;
+	notified_keys.notified_keys[6] = KPD_KEY_6;
+	notified_keys.notified_keys[7] = KPD_KEY_7;
+	notified_keys.notified_keys[8] = KPD_KEY_8;
+	notified_keys.notified_keys[9] = KPD_KEY_9;
+	notified_keys.notified_keys[10] = KPD_KEY_UP;
+	notified_keys.notified_keys[11] = KPD_KEY_DOWN;
+	notified_keys.notified_keys[12] = KPD_KEY_SOFT_LEFT;
+	notified_keys.notified_keys[13] = KPD_KEY_SOFT_RIGHT;
+	notified_keys.notified_keys[14] = KPD_KEY_CONNECT;
+	notified_keys.notified_keys[15] = KPD_KEY_DISCONNECT;
+	notified_keys.notified_keys[16] = KPD_KEY_STAR;
+	notified_keys.notified_keys[17] = KPD_KEY_DIESE;
+	notified_keys.notified_keys[18] = KPD_KEY_LEFT;
+	notified_keys.notified_keys[19] = KPD_KEY_RIGHT;
+	notified_keys.notified_keys[20] = KPD_KEY_ENTER;
+	notified_keys.notified_keys[21] = KPD_KEY_VOL_UP;
+	notified_keys.notified_keys[22] = KPD_KEY_VOL_DOWN;
+	notified_keys.notified_keys[23] = KPD_KEY_RECORD;
+
+	rc = kpd_subscribe(&fcbm_kpd_sub, KPD_DEFAULT_MODE, &notified_keys,
+			   return_path);
+	if (rc != RV_OK) {
+		rvf_send_trace("kpd_subscribe() failed", 22, rc,
+				RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
+		return rc;
+	}
+
+	/* long press and repeat times are dummies copied from MFW */
+	rc = kpd_define_key_notification(fcbm_kpd_sub, &notified_keys,
+					 KPD_FIRST_PRESS_NOTIF |
+					 KPD_RELEASE_NOTIF, 30, 50);
+	if (rc != RV_OK)
+		rvf_send_trace("kpd_define_key_notification() failed", 36, rc,
+				RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
+	return rc;
+}
+
+T_RV_RET fcbm_unsubscribe_kpd(void)
+{
+	T_RV_RET rc;
+
+	rc = kpd_unsubscribe(&fcbm_kpd_sub);
+	if (rc != RV_OK)
+		rvf_send_trace("kpd_unsubscribe() failed", 24, rc,
+				RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
+	return rc;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_life_cycle.h	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,16 @@
+/*
+ * FCBM life cycle state definitions
+ */
+
+#ifndef __FCBM_LIFE_CYCLE_H
+#define __FCBM_LIFE_CYCLE_H
+
+enum fcbm_life_cycle_state {
+	FCBM_STATE_INACTIVE	= 0,
+	FCBM_STATE_ACTIVE,
+	FCBM_STATE_PHONE_ON
+};
+
+extern enum fcbm_life_cycle_state fcbm_life_cycle_state;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_messages.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,29 @@
+/*
+ * Incoming message dispatch for the FCBM task is implemented here.
+ */
+
+#include "fcbm/fcbm_func_i.h"
+#include "fcbm/fcbm_messages.h"
+#include "kpd/kpd_api.h"
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+
+void fcbm_process_message(T_RV_HDR *msg_ptr)
+{
+	switch (msg_ptr->msg_id) {
+	case FCBM_START_CHG_MODE:
+		fcbm_process_msg_chg_mode();
+		return;
+	case FCBM_START_PHONE:
+		fcbm_process_msg_phone_on();
+		return;
+	case KPD_KEY_EVENT_MSG:
+		fcbm_process_kpd_msg((T_KPD_KEY_EVENT_MSG *) msg_ptr);
+		return;
+	default:
+		rvf_send_trace("FCBM task: Received an unknown message", 38,
+				NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
+				FCHG_USE_ID);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_messages.h	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,15 @@
+/*
+ * In this header file we are going to define the messages
+ * that can be sent to the FCBM task.
+ */
+
+#ifndef __FCBM_MESSAGES_H
+#define __FCBM_MESSAGES_H
+
+enum fcbm_msg_id {
+	FCBM_START_CHG_MODE	= 1,
+	FCBM_START_RESET_MODE,
+	FCBM_START_PHONE
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_phone_on.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,30 @@
+/*
+ * In this module we are going to implement FCBM functions
+ * for handing off to MMI, for phone-on operation.
+ */
+
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+#include "fcbm/fcbm_func_i.h"
+#include "fcbm/fcbm_life_cycle.h"
+#include "fcbm/fcbm_timer_i.h"
+
+extern void fchs_pwon_button_boot(void);
+
+void fcbm_process_msg_phone_on(void)
+{
+	if (fcbm_life_cycle_state != FCBM_STATE_ACTIVE) {
+		rvf_send_trace("FCBM got phone-on request in wrong state", 40,
+				fcbm_life_cycle_state,
+				RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
+		return;
+	}
+	rvf_send_trace("FCBM handing off to MMI", 23, NULL_PARAM,
+			RV_TRACE_LEVEL_DEBUG_HIGH, FCBM_USE_ID);
+	fcbm_unsubscribe_kpd();
+	rvf_stop_timer(FCBM_TIMER_CHG_UPD);
+	rvf_stop_timer(FCBM_TIMER_DSPL_OFF);
+	fcbm_life_cycle_state = FCBM_STATE_PHONE_ON;
+	fchs_pwon_button_boot();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_pool_size.h	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,13 @@
+/*
+ * Pool size definition required for every RiViera SWE
+ * FCBM is an entirely new FreeCalypso addition
+ */
+
+#ifndef __FCBM_POOL_SIZE_H_
+#define __FCBM_POOL_SIZE_H_
+
+#define FCBM_STACK_SIZE (1024)
+#define FCBM_MB1_SIZE   (1024)
+ 
+#define FCBM_POOL_SIZE  (FCBM_STACK_SIZE + FCBM_MB1_SIZE)
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_powerkey_if.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,21 @@
+/*
+ * This module implements the long-press-PWON interface for FCBM.
+ */
+
+#include "fcbm/fcbm_func_i.h"
+#include "fcbm/fcbm_send_msg.h"
+#include "kpd/kpd_api.h"
+
+static void press_func(T_KPD_VIRTUAL_KEY_ID key)
+{
+	fcbm_message_to_task(FCBM_START_PHONE);
+}
+
+static void release_func(void)
+{
+}
+
+void fcbm_setup_long_pwon(void)
+{
+	KP_Init(press_func, release_func);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_send_msg.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,33 @@
+/*
+ * The implementation of our fcbm_message_to_task() function lives here.
+ */
+
+#include "fcbm/fcbm_env.h"
+#include "fcbm/fcbm_send_msg.h"
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+
+T_RV_RET fcbm_message_to_task(enum fcbm_msg_id msg_id)
+{
+	T_RV_HDR *msg;
+
+	if (rvf_get_buf(fcbm_prim_id, sizeof(T_RV_HDR),
+			(T_RVF_BUFFER **)&msg) == RVF_RED) {
+		rvf_send_trace(
+			"rvf_get_buf() failed in fcbm_message_to_task()", 46,
+			NULL_PARAM, RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
+		return RV_MEMORY_ERR;
+	}
+	msg->msg_id        = msg_id;
+	msg->src_addr_id   = fcbm_addr_id;
+	msg->dest_addr_id  = fcbm_addr_id;
+	msg->callback_func = NULL;
+	if (rvf_send_msg(fcbm_addr_id, msg) != RV_OK) {
+		rvf_send_trace("fcbm_message_to_task(): Send failed!", 36,
+				NULL_PARAM, RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
+		rvf_free_buf(msg);
+		return RV_INTERNAL_ERR;
+	}
+	return RV_OK;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_send_msg.h	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,13 @@
+/*
+ * This header file defines the interface for sending messages to FCBM task.
+ */
+
+#ifndef __FCBM_SEND_MSG_H
+#define __FCBM_SEND_MSG_H
+
+#include "rv/rv_general.h"
+#include "fcbm/fcbm_messages.h"
+
+T_RV_RET fcbm_message_to_task(enum fcbm_msg_id);
+
+#endif	/* include guard */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_task.c	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,45 @@
+/*
+ * The FCBM task's core function lives here.
+ */
+
+#include "fcbm/fcbm_env.h"
+#include "fcbm/fcbm_func_i.h"
+#include "fcbm/fcbm_timer_i.h"
+#include "fcbm/fcbm_life_cycle.h"
+#include "rv/rv_general.h"
+#include "rvf/rvf_api.h"
+#include "rvm/rvm_use_id_list.h"
+
+enum fcbm_life_cycle_state fcbm_life_cycle_state;
+
+T_RV_RET fcbm_core(void)
+{	
+	BOOLEAN error_occured = FALSE;
+	T_RV_HDR *msg_ptr;
+
+	/* loop to process messages */
+	while (error_occured == FALSE)
+	{
+		/* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */
+		UINT16 received_event = rvf_wait (0xffff, 0);
+					
+		/* If an event related to mailbox 0 is received, then */
+		if (received_event & RVF_TASK_MBOX_0_EVT_MASK) 
+		{
+			/* Read the message in the driver mailbox and delegate action..*/
+			msg_ptr = (T_RV_HDR *) rvf_read_mbox(FCBM_MAILBOX);
+			if (msg_ptr) {
+				fcbm_process_message(msg_ptr);
+				rvf_free_buf ((void *) msg_ptr);
+			}
+		}
+
+		/* Timers */
+		if (received_event & RVF_TIMER_0_EVT_MASK)
+			fcbm_chg_periodic_timer();
+		if (received_event & RVF_TIMER_1_EVT_MASK)
+			fcbm_display_off_timer();
+
+	}	 // end of while
+	return RV_OK;	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/services/fcbm/fcbm_timer_i.h	Sat May 01 10:05:53 2021 +0000
@@ -0,0 +1,14 @@
+/*
+ * FCBM timer definitions
+ */
+
+#ifndef __FCBM_TIMER_I
+#define __FCBM_TIMER_I
+
+#define	FCBM_TIMER_CHG_UPD	RVF_TIMER_0
+#define	FCBM_TIMER_DSPL_OFF	RVF_TIMER_1
+
+#define	FCBM_CHG_UPD_INTERVAL	1000	/* ms */
+#define	FCBM_DISPLAY_SECS	10	/* seconds */
+
+#endif	/* include guard */