Use hal-rootstrap package for build and change hal_backend_power_funcs memory allocat... 95/314795/1 accepted/tizen_unified_dev accepted/tizen/9.0/unified/20241030.232815 accepted/tizen/unified/20240722.104300 accepted/tizen/unified/dev/20240724.110129 accepted/tizen/unified/x/20241218.081934 accepted/tizen/unified/x/asan/20241224.003802 tizen_9.0_m2_release
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 19 Jul 2024 06:50:36 +0000 (15:50 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 19 Jul 2024 07:44:47 +0000 (16:44 +0900)
hal-roostrap package contains the allowed and maintained files
to build hal-backend package. In order to keep ABI (Application Binary
Interface) compatibility between platfrom and hal image,
must use only hal-rootstrap pacakge for build.

And chagnge the memory allocation/free way of hal_backend_power_funcs
in order to support new 1-platform Multi-HAL Interface approach.

Change-Id: I15707fae89d53a5702be1bfe34e9779325319253
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt
packaging/hal-backend-power-emulator.spec
src/hal-backend-power.c

index 5edccaacf9c4c01a3341a8d3388b845fd8c03f33..696bb71b7770318bfd83d4ff78799a224a4b04a8 100644 (file)
@@ -9,8 +9,7 @@ SET(HAL_LICENSEDIR ${CMAKE_HAL_LICENSEDIR_PREFIX})
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-       hal-api-common
-       hal-api-power
+       hal-rootstrap
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 47ae21c082eac6969ece0f3a9bf53c2f8059027d..09f0b175491c0066297af215284f7e9520b66361 100644 (file)
@@ -16,8 +16,7 @@ Requires(post): security-config
 Requires(postun): /sbin/ldconfig
 Requires(postun): /bin/systemctl
 BuildRequires:  cmake
-BuildRequires:  pkgconfig(hal-api-common)
-BuildRequires:  pkgconfig(hal-api-power)
+BuildRequires:  pkgconfig(hal-rootstrap)
 
 %description
 PASS standard hal
index ae12b606f2d69ab96d511a7718e96ff34c2cb3ef..24f79be345bfa6decc52c83bed3b915340c990ad 100644 (file)
@@ -472,106 +472,32 @@ static int memory_set_fault_around_bytes(char *res_name,
 static int power_init(void **data)
 {
        hal_backend_power_funcs *power_funcs = NULL;
-       struct pass_resource_cpu *cpu = NULL;
-       struct pass_resource_bus *bus = NULL;
-       struct pass_resource_gpu *gpu = NULL;
-       struct pass_resource_memory *memory = NULL;
-       struct pass_resource_battery *battery = NULL;
-       int ret;
-
-       /* Allocate memory */
-       power_funcs = calloc(1, sizeof(hal_backend_power_funcs));
-       if (!power_funcs)
-               return -ENOMEM;
-
-       cpu = calloc(1, sizeof(struct pass_resource_cpu));
-       if (!cpu) {
-               ret = -ENOMEM;
-               goto err_funcs;
-       }
-
-       bus = calloc(1, sizeof(struct pass_resource_bus));
-       if (!bus) {
-               ret = -ENOMEM;
-               goto err_cpu;
-       }
-
-       gpu = calloc(1, sizeof(struct pass_resource_gpu));
-       if (!gpu) {
-               ret = -ENOMEM;
-               goto err_bus;
-       }
-
-       memory = calloc(1, sizeof(struct pass_resource_memory));
-       if (!memory) {
-               ret = -ENOMEM;
-               goto err_gpu;
-       }
-
-       battery = calloc(1, sizeof(struct pass_resource_battery));
-       if (!battery) {
-               ret = -ENOMEM;
-               goto err_memory;
-       }
 
-       /* Initialize each h/w resource */
-       cpu->dvfs = cpufreq_dvfs_ops;
-       cpu->hotplug = cpu_hotplus_ops;
-       cpu->tmu = tmu_ops;
+       if (!data)
+               return -EINVAL;
 
-       bus->dvfs = bus_dvfs_ops;
-       bus->tmu = tmu_ops;
+       power_funcs = *(hal_backend_power_funcs **)data;
 
-       gpu->dvfs = gpu_dvfs_ops;
-       gpu->tmu = tmu_ops;
+       power_funcs->cpu->dvfs = cpufreq_dvfs_ops;
+       power_funcs->cpu->hotplug = cpu_hotplus_ops;
+       power_funcs->cpu->tmu = tmu_ops;
 
-       battery->tmu = tmu_ops;
+       power_funcs->bus->dvfs = bus_dvfs_ops;
+       power_funcs->bus->tmu = tmu_ops;
 
-       memory->get_fault_around_bytes = memory_get_fault_around_bytes;
-       memory->set_fault_around_bytes = memory_set_fault_around_bytes;
+       power_funcs->gpu->dvfs = gpu_dvfs_ops;
+       power_funcs->gpu->tmu = tmu_ops;
 
-       /* Initialize hal_backend_power_funcs  */
-       power_funcs->cpu = cpu;
-       power_funcs->bus = bus;
-       power_funcs->gpu = gpu;
-       power_funcs->memory = memory;
-       power_funcs->battery = battery;
+       power_funcs->battery->tmu = tmu_ops;
 
-       *data = (void *)power_funcs;
+       power_funcs->memory->get_fault_around_bytes = memory_get_fault_around_bytes;
+       power_funcs->memory->set_fault_around_bytes = memory_set_fault_around_bytes;
 
        return 0;
-
-err_memory:
-       free(memory);
-err_gpu:
-       free(gpu);
-err_bus:
-       free(bus);
-err_cpu:
-       free(cpu);
-err_funcs:
-       free(power_funcs);
-
-       return ret;
 }
 
 static int power_exit(void *data)
 {
-       hal_backend_power_funcs *funcs;
-
-       if (!data)
-               return -EINVAL;
-
-       funcs = (hal_backend_power_funcs *)data;
-
-       free(funcs->cpu);
-       free(funcs->bus);
-       free(funcs->gpu);
-       free(funcs->memory);
-       free(funcs->battery);
-
-       free(funcs);
-
        return 0;
 }