dump_syspara.c 2.8 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright (c) 2020 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.
 */

#include "dump_syspara.h"
#include <stdio.h>
#include <stdlib.h>
H
hhj 已提交
19
#include "securec.h"
M
mamingshuai 已提交
20 21 22 23 24
#include "parameter.h"
#if defined(__LITEOS_RISCV__)
#include "wifiiot_at.h"
#endif

L
lanxueyuan 已提交
25 26
#define API_VERSION_LEN 10

N
Neil Chen 已提交
27
static const char* GetSdkApiLevel(void)
L
lanxueyuan 已提交
28 29 30 31
{
    static char sdkApiVersion[API_VERSION_LEN] = {0};
    int sdkApi = GetSdkApiVersion();
    sprintf_s(sdkApiVersion, API_VERSION_LEN, "%d", sdkApi);
H
hhj 已提交
32
    return (const char*)sdkApiVersion;
L
lanxueyuan 已提交
33 34
}

N
Neil Chen 已提交
35
static const char* GetFirstApiLevel(void)
L
lanxueyuan 已提交
36 37
{
    static char firstApiVersion[API_VERSION_LEN] = {0};
L
lanxueyuan 已提交
38
    int firstApi = GetFirstApiVersion();
L
lanxueyuan 已提交
39
    sprintf_s(firstApiVersion, API_VERSION_LEN, "%d", firstApi);
H
hhj 已提交
40
    return (const char*)firstApiVersion;
L
lanxueyuan 已提交
41 42
}

M
mamingshuai 已提交
43
static const SysParaInfoItem SYSPARA_LIST[] = {
L
lanxueyuan 已提交
44
    {"DeviceType", GetDeviceType},
M
mamingshuai 已提交
45 46 47 48 49 50 51 52
    {"Manufacture", GetManufacture},
    {"Brand", GetBrand},
    {"MarketName", GetMarketName},
    {"ProductSeries", GetProductSeries},
    {"ProductModel", GetProductModel},
    {"SoftwareModel", GetSoftwareModel},
    {"HardwareModel", GetHardwareModel},
    {"Serial", GetSerial},
L
lanxueyuan 已提交
53
    {"OSFullName", GetOSFullName},
M
mamingshuai 已提交
54 55 56 57
    {"DisplayVersion", GetDisplayVersion},
    {"BootloaderVersion", GetBootloaderVersion},
    {"GetSecurityPatchTag", GetSecurityPatchTag},
    {"AbiList", GetAbiList},
L
lanxueyuan 已提交
58 59
    {"SdkApiVersion", GetSdkApiLevel},
    {"FirstApiVersion", GetFirstApiLevel},
M
mamingshuai 已提交
60 61 62 63 64 65 66 67 68
    {"IncrementalVersion", GetIncrementalVersion},
    {"VersionId", GetVersionId},
    {"BuildType", GetBuildType},
    {"BuildUser", GetBuildUser},
    {"BuildHost", GetBuildHost},
    {"BuildTime", GetBuildTime},
    {"BuildRootHash", GetBuildRootHash},
};

N
Neil Chen 已提交
69
int QuerySysparaCmd(void)
M
mamingshuai 已提交
70 71 72
{
    int index = 0;
    int dumpInfoItemNum = (sizeof(SYSPARA_LIST) / sizeof(SysParaInfoItem));
H
hhj 已提交
73
    const char *temp = NULL;
M
mamingshuai 已提交
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    int (*pfnPrintf)(const char *format, ...) = NULL;
#if defined(__LITEOS_RISCV__)
    pfnPrintf = &AtPrintf;
#else
    pfnPrintf = &printf;
#endif

    pfnPrintf("Begin dump syspara\r\n");
    pfnPrintf("=======================\r\n");
    while (index < dumpInfoItemNum) {
        temp = SYSPARA_LIST[index].getInfoValue();
        pfnPrintf("%s:%s\r\n", SYSPARA_LIST[index].infoName, temp);
        index++;
    }
    pfnPrintf("=======================\r\n");
    pfnPrintf("End dump syspara\r\n");
    pfnPrintf = NULL;
    return 0;
}