X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=drivers%2Fdsp%2Fbridge%2Fservices%2Freg.c;fp=drivers%2Fdsp%2Fbridge%2Fservices%2Freg.c;h=0d85f4169dd22f1d5f144e05a80c838d374291ca;hb=a78d411c6518eb7dd038eef6668f78a7e6c14ec4;hp=0000000000000000000000000000000000000000;hpb=4a6908a3a050aacc9c3a2f36b276b46c0629ad91;p=h-e-n diff --git a/drivers/dsp/bridge/services/reg.c b/drivers/dsp/bridge/services/reg.c new file mode 100644 index 0000000..0d85f41 --- /dev/null +++ b/drivers/dsp/bridge/services/reg.c @@ -0,0 +1,196 @@ +/* + * reg.c + * + * DSP-BIOS Bridge driver support functions for TI OMAP processors. + * + * Copyright (C) 2005-2006 Texas Instruments, Inc. + * + * This package is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + + +/* + * ======== regce.c ======== + * Purpose: + * Provide registry functions. + * + * Public Functions: + * REG_DeleteValue + * REG_EnumValue + * REG_Exit + * REG_GetValue + * REG_Init + * REG_SetValue + * + *! Revision History: + *! ================ + * + */ + +/* ----------------------------------- Host OS */ +#include + +/* ----------------------------------- DSP/BIOS Bridge */ +#include +#include +#include + +/* ----------------------------------- Trace & Debug */ +#include +#include + +/* ----------------------------------- OS Adaptation Layer */ +#include +#include + +/* ----------------------------------- Others */ +#include + +/* ----------------------------------- This */ +#include +#include + +#if GT_TRACE +struct GT_Mask REG_debugMask = { NULL, NULL }; /* GT trace var. */ +#endif + +/* + * ======== REG_DeleteValue ======== + * Deletes a registry entry value. NOTE: A registry entry value is not the + * same as * a registry key. + */ +DSP_STATUS REG_DeleteValue(OPTIONAL IN HANDLE *phKey, IN CONST char *pstrSubkey, + IN CONST char *pstrValue) +{ + DSP_STATUS status; + DBC_Require(pstrSubkey && pstrValue); + DBC_Require(phKey == NULL); + DBC_Require(strlen(pstrSubkey) < REG_MAXREGPATHLENGTH); + DBC_Require(strlen(pstrValue) < REG_MAXREGPATHLENGTH); + + GT_0trace(REG_debugMask, GT_ENTER, "REG_DeleteValue: entered\n"); + + /* Note that we don't use phKey */ + if (regsupDeleteValue(pstrSubkey, pstrValue) == DSP_SOK) + status = DSP_SOK; + else + status = DSP_EFAIL; + + return status; +} + +/* + * ======== REG_EnumValue ======== + * Enumerates a registry key and retrieve values stored under the key. + * We will assume the input pdwValueSize is smaller than + * REG_MAXREGPATHLENGTH for implementation purposes. + */ +DSP_STATUS REG_EnumValue(IN HANDLE *phKey, IN u32 dwIndex, + IN CONST char *pstrKey, IN OUT char *pstrValue, + IN OUT u32 *pdwValueSize, IN OUT char *pstrData, + IN OUT u32 *pdwDataSize) +{ + DSP_STATUS status; + + DBC_Require(pstrKey && pstrValue && pdwValueSize && pstrData && + pdwDataSize); + DBC_Require(*pdwValueSize <= REG_MAXREGPATHLENGTH); + DBC_Require(phKey == NULL); + DBC_Require(strlen(pstrKey) < REG_MAXREGPATHLENGTH); + + GT_0trace(REG_debugMask, GT_ENTER, "REG_EnumValue: entered\n"); + + status = regsupEnumValue(dwIndex, pstrKey, pstrValue, pdwValueSize, + pstrData, pdwDataSize); + + return status; +} + +/* + * ======== REG_Exit ======== + * Discontinue usage of the REG module. + */ +void REG_Exit(void) +{ + GT_0trace(REG_debugMask, GT_5CLASS, "REG_Exit\n"); + + regsupExit(); +} + +/* + * ======== REG_GetValue ======== + * Retrieve a value from the registry. + */ +DSP_STATUS REG_GetValue(OPTIONAL IN HANDLE *phKey, IN CONST char *pstrSubkey, + IN CONST char *pstrValue, OUT u8 *pbData, + IN OUT u32 *pdwDataSize) +{ + DSP_STATUS status; + + DBC_Require(pstrSubkey && pstrValue && pbData); + DBC_Require(phKey == NULL); + DBC_Require(strlen(pstrSubkey) < REG_MAXREGPATHLENGTH); + DBC_Require(strlen(pstrValue) < REG_MAXREGPATHLENGTH); + + GT_0trace(REG_debugMask, GT_ENTER, "REG_GetValue: entered\n"); + + /* We need to use regsup calls... */ + /* ...for now we don't need the key handle or */ + /* the subkey, all we need is the value to lookup. */ + if (regsupGetValue((char *)pstrValue, pbData, pdwDataSize) == DSP_SOK) + status = DSP_SOK; + else + status = DSP_EFAIL; + + return status; +} + +/* + * ======== REG_Init ======== + * Initialize the REG module's private state. + */ +bool REG_Init(void) +{ + bool fInit; + + GT_create(®_debugMask, "RG"); /* RG for ReG */ + + fInit = regsupInit(); + + GT_0trace(REG_debugMask, GT_5CLASS, "REG_Init\n"); + + return fInit; +} + +/* + * ======== REG_SetValue ======== + * Set a value in the registry. + */ +DSP_STATUS REG_SetValue(OPTIONAL IN HANDLE *phKey, IN CONST char *pstrSubkey, + IN CONST char *pstrValue, IN CONST u32 dwType, + IN u8 *pbData, IN u32 dwDataSize) +{ + DSP_STATUS status; + + DBC_Require(pstrValue && pbData); + DBC_Require(phKey == NULL); + DBC_Require(dwDataSize > 0); + DBC_Require(strlen(pstrValue) < REG_MAXREGPATHLENGTH); + + /* We need to use regsup calls... */ + /* ...for now we don't need the key handle or */ + /* the subkey, all we need is the value to lookup. */ + if (regsupSetValue((char *)pstrValue, pbData, dwDataSize) == DSP_SOK) + status = DSP_SOK; + else + status = DSP_EFAIL; + + return status; +} +