From a9cde31586cd92fe90ff1fb3e045166441ae71d6 Mon Sep 17 00:00:00 2001 From: chengjinsong2 Date: Mon, 28 Nov 2022 16:23:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81L0=E4=BA=A7=E5=93=81=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=94=B3=E8=AF=B7=E5=86=85=E5=AD=98=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengjinsong2 --- begetd.gni | 3 +++ services/etc/BUILD.gn | 12 ++++++++++++ services/etc/param/ohos.para | 2 -- services/etc/param/ohos.startup.para | 15 +++++++++++++++ services/param/base/BUILD.gn | 4 ++++ services/param/include/param_osadp.h | 4 +++- services/param/liteos/BUILD.gn | 8 ++++++++ services/param/liteos/param_osadp.c | 17 +++++++++++++++-- 8 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 services/etc/param/ohos.startup.para diff --git a/begetd.gni b/begetd.gni index 1e86e746..07ff1952 100644 --- a/begetd.gni +++ b/begetd.gni @@ -25,5 +25,8 @@ declare_args() { enable_ohos_startup_init_feature_loader = false config_ohos_startup_init_lite_data_path = "" + # config memory size for liteos-m + config_ohos_startup_init_lite_memory_size = 5120 + # boot_kernel_extended_cmdline for extend cmdline } diff --git a/services/etc/BUILD.gn b/services/etc/BUILD.gn index 8a482b1f..55b0952b 100755 --- a/services/etc/BUILD.gn +++ b/services/etc/BUILD.gn @@ -125,6 +125,17 @@ if (defined(ohos_lite)) { module_install_dir = "etc/param" } + ohos_prebuilt_para("ohos.startup.para") { + source = "//base/startup/init/services/etc/param/ohos.startup.para" + install_images = [ + "system", + "updater", + ] + part_name = "init" + subsystem_name = "startup" + module_install_dir = "etc/param" + } + ohos_prebuilt_para("ohos.para.dac") { source = "//base/startup/init/services/etc/param/ohos.para.dac" install_images = [ @@ -232,6 +243,7 @@ if (defined(ohos_lite)) { ":ohos.para", ":ohos.para.dac", ":ohos.para.size", + ":ohos.startup.para", ":ohos_const.para", ":passwd", ":syscap.json", diff --git a/services/etc/param/ohos.para b/services/etc/param/ohos.para index 493016f2..e93bbaca 100755 --- a/services/etc/param/ohos.para +++ b/services/etc/param/ohos.para @@ -20,8 +20,6 @@ const.debuggable=1 const.build.characteristics=default const.product.model=ohos const.product.name="OpenHarmony 3.2" -persist.sys.usb.config=hdc -persist.init.bootevent.enable=true const.sandbox=enable const.product.devicetype=default const.software.model=default diff --git a/services/etc/param/ohos.startup.para b/services/etc/param/ohos.startup.para new file mode 100644 index 00000000..1a039250 --- /dev/null +++ b/services/etc/param/ohos.startup.para @@ -0,0 +1,15 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. + +persist.sys.usb.config=hdc +persist.init.bootevent.enable=true \ No newline at end of file diff --git a/services/param/base/BUILD.gn b/services/param/base/BUILD.gn index b1aadaae..d012356b 100644 --- a/services/param/base/BUILD.gn +++ b/services/param/base/BUILD.gn @@ -69,6 +69,10 @@ if (defined(ohos_lite)) { "PARAMWORKSPACE_NEED_MUTEX", ] } + if (defined(config_ohos_startup_init_lite_memory_size)) { + defines += + [ "PARAM_WORKSPACE_MAX=${config_ohos_startup_init_lite_memory_size}" ] + } } } else { if (use_musl) { diff --git a/services/param/include/param_osadp.h b/services/param/include/param_osadp.h index ba7e7d02..861a3dd6 100755 --- a/services/param/include/param_osadp.h +++ b/services/param/include/param_osadp.h @@ -59,7 +59,9 @@ extern "C" { #ifdef STARTUP_INIT_TEST #define PARAM_WORKSPACE_MAX (1024 * 50) #else -#define PARAM_WORKSPACE_MAX (1024 * 30) +#ifndef PARAM_WORKSPACE_MAX +#define PARAM_WORKSPACE_MAX (1024 * 5) +#endif #endif #define PARAM_WORKSPACE_SMALL PARAM_WORKSPACE_MAX #define PARAM_WORKSPACE_DEF PARAM_WORKSPACE_MAX diff --git a/services/param/liteos/BUILD.gn b/services/param/liteos/BUILD.gn index ea03c3b9..3288e0ac 100644 --- a/services/param/liteos/BUILD.gn +++ b/services/param/liteos/BUILD.gn @@ -103,6 +103,10 @@ static_library("param_init_lite") { "PARAM_SUPPORT_CYCLE_CHECK", ] } + if (defined(config_ohos_startup_init_lite_memory_size)) { + defines += + [ "PARAM_WORKSPACE_MAX=${config_ohos_startup_init_lite_memory_size}" ] + } } static_library("param_client_lite") { @@ -148,5 +152,9 @@ static_library("param_client_lite") { include_dirs += [ "$root_out_dir/gen/init" ] defines += [ "PARAM_LOAD_CFG_FROM_CODE" ] } + if (defined(config_ohos_startup_init_lite_memory_size)) { + defines += + [ "PARAM_WORKSPACE_MAX=${config_ohos_startup_init_lite_memory_size}" ] + } } } diff --git a/services/param/liteos/param_osadp.c b/services/param/liteos/param_osadp.c index 3451c249..c6c59ee4 100644 --- a/services/param/liteos/param_osadp.c +++ b/services/param/liteos/param_osadp.c @@ -215,13 +215,26 @@ INIT_LOCAL_API int ParamMutexDelete(ParamMutex *mutex) #endif #ifdef __LITEOS_M__ +__attribute__((weak)) void* GetSysParamMem(uint32_t spaceSize) +{ + return malloc(spaceSize); +} + +__attribute__((weak)) void FreeSysParamMem(void *mem) +{ + if (mem == NULL) { + return; + } + free(mem); +} + INIT_LOCAL_API void *GetSharedMem(const char *fileName, MemHandle *handle, uint32_t spaceSize, int readOnly) { PARAM_CHECK(spaceSize <= PARAM_WORKSPACE_MAX, return NULL, "Invalid spaceSize %u", spaceSize); UNUSED(fileName); UNUSED(handle); UNUSED(readOnly); - return (void *)malloc(spaceSize); + return GetSysParamMem(spaceSize); } INIT_LOCAL_API void FreeSharedMem(const MemHandle *handle, void *mem, uint32_t dataSize) @@ -229,7 +242,7 @@ INIT_LOCAL_API void FreeSharedMem(const MemHandle *handle, void *mem, uint32_t d PARAM_CHECK(mem != NULL && handle != NULL, return, "Invalid mem or handle"); UNUSED(handle); UNUSED(dataSize); - free(mem); + FreeSysParamMem(mem); } INIT_LOCAL_API void paramMutexEnvInit(void) -- GitLab