blob: 9dfc02950e7bb369caf5c9e580b25b47c25210d9 [file] [log] [blame]
Per Åstrandec3f2b02021-06-09 10:43:38 +02001/*
2 * Copyright (c) 2020-2021 Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include <uapi/ethosu.h>
20
21#include <ethosu.hpp>
22#include <exception>
23#include <iostream>
24
25#include <fcntl.h>
26#include <poll.h>
27#include <sys/ioctl.h>
28#include <sys/mman.h>
29#include <unistd.h>
30
31namespace EthosU {
32int eopen(const char *p, int) {
33 std::cout << "Opened filedescriptor for " << p;
34 return 1;
35}
36
37int eclose(int) {
38 return 0;
39}
40
41void *emmap(void *, size_t length, int, int, int, off_t) {
42 void *d = malloc(length);
43 return d;
44}
45
46int emunmap(void *addr, size_t) {
47 free(addr);
48 return 0;
49}
50
51int eioctl(int, unsigned long cmd, void *) {
52 int result = 0;
53 using namespace EthosU;
54
55 switch (cmd) {
56 case ETHOSU_IOCTL_PING:
57 return result;
58 case ETHOSU_IOCTL_VERSION_REQ:
59 return result;
60 case ETHOSU_IOCTL_CAPABILITIES_REQ:
61 return result;
62 case ETHOSU_IOCTL_BUFFER_CREATE:
63 return result;
64 case ETHOSU_IOCTL_BUFFER_SET:
65 return result;
66 case ETHOSU_IOCTL_BUFFER_GET:
67 return result;
68 case ETHOSU_IOCTL_NETWORK_CREATE:
69 return result;
70 case ETHOSU_IOCTL_INFERENCE_CREATE:
71 return result;
72 case ETHOSU_IOCTL_INFERENCE_STATUS:
73 return result;
74 default:
75 throw EthosU::Exception("Unknown IOCTL");
76 }
77}
78
79int epoll(struct pollfd *, nfds_t, int timeout) {
80 sleep(timeout / 2);
81 return 1;
82}
83} // namespace EthosU