1cc290419Sopenharmony_ci/*
2cc290419Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
3cc290419Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4cc290419Sopenharmony_ci * you may not use this file except in compliance with the License.
5cc290419Sopenharmony_ci * You may obtain a copy of the License at
6cc290419Sopenharmony_ci *
7cc290419Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8cc290419Sopenharmony_ci *
9cc290419Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10cc290419Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11cc290419Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cc290419Sopenharmony_ci * See the License for the specific language governing permissions and
13cc290419Sopenharmony_ci * limitations under the License.
14cc290419Sopenharmony_ci */
15cc290419Sopenharmony_ci#ifndef HDC_HOST_UNITY_H
16cc290419Sopenharmony_ci#define HDC_HOST_UNITY_H
17cc290419Sopenharmony_ci#include "host_common.h"
18cc290419Sopenharmony_ci
19cc290419Sopenharmony_cinamespace Hdc {
20cc290419Sopenharmony_ciclass HdcHostUnity : public HdcTaskBase {
21cc290419Sopenharmony_cipublic:
22cc290419Sopenharmony_ci    HdcHostUnity(HTaskInfo hTaskInfo);
23cc290419Sopenharmony_ci    virtual ~HdcHostUnity();
24cc290419Sopenharmony_ci    bool CommandDispatch(const uint16_t command, uint8_t *payload, const int payloadSize) override;
25cc290419Sopenharmony_ci    void StopTask() override;
26cc290419Sopenharmony_ci    bool ReadyForRelease() override;
27cc290419Sopenharmony_ci
28cc290419Sopenharmony_ciprivate:
29cc290419Sopenharmony_ci    struct ContextUnity {
30cc290419Sopenharmony_ci        bool enableLog;
31cc290419Sopenharmony_ci        uv_file fileLog;
32cc290419Sopenharmony_ci        uint64_t fileIOIndex;
33cc290419Sopenharmony_ci        uint64_t fileBufIndex;
34cc290419Sopenharmony_ci        bool hasFilelogClosed;
35cc290419Sopenharmony_ci        uv_fs_t fsClose;
36cc290419Sopenharmony_ci        HdcHostUnity *thisClass;
37cc290419Sopenharmony_ci    };
38cc290419Sopenharmony_ci    struct CtxUnityIO {
39cc290419Sopenharmony_ci        uv_fs_t fs;
40cc290419Sopenharmony_ci        uint8_t *bufIO;
41cc290419Sopenharmony_ci        ContextUnity *context;
42cc290419Sopenharmony_ci    };
43cc290419Sopenharmony_ci    static void OnFileIO(uv_fs_t *req);
44cc290419Sopenharmony_ci    static void OnFileClose(uv_fs_t *req);
45cc290419Sopenharmony_ci    bool InitLocalLog(const char *path);
46cc290419Sopenharmony_ci    bool AppendLocalLog(const char *bufLog, const int sizeLog);
47cc290419Sopenharmony_ci
48cc290419Sopenharmony_ci    ContextUnity opContext = {};
49cc290419Sopenharmony_ci};
50cc290419Sopenharmony_ci}  // namespace Hdc
51cc290419Sopenharmony_ci#endif  // HDC_HOST_UNITY_H