forked from aws/aws-fpga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfpga_hal_mbox.h
174 lines (157 loc) · 4.25 KB
/
fpga_hal_mbox.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
* Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file 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.
*/
/** @file
* FPGA HAL mailbox operations.
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <fpga_pci.h>
#define FPGA_MBOX_MSG_DATA_LEN 4096
/**
* Mailbox version info.
*/
struct fpga_hal_mbox_versions {
uint32_t sh_version;
};
/**
* Mailbox init structure.
*/
struct fpga_hal_mbox {
uint32_t timeout; /**< timeout, e.g. N x delay_mec */
uint32_t delay_msec;
};
/**
* Initialize the Mailbox
*
* @param[in] mbox the Mailbox init structure.
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_init(struct fpga_hal_mbox *mbox);
/**
* Reset the Mailbox to initial state (e.g. clear RX and TX event).
*
* @param[in] handle handle provided by fpga_pci_attach
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_reset(pci_bar_handle_t handle);
/**
* Get Mailbox versions.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in,out] ver Mailbox version info to return.
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_get_versions(pci_bar_handle_t handle,
struct fpga_hal_mbox_versions *ver);
/**
* Attach the Mailbox. Wrapper around fpga_hal_mbox_reset for attach
* semantics.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in] clear_state reset mbox to initial state.
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_attach(pci_bar_handle_t handle, bool clear_state);
/**
* Detach the Mailbox. Wrapper around fpga_hal_mbox_reset for detach
* semantics.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in] clear_state reset mbox to initial state.
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_detach(pci_bar_handle_t handle, bool clear_state);
/**
* Perform a synchronous read from the Mailbox using the timeout and delay_msec
* values from fpga_hal_mbox_init.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in,out] msg the msg buffer to use
* @param[in,out] len the msg length to set
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_read(pci_bar_handle_t handle, void *msg, uint32_t *len);
/**
* Perform a synchronous write to the Mailbox using the timeout and delay_msec
* values from fpga_hal_mbox_init.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in] msg the msg buffer to use
* @param[in] len the msg length to write
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_write(pci_bar_handle_t handle, void *msg, uint32_t len);
/**
* Perform an asynchronous (non-blocking) read from the Mailbox.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in,out] msg the msg buffer to use
* @param[in,out] len the msg length to set
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_read_async(pci_bar_handle_t handle,
void *msg, uint32_t *len);
/**
* Perform an asynchronous (non-blocking) write to the Mailbox.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in] msg the msg buffer to use
* @param[in] len the msg length to write
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_write_async(pci_bar_handle_t handle,
void *msg, uint32_t len);
/**
* Test and Clear (TC) asynchronous write acknowledgement.
* e.g. use this to check if an async write was ack'd by the peer.
* If the write was ack'd, clear the ack status within the Mailbox,
* and return the ack status.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in,out] ack the ack flag to set
*
* @returns
* 0 on success
* -1 on failure
*/
int fpga_hal_mbox_write_async_tc_ack(pci_bar_handle_t handle, bool *ack);