view src/cs/services/buzm/buzm_env.c @ 297:8dfdf88d632f

BUZM SWE initial implementation
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Mar 2022 03:45:41 +0000
parents
children
line wrap: on
line source

/*
 * This module provides the glue to the RiViera environment
 * for our BUZM SWE.
 */

#include "buzm/buzm_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 control block for our SWE */
struct buzm_env *buzm_env;

/* Define global pointer to the error function */
static T_RVM_RETURN (*xxx_error_ft) (T_RVM_NAME    swe_name,
                                     T_RVM_RETURN  error_cause,
                                     T_RVM_ERROR_TYPE  error_type,
                                     T_RVM_STRING   error_msg);

T_RVM_RETURN buzm_get_info (T_RVM_INFO_SWE  *infoSWE)
{
   /* SWE info */

   infoSWE->swe_type = RVM_SWE_TYPE_4;
   infoSWE->type_info.type4.swe_use_id = BUZM_USE_ID;
   memcpy( infoSWE->type_info.type4.swe_name, "BUZM", 5 );

   infoSWE->type_info.type4.stack_size = BUZM_STACK_SIZE;
   infoSWE->type_info.type4.priority   = RVM_BUZM_TASK_PRIORITY;

   /* memory bank info */
   infoSWE->type_info.type4.nb_mem_bank = 1;

   memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "BUZM_PRIM", 10);
   infoSWE->type_info.type4.mem_bank[0].initial_params.size          = BUZM_MB_PRIM_SIZE;
   infoSWE->type_info.type4.mem_bank[0].initial_params.watermark     = BUZM_MB_PRIM_WATERMARK;

   /* linked SWE info: we use FFS */
   infoSWE->type_info.type4.nb_linked_swe    = 1;
   infoSWE->type_info.type4.linked_swe_id[0] = FFS_USE_ID;

   /* generic functions */
   infoSWE->type_info.type4.set_info = buzm_set_info;
   infoSWE->type_info.type4.init     = buzm_init;
   infoSWE->type_info.type4.core     = buzm_core;
   infoSWE->type_info.type4.stop     = buzm_stop;
   infoSWE->type_info.type4.kill     = buzm_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 buzm_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_RVF_MB_STATUS   mb_status;

    mb_status = rvf_get_buf(mbId[0],sizeof(struct buzm_env),(void **) &buzm_env);
    if (mb_status == RVF_RED) 
    {
        rvf_send_trace("buzm_set_info: rvf_get_buf() failed", 35,
                       NULL_PARAM, RV_TRACE_LEVEL_ERROR, BUZM_USE_ID);
        return (RVM_MEMORY_ERR);
    }
    memset(buzm_env, 0, sizeof(struct buzm_env));

    /* store the pointer to the error function */
    xxx_error_ft = callBackFct ;

    /* Store the addr id */
    buzm_env->addr_id = addr_id;

    /* Store the memory bank id */
    buzm_env->prim_id = mbId[0];

    return RV_OK;
}

T_RVM_RETURN buzm_init(void)
{
   return RV_OK;
}

T_RVM_RETURN buzm_stop(void)
{
   return RV_OK;
}

T_RVM_RETURN buzm_kill(void)
{
   /* free all memory buffer previously allocated */
   rvf_free_buf ((void *) buzm_env);

   return RV_OK;
}