Пример #1
0
static void esif_ws_http_process_post (const char *buffer)
{
	char *begPtr;
	char *endPtr;
	char *namebox;
	char *nameboxVal     = NULL;
	char *passwordbox;
	char *passwordboxVal = NULL;
	size_t namebox_size;
	size_t passwordbox_size;

	printf("buffer from POST: %s\n", buffer);

	namebox = strstr(buffer, "namebox");
	if (namebox) {
		begPtr = strchr((const char*)namebox, '=');
		begPtr++;
		endPtr = strchr(begPtr, '&');
		namebox_size = endPtr - begPtr;
		nameboxVal   = (char*)esif_ccb_malloc(namebox_size + 1);
		if (NULL == nameboxVal) {
			exit(1);
		}
		esif_ccb_memcpy(nameboxVal, namebox + 8, namebox_size + 1);
		nameboxVal[namebox_size] = 0;
		printf("name: %s ", nameboxVal);
	}

	passwordbox = strstr(buffer, "passwordbox");

	if (passwordbox) {
		begPtr = strchr((const char*)passwordbox, '=');
		begPtr++;
		endPtr = strchr(begPtr, '&');
		passwordbox_size = endPtr - begPtr;
		passwordboxVal   = (char*)esif_ccb_malloc(passwordbox_size + 1);
		if (NULL == passwordboxVal) {
			exit(1);
		}
		esif_ccb_memcpy(passwordboxVal, passwordbox + 12, passwordbox_size + 1);
		passwordboxVal[passwordbox_size] = 0;
		printf("password: %s\n", passwordboxVal);
	}

	if (nameboxVal) {
		esif_ccb_free(nameboxVal);
	}

	if (passwordboxVal) {
		esif_ccb_free(passwordboxVal);
	}
}
Пример #2
0
static enum esif_rc esif_ccb_timer_obj_create(
	const esif_ccb_timer_cb function_ptr,	/* Callback when timer fires */
	void *context_ptr,			/* Callback context if any */
	struct esif_timer_obj **timer_obj_ptr
	)
{
	enum esif_rc rc = ESIF_OK;
	struct esif_timer_obj *new_timer_obj_ptr = NULL;

	ESIF_ASSERT(function_ptr != NULL);
	ESIF_ASSERT(timer_obj_ptr != NULL);

	new_timer_obj_ptr = (struct esif_timer_obj *)esif_ccb_malloc(sizeof(*new_timer_obj_ptr));
	if (NULL == new_timer_obj_ptr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	rc = esif_ccb_timer_obj_create_timer(new_timer_obj_ptr);
	if (rc != ESIF_OK)
		goto exit;

	new_timer_obj_ptr->function_ptr = function_ptr;
	new_timer_obj_ptr->context_ptr = context_ptr;

	*timer_obj_ptr = new_timer_obj_ptr;
exit:
	if (rc != ESIF_OK)
		esif_ccb_timer_obj_destroy(new_timer_obj_ptr);

	return rc;
}
Пример #3
0
// Resize an IString buffer (if dynamically allocated)
ZString IString_Resize (
	IStringPtr self,
	u32 buf_len
	)
{
	ESIF_ASSERT(self);
	// Allocate initial buffer if it has never been allocated
	if (self->buf_ptr == 0) {
		self->buf_ptr = esif_ccb_malloc(buf_len);
		if (self->buf_ptr) {
			self->buf_len  = buf_len;
			self->data_len = 1;
			return (ZString)self->buf_ptr;
		}
	}
	// Resize buffer if it is not a static string
	if (self->buf_len > 0) {
		ZString buf_ptr = (ZString)esif_ccb_realloc(self->buf_ptr, buf_len);
		if (buf_ptr) {
			if (buf_len > self->buf_len) {
				esif_ccb_memset(buf_ptr + self->buf_len, 0, buf_len - self->buf_len);
			}
			self->buf_ptr = buf_ptr;
			self->buf_len = buf_len;
			return (ZString)self->buf_ptr;
		}
	}
	return 0;
}
Пример #4
0
/* Data For Interface Marshaling */
static AppDomainDataPtr CreateDomainData(const struct esif_fpc_domain *domainPtr)
{
	AppDomainDataPtr dom_data_ptr = (AppDomainDataPtr)esif_ccb_malloc(sizeof(AppDomainData));

	ESIF_TRACE_DEBUG("%s\n", domainPtr->descriptor.name);

	if (NULL == dom_data_ptr) {
		goto exit;
	}

	dom_data_ptr->fName.buf_ptr  = (void *)domainPtr->descriptor.name;
	dom_data_ptr->fName.buf_len  = ESIF_NAME_LEN;
	dom_data_ptr->fName.data_len = (UInt32)esif_ccb_strlen(domainPtr->descriptor.name, ESIF_NAME_LEN);
	dom_data_ptr->fName.type     = ESIF_DATA_STRING;

	dom_data_ptr->fDescription.buf_ptr  = (void *)domainPtr->descriptor.description;
	dom_data_ptr->fDescription.buf_len  = ESIF_DESC_LEN;
	dom_data_ptr->fDescription.data_len = (UInt32)esif_ccb_strlen(domainPtr->descriptor.description, ESIF_DESC_LEN);
	dom_data_ptr->fDescription.type     = ESIF_DATA_STRING;

	dom_data_ptr->fGuid.buf_ptr  = (void *)domainPtr->descriptor.guid;
	dom_data_ptr->fGuid.buf_len  = ESIF_GUID_LEN;
	dom_data_ptr->fGuid.data_len = ESIF_GUID_LEN;
	dom_data_ptr->fGuid.type     = ESIF_DATA_GUID;

	dom_data_ptr->fVersion    = APP_DOMAIN_VERSION;
	dom_data_ptr->fType       = (enum esif_domain_type)domainPtr->descriptor.domainType;
	dom_data_ptr->fCapability = domainPtr->capability_for_domain.capability_flags;
	esif_ccb_memcpy(dom_data_ptr->fCapabilityBytes, domainPtr->capability_for_domain.capability_mask, 32);

exit:

	return dom_data_ptr;
}
Пример #5
0
// constructors
IStringPtr IString_CreateAs (u32 buf_len)
{
	IStringPtr self = IString_Create();
	if (self && buf_len) {
		IString_SetInstance(self, esif_ccb_malloc(buf_len), buf_len, 1);
	}
	return self;
}
Пример #6
0
DataBankPtr DataBank_Create ()
{
	DataBankPtr self = (DataBankPtr)esif_ccb_malloc(sizeof(*self));
	if (self) {
		esif_ccb_lock_init(&self->lock);
	}
	return self;
}
Пример #7
0
// Automatically Load all Static DataVaults and *.dv files in the current folder into the DataBank
eEsifError DataBank_LoadDataVaults (DataBankPtr self)
{
	eEsifError rc = ESIF_OK;
	esif_ccb_file_find_handle find_handle = INVALID_HANDLE_VALUE;
	char file_path[MAX_PATH] = {0};
	char file_pattern[MAX_PATH] = {0};
	struct esif_ccb_file *ffd_ptr;
	UInt32 idx;

	ASSERT(self);

	// Import all Static DataVaults into ReadOnly DataVaults
	for (idx = 0; g_StaticDataVaults[idx].name; idx++) {
		DataVaultPtr DB = DataBank_OpenNameSpace(self, g_StaticDataVaults[idx].name);
		if (DB) {
			IOStream_SetMemory(DB->stream, g_StaticDataVaults[idx].buffer, g_StaticDataVaults[idx].buf_len);
			DB->flags |= (ESIF_SERVICE_CONFIG_READONLY | ESIF_SERVICE_CONFIG_NOCACHE);
			DataVault_ReadVault(DB);
		}
	}

	// Create DataVault Directory if it doesn't exit
	esif_build_path(file_path, sizeof(file_path), ESIF_PATHTYPE_DV, NULL, NULL);
	esif_ccb_makepath(file_path);

	// Import all matching *.dv files into ReadWrite DataVaults
	esif_ccb_sprintf(MAX_PATH, file_pattern, "*%s", ESIFDV_FILEEXT);
	ffd_ptr   = (struct esif_ccb_file*)esif_ccb_malloc(sizeof(*ffd_ptr));
	if (NULL == ffd_ptr) {
		rc = ESIF_E_NO_MEMORY;
	}

	if (rc == ESIF_OK) {
		find_handle = esif_ccb_file_enum_first(file_path, file_pattern, ffd_ptr);
	}
	if (INVALID_HANDLE_VALUE != find_handle) {
		do {
			struct esif_ccb_file dv_file = {0};
			DataVaultPtr DB = 0;

			// Read DataVault File, unless it's already been loaded as a Static DataVault
			if (esif_ccb_strlen(ffd_ptr->filename, MAX_PATH) > sizeof(ESIFDV_FILEEXT)) {
				ffd_ptr->filename[esif_ccb_strlen(ffd_ptr->filename, MAX_PATH) - (sizeof(ESIFDV_FILEEXT) - 1)] = 0;	// Truncate ".dv" extension
				if (DataBank_GetNameSpace(self, ffd_ptr->filename) == NULL) {
					DB = DataBank_OpenNameSpace(self, ffd_ptr->filename);
					if (DB) {
						esif_build_path(dv_file.filename, sizeof(dv_file.filename), ESIF_PATHTYPE_DV, DB->name, ESIFDV_FILEEXT);
						IOStream_SetFile(DB->stream, dv_file.filename, "rb");
						DataVault_ReadVault(DB);
					}
				}
			}
		} while (esif_ccb_file_enum_next(find_handle, file_pattern, ffd_ptr));
		esif_ccb_file_enum_close(find_handle);
	}
	esif_ccb_free(ffd_ptr);
	return rc;
}
Пример #8
0
static void esif_ws_cgi_parse_query (
    char *query,
    const char *beg_parms_loc_in_query,
    int fd,
    char *cgi_dir
)
{
    char *cgi_script;
    char *cgi_script_buf;
    // char *cgi_dir;
    char cgiParms[100];
    size_t cgi_script_size;
#define MAX_SIZE 100

    cgi_script_size = query - beg_parms_loc_in_query;
    cgi_script = (char*)esif_ccb_malloc(cgi_script_size + 1);
    if (cgi_script == NULL) {
        exit(1);
    }
    // cgi_dir = (char*)esif_ccb_malloc(esif_ccb_strlen(cgi_dir, MAX_SIZE) + cgi_script_size);
    // if (cgi_dir == NULL)
    // exit(1);

    esif_ccb_memcpy(cgi_script, beg_parms_loc_in_query, cgi_script_size);
    // esif_ccb_memcpy(cgi_dir, DIRECTORY, esif_ccb_strlen(DIRECTORY, MAX_SIZE));

    cgi_script[cgi_script_size] = '\0';
    // cgi_dir[esif_ccb_strlen(DIRECTORY, MAX_SIZE)]='\0';
    printf("cgi_script 1: %s\n", cgi_script);
    query++;

    cgi_script_buf = cgi_script;

#ifdef ESIF_ATTR_OS_WINDOWS

    cgi_script_buf = (char*)strrchr(cgi_script_buf, '/');
    cgi_script_buf++;
    cgi_script_buf[esif_ccb_strlen(cgi_script_buf, MAX_SIZE)] = '\0';
#endif


    esif_ccb_strcpy(cgiParms, query, esif_ccb_strlen(query, MAX_SIZE));

    printf("cgi_dir: %s\n", cgi_dir);

    printf("cgiParms 1: %s\n", cgiParms);

    esif_ccb_strcat(cgi_dir, cgi_script_buf, sizeof(cgi_dir));


    esif_ws_cgi_redirect_output(cgi_dir, fd);
    if (cgi_script) {
        esif_ccb_free(cgi_script);
    }
    // if (cgi_dir)
    // esif_ccb_free(cgi_dir);
}
Пример #9
0
static int esif_ws_http_is_authorized (const char *buffer)
{
	char *begPtr;
	char *endPtr;
	char *namebox;
	char *nameboxVal;
	char *passwordbox;
	char *passwordboxVal = NULL;
	int result;

	printf("esif_ws_http_is_authorized : Buffer received: %s\n", buffer);

	namebox = strstr(buffer, "namebox");
	if (namebox) {
		begPtr     = strchr((const char*)namebox, '=');
		begPtr++;
		endPtr     = strchr(begPtr, '&');
		nameboxVal = (char*)esif_ccb_malloc(endPtr - begPtr + 1);
		esif_ccb_memcpy(nameboxVal, namebox + 8, endPtr - begPtr + 1);
		nameboxVal[endPtr - begPtr] = 0;
		printf("name: %s ", nameboxVal);
	}

	passwordbox = strstr(buffer, "passwordbox");

	if (passwordbox) {
		begPtr = strchr((const char*)passwordbox, '=');
		begPtr++;
		endPtr = strchr(begPtr, '&');
		passwordboxVal = (char*)esif_ccb_malloc(endPtr - begPtr + 1);
		esif_ccb_memcpy(passwordboxVal, passwordbox + 12, endPtr - begPtr + 1);
		passwordboxVal[endPtr - begPtr] = 0;
		printf("esif_ws_http_password: %s\n", passwordboxVal);
	}

	if (passwordboxVal && !strcmp(passwordboxVal, esif_ws_http_password)) {
		result = 1;
	} else {
		result = 0;
	}

	return result;
}
Пример #10
0
// new operator
DataVaultPtr DataVault_Create(char* name)
{
	DataVaultPtr self = (DataVaultPtr)esif_ccb_malloc(sizeof(*self));
	DataVault_ctor(self);

	esif_ccb_strcpy(self->name, name, sizeof(self->name));
	esif_ccb_strlwr(self->name, sizeof(self->name));

	return self;
}
Пример #11
0
// Read a Registry Key Value into a specified memory buffer
static eEsifError DataVault_ReadRegistry (
	DataVaultPtr self,
	esif_string keyname,
	void * *buffer,
	UInt32 *buf_size
	)
{
	eEsifError rc   = ESIF_E_UNSPECIFIED;
	HKEY hKey       = 0;
	DWORD dwFlags   = RRF_RT_ANY;
	DWORD dwError   = 0;
	DWORD dwSize    = 0;
	char *regkey    = 0;
	char *valuename = 0;
	u32 j;

	UNREFERENCED_PARAMETER(self);

	// Format: HKLM\Subkey\Path\ValueName
	for (j = 0; HKeyList[j].name; j++) {
		size_t namelen = esif_ccb_strlen(HKeyList[j].name, 30);
		if (esif_ccb_strnicmp(HKeyList[j].name, keyname, namelen) == 0 && keyname[namelen] == '\\') {
			hKey     = HKeyList[j].hkey;
			keyname += esif_ccb_strlen(HKeyList[j].name, 30) + 1;
			break;
		}
	}
	if (!hKey) {
		return rc;
	}

	regkey = esif_ccb_strdup(keyname);
	if ((valuename = strrchr(regkey, '\\')) == 0) {
		esif_ccb_free(regkey);
		return rc;
	}
	*valuename++ = 0;

	// Get Data Size from Registry and copy into buffer if found
	if ((dwError = RegGetValueA(hKey, regkey, valuename, dwFlags, NULL, 0, &dwSize)) == 0) {
		void *reg_buf = esif_ccb_malloc(dwSize);
		dwError = RegGetValueA(hKey, regkey, valuename, dwFlags, NULL, reg_buf, &dwSize);
		if (dwError == 0) {
			*buffer   = reg_buf;
			*buf_size = dwSize;
			rc = ESIF_OK;
		} else {
			esif_ccb_free(reg_buf);
		}
	} else {
		rc = ESIF_E_NOT_FOUND;
	}
	esif_ccb_free(regkey);
	return rc;
}
Пример #12
0
static struct esif_ht_node *esif_alloc_ht_node(
    u8 *key_ptr,
    u32 key_length,
    void *item_ptr
)
{
    enum esif_rc rc = ESIF_OK;
    struct esif_ht_node *ht_node_ptr = NULL;

    ESIF_ASSERT(key_ptr != NULL);

    ht_node_ptr =
        (struct esif_ht_node *)esif_ccb_malloc(sizeof(*ht_node_ptr));
    if (ht_node_ptr == NULL) {
        ESIF_TRACE_ERROR("Unable to allocate HT node\n");
        rc = ESIF_E_NO_MEMORY;
        goto exit;
    }

    ht_node_ptr->key_ptr = esif_ccb_malloc(key_length);
    if (ht_node_ptr->key_ptr == NULL) {
        ESIF_TRACE_ERROR("Unable to allocate HT node key ptr\n");
        rc = ESIF_E_NO_MEMORY;
        goto exit;
    }

    esif_ccb_memcpy(ht_node_ptr->key_ptr, key_ptr, key_length);
    ht_node_ptr->key_length = key_length;
    ht_node_ptr->item_ptr = item_ptr;
exit:
    if (rc != ESIF_OK) {
        if (ht_node_ptr) {
            if (ht_node_ptr->key_ptr)
                esif_ccb_free(ht_node_ptr->key_ptr);

            esif_ccb_free(ht_node_ptr);
            ht_node_ptr = NULL;
        }
    }

    return ht_node_ptr;
}
Пример #13
0
IStringPtr IString_CreateFrom (IStringPtr src)
{
	IStringPtr self = IString_Create();
	if (self && src) {
		IString_SetInstance(self, esif_ccb_malloc(src->buf_len), src->buf_len, src->data_len);
		if (self->buf_ptr) {
			esif_ccb_strcpy((ZString)self->buf_ptr, (ZString)src->buf_ptr, src->data_len);
		}
	}
	return self;
}
Пример #14
0
/* CPC Unpack */
enum esif_rc esif_cpc_unpack(
	struct esif_lp_dsp *dsp_ptr,
	const struct esif_data *req_data_ptr
	)
{
	struct esif_lp_cpc *cpc_ptr = NULL;
	struct esif_cpc_header *cpc_header_ptr = NULL;

	ESIF_TRACE_DYN_CPC("%s: START\n", ESIF_FUNC);
	ESIF_TRACE_DYN_CPC("%s: dsp %p req_data %p cpc %p size %d\n",
			   ESIF_FUNC,
			   dsp_ptr,
			   req_data_ptr,
			   req_data_ptr->buf_ptr,
			   req_data_ptr->buf_len);

	/* Validate Thourougly Here */
	if (req_data_ptr->type != ESIF_DATA_DSP)
		return ESIF_E_INVALID_REQUEST_TYPE;

	if (req_data_ptr->buf_len < sizeof(struct esif_cpc_header))
		return ESIF_E_CPC_SHORT;

	cpc_ptr        = (struct esif_lp_cpc *)req_data_ptr->buf_ptr;
	cpc_header_ptr = (struct esif_cpc_header *)&cpc_ptr->header;

	ESIF_TRACE_DYN_CPC(
		"%s: code %s ver %x (%x,%x), signature %08x, version %x\n",
		ESIF_FUNC,
		cpc_header_ptr->code,
		cpc_header_ptr->version,
		cpc_header_ptr->ver_major,
		cpc_header_ptr->ver_minor,
		cpc_header_ptr->cpc.signature,
		cpc_header_ptr->cpc.version);

	if (cpc_header_ptr->cpc.signature != *(unsigned int *)"@CPC")
		return ESIF_E_CPC_SIGNATURE;

	/* Make a copy for now */
	cpc_ptr = (struct esif_lp_cpc *)esif_ccb_malloc(req_data_ptr->buf_len);
	if (NULL != cpc_ptr) {
		esif_ccb_memcpy(cpc_ptr,
				req_data_ptr->buf_ptr,
				req_data_ptr->buf_len);

		dsp_ptr->cpc_ptr = cpc_ptr;
		esif_cpc_to_dsp(dsp_ptr);
	}
	ESIF_TRACE_DYN_CPC(" %s: STOP\n", ESIF_FUNC);
	return ESIF_OK;
}
Пример #15
0
/* Data For Interface Marshaling */
static AppParticipantDataPtr CreateParticipantData(
	const EsifUpPtr upPtr,
	const EsifUpDataPtr upDataPtr
	)
{
	AppParticipantDataPtr app_data_ptr = NULL;

	if (upPtr->fDspPtr == NULL) {
		goto exit;
	}

	app_data_ptr = (AppParticipantDataPtr)esif_ccb_malloc(sizeof(AppParticipantData));
	if (NULL == app_data_ptr) {
		goto exit;
	}

	/* Common */
	app_data_ptr->fVersion = upDataPtr->fVersion;
	ASSIGN_DATA_GUID(app_data_ptr->fDriverType, upDataPtr->fDriverType);
	ASSIGN_DATA_GUID(app_data_ptr->fDeviceType, upDataPtr->fDriverType);
	ASSIGN_DATA_STRING(app_data_ptr->fName, upDataPtr->fName, ESIF_NAME_LEN);
	ASSIGN_DATA_STRING(app_data_ptr->fDesc, upDataPtr->fDesc, ESIF_DESC_LEN);

	ASSIGN_DATA_STRING(app_data_ptr->fDriverName, upDataPtr->fDriverName, ESIF_NAME_LEN);
	ASSIGN_DATA_STRING(app_data_ptr->fDeviceName, upDataPtr->fDeviceName, ESIF_NAME_LEN);
	ASSIGN_DATA_STRING(app_data_ptr->fDevicePath, upDataPtr->fDevicePath, ESIF_PATH_LEN);

	app_data_ptr->fDomainCount   = (u8)upPtr->fDspPtr->get_domain_count(upPtr->fDspPtr);
	app_data_ptr->fBusEnumerator = upDataPtr->fEnumerator;

	/* ACPI Device */
	ASSIGN_DATA_STRING(app_data_ptr->fAcpiDevice, upDataPtr->fAcpiDevice, ESIF_NAME_LEN);
	ASSIGN_DATA_STRING(app_data_ptr->fAcpiScope, upDataPtr->fAcpiScope, ESIF_SCOPE_LEN);
	app_data_ptr->fAcpiType = upDataPtr->fAcpiType;
	ASSIGN_DATA_STRING(app_data_ptr->fAcpiUID, upDataPtr->fAcpiUID, sizeof(app_data_ptr->fAcpiUID));

	/* PCI Device */
	app_data_ptr->fPciVendor    = upDataPtr->fPciVendor;
	app_data_ptr->fPciDevice    = upDataPtr->fPciDevice;
	app_data_ptr->fPciBus       = upDataPtr->fPciBus;
	app_data_ptr->fPciBusDevice = upDataPtr->fPciBusDevice;
	app_data_ptr->fPciFunction  = upDataPtr->fPciFunction;
	app_data_ptr->fPciRevision  = upDataPtr->fPciRevision;
	app_data_ptr->fPciClass     = upDataPtr->fPciClass;
	app_data_ptr->fPciSubClass  = upDataPtr->fPciSubClass;
	app_data_ptr->fPciProgIf    = upDataPtr->fPciProgIf;

exit:

	return app_data_ptr;
}
Пример #16
0
// IPC Connect
eEsifError ipc_connect()
{
	eEsifError rc = ESIF_OK;
	int check_kernel_version = ESIF_TRUE;

	ESIF_TRACE_ENTRY_INFO();

	// Exit if IPC already connected
	if (g_ipc_handle != ESIF_INVALID_HANDLE) {
		return ESIF_OK;
	}

	// Connect to LF
	g_ipc_handle = esif_ipc_connect((char *)SESSION_ID);
	if (g_ipc_handle == ESIF_INVALID_HANDLE) {
		ESIF_TRACE_WARN("ESIF LF is not available\n");
		rc = ESIF_E_NO_LOWER_FRAMEWORK;
	}
	else {
		char *outbuf = esif_ccb_malloc(OUT_BUF_LEN);
		char *kern_str = (outbuf != NULL ? esif_cmd_info(outbuf) : NULL);
		ESIF_TRACE_DEBUG("ESIF IPC Kernel Device Opened\n");
		if (NULL != kern_str) {
			// Extract just the Kernel LF Version from the result string
			extract_kernel_version(kern_str, OUT_BUF_LEN);

			// Bypass Kernel Version check for DEBUG builds
			#if defined(ESIF_ATTR_DEBUG)
			check_kernel_version = ESIF_FALSE;
			#endif

			// Validate Kernel LF version is compatible with UF version
			if (check_kernel_version == ESIF_FALSE || esif_ccb_strcmp(kern_str, ESIF_VERSION) == 0) {
				ESIF_TRACE_INFO("Kernel Version: %s\n", kern_str);
				esif_ccb_sprintf(sizeof(g_esif_kernel_version), g_esif_kernel_version, "%s", kern_str);
			}
			else {
				ESIF_TRACE_ERROR("ESIF_LF Version (%s) Incompatible with ESIF_UF Version (%s)\n", kern_str, ESIF_VERSION);
				ipc_disconnect();
				rc = ESIF_E_NOT_SUPPORTED;
			}
		}
		esif_ccb_free(outbuf);
	}
	ESIF_TRACE_EXIT_INFO_W_STATUS(rc);
	return rc;
}
Пример #17
0
// Load an External File into a specified memory buffer
static eEsifError ReadFileIntoBuffer(
	esif_string filename,
	void **buffer,
	UInt32 *buf_size
	)
{
	eEsifError rc    = ESIF_OK;
	IOStreamPtr file = IOStream_Create();
	BytePtr bufPtr = NULL;
	size_t size = 0;
	size_t bytesRead = 0;

	if (IOStream_SetFile(file, filename, "rb") != EOK) {
		rc = ESIF_E_IO_ERROR;
		goto exit;
	}

	size = IOStream_GetSize(file);

	bufPtr = (BytePtr) esif_ccb_malloc(size + 1);
	if (NULL == bufPtr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	if (IOStream_Open(file) != 0) {
		rc = ESIF_E_IO_ERROR;
		goto exit;
	}

	bytesRead = IOStream_ReadAt(file, bufPtr, size, 0);
	if (bytesRead != size) {
		rc = ESIF_E_IO_ERROR;
		goto exit;
	}
	bufPtr[size] = 0;

	*buffer = bufPtr;
	*buf_size = (UInt32)size;
exit:
	IOStream_Destroy(file);
	if (rc != ESIF_OK) {
		esif_ccb_free(bufPtr);
	}
	return rc;
}
Пример #18
0
static enum esif_rc esif_ccb_tmrm_create_tmrm_item(
	const esif_ccb_timer_cb function_ptr,	/* Callback when timer fires */
	void *context_ptr,			/* Callback context if any */
	struct esif_tmrm_item **tmrm_item_ptr
	)
{
	enum esif_rc rc = ESIF_E_NO_MEMORY;
	struct esif_tmrm_item *new_item_ptr = NULL;
	struct esif_timer_obj *timer_obj_ptr = NULL;
	esif_ccb_timer_handle_t handle = 0;

	ESIF_ASSERT(tmrm_item_ptr != NULL);
	ESIF_ASSERT(function_ptr != NULL);

	new_item_ptr = (struct esif_tmrm_item *)
		esif_ccb_malloc(sizeof(*new_item_ptr));
	if (NULL == new_item_ptr)
		goto exit;

	new_item_ptr->destroy_list_ptr = esif_link_list_create();
	if (NULL == new_item_ptr->destroy_list_ptr)
		goto exit;	

	rc = esif_ccb_timer_obj_create(function_ptr,
		context_ptr,
		&timer_obj_ptr);
	if (rc != ESIF_OK)
		goto exit;

	new_item_ptr->timer_obj_ptr = timer_obj_ptr;

	rc = esif_ccb_tmrm_get_next_handle(&handle);
	if (rc != ESIF_OK)
		goto exit;

	new_item_ptr->timer_handle = handle;

	*tmrm_item_ptr = new_item_ptr;
exit:
	if (rc != ESIF_OK)
		esif_ccb_tmrm_destroy_tmrm_item(new_item_ptr);

	return rc;
}
Пример #19
0
/* Create Hash Table */
struct esif_ht * esif_ht_create(
    u32 size
)
{
    u32 index = 0;
    struct esif_ht *new_ht_ptr = NULL;

    new_ht_ptr = (struct esif_ht *)
                 esif_ccb_mempool_zalloc(ESIF_MEMPOOL_TYPE_HASH2);

    if (NULL == new_ht_ptr) {
        ESIF_TRACE_ERROR("Cannot allocate mem for hash table\n");
        ESIF_ASSERT(ESIF_FALSE);
        goto exit;
    }

    new_ht_ptr->size = size;
    new_ht_ptr->table = (struct esif_link_list **)
                        esif_ccb_malloc(sizeof(*new_ht_ptr->table) * size);

    if (new_ht_ptr->table == NULL) {
        esif_ccb_mempool_free(ESIF_MEMPOOL_TYPE_HASH2, new_ht_ptr);
        new_ht_ptr = NULL;
        goto exit;
    }

    for (index = 0; index < size; ++index) {
        ESIF_TRACE_DYN_VERB("Create linked list %d\n", index);
        new_ht_ptr->table[index] = esif_link_list_create();

        if (new_ht_ptr->table[index] == NULL) {
            ESIF_TRACE_DYN_VERB("Creation failed\n");
            esif_ht_destroy(new_ht_ptr, NULL);
            new_ht_ptr = NULL;
            goto exit;
        }
    }

    ESIF_TRACE_DYN_VERB("Have hash table %p\n", new_ht_ptr);
exit:
    return new_ht_ptr;
}
Пример #20
0
static eEsifError EsifActMgr_CreatePossActList_Locked()
{
	eEsifError rc = ESIF_OK;
	struct esif_ccb_file curFile = {0};
	esif_ccb_file_enum_t fileIter = {0};
	char libPath[ESIF_LIBPATH_LEN];
	char *dotPtr = NULL;
	EsifActMgrEntryPtr newPossPtr = NULL;
	EsifString filePattern = ESIF_UPE_FILE_PREFIX "*" ESIF_LIB_EXT;

	g_actMgr.possibleActions = esif_link_list_create();
	if (NULL == g_actMgr.possibleActions) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	/* Get the loadable action directory path */
	esif_build_path(libPath, sizeof(libPath), ESIF_PATHTYPE_DLL, NULL, NULL);

	fileIter = esif_ccb_file_enum_first(libPath, filePattern, &curFile);
	if (INVALID_HANDLE_VALUE == fileIter) {
		goto exit;
	}

	do {
		newPossPtr = esif_ccb_malloc(sizeof(*newPossPtr));
		if(NULL == newPossPtr) {
			break;
		}
		dotPtr = esif_ccb_strchr(curFile.filename, '.');
		if (dotPtr != NULL) {
			*dotPtr = '\0';
			newPossPtr->libName = (esif_string)esif_ccb_strdup(curFile.filename);

			esif_link_list_add_at_back(g_actMgr.possibleActions, (void *)newPossPtr);
		}
	} while (esif_ccb_file_enum_next(fileIter, filePattern, &curFile));
	esif_ccb_file_enum_close(fileIter);
exit:
	return rc;
}
Пример #21
0
static void esif_ws_http_serve_cgi_scripts (
	const char *buffer,
	int fd
	)
{
	char *blankCharPtr;
	char *endPtr;
	char *uri;
	size_t uri_size;
	printf("CGI script\n");

	blankCharPtr = strchr((const char*)buffer, ' ');
	blankCharPtr++;
	endPtr = strchr(blankCharPtr, ' ');


	uri_size = endPtr - blankCharPtr;

	uri = (char*)esif_ccb_malloc(uri_size + 1);
	if (uri == NULL) {
		exit(1);
	}


	esif_ccb_memcpy(uri, buffer + 4, uri_size + 1);
	uri[uri_size] = 0;

	printf("uri: %s\n", uri);

	if (!strncmp(buffer, "POST ", 5)) {
		esif_ws_http_process_post((const char*)buffer);
	}

	esif_ws_cgi_execute_cgi_script(uri, fd, g_server_root);

	if (uri) {
		esif_ccb_free(uri);
	}
}
Пример #22
0
/* Translate User Space IPC to Kernel */
static struct esif_ipc *esif_ipc_user_to_kernel(struct esif_ipc *ipc_user_ptr)
{
	int ipc_len = 0;
	struct esif_ipc ipc_hdr  = {0};
	struct esif_ipc *ipc_ptr = NULL;

	if (NULL == ipc_user_ptr)
		return NULL;

	/* Copy from user an error indicates how many bytes copied. */
	if (copy_from_user(&ipc_hdr, ipc_user_ptr,
			   sizeof(struct esif_ipc)) > 0) {
		return NULL;
	}

	/* Sanity Check */
	if (ESIF_IPC_VERSION != ipc_hdr.version)
		return NULL;

	ESIF_TRACE_DYN_IPC(
		"linux_%s: ipc version=%d, type=%d, data_len=%d, rc=%d\n",
		__func__,
		ipc_hdr.version,
		ipc_hdr.type,
		(int)ipc_hdr.data_len,
		(int)ipc_hdr.return_code);

	ipc_len = ipc_hdr.data_len + sizeof(struct esif_ipc);
	ipc_ptr = esif_ccb_malloc(ipc_len);
	if (NULL == ipc_ptr)
		return NULL;

	/* Copy from user an error indicates how many bytes copied. */
	if (copy_from_user(ipc_ptr, ipc_user_ptr, ipc_len) > 0) {
		esif_ccb_free(ipc_ptr);
		return NULL;
	}
	return ipc_ptr;
}
Пример #23
0
/* Allocate IPC */
static struct esif_ipc *esif_ipc_alloc(
	enum esif_ipc_type type,
	u32 data_len
	)
{
	struct esif_ipc *ipc_ptr = NULL;
	u32 ipc_size = sizeof(*ipc_ptr) + data_len;

	ipc_ptr = (struct esif_ipc *)esif_ccb_malloc(ipc_size);
	if (NULL == ipc_ptr)
		return NULL;

	ipc_ptr->version     = ESIF_IPC_VERSION;
	ipc_ptr->type        = type;
	ipc_ptr->data_len    = data_len;
	ipc_ptr->return_code = ESIF_OK;

	ESIF_TRACE_DEBUG("IPC = %p, type = %d, size = %d data_len = %d\n",
		ipc_ptr, type,
		(int)ipc_size,
		(int)data_len);
	return ipc_ptr;
}
Пример #24
0
/* Allocate IPC */
struct esif_ipc *esif_ipc_alloc(
	enum esif_ipc_type type,
	u32 data_len
	)
{
	u32 ipc_size = data_len + sizeof(struct esif_ipc);
	struct esif_ipc *ipc_ptr = (struct esif_ipc *)esif_ccb_malloc(ipc_size);
	if (NULL == ipc_ptr)
		return NULL;

	ipc_ptr->version     = ESIF_IPC_VERSION;
	ipc_ptr->type        = type;
	ipc_ptr->data_len    = data_len;
	ipc_ptr->return_code = ESIF_OK;

#ifdef ESIF_ATTR_HMAC
	esif_ccb_memcpy(ipc->hmac, x, ESIF_HMAC_LEN);
#endif
	ESIF_TRACE_DEBUG("%s: ipc = %p, type = %d, size = %d data_len = %d\n",
			 ESIF_FUNC, ipc_ptr, type, (int)ipc_size,
			 (int)data_len);
	return ipc_ptr;
}
Пример #25
0
/* Data For Interface Marshaling */
static AppDataPtr CreateAppData(esif_string pathBuf)
{
	AppDataPtr app_data_ptr = NULL;
	char policyPath[ESIF_PATH_LEN] = { 0 };

	if (NULL == pathBuf) {
		ESIF_TRACE_ERROR("Path buffer is NULL\n");
		goto exit;
	}

	/* Build path(s) for DPTF: "HomeDir" or "HomeDir|[#]PolicyDir" */
	esif_build_path(pathBuf, ESIF_PATH_LEN, ESIF_PATHTYPE_DPTF, NULL, NULL);
	esif_build_path(policyPath, sizeof(policyPath), ESIF_PATHTYPE_DLL, NULL, NULL);
	if (esif_ccb_strcmp(pathBuf, policyPath) != 0) {
		char policyDummyPath[ESIF_PATH_LEN] = { 0 }; /* empty if path starts with "#" */
		esif_build_path(policyDummyPath, sizeof(policyDummyPath), ESIF_PATHTYPE_DLL, "", NULL);
		esif_ccb_sprintf_concat(ESIF_PATH_LEN, pathBuf, "|%s%s", (policyDummyPath[0] ? "" : "#"), policyPath);
	}
	ESIF_TRACE_DEBUG("pathBuf=%s\n\n", (esif_string)pathBuf);

	app_data_ptr = (AppDataPtr)esif_ccb_malloc(sizeof(AppData));
	if (NULL == app_data_ptr) {
		ESIF_TRACE_ERROR("Fail to allocate AppData\n");
		goto exit;
	}

	app_data_ptr->fPathHome.buf_ptr  = (void *)pathBuf;
	app_data_ptr->fPathHome.buf_len  = ESIF_PATH_LEN;
	app_data_ptr->fPathHome.data_len = (UInt32)esif_ccb_strlen(pathBuf, ESIF_PATH_LEN);
	app_data_ptr->fPathHome.type     = ESIF_DATA_STRING;
	app_data_ptr->fLogLevel          = (eLogType) g_traceLevel;

exit:

	return app_data_ptr;
}
Пример #26
0
static eEsifError EsifActMgr_CreateEntry(
	EsifActMgrEntryPtr* entryPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifActMgrEntryPtr newEntryPtr = NULL;

	if (NULL == entryPtr) {
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	newEntryPtr = esif_ccb_malloc(sizeof(*newEntryPtr));
	if (NULL == newEntryPtr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	newEntryPtr->upInstance = ACT_MGR_NO_UPINSTANCE;

	*entryPtr = newEntryPtr;
exit:
	return rc;
}
Пример #27
0
static eEsifError EsifEventMgr_AddEntry(
	EsifFpcEventPtr fpcEventPtr,
	UInt8 participantId,
	UInt16 domainId,
	EVENT_OBSERVER_CALLBACK eventCallback,
	void *contextPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifLinkListPtr listPtr = NULL;
	EsifLinkListNodePtr nodePtr = NULL;
	EventMgrEntryPtr curEntryPtr = NULL;
	EventMgrEntryPtr newEntryPtr = NULL;
	atomic_t refCount = 1;

	ESIF_ASSERT(eventCallback != NULL);

	esif_ccb_write_lock(&g_EsifEventMgr.listLock);

	listPtr = g_EsifEventMgr.observerLists[fpcEventPtr->esif_event % NUM_EVENT_LISTS];
	if(NULL == listPtr) {
		rc = ESIF_E_UNSPECIFIED;
		esif_ccb_write_unlock(&g_EsifEventMgr.listLock);
		goto exit;
	}

	/* 
	 * First verify we don't already have the same entry.
	 * If we do, just increment the reference count.
	 */
	nodePtr = listPtr->head_ptr;
	while (nodePtr != NULL) {
		curEntryPtr = (EventMgrEntryPtr) nodePtr->data_ptr;
		if ((curEntryPtr->fpcEvent.esif_event == fpcEventPtr->esif_event) &&
			(curEntryPtr->participantId == participantId) &&
			(curEntryPtr->domainId == domainId) &&
			(curEntryPtr->contextPtr == contextPtr) &&
			(curEntryPtr->callback == eventCallback)){
			break;
		}
		nodePtr = nodePtr->next_ptr;
	}
	/* If we found an existing entry, update the reference count */
	if (nodePtr != NULL) {
		atomic_inc(&curEntryPtr->refCount);
		esif_ccb_write_unlock(&g_EsifEventMgr.listLock);
		goto exit;
	}
	esif_ccb_write_unlock(&g_EsifEventMgr.listLock);

	/*
	 * If an matching observer entry was not present; create a new observer entry,
	 * enable the events, and then place it into the list
	 */
	newEntryPtr = esif_ccb_malloc(sizeof(*newEntryPtr));
	if (NULL == newEntryPtr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	newEntryPtr->callback = eventCallback;
	newEntryPtr->contextPtr = contextPtr;
	newEntryPtr->domainId = domainId;
	newEntryPtr->participantId = participantId;
	newEntryPtr->refCount = refCount;
	esif_ccb_memcpy(&newEntryPtr->fpcEvent, fpcEventPtr, sizeof(newEntryPtr->fpcEvent));

	nodePtr = esif_link_list_create_node(newEntryPtr);
	if (NULL == nodePtr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}
	
	esif_ccb_write_lock(&g_EsifEventMgr.listLock);
	esif_link_list_add_node_at_back(listPtr, nodePtr);
	esif_ccb_write_unlock(&g_EsifEventMgr.listLock);

	rc = EsifEventMgr_EnableEvent(newEntryPtr);
	if (ESIF_OK != rc)
	{
		esif_ccb_write_lock(&g_EsifEventMgr.listLock);
		esif_link_list_node_remove(listPtr, nodePtr);
		esif_ccb_write_unlock(&g_EsifEventMgr.listLock);
		goto exit;
	}

exit:
	ESIF_TRACE_DEBUG("  RefCount: " ATOMIC_FMT "\n", refCount);

	if (ESIF_OK != rc) {
		esif_ccb_free(newEntryPtr);
	}

	return rc;
}
Пример #28
0
eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent(
	UInt8 participantId,
	UInt16 domainId,
	eEsifEventType eventType,
	const EsifDataPtr eventDataPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifEventQueueItemPtr queueEventPtr = NULL;
	EsifDataPtr queueDataPtr = NULL;

	if (NULL == g_EsifEventMgr.eventQueuePtr) { /* Should never happen */
		rc = ESIF_E_UNSPECIFIED;
		goto exit;
	}

	queueEventPtr = esif_ccb_malloc(sizeof(*queueEventPtr));
	if (NULL == queueEventPtr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	if ((eventDataPtr != NULL) &&
	    (eventDataPtr->buf_ptr != NULL) && 
	    (eventDataPtr->buf_len > 0) &&
	    (eventDataPtr->data_len > 0) &&
	    (eventDataPtr->buf_len >= eventDataPtr->data_len)) {

		queueDataPtr = esif_ccb_malloc(eventDataPtr->data_len);
		if (NULL == queueDataPtr) {
			rc = ESIF_E_NO_MEMORY;
			goto exit;
		}

		esif_ccb_memcpy(queueDataPtr, eventDataPtr->buf_ptr, eventDataPtr->data_len);

		queueEventPtr->eventData.type = eventDataPtr->type;
		queueEventPtr->eventData.buf_ptr = queueDataPtr;
		queueEventPtr->eventData.buf_len = eventDataPtr->data_len;
		queueEventPtr->eventData.data_len = eventDataPtr->data_len;
	}

	queueEventPtr->participantId = participantId;
	queueEventPtr->domainId = domainId;
	queueEventPtr->eventType = eventType;

	ESIF_TRACE_INFO("Queuing %s event for Part. %u Dom. 0x%04X\n",
		esif_event_type_str(eventType),
		participantId,
		domainId);

	rc = esif_queue_enqueue(g_EsifEventMgr.eventQueuePtr, queueEventPtr);
	if (rc != ESIF_OK) {
		goto exit;
	}

exit:
	if (rc != ESIF_OK) {
		esif_ccb_free(queueEventPtr);
		esif_ccb_free(queueDataPtr);

	}
	return rc;
}
Пример #29
0
/* Create participant */
EsifUpPtr EsifUpManagerCreateParticipant(
	const eEsifParticipantOrigin origin,
	const void *handle,
	const void *metadataPtr
	)
{
	EsifUpPtr up_ptr = NULL;
	EsifUpManagerEntryPtr entry_ptr = NULL;
	UInt8 i = 0;
	UInt8 lpInstance;

	/* Lock manager */
	esif_ccb_write_lock(&g_uppMgr.fLock);

	/* Validate parameters */
	if (NULL == handle || NULL == metadataPtr) {
		ESIF_TRACE_ERROR("Invalid handle or meta data pointer\n");
		goto exit;
	}

	lpInstance = *(UInt8 *)handle;

	/*
	 * Check if a participant has already been created, but was then removed.
	 * In that case, just re-enable the participant.
	 */
	entry_ptr = EsifUpManagerGetParticipantEntryFromMetadata(origin, metadataPtr);
	if (NULL != entry_ptr) {
		up_ptr = entry_ptr->fUpPtr;
		entry_ptr->fState = ESIF_PM_PARTICIPANT_STATE_CREATED;
		g_uppMgr.fEntryCount++;
		goto exit;
	}

	/* Allocate a particpant */
	up_ptr = (EsifUpPtr)esif_ccb_malloc(sizeof(EsifUp));
	if (NULL == up_ptr) {
		ESIF_TRACE_ERROR("Fail to allocate EsifUp\n");
		ESIF_ASSERT(up_ptr != NULL);
		goto exit;
	}

	/*
	**  Find available slot in participant manager table.  Simple Table Lookup For Now.
	**  Scan table and find first empty slot.  Empty slot indicated by AVAILABLE state.
	*/
	for (i = 0; i < MAX_PARTICIPANT_ENTRY; i++) {
		if (ESIF_PM_PARTICIPANT_STATE_AVAILABLE == g_uppMgr.fEntries[i].fState) {
			break;
		}
	}

	/* If no available slots return */
	if (i >= MAX_PARTICIPANT_ENTRY) {
		ESIF_TRACE_ERROR("No available slot in participant manager\n");
		esif_ccb_free(up_ptr);
		up_ptr = NULL;
		goto exit;
	}

	/* Take slot */
	g_uppMgr.fEntries[i].fState = ESIF_PM_PARTICIPANT_STATE_CREATED;
	g_uppMgr.fEntryCount++;

	/* Initialize participant */
	up_ptr->fInstance = i;
	up_ptr->fEnabled  = ESIF_TRUE;

	/* Initialize based on origin */
	switch (origin) {
	case eParticipantOriginLF:
		UpInitializeOriginLF(up_ptr, lpInstance, metadataPtr);
		break;

	case eParticipantOriginUF:
		UpInitializeOriginUF(up_ptr, metadataPtr);
		break;

	default:
		break;
	}

	/* Unlock manager */
	g_uppMgr.fEntries[i].fUpPtr = up_ptr;
	ESIF_TRACE_INFO("The participant data of %s is created in ESIF UF, instance = %d\n", up_ptr->fMetadata.fName, i);

exit:
	esif_ccb_write_unlock(&g_uppMgr.fLock);
	return up_ptr;
}
Пример #30
0
static eEsifError ActionCreate(
	EsifActPtr actionPtr,
	GetIfaceFuncPtr ifaceFuncPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifActTypePtr action_type_ptr = NULL;
	EsifData p1   = {ESIF_DATA_STRING, "action_iD", sizeof("action_id")};
	EsifData p2   = {ESIF_DATA_STRING, "domain_qualifier", sizeof("domain_qaulifier")};
	EsifData p3   = {ESIF_DATA_UINT32, "kernel_abi_type", sizeof("Kernel_abi_type")};
	EsifData p4   = {ESIF_DATA_UINT8, "mode", sizeof("mode")};

	char name[ESIF_NAME_LEN] = {0};
	ESIF_DATA(data_name, ESIF_DATA_STRING, name, ESIF_NAME_LEN);

	char desc[ESIF_DESC_LEN] = {0};
	ESIF_DATA(data_desc, ESIF_DATA_STRING, desc, ESIF_DESC_LEN);

	char version[ESIF_DESC_LEN] = {0};
	ESIF_DATA(data_version, ESIF_DATA_STRING, version, ESIF_DESC_LEN);

	UInt32 action_type_id = 0;
	EsifData action_type  = {ESIF_DATA_UINT32, &action_type_id, sizeof(action_type_id), 0};

	esif_guid_t guid   = {0};
	EsifData data_guid = {ESIF_DATA_GUID, &guid, sizeof(guid), 0};

	EsifString act_type_ptr = NULL;
	EsifInterface act_service_iface;

	ESIF_ASSERT(actionPtr != NULL);
	ESIF_ASSERT(ifaceFuncPtr != NULL);

	/* Assign the EsifInterface Functions */
	act_service_iface.fIfaceType              = eIfaceTypeEsifService;
	act_service_iface.fIfaceVersion           = 1;
	act_service_iface.fIfaceSize              = (UInt16)sizeof(EsifInterface);

	act_service_iface.fGetConfigFuncPtr       = EsifSvcConfigGet;
	act_service_iface.fSetConfigFuncPtr       = EsifSvcConfigSet;
	act_service_iface.fPrimitiveFuncPtr       = EsifSvcPrimitiveExec;
	act_service_iface.fWriteLogFuncPtr        = EsifSvcWriteLog;
	act_service_iface.fRegisterEventFuncPtr   = EsifSvcEventRegister;
	act_service_iface.fUnregisterEventFuncPtr = EsifSvcEventUnregister;

	/* GetApplicationInterface Handleshake send ESIF receive APP Interface */
	rc = ifaceFuncPtr(&actionPtr->fInterface);
	if (ESIF_OK != rc) {
		goto exit;
	}

	/* Check EsifAppInterface */
	if (actionPtr->fInterface.fIfaceType != eIfaceTypeAction ||
		actionPtr->fInterface.fIfaceSize != (UInt16)sizeof(EsifActInterface) ||
		actionPtr->fInterface.fIfaceVersion != 1 ||

		/* Functions Pointers */
		actionPtr->fInterface.fActCreateFuncPtr == NULL ||
		actionPtr->fInterface.fActDestroyFuncPtr == NULL ||
		actionPtr->fInterface.fActGetAboutFuncPtr == NULL ||
		actionPtr->fInterface.fActGetDescriptionFuncPtr == NULL ||
		actionPtr->fInterface.fActGetFuncPtr == NULL ||
		actionPtr->fInterface.fActGetIDFuncPtr == NULL ||
		actionPtr->fInterface.fActGetGuidFuncPtr == NULL ||
		actionPtr->fInterface.fActGetNameFuncPtr == NULL ||
		actionPtr->fInterface.fActGetStateFuncPtr == NULL ||
		actionPtr->fInterface.fActGetStatusFuncPtr == NULL ||
		actionPtr->fInterface.fActGetVersionFuncPtr == NULL ||
		actionPtr->fInterface.fActSetFuncPtr == NULL ||
		actionPtr->fInterface.fActSetStateFuncPtr == NULL) {
		ESIF_TRACE_ERROR("The required function pointer in EsifActInterface is NULL\n");
		goto exit;
	}

	/* Callback for application information */
	rc = actionPtr->fInterface.fActGetNameFuncPtr(&data_name);
	if (ESIF_OK != rc) {
		goto exit;
	}

	rc = actionPtr->fInterface.fActGetDescriptionFuncPtr(&data_desc);
	if (ESIF_OK != rc) {
		goto exit;
	}

	rc = actionPtr->fInterface.fActGetVersionFuncPtr(&data_version);
	if (ESIF_OK != rc) {
		goto exit;
	}

	rc = actionPtr->fInterface.fActGetIDFuncPtr(&action_type);
	if (ESIF_OK != rc) {
		goto exit;
	}

	rc = actionPtr->fInterface.fActGetGuidFuncPtr(&data_guid);
	if (ESIF_OK != rc) {
		goto exit;
	}

	act_type_ptr = "plugin";

	ESIF_TRACE_DEBUG("%s\n\n"
					 "Action Name   : %s\n"
					 "Action Desc   : %s\n"
					 "Action Type   : %s\n"
					 "Action Version: %s\n\n",
					 ESIF_FUNC,
					 (EsifString)data_name.buf_ptr,
					 (EsifString)data_desc.buf_ptr,
					 (EsifString)act_type_ptr,
					 (EsifString)data_version.buf_ptr);

	/* Create The Application */
	CMD_OUT("create action\n");
	rc = actionPtr->fInterface.fActCreateFuncPtr(
			&act_service_iface,
			NULL,
			&actionPtr->fHandle,
			eEsifActStateEnabled,
			&p1,
			&p2,
			&p3,
			&p4,
			NULL);

	if (ESIF_OK != rc) {
		goto exit;
	}

	/* Append New Action To Linked List */
	action_type_ptr = (EsifActTypePtr)esif_ccb_malloc(sizeof(EsifActType));

	if (NULL == action_type_ptr) {
		ESIF_TRACE_ERROR("Fail to allocate EsifActType\n");
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}
	action_type_ptr->fHandle = actionPtr->fHandle;
	action_type_ptr->fType   = *(UInt8 *)action_type.buf_ptr;

	esif_ccb_strcpy(action_type_ptr->fName,
					(EsifString)data_name.buf_ptr, ESIF_NAME_LEN);
	esif_ccb_strcpy(action_type_ptr->fDesc,
					(EsifString)data_desc.buf_ptr, ESIF_DESC_LEN);
	esif_ccb_strcpy(action_type_ptr->fOsType, ESIF_ATTR_OS, ESIF_NAME_LEN);

	action_type_ptr->fGetFuncPtr = actionPtr->fInterface.fActGetFuncPtr;
	action_type_ptr->fSetFuncPtr = actionPtr->fInterface.fActSetFuncPtr;
	esif_ccb_memcpy(action_type_ptr->fGuid, data_guid.buf_ptr, ESIF_GUID_LEN);
	action_type_ptr->fIsKernel   = ESIF_FALSE;
	action_type_ptr->fIsPlugin   = ESIF_TRUE;

	/* Register Action */
	if (NULL != g_actMgr.AddActType) {
		rc = g_actMgr.AddActType(&g_actMgr, action_type_ptr);
	} else {
		ESIF_TRACE_ERROR("Fail to add action type since g_actMrg.AddActType is NULL\n");
		esif_ccb_free(action_type_ptr);
		rc = ESIF_E_NO_CREATE;
	}
exit:
	return rc;
}