Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 31 | namespace EthosU { |
| 32 | int eopen(const char *p, int) { |
| 33 | std::cout << "Opened filedescriptor for " << p; |
| 34 | return 1; |
| 35 | } |
| 36 | |
| 37 | int eclose(int) { |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | void *emmap(void *, size_t length, int, int, int, off_t) { |
| 42 | void *d = malloc(length); |
| 43 | return d; |
| 44 | } |
| 45 | |
| 46 | int emunmap(void *addr, size_t) { |
| 47 | free(addr); |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | int 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 | |
Per Åstrand | 5c05a33 | 2021-09-06 17:25:57 +0200 | [diff] [blame] | 79 | int epoll(struct pollfd *, nfds_t, int timeout_ms) { |
| 80 | int t = 1000 * timeout_ms / 2; |
| 81 | usleep(t); |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 82 | return 1; |
| 83 | } |
| 84 | } // namespace EthosU |