src/hal-api-conf.c
src/hal-api-compatibility-checker.c
src/hal-api-compatibility-checker-object.c
- src/hal-api-compatibility-checker-parser.c
- src/hal-api-compatibility-checker-util.c)
+ src/hal-api-compatibility-checker-parser.c)
ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS})
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -Wl,-z,nodelete,--no-undefined)
#endif
#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#define HALCC_NAME_MAX 128
enum hal_license {
HAL_LICENSE_UNKNOWN = 0,
#include <errno.h>
#include <glib.h>
+#include "common.h"
#include "hal-api-compatibility-checker-object.h"
#include "hal-api-compatibility-checker-parser.h"
-#include "hal-api-compatibility-checker-util.h"
#define HALCC_TRANSPORT_DEFAULT HALCC_TRANSPORT_PASSTHROUGH
#define MAX_NUM_VERSION 8
} halcc_hal;
typedef struct halcc_manifest {
- halcc_manifest_type_e manifest_type;
- halcc_version version;
+ halcc_version platform_version;
GHashTable *hals;
} halcc_manifest;
}
*m = (halcc_manifest) {
- .manifest_type = HALCC_UNINITIALIZED_INT,
- .version.major = HALCC_UNINITIALIZED_INT,
- .version.minor = HALCC_UNINITIALIZED_INT,
+ .platform_version.major = 0,
+ .platform_version.minor = 0,
.hals = hashtable_hal_new(),
};
free(manifest);
}
-int halcc_manifest_set_type(halcc_manifest *manifest, halcc_manifest_type_e type)
-{
- if (!manifest) {
- printf("Invalid parameter\n");
- return -EINVAL;
- }
-
- if (type < HALCC_MANIFEST_TYPE_HAL_API || type > HALCC_MANIFEST_TYPE_HAL_BACKEND) {
- printf("Invalid parameter of type=%d\n", type);
- return -EINVAL;
- }
-
-
- return halcc_util_set_int_once(&manifest->manifest_type, type, "manifest.type");
-}
-
-int halcc_manifest_get_type(halcc_manifest *manifest, halcc_manifest_type_e *type)
+int halcc_manifest_set_platform_version(halcc_manifest *manifest, int major, int minor)
{
- if (!manifest || !type) {
- printf("Invalid parameter\n");
- return -EINVAL;
- }
-
- *type = manifest->manifest_type;
-
- return 0;
-}
-
-int halcc_manifest_set_version(halcc_manifest *manifest, int major, int minor)
-{
- int ret;
-
if (!manifest) {
printf("Invalid parameter\n");
return -EINVAL;
return -EINVAL;
}
- ret = halcc_util_set_int_once(&manifest->version.major, major, "manifest.version.major");
- if (ret != 0) {
- printf("Failed to set major version=%d\n", major);
- return ret;
- }
-
- ret = halcc_util_set_int_once(&manifest->version.minor, minor, "manifest.version.minor");
- if (ret != 0) {
- printf("Failed to set minor version=%d\n", minor);
- return ret;
- }
+ manifest->platform_version.major = major;
+ manifest->platform_version.minor = minor;
return 0;
}
-int halcc_manifest_get_version(halcc_manifest *manifest, int *major, int *minor)
+int halcc_manifest_get_platform_version(halcc_manifest *manifest, int *major, int *minor)
{
if (!manifest || !major || !minor) {
printf("Invalid parameter\n");
return -EINVAL;
}
- *major = manifest->version.major;
- *minor = manifest->version.minor;
+ *major = manifest->platform_version.major;
+ *minor = manifest->platform_version.minor;
return 0;
}
int halcc_manifest_new(halcc_manifest **manifest);
void halcc_manifest_free(halcc_manifest *manifest);
-int halcc_manifest_set_type(halcc_manifest *manifest, halcc_manifest_type_e type);
-int halcc_manifest_get_type(halcc_manifest *manifest, halcc_manifest_type_e *type);
-int halcc_manifest_set_version(halcc_manifest *manifest, int major, int minor);
-int halcc_manifest_get_version(halcc_manifest *manifest, int *major, int *minor);
+int halcc_manifest_set_platform_version(halcc_manifest *manifest, int major, int minor);
+int halcc_manifest_get_platform_version(halcc_manifest *manifest, int *major, int *minor);
int halcc_manifest_add_hal(halcc_manifest *manifest, halcc_hal *hal);
int halcc_manifest_find_hal(halcc_manifest *manifest, const char *hal_name, halcc_hal **hal);
void halcc_manifest_remove_hal(halcc_manifest *manifest, const char *hal_name);
#include "hal-api-compatibility-checker-object.h"
#include "hal-api-compatibility-checker-parser.h"
-#include "hal-api-compatibility-checker-util.h"
#define HALCC_DESERIALIZER_VERSION_MAJOR 1
#define HALCC_DESERIALIZER_VERSION_MINOR 0
}
// version
- prop = xmlGetProp(node, "version");
+ prop = xmlGetProp(node, "platform-version");
if (!prop) {
- printf("Failed to xmlGetProp() \"version\"\n");
+ printf("Failed to xmlGetProp() \"platform-version\"\n");
return -EINVAL;
}
xmlFree(prop);
if (ret != 2) {
- printf("Failed to scan version, ret=%d\n", ret);
+ printf("Failed to scan platform-version, ret=%d\n", ret);
return -EINVAL;
}
- if (major != HALCC_DESERIALIZER_VERSION_MAJOR || minor != HALCC_DESERIALIZER_VERSION_MINOR) {
- printf("Manifest scheme doesn't match. Requires manifest version %d.%d\n",
- HALCC_DESERIALIZER_VERSION_MAJOR, HALCC_DESERIALIZER_VERSION_MINOR);
- return -ENOTSUP;
- }
-
- ret = halcc_manifest_set_version(manifest, major, minor);
+ ret = halcc_manifest_set_platform_version(manifest, major, minor);
if (ret != 0) {
printf("Failed to halcc_manifest_set_version(), ret=%d\n", ret);
return -EINVAL;
}
- // type
- prop = xmlGetProp(node, "type");
- if (!prop) {
- printf("Failed to xmlGetProp() \"type\"\n");
- return -EINVAL;
- }
-
- if (xmlStrEqual(prop, "platform")) {
- ret = halcc_manifest_set_type(manifest, HALCC_MANIFEST_TYPE_HAL_API);
- if (ret != 0)
- printf("Failed to halcc_manifest_set_type() HALCC_MANIFEST_TYPE_HAL_API, ret=%d\n", ret);
- } else if (xmlStrEqual(prop, "device")) {
- ret = halcc_manifest_set_type(manifest, HALCC_MANIFEST_TYPE_HAL_BACKEND);
- if (ret != 0)
- printf("Failed to halcc_manifest_set_type() HALCC_MANIFEST_TYPE_HAL_BACKEND, ret=%d\n", ret);
- } else {
- printf("Invalid type property=%s\n", prop);
- ret = -EINVAL;
- }
-
- xmlFree(prop);
-
- if (ret != 0)
- return ret;
-
for (xmlNode *child = node->children; child; child = child->next) {
int ret;
+++ /dev/null
-/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <errno.h>
-
-#include "hal-api-compatibility-checker-util.h"
-
-int halcc_util_set_int_once(void *buf, int value, const char *buf_desc)
-{
- int old_value;
-
- if (!buf)
- return -EINVAL;
-
- old_value = *(int *) buf;
-
- if (old_value != HALCC_UNINITIALIZED_INT && old_value != value) {
- printf("Cannot modify initialized value, %s, %d to %d\n",
- buf_desc ? : "Unknown", old_value, value);
- return -EALREADY;
- }
-
- *(int *) buf = value;
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HAL_API_COMPATIBILITY_CHECKER_UTIL_H__
-#define __HAL_API_COMPATIBILITY_CHECKER_UTIL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define HALCC_NAME_MAX 128
-#define HALCC_UNINITIALIZED_INT (-1)
-
-/**
- * Modifies buffer pointed by 'buf' to 'value' only when the buffer
- * has value of HALCC_UNINITIALIZED_INT. Once it has changed to value other
- * than HALCC_UNINITIALIZED_INT and trying to change the value, the buffer
- * remains unchanged and this function returns -EALREADY.
- */
-int halcc_util_set_int_once(void *buf, int value, const char *buf_desc);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __HAL_API_COMPATIBILITY_CHECKER_UTIL_H__
#include "hal-api-compatibility-checker.h"
#include "hal-api-compatibility-checker-object.h"
#include "hal-api-compatibility-checker-parser.h"
-#include "hal-api-compatibility-checker-util.h"
#define HAL_CC_DEFAULT_HAL_INFO_INI_PATH "/hal/etc/hal-info.ini"
#define HAL_CC_DEFAULT_HAL_MANIFEST_DIR "/etc/hal-manifest"
static char g_manifest_xml[] =
"<root>"
-" <manifest version=\"1.0\" type=\"platform\">"
+" <manifest platform-version=\"9.0\">"
" <hal>"
" <name>hal.device.display</name>"
" <version>1.5</version>"
" </interface>"
" </hal>"
" </manifest>"
-" <manifest version=\"1.0\" type=\"platform\">"
+" <manifest platform-version=\"10.0\">"
" <hal>"
" <name>HAL_MODULE_BAR</name>"
" <version>2.0</version>"
" </hal>"
" </manifest>"
-" <manifest version=\"1.0\" type=\"platform\">"
+" <manifest platform-version=\"1.0\">"
" <hal>"
" <name>HAL_MODULE_BAR</name>"
" <version>2.2</version>"
halcc_hal* HalccObjectTest::g_hal = NULL;
halcc_interface* HalccObjectTest::g_interface = NULL;
-TEST_F(HalccObjectTest, manifest_get_type)
-{
- halcc_manifest_type_e type;
- int ret;
-
- ret = halcc_manifest_get_type(g_manifest, &type);
- ASSERT_EQ(ret, 0);
- ASSERT_EQ(type, HALCC_MANIFEST_TYPE_HAL_API);
-}
-
-TEST_F(HalccObjectTest, manifest_get_version)
-{
- int major, minor;
- int ret;
-
- ret = halcc_manifest_get_version(g_manifest, &major, &minor);
- ASSERT_EQ(ret, 0);
- ASSERT_EQ(major, 1);
- ASSERT_EQ(minor, 0);
-}
-
TEST_F(HalccObjectTest, manifest_find_hal_success)
{
halcc_hal *hal = NULL;