1 /*
2 * Copyright (c) 2022 Talkweb Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <stdbool.h>
16 #include "uart.h"
17 #include "watch_dog.h"
18 #include "devmgr_service_start.h"
19 #include "hiview_def.h"
20 #include "hiview_output_log.h"
21
22 #define BUFLEN 2
23
HilogProc_Impl(const HiLogContent * hilogContent,uint32_t len)24 bool HilogProc_Impl(const HiLogContent *hilogContent, uint32_t len)
25 {
26 char tempOutStr[LOG_FMT_MAX_LEN];
27 tempOutStr[0] = 0, tempOutStr[1] = 0;
28 if (LogContentFmt(tempOutStr, sizeof(tempOutStr), hilogContent) > 0) {
29 printf(tempOutStr);
30 }
31 return true;
32 }
33
HiLogWriteInternal(const char * buffer,size_t bufLen)34 int HiLogWriteInternal(const char *buffer, size_t bufLen)
35 {
36 if (!buffer) {
37 return -1;
38 }
39
40 if (bufLen < BUFLEN) {
41 return 0;
42 }
43
44 if (buffer[bufLen - 2] != '\n') {
45 *((char *)buffer + bufLen - 1) = '\n';
46 }
47 printf("%s\n", buffer);
48 return 0;
49 }
50
sys_service_config()51 void sys_service_config()
52 {
53 HiviewRegisterHilogProc(HilogProc_Impl);
54
55 #ifdef LOSCFG_WATCH_DOG
56 watch_dog_init(1100);
57 #endif
58
59 #ifdef LOSCFG_DRIVERS_HDF
60 DeviceManagerStart();
61 #endif
62
63 #ifdef LOSCFG_SHELL
64 ShellUartInit();
65 #endif
66 }