libocxl
Loading...
Searching...
No Matches
setup.c
Go to the documentation of this file.
1/*
2 * Copyright 2017 International Business Machines
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "libocxl_internal.h"
18#include <string.h>
19#include <stdlib.h>
20
29#ifdef TEST_ENVIRONMENT
37__attribute__ ((used)) static void ocxl_set_sys_path(const char *path)
38{
39 sys_path = path;
40}
41
49__attribute__ ((used)) static void ocxl_set_dev_path(const char *path)
50{
51 dev_path = path;
52}
53
54#endif // TEST_ENVIRONMENT
55
70void ocxl_enable_messages(uint64_t sources)
71{
72 verbose_errors = !!(sources & OCXL_ERRORS);
73 tracing = !!(sources & OCXL_TRACING);
74}
75
93void ocxl_set_error_message_handler(void (*handler)(ocxl_err error, const char *message))
94{
95 error_handler = handler;
96}
97
112{
113 switch (err) {
114 case OCXL_OK:
115 return "OK";
116
117 case OCXL_NO_MEM:
118 return "No memory";
119
120 case OCXL_NO_CONTEXT:
121 return "AFU context not available";
122
123 case OCXL_NO_IRQ:
124 return "AFU interrupt not available";
125
127 return "Internal error";
128
130 return "Already done";
131
133 return "Out of bounds";
134
136 return "No more contexts";
137
139 return "Invalid arguments";
140
141 default:
142 return "Unknown error";
143 }
144}
145
154const char *ocxl_info()
155{
156 return libocxl_info;
157}
158
const char * ocxl_err_to_string(ocxl_err err)
Convert an error value to a string.
Definition setup.c:111
void ocxl_enable_messages(uint64_t sources)
Enable messages from libocxl open calls.
Definition setup.c:70
const char * ocxl_info()
Get version & compilation information about LibOCXL.
Definition setup.c:154
void ocxl_set_error_message_handler(void(*handler)(ocxl_err error, const char *message))
Override the default handler for emitting error messages from open calls.
Definition setup.c:93
ocxl_err
Potential return values from ocxl_* functions.
Definition libocxl.h:92
@ OCXL_NO_MORE_CONTEXTS
No more contexts can be opened on the AFU.
Definition libocxl.h:101
@ OCXL_NO_IRQ
no further interrupts are available, or the interrupt is invalid
Definition libocxl.h:97
@ OCXL_INVALID_ARGS
One or more arguments are invalid.
Definition libocxl.h:102
@ OCXL_OUT_OF_BOUNDS
The action requested falls outside the permitted area.
Definition libocxl.h:100
@ OCXL_INTERNAL_ERROR
an internal error has occurred
Definition libocxl.h:98
@ OCXL_OK
The call succeeded.
Definition libocxl.h:93
@ OCXL_ALREADY_DONE
The action requested has already been performed.
Definition libocxl.h:99
@ OCXL_NO_MEM
An out of memory error occurred.
Definition libocxl.h:94
@ OCXL_NO_CONTEXT
The call requires an open context on the AFU.
Definition libocxl.h:96
#define OCXL_TRACING
Tracing requested.
Definition libocxl.h:41
#define OCXL_ERRORS
Error messages requested.
Definition libocxl.h:40