forked from ANSSI-FR/IPECC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw_accelerator_driver_ipecc_platform.h
78 lines (68 loc) · 2.58 KB
/
hw_accelerator_driver_ipecc_platform.h
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
/*
* Copyright (C) 2023 - This file is part of IPECC project
*
* Authors:
* Karim KHALFALLAH <[email protected]>
* Ryad BENADJILA <[email protected]>
*
* Contributors:
* Adrian THILLARD
* Emmanuel PROUFF
*
* This software is licensed under GPL v2 license.
* See LICENSE file at the root folder of the project.
*/
#ifndef __HW_ACCELERATOR_DRIVER_PLATFORM_H__
#define __HW_ACCELERATOR_DRIVER_PLATFORM_H__
#include <stdint.h>
#if defined(WITH_EC_HW_ACCELERATOR) && !defined(WITH_EC_HW_SOCKET_EMUL)
/* Hardware accelerator driver platform specific stuff.
*
* The physical address of the IP should be 0x40000000, but depending on
* the OS/environment access method (standalone, Linux with /dev/mem, Linux with
* UIO, etc.) this may change. Anyhow, the relative mapping of the registers should
* remain fixed once this base address is known.
*/
#if defined(WITH_EC_HW_STANDALONE) && (defined(WITH_EC_HW_UIO) || defined(WITH_EC_HW_DEVMEM))
#error "WITH_EC_HW_STANDALONE, WITH_EC_HW_UIO and WITH_EC_HW_DEVMEM are mutually exclusive!"
#endif
#if defined(WITH_EC_HW_UIO) && (defined(WITH_EC_HW_STANDALONE) || defined(WITH_EC_HW_DEVMEM))
#error "WITH_EC_HW_STANDALONE, WITH_EC_HW_UIO and WITH_EC_HW_DEVMEM are mutually exclusive!"
#endif
#if defined(WITH_EC_HW_DEVMEM) && (defined(WITH_EC_HW_UIO) || defined(WITH_EC_HW_STANDALONE))
#error "WITH_EC_HW_STANDALONE, WITH_EC_HW_UIO and WITH_EC_HW_DEVMEM are mutually exclusive!"
#endif
#if !defined(WITH_EC_HW_STANDALONE) && !defined(WITH_EC_HW_UIO) && !defined(WITH_EC_HW_DEVMEM)
#error "One of WITH_EC_HW_STANDALONE, WITH_EC_HW_UIO or WITH_EC_HW_DEVMEM must be set for the driver!"
#endif
#if defined(WITH_EC_HW_UIO) || defined(WITH_EC_HW_DEVMEM)
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <errno.h>
#endif
#if defined(WITH_EC_HW_STANDALONE)
#include <stddef.h>
#endif
/* Log handling on the platform
* (usually printf, adapt)
*/
#if defined(WITH_EC_HW_DEBUG)
#include <stdio.h>
#define log_print(...) printf(__VA_ARGS__)
#else
#if defined(WITH_EC_HW_STANDALONE) && defined(WITH_EC_HW_STANDALONE_XILINX)
#include "xil_printf.h"
#define log_print(...) xil_printf(__VA_ARGS__)
#else
#define log_print(...)
#endif
#endif /* WITH_EC_HW_DEBUG */
/* Setup the driver depending on the environment,
* and set the base address of the driver mapping.
*/
int hw_driver_setup(volatile uint8_t **base_addr_p, volatile uint8_t **pseudotrng_base_addr_p);
#endif /* WITH_EC_HW_ACCELERATOR */
#endif /* __HW_ACCELERATOR_DRIVER_PLATFORM_H__ */