-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINR.c
141 lines (132 loc) · 3.17 KB
/
INR.c
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
/**
*@file INR.c
*@brief Global helper functions
*@author M.Ulbricht 2015
**/
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include "INR.h"
const uint8_t debug_enable = 1;
const uint8_t fpga_read_check = 1;
const uint8_t timelog_enable = 1;
struct timespec INR_LOG_lasttime;
volatile uint64_t INR_status = 0;
volatile uint64_t INR_NW_status = 0;
/**
*zero all global vars
*/
void INR_zerovars() {
INR_status = 0;
INR_NW_status = 0;
}
/**
*error if 0xffffffffffffffff is readed from fpga
*@param val value to check
*/
void
INR_CHECK_fpga_read_val (uint64_t val, const char *msg, uint8_t bit64)
{
if (fpga_read_check) {
if (bit64) {
if (val == 0xffffffffffffffff) {
INR_LOG_debug (loglevel_err"FPGA read check faild: %s", msg);
} else if (val == 0xffffffff) {
INR_LOG_debug (loglevel_err"FPGA read check faild: %s", msg);
}
}
}
}
//*****************************************************************************************************************
/**
*NW status management
*@param stat Status to set
*/
void
INR_NW_STATUS_set (uint64_t stat)
{
INR_NW_status |= stat;
}
//*****************************************************************************************************************
/**
*NW status management
*@param stat Status to set
*/
uint8_t
INR_NW_STATUS_get (uint64_t stat)
{
if (INR_NW_status & stat) {
return 1;
} else {
return 0;
}
}
//*****************************************************************************************************************
/**
*status management
*@param stat Status to set
*/
void
INR_STATUS_set (uint64_t stat)
{
INR_status |= stat;
}
//*****************************************************************************************************************
/**
*status management
*@param stat Status to set
*/
uint8_t
INR_STATUS_get (uint64_t stat)
{
if (INR_status & stat) {
return 1;
} else {
return 0;
}
}
void
INR_LOG_timelog_init ()
{
getnstimeofday (&INR_LOG_lasttime);
}
//*****************************************************************************************************************
/**
*central debug print
*@param strg message
*/
/*void
INR_LOG_debug (const char *strg, ...)
{
va_list format;
va_start (format, strg);
if (debug_enable) {
printk (KERN_WARNING "INR:");
vprintk (KERN_WARNING strg, format);
}
}
*
//*****************************************************************************************************************
/**
*central timelog print
*@param strg message
*/
void
INR_LOG_timelog (const char *strg, ...)
{
va_list format;
va_start (format, strg);
if (timelog_enable) {
struct timespec tmp;
getnstimeofday (&tmp);
printk ("INR_Time[%lds%ldns]Diff:[%lds,%ldns]:", tmp.tv_sec, tmp.tv_nsec, tmp.tv_sec - INR_LOG_lasttime.tv_sec, tmp.tv_nsec - INR_LOG_lasttime.tv_nsec);
INR_LOG_lasttime = tmp;
vprintk (strg, format);
}
}