#ifndef PHSTBDBG_INTERNAL_H    /* Multi-include protection.   <FILENAME>_H */
#define PHSTBDBG_INTERNAL_H


/*****************************************************************************/
/* Copyright (c) 2009 NXP B.V.                                               */
/*                                                                           */
/* This program is free software; you can redistribute it and/or modify      */
/* it under the terms of the GNU General Public License as published by      */
/* the Free Software Foundation, using version 2 of the License.             */
/*                                                                           */
/* This program is distributed in the hope that it will be useful,           */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the              */
/* GNU General Public License for more details.                              */
/*                                                                           */
/* You should have received a copy of the GNU General Public License         */
/* along with this program; if not, write to the Free Software               */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307       */
/* USA.                                                                      */
/*                                                                           */
/*****************************************************************************/
/**
    @file   phStbDbg_Internal.h
    @brief  Internal header file for StbRpc component.

@b  Component:  phStbDbg.

*//*

Rev Date        Author      Comments
--------------------------------------------------------------------------------
  1 20050728    batelaan    Initial.
  2 20050823    batelaan    Removed unneeded public functions. Correct ioctl code.
  3 20050824    batelaan    Crosscheck corrections.
  4 20050905    batelaan    Ensure compilation for all release types.
  5 20061109    G.Lawrance  Fix after tmStbDbg.h changes
  6 20071016    batelaan    WinCE port
  7 20080131    hutchinson  Merged in EB's changes from 30th Jan 2008 Snapshot
  8 20080408    steel       add copy_from_user for virtual addresses
  9 20081106    batelaan    Add key handling functionality.
 10 20090120    batelaan    Update file copyright/license text
--------------------------------------------------------------------------------
    For consistency and standardisation retain the Section Separators.
*/


/*******************
* INCLUDE FILES    *
********************/

#include <tmNxTypes.h>

/**************************************************************************
* EXPORTED MACROS                          PH_STBDBG_<_WORD>+        *
***************************************************************************/

#if TMFL_OS_IS_LINUX
/* The base of phStbDbg ioctls */
#define PHSTBDBG_IOCTL_BASE 0xBE

/** Register module name. Args:
    - module name.
    ioctl return value is offset of debug unit from ::gpphStbDbg_Entries. */
#define PH_STBDBG_IOCTL_REGISTER_MODULE _IOW(PHSTBDBG_IOCTL_BASE, 0, char*)

/** Set key value. Args:
    - key name
    - pointer to value. This should be maximum #DBG_KEY_MAX_LEN bytes
    including the terminating null character.
    @see tmDbg_KeySet()
*/
#define PH_STBDBG_IOCTL_KEY_SET _IOW(PHSTBDBG_IOCTL_BASE, 1, char*)

/** Get key value. Args:
    - key name
    - pointer to value storage buffer. This should be maximum #DBG_KEY_MAX_LEN bytes
    including the terminating null character.
    @see tmDbg_KeyGet()
*/
#define PH_STBDBG_IOCTL_KEY_GET _IOWR(PHSTBDBG_IOCTL_BASE, 2, char*)

/** Get next key and value. Args:
    - pointer to current key value. This will be updated with the next key value.
    - pointer to value storage buffer. This should be maximum #DBG_KEY_MAX_LEN bytes
    including the terminating null character.
    @see tmDbg_KeyNext()
*/
#define PH_STBDBG_IOCTL_KEY_NEXT _IOWR(PHSTBDBG_IOCTL_BASE, 3, char*)

#define PH_STBDBG_DEVLEN  4096U
#endif

#if TMFL_OS_IS_CE
//  IN                      OUT                 RET
//  const char[]            tmDbgUnit_t         -
#define PH_STBDBG_IOCTL_REGISTER_MODULE 'DGRM'
//  tmDbgUnit_t             -                   -
#define PH_STBDBG_IOCTL_GET_FLAGS       'DGGF'
//  tmDbgUnit_t             -                   -
#define PH_STBDBG_IOCTL_SET_FLAGS       'DGSF'
//  -                       char*               -
#define PH_STBDBG_IOCTL_GET_INFO        'DGGI'
#endif

/** Max length of a DBG module unit name.
    This includes the terminating nul char at the end of the string */
#define PHSTBDBG_MAX_MODULE_NAME_LENGTH   256

/*********************************************************************
* EXPORTED TYPEDEFS                      [p]phStbDbg_<Word>+_t  *
**********************************************************************/
typedef struct phStbDbg_RegisterModule
{
    char *name;
    unsigned int  length;
} phStbDbg_RegisterModule_t;

/** Used by DBG KEY ioctl functions. */
typedef struct phStbDbg_KeyAccess
{
    char *key;
    char *value;
    tmErrorCode_t err;
} phStbDbg_KeyAccess_t;

/**************************************************************************
* EXPORTED DATA                     g[k|p|kp|pk|kpk]phStbDbg_<Word>+ *
***************************************************************************/

/** Base of all tmDbgUnit_t structures. */
DBG_UNIT_EXTERN(gpphStbDbg_Entries);

/****************************************************************************
* EXPORTED FUNCTION PROTOTYPES                    phStbDbg[_<Word>+]   *
*****************************************************************************/

/** Allocate some memory.
    @param size @b IN Number of bytes to allocated.
    @retval NULL Could not allocate memory.
    @retval not-NULL Address of memory.
*/
extern void *phStbDbg_Allocator(size_t size);

/** Deallocate memory allocated by phStbDbg_Allocator().
    @param addr @b IN Memory to deallocate.
*/
extern void phStbDbg_Deallocator(void *addr);

/** Initialise the key tree for the DBG_KEY_* macros. */
extern void phStbDbg_KeyInit(void);

/* Initialise the lock used to protect the key tree. */
extern void phStbDbg_KeyTreeLockInit(void);

/* Lock the key tree from other access. */
extern void phStbDbg_KeyTreeLockEnter(void);

/* Unlock the key tree. */
extern void phStbDbg_KeyTreeLockExit(void);

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

#endif /* PHSTBDBG_INTERNAL_H      Do not add any thing below this line */
