view src/aci2/bmi/mmiBlkManager.c @ 600:8f50b202e81f

board preprocessor conditionals: prep for more FC hw in the future This change eliminates the CONFIG_TARGET_FCDEV3B preprocessor symbol and all preprocessor conditionals throughout the code base that tested for it, replacing them with CONFIG_TARGET_FCFAM or CONFIG_TARGET_FCMODEM. These new symbols are specified as follows: CONFIG_TARGET_FCFAM is intended to cover all hardware designs created by Mother Mychaela under the FreeCalypso trademark. This family will include modem products (repackagings of the FCDEV3B, possibly with RFFE or even RF transceiver changes), and also my desired FreeCalypso handset product. CONFIG_TARGET_FCMODEM is intended to cover all FreeCalypso modem products (which will be firmware-compatible with the FCDEV3B if they use TI Rita transceiver, or will require a different fw build if we switch to one of Silabs Aero transceivers), but not the handset product. Right now this CONFIG_TARGET_FCMODEM preprocessor symbol is used to conditionalize everything dealing with MCSI. At the present moment the future of FC hardware evolution is still unknown: it is not known whether we will ever have any beyond-FCDEV3B hardware at all (contingent on uncertain funding), and if we do produce further FC hardware designs, it is not known whether they will retain the same FIC modem core (triband), if we are going to have a quadband design that still retains the classic Rita transceiver, or if we are going to switch to Silabs Aero II or some other transceiver. If we produce a quadband modem that still uses Rita, it will run exactly the same fw as the FCDEV3B thanks to the way we define TSPACT signals for the RF_FAM=12 && CONFIG_TARGET_FCFAM combination, and the current fcdev3b build target will be renamed to fcmodem. OTOH, if that putative quadband modem will be Aero-based, then it will require a different fw build target, the fcdev3b target will stay as it is, and the two targets will both define CONFIG_TARGET_FCFAM and CONFIG_TARGET_FCMODEM, but will have different RF_FAM numbers. But no matter which way we are going to evolve, it is not right to have conditionals on CONFIG_TARGET_FCDEV3B in places like ACI, and the present change clears the way for future evolution.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 01 Apr 2019 01:05:24 +0000
parents 3c2acfa1a72f
children
line wrap: on
line source

/*******************************************************************************

					CONDAT (UK)

********************************************************************************                                                                              

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.                                 
                                                                              
********************************************************************************

 $Project name:	Basic MMI                                                      
 $Project code:	BMI (6349)                                                           
 $Module:		PhoneBook
 $File:		    MmiBlkManager.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		Condat(UK)                                                         
 $Date:		    25/10/00                                                      
                                                                               
********************************************************************************
                                                                              
 Description:

    This module, in conjunction with the MmiBlkResources module,
	provides the access to block resources for the MMI.
                        
    The block manager is responsible for creating and initialising
    the structures and tables to allow access to the strings, icons
    sounds and vibrations required by the MMI.
   
    Each of these items is effectively a contiguous block of memory,
    which is accessed via a block resource. Each of the block resources
    are provided by this package

********************************************************************************

 $History: MmiBlkManager.c

	25/10/00			Original Condat(UK) BMI version.	
	   
 $End

*******************************************************************************/


/*******************************************************************************
                                                                              
                                Include Files
                                                                              
*******************************************************************************/

#define ENTITY_MFW

/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"

#else

#include "STDDEFS.H"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#endif
// #include <malloc.h>

#include "MmiBlkManager.h"


/*******************************************************************************
                                                                              
                       Local structures and definitions
                                                                              
*******************************************************************************/

/* Define a type for the manager control block, this contains
   an array identifying each of the resource manager handles
   which are populated as part of the initialisation sequence
*/
#define BLOCK_MANAGER_KEY          0x00BABE01L
#define BLOCK_MANAGER_ENTRY_COUNT  0x00000010L

typedef struct _tManagerEntry_
{
	tBlkId     Id;
	int		   NumEntries;
	tBlkHandle EntryBase;
} tManagerEntry, *pManagerEntry;

typedef struct _tManagerControl_
{
    long int        BlkKey;
	tBlkHandle      BaseAddress;
	int             BlkLength;
	tBlkHandle      RsrcList[BLOCK_MANAGER_ENTRY_COUNT]; 
	pManagerEntry   EntryPtr;
} tManagerControl, *pManagerControl;


/*******************************************************************************
                                                                              
                                Local routines
                                                                              
*******************************************************************************/

/*******************************************************************************

 $Function:    	ValidManagerResource

 $Description:	Determines if the resource indicated by the handle is valid

 $Returns:		Zero if failure, non-zero if valid resource

 $Arguments:	ManagerRsrc, handle of resource manager
 
*******************************************************************************/

static int ValidManagerResource( tBlkHandle ManagerRsrc )
{
	pManagerControl ManagerControl = (pManagerControl) ManagerRsrc;

	if ( ManagerControl == NULL )
		return 0;

	return ( ManagerControl->BlkKey == BLOCK_MANAGER_KEY );
}


/*******************************************************************************
                                                                              
                                Public routines
                                                                              
*******************************************************************************/


/*******************************************************************************

 $Function:    	mmibm_Initialise

 $Description:	Initialise a block manager object 

 $Returns:		Handle of block manager object, NULL if failure

 $Arguments:	BlkBase, base address of the block manager data
                NumEntries, number of entries to be dealt with by the
				block manager
 
*******************************************************************************/

tBlkHandle mmibm_Initialise( tBlkHandle BlkBase, int NumEntries )
{
	pManagerControl MyControl;
	tBlkId          Entry;
	int i;

	if ( ( MyControl = (pManagerControl) ALLOC_MEMORY( sizeof(tManagerControl) ) ) != NULL )
	{
		/* Fill in the bits we know are pretty constant
		*/
		MyControl->BlkKey      = BLOCK_MANAGER_KEY;
		MyControl->BaseAddress = BlkBase;
		MyControl->BlkLength   = NumEntries;
		MyControl->EntryPtr    = (pManagerEntry) BlkBase;

		/* Initialise the handle array to empty initially
		*/
		for ( i = 0; i < BLOCK_MANAGER_ENTRY_COUNT; i++ )
			MyControl->RsrcList[i] = NULL;

		/* Now for each entry in the incoming block list we can create
		   a handler instance
		*/
		for ( i = 0; i < NumEntries; i++ )
			if ( ( Entry = MyControl->EntryPtr[i].Id ) < BLOCK_MANAGER_ENTRY_COUNT )
				MyControl->RsrcList[ Entry ] = mmibr_Initialise( 
				    MyControl->EntryPtr[i].EntryBase, MyControl->EntryPtr[i].NumEntries );
	}

	return MyControl;
}


/*******************************************************************************

 $Function:    	mmibm_ShutDown

 $Description:	Shutdown routine to deallocate resources ina controlled manner

 $Returns:		none.

 $Arguments:	*BlkHandle, pointer to resource manager handle
 
*******************************************************************************/

void mmibm_ShutDown( tBlkHandle *BlkHandle )
{
	/* Convert and verify the incoming handle
	*/
	pManagerControl MyControl = (pManagerControl) *BlkHandle;
	int i;

	if ( ValidManagerResource( *BlkHandle ) )
	{
	    /* Clear down the allocated resource managers
	    */
	    for ( i = 0; i < BLOCK_MANAGER_ENTRY_COUNT; i++ )
		    if ( MyControl->RsrcList[i] != NULL )
			    mmibr_ShutDown( &MyControl->RsrcList[i] );

		/* and free the resource manager handle
		*/
        free( *BlkHandle );
	    *BlkHandle = NULL;
	}
}


/*******************************************************************************

 $Function:    	mmibm_SupplyResourceHandler

 $Description:	

    Since this module will be managing each of the block handlers
    for each of the resources, we need to be able to supply the
    appropriate handle for any given type to the calling routine.

 $Returns:		Handle to requesteb block resource handler, NULL if failure

 $Arguments:	ManagerHandle, handle of the block manager
                Id, identifier of the resource table for which the resource
				handler is required
 
*******************************************************************************/

tBlkHandle mmibm_SupplyResourceHandler( tBlkHandle ManagerHandle, tBlkId Id )
{
	/* Convert and verify the incoming handle
	*/
	pManagerControl MyControl = (pManagerControl) ManagerHandle;
	if ( ! ValidManagerResource( ManagerHandle ) )
		return NULL;

	/* Verify the id is within the range we expect
	*/
	if ( ( Id >= 0 ) && ( Id < BLOCK_MANAGER_ENTRY_COUNT ) )
		return MyControl->RsrcList[Id];

	/* Okay, we have something invalid, so return NULL
	*/
	return NULL;
}



/*******************************************************************************
                                                                              
                                End of File
                                                                              
*******************************************************************************/