aboutsummaryrefslogtreecommitdiff
path: root/driver_library/src/ethosu_stub.cpp
blob: 9dfc02950e7bb369caf5c9e580b25b47c25210d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (c) 2020-2021 Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * 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
 *
 * 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 <uapi/ethosu.h>

#include <ethosu.hpp>
#include <exception>
#include <iostream>

#include <fcntl.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>

namespace EthosU {
int eopen(const char *p, int) {
    std::cout << "Opened filedescriptor for " << p;
    return 1;
}

int eclose(int) {
    return 0;
}

void *emmap(void *, size_t length, int, int, int, off_t) {
    void *d = malloc(length);
    return d;
}

int emunmap(void *addr, size_t) {
    free(addr);
    return 0;
}

int eioctl(int, unsigned long cmd, void *) {
    int result = 0;
    using namespace EthosU;

    switch (cmd) {
    case ETHOSU_IOCTL_PING:
        return result;
    case ETHOSU_IOCTL_VERSION_REQ:
        return result;
    case ETHOSU_IOCTL_CAPABILITIES_REQ:
        return result;
    case ETHOSU_IOCTL_BUFFER_CREATE:
        return result;
    case ETHOSU_IOCTL_BUFFER_SET:
        return result;
    case ETHOSU_IOCTL_BUFFER_GET:
        return result;
    case ETHOSU_IOCTL_NETWORK_CREATE:
        return result;
    case ETHOSU_IOCTL_INFERENCE_CREATE:
        return result;
    case ETHOSU_IOCTL_INFERENCE_STATUS:
        return result;
    default:
        throw EthosU::Exception("Unknown IOCTL");
    }
}

int epoll(struct pollfd *, nfds_t, int timeout) {
    sleep(timeout / 2);
    return 1;
}
} // namespace EthosU