Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Mock Turtle
Commits
f17ee1e6
Commit
f17ee1e6
authored
Oct 13, 2014
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: remove trailing space
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
0b0673fb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
100 deletions
+60
-100
fmc-lib.c
list/lib/fmc-lib.c
+5
-9
fmc-lib.h
list/lib/fmc-lib.h
+9
-14
list-lib.c
list/lib/list-lib.c
+26
-35
list-lib.h
list/lib/list-lib.h
+4
-8
wrn-lib-private.h
list/lib/wrn-lib-private.h
+1
-5
wrn-lib.cpp
list/lib/wrn-lib.cpp
+14
-27
wrn-lib.h
list/lib/wrn-lib.h
+1
-2
No files found.
list/lib/fmc-lib.c
View file @
f17ee1e6
...
...
@@ -20,7 +20,6 @@ struct svec_dev {
pthread_mutex_t
lock
;
};
static
void
svec_lock
(
struct
svec_dev
*
dev
)
{
pthread_mutex_lock
(
&
dev
->
lock
);
...
...
@@ -56,7 +55,7 @@ static uint64_t generic_readq(struct fmc_dev *dev, uint64_t addr)
static
uint32_t
svec_readl
(
struct
fmc_dev
*
dev
,
uint64_t
addr
)
{
int
addr_fd
,
data_fd
;
struct
svec_dev
*
svec
=
(
struct
svec_dev
*
)
dev
->
priv
;
struct
svec_dev
*
svec
=
(
struct
svec_dev
*
)
dev
->
priv
;
char
str
[
1024
];
svec_lock
(
svec
);
sprintf
(
str
,
"/sys/bus/vme/devices/svec.%d/vme_addr"
,
svec
->
lun
);
...
...
@@ -87,7 +86,6 @@ static uint32_t svec_readl(struct fmc_dev *dev, uint64_t addr)
return
data
;
}
static
void
svec_writel
(
struct
fmc_dev
*
dev
,
uint32_t
data
,
uint64_t
addr
)
{
struct
svec_dev
*
svec
=
(
struct
svec_dev
*
)
dev
->
priv
;
...
...
@@ -119,7 +117,7 @@ static void *load_binary ( const char *filename, int *size )
{
FILE
*
f
=
fopen
(
filename
,
"rb"
);
if
(
!
f
)
return
NULL
;
return
NULL
;
fseek
(
f
,
0
,
SEEK_END
);
int
s
=
ftell
(
f
);
rewind
(
f
);
...
...
@@ -170,7 +168,6 @@ static int svec_reprogram ( struct fmc_dev *dev, const char *filename )
return
0
;
}
#define INTERCONNECT 0
#define DEVICE 1
#define BRIDGE 2
...
...
@@ -201,7 +198,7 @@ static uint32_t sdb_traverse (struct fmc_dev *dev, uint32_t base, uint32_t sdb_a
return
rv
;
break
;
}
case
DEVICE
:
case
DEVICE
:
{
uint64_t
dev_addr
=
base
+
dev
->
readq
(
dev
,
addr
+
8
);
uint64_t
dev_vendor
=
dev
->
readq
(
dev
,
addr
+
24
);
...
...
@@ -211,7 +208,7 @@ static uint32_t sdb_traverse (struct fmc_dev *dev, uint32_t base, uint32_t sdb_a
break
;
}
}
addr
+=
0x40
;
}
return
-
1
;
...
...
@@ -236,7 +233,6 @@ struct fmc_dev *fmc_svec_create(int lun)
struct
fmc_dev
*
dev
=
malloc
(
sizeof
(
struct
fmc_dev
));
struct
svec_dev
*
svec
=
malloc
(
sizeof
(
struct
svec_dev
));
dev
->
priv
=
svec
;
dev
->
readl
=
svec_readl
;
dev
->
writel
=
svec_writel
;
...
...
@@ -248,5 +244,5 @@ struct fmc_dev *fmc_svec_create(int lun)
svec
->
lun
=
lun
;
pthread_mutex_init
(
&
svec
->
lock
,
NULL
);
return
dev
;
}
list/lib/fmc-lib.h
View file @
f17ee1e6
...
...
@@ -7,36 +7,33 @@
extern
"C"
{
#endif
// use DMA when reading/writing the block
#define FMC_BLK_DMA_ENABLE (1<<0)
// don't increment DMA device address (not all plaftorms)
#define FMC_BLK_DMA_NO_INCREMENT (1<<1)
//
//
#define FMC_IRQ_USE_VIC (1<<0)
#define FMC_PGM_PROGRAMMED 1
#define FMC_PGM_BOOTLOADER_MODE 2
#define FMC_PGM_UNPROGRAMMED -1
#define FMC_MEM_MEZZANINE_EEPROM(x)
#define FMC_MEM_CARRIER_EEPROM(x)
#define FMC_MEM_CARRIER_FLASH(x)
#define FMC_MEM_MEZZANINE_EEPROM(x)
#define FMC_MEM_CARRIER_EEPROM(x)
#define FMC_MEM_CARRIER_FLASH(x)
struct
fmc_dev
{
void
(
*
writeb
)
(
struct
fmc_dev
*
,
uint8_t
,
uint64_t
addr
);
void
(
*
writeh
)
(
struct
fmc_dev
*
,
uint16_t
,
uint64_t
addr
);
void
(
*
writel
)
(
struct
fmc_dev
*
,
uint32_t
,
uint64_t
addr
);
void
(
*
writeq
)
(
struct
fmc_dev
*
,
uint64_t
,
uint64_t
addr
);
uint8_t
(
*
readb
)
(
struct
fmc_dev
*
,
uint64_t
addr
);
uint16_t
(
*
readh
)
(
struct
fmc_dev
*
,
uint64_t
addr
);
uint32_t
(
*
readl
)
(
struct
fmc_dev
*
,
uint64_t
addr
);
uint64_t
(
*
readq
)
(
struct
fmc_dev
*
,
uint64_t
addr
);
int
(
*
read_block
)
(
struct
fmc_dev
*
,
uint64_t
addr
,
void
*
buf
,
size_t
size
,
int
flags
);
int
(
*
write_block
)
(
struct
fmc_dev
*
,
uint64_t
addr
,
void
*
buf
,
size_t
size
,
int
flags
);
...
...
@@ -48,26 +45,24 @@ struct fmc_dev {
int
(
*
read_nv
)
(
struct
fmc_dev
*
,
int
mem
,
uint64_t
address
,
void
*
data
,
size_t
size
);
int
(
*
write_nv
)
(
struct
fmc_dev
*
,
int
mem
,
uint64_t
address
,
void
*
data
,
size_t
size
);
int
(
*
flush_nv
)
(
struct
fmc_dev
*
,
int
mem
);
uint32_t
(
*
sdb_find_device
)
(
struct
fmc_dev
*
,
uint64_t
vendor
,
uint32_t
dev_id
,
int
ordinal
);
int
(
*
enable_irq
)
(
struct
fmc_dev
*
,
int
irq_id
,
int
enable
,
int
flags
);
int
(
*
wait_irq
)
(
struct
fmc_dev
*
,
int
irq_id
,
int
flags
,
int
timeout_us
);
void
*
priv
;
};
struct
fmc_dev
*
fmc_svec_create
(
int
lun
);
// path format:
// svec:slot=NUM,lun=NUM
// spec:bus=NUM,dev=NUM
// etherbone:ip=IP_ADDR,port=PORT,interface=NETWORK_CARD
// raw:base=ADDR,size=SIZE
struct
fmc_dev
*
fmc_open
(
const
char
*
path
);
struct
fmc_dev
*
fmc_open
(
const
char
*
path
);
#ifdef __cplusplus
};
...
...
list/lib/list-lib.c
View file @
f17ee1e6
...
...
@@ -4,7 +4,6 @@
#include "wrn-lib.h"
#include "list-lib.h"
#define TDC_APPLICATION "rt/tdc/rt-tdc.bin"
#define FD_APPLICATION "rt/fd/rt-fd.bin"
...
...
@@ -23,7 +22,6 @@ struct list_node {
struct
wrn_dev
*
wrn
;
};
struct
list_timestamp
picos_to_ts
(
uint64_t
p
)
{
struct
list_timestamp
t
;
...
...
@@ -78,14 +76,12 @@ static int check_node_running( struct list_node *dev )
uint32_t rsp[2];
if ( cpu_cmd( n, 0, ID_TDC_CMD_PING, NULL, 0, rsp) == 2);
return rsp[0] == ID_TDC
return rsp[0] == ID_TDC
}
#endif
// private function used by list-init, move to the driver
void
list_boot_node
(
struct
list_node
*
dev
)
{
...
...
@@ -118,24 +114,23 @@ struct list_node* list_open_node_by_lun(int lun)
case
WRN_APPID_LIST_TDC_FD
:
// printf("Found TDC-FD node\n");
n
->
n_inputs
=
5
;
n
->
n_outputs
=
4
;
n
->
n_outputs
=
4
;
n
->
fd_cpu_control
[
0
]
=
wrn_open_slot
(
wrn
,
0
,
WRN_SLOT_OUTGOING
|
WRN_SLOT_INCOMING
);
n
->
fd_cpu_control
[
1
]
=
wrn_open_slot
(
wrn
,
1
,
WRN_SLOT_OUTGOING
|
WRN_SLOT_INCOMING
);
n
->
fd_cpu_logging
[
0
]
=
wrn_open_slot
(
wrn
,
2
,
WRN_SLOT_OUTGOING
);
n
->
fd_cpu_logging
[
1
]
=
wrn_open_slot
(
wrn
,
3
,
WRN_SLOT_OUTGOING
);
break
;
}
return
n
;
}
int
list_in_enable
(
struct
list_node
*
dev
,
int
input
,
int
enable
)
{
if
(
input
<
1
||
input
>
5
)
return
-
EINVAL
;
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_ENABLE
,
2
,
input
-
1
,
enable
?
1
:
0
);
}
...
...
@@ -157,7 +152,7 @@ int list_in_software_trigger ( struct list_node* dev, struct list_trigger_entry
uint32_t
rsp
[
128
];
int
n
=
rt_request
(
dev
,
0
,
ID_TDC_CMD_SOFTWARE_TRIGGER
,
(
uint32_t
*
)
trigger
,
sizeof
(
struct
list_trigger_entry
)
/
4
,
rsp
);
if
(
n
==
2
&&
rsp
[
0
]
==
ID_REP_ACK
)
return
0
;
else
...
...
@@ -168,9 +163,9 @@ int list_in_assign_trigger ( struct list_node *dev, int input, struct list_id *t
{
if
(
input
<
1
||
input
>
dev
->
n_inputs
)
return
-
EINVAL
;
if
(
trig
==
NULL
)
// un-assign
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_ASSIGN_TRIGGER
,
5
,
input
-
1
,
0
,
0
,
0
,
0
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_ASSIGN_TRIGGER
,
5
,
input
-
1
,
0
,
0
,
0
,
0
);
else
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_ASSIGN_TRIGGER
,
5
,
input
-
1
,
1
,
trig
->
system
,
trig
->
source_port
,
trig
->
trigger
);
}
...
...
@@ -188,18 +183,18 @@ int list_out_enable ( struct list_node *dev, int output, int enable )
int
list_in_arm
(
struct
list_node
*
dev
,
int
input
,
int
armed
)
{
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_ARM
,
2
,
input
-
1
,
armed
?
1
:
0
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_ARM
,
2
,
input
-
1
,
armed
?
1
:
0
);
}
int
list_in_reset_counters
(
struct
list_node
*
dev
,
int
input
)
{
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_RESET_COUNTERS
,
1
,
input
-
1
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_RESET_COUNTERS
,
1
,
input
-
1
);
}
int
list_in_set_timebase_offset
(
struct
list_node
*
dev
,
int
input
,
uint64_t
offset
)
{
struct
list_timestamp
t
=
picos_to_ts
(
offset
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_SET_TIMEBASE_OFFSET
,
4
,
input
-
1
,
t
.
seconds
,
t
.
cycles
,
t
.
frac
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_SET_TIMEBASE_OFFSET
,
4
,
input
-
1
,
t
.
seconds
,
t
.
cycles
,
t
.
frac
);
}
static
void
unbag_ts
(
uint32_t
*
buf
,
int
offset
,
struct
list_timestamp
*
ts
)
...
...
@@ -219,7 +214,7 @@ int list_in_get_state ( struct list_node *dev, int input, struct list_input_stat
req
[
0
]
=
input
-
1
;
int
n
=
rt_request
(
dev
,
0
,
ID_TDC_CMD_CHAN_GET_STATE
,
req
,
1
,
rsp
);
if
(
n
==
29
&&
rsp
[
0
]
==
ID_REP_STATE
)
{
state
->
input
=
input
;
...
...
@@ -235,7 +230,7 @@ int list_in_get_state ( struct list_node *dev, int input, struct list_input_stat
state
->
assigned_id
.
system
=
rsp
[
3
];
state
->
assigned_id
.
source_port
=
rsp
[
4
];
state
->
assigned_id
.
trigger
=
rsp
[
5
];
unbag_ts
(
rsp
,
6
,
&
state
->
delay
);
unbag_ts
(
rsp
,
12
,
&
state
->
last
);
unbag_ts
(
rsp
,
21
,
&
state
->
last_sent
.
ts
);
...
...
@@ -249,20 +244,18 @@ int list_in_get_state ( struct list_node *dev, int input, struct list_input_stat
}
else
return
-
1
;
}
int
list_in_set_delay
(
struct
list_node
*
dev
,
int
input
,
uint64_t
delay_ps
)
{
struct
list_timestamp
t
=
picos_to_ts
(
delay_ps
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_SET_DELAY
,
4
,
input
-
1
,
t
.
seconds
,
t
.
cycles
,
t
.
frac
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_SET_DELAY
,
4
,
input
-
1
,
t
.
seconds
,
t
.
cycles
,
t
.
frac
);
}
int
list_in_set_log_level
(
struct
list_node
*
dev
,
int
input
,
uint32_t
log_level
)
{
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_SET_LOG_LEVEL
,
2
,
input
-
1
,
log_level
);
return
rt_requestf
(
dev
,
0
,
ID_TDC_CMD_CHAN_SET_LOG_LEVEL
,
2
,
input
-
1
,
log_level
);
}
int
list_in_read_log
(
struct
list_node
*
dev
,
struct
list_log_entry
*
log
,
int
flags
,
int
input_mask
,
int
count
)
...
...
@@ -293,16 +286,14 @@ int list_in_read_log ( struct list_node *dev, struct list_log_entry *log, int fl
n_read
++
;
cur
++
;
}
}
else
}
else
break
;
}
return
n_read
;
}
int
list_out_trig_assign
(
struct
list_node
*
dev
,
struct
list_trigger_handle
*
handle
,
int
output
,
struct
list_id
*
trig
,
struct
list_id
*
condition
)
{
uint32_t
req
[
128
],
rsp
[
128
];
...
...
@@ -315,7 +306,7 @@ int list_out_trig_assign ( struct list_node *dev, struct list_trigger_handle *ha
req
[
1
]
=
trig
->
system
;
req
[
2
]
=
trig
->
source_port
;
req
[
3
]
=
trig
->
trigger
;
if
(
condition
)
{
req
[
5
]
=
condition
->
system
;
...
...
@@ -333,7 +324,7 @@ int list_out_trig_assign ( struct list_node *dev, struct list_trigger_handle *ha
handle
->
ptr_cond
=
rsp
[
3
];
handle
->
ptr_trig
=
rsp
[
4
];
}
return
0
;
}
else
return
-
1
;
...
...
@@ -346,9 +337,9 @@ int list_out_trig_remove ( struct list_node *dev, struct list_trigger_handle *ha
req
[
0
]
=
handle
->
channel
;
req
[
1
]
=
handle
->
ptr_cond
;
req
[
2
]
=
handle
->
ptr_trig
;
// printf("remove: %x %x %x\n", handle->channel, handle->ptr_cond, handle->ptr_trig);
int
n
=
rt_request
(
dev
,
1
,
ID_FD_CMD_CHAN_REMOVE_TRIGGER
,
req
,
3
,
rsp
);
if
(
n
==
2
&&
rsp
[
0
]
==
ID_REP_ACK
)
...
...
@@ -377,7 +368,7 @@ int list_out_trig_get_all (struct list_node *dev, int output, struct list_output
req
[
1
]
=
index
;
req
[
2
]
=
output
-
1
;
int
n
=
rt_request
(
dev
,
1
,
ID_FD_CMD_READ_HASH
,
req
,
3
,
rsp
);
if
(
n
!=
11
&&
rsp
[
0
]
!=
ID_REP_HASH_ENTRY
)
return
-
1
;
...
...
@@ -386,15 +377,16 @@ int list_out_trig_get_all (struct list_node *dev, int output, struct list_output
break
;
uint32_t
state
=
rsp
[
8
];
// printf("%d %d %x\n", bucket, index, state);
if
(
state
!=
HASH_ENT_EMPTY
&&
!
(
state
&
HASH_ENT_CONDITIONAL
))
{
struct
list_output_trigger_state
*
current
=
&
triggers
[
count
];
current
->
handle
.
channel
=
output
-
1
;
current
->
handle
.
ptr_cond
=
rsp
[
9
];
current
->
handle
.
ptr_trig
=
rsp
[
10
];
current
->
trigger
.
system
=
rsp
[
3
];
current
->
trigger
.
source_port
=
rsp
[
4
];
current
->
trigger
.
trigger
=
rsp
[
5
];
...
...
@@ -429,8 +421,7 @@ int list_out_trig_get_all (struct list_node *dev, int output, struct list_output
int
list_out_trig_set_delay
(
struct
list_node
*
dev
,
struct
list_trigger_handle
*
handle
,
uint64_t
delay_ps
)
{
struct
list_timestamp
t
=
picos_to_ts
(
delay_ps
);
return
rt_requestf
(
dev
,
1
,
ID_FD_CMD_CHAN_SET_DELAY
,
4
,
handle
->
channel
,
handle
->
ptr_trig
,
t
.
cycles
,
t
.
frac
);
}
...
...
@@ -443,7 +434,7 @@ int list_out_get_state ( struct list_node *dev, int output, struct list_output_s
req
[
0
]
=
output
-
1
;
int
n
=
rt_request
(
dev
,
1
,
ID_FD_CMD_CHAN_GET_STATE
,
req
,
1
,
rsp
);
if
(
n
==
29
&&
rsp
[
0
]
==
ID_REP_STATE
)
{
state
->
output
=
output
;
...
...
@@ -452,7 +443,7 @@ int list_out_get_state ( struct list_node *dev, int output, struct list_output_s
state
->
missed_pulses_deadtime
=
rsp
[
5
];
state
->
missed_pulses_overflow
=
rsp
[
6
];
state
->
rx_packets
=
rsp
[
27
];
state
->
rx_loopback
=
rsp
[
28
];
...
...
list/lib/list-lib.h
View file @
f17ee1e6
...
...
@@ -11,19 +11,19 @@ struct list_trigger_handle {
uint32_t
ptr_trig
;
int
channel
;
};
struct
list_input_state
{
int
input
;
uint32_t
flags
;
///> enum list_io_flags
uint32_t
log_level
;
///> enum list_log_level
int
mode
;
uint32_t
tagged_pulses
;
uint32_t
sent_triggers
;
uint32_t
sent_packets
;
struct
list_trigger_entry
last_sent
;
struct
list_trigger_entry
last_sent
;
struct
list_id
assigned_id
;
struct
list_timestamp
dead_time
;
struct
list_timestamp
delay
;
...
...
@@ -82,7 +82,6 @@ struct list_node* list_open_node_by_lun(int lun);
void
list_close_node
(
struct
list_node
*
node
);
/* 3.3.1a Enable/disable the input. */
//! Hardware enable/disable a LIST trigger input.
...
...
@@ -94,7 +93,6 @@ void list_close_node ( struct list_node *node );
int
list_in_enable
(
struct
list_node
*
dev
,
int
input
,
int
enable
);
int
list_in_is_enabled
(
struct
list_node
*
dev
,
int
input
);
/* 3.3.1b Get/set the Trigger/System/Source Port ID. Change the IDs during operation of the node. */
//! Assign/unassign a trigger ID to a given LIST input.
...
...
@@ -130,7 +128,6 @@ int list_in_set_trigger_mode ( struct list_node *, int input, int mode );
int
list_in_arm
(
struct
list_node
*
,
int
input
,
int
armed
);
/*
3.3.1h Log every trigger pulse sent out to the network. Each log message contains the input
number, sequence ID, trigger ID, trigger counter (since arm) and origin timestamp.
...
...
@@ -167,7 +164,6 @@ int list_in_reset_counters ( struct list_node *dev, int input );
int
list_in_set_log_level
(
struct
list_node
*
,
int
input
,
uint32_t
log_level
);
int
list_out_enable
(
struct
list_node
*
dev
,
int
output
,
int
enable
);
int
list_out_set_dead_time
(
struct
list_node
*
dev
,
int
output
,
uint64_t
dead_time_ps
);
...
...
@@ -190,4 +186,4 @@ int list_out_reset_counters ( struct list_node *dev, int output );
int
list_out_check_triggered
(
struct
list_node
*
,
int
output
);
//int list_out_wait_trigger ( struct list_node*, int output_mask, struct list_id *id );
#endif
#endif
list/lib/wrn-lib-private.h
View file @
f17ee1e6
...
...
@@ -18,7 +18,6 @@
typedef
std
::
vector
<
uint32_t
>
wrn_message
;
struct
wrn_mqueue_slot
{
int
size
;
int
width
;
...
...
@@ -34,7 +33,6 @@ struct wrn_mqueue {
struct
wrn_buffer
{
int
slot
;
int
total
;
wrn_buffer
(
int
slot
);
~
wrn_buffer
();
...
...
@@ -65,7 +63,7 @@ struct wrn_buffer {
{
return
msgs
.
size
();
}
pthread_mutex_t
mutex
;
std
::
deque
<
wrn_message
>
msgs
;
};
...
...
@@ -91,6 +89,4 @@ struct wrn_dev {
pthread_t
update_thread
;
};
#endif
list/lib/wrn-lib.cpp
View file @
f17ee1e6
...
...
@@ -34,7 +34,7 @@ int wrn_lib_init()
void
wrn_lib_exit
()
{
}
int
wrn_get_node_count
()
...
...
@@ -121,23 +121,21 @@ static void start_update_thread ( wrn_dev *dev )
struct
wrn_dev
*
wrn_open_by_lun
(
int
lun
)
{
struct
wrn_dev
*
dev
=
new
wrn_dev
();
dev
->
base
=
0xc0000
;
dev
->
fmc
=
fmc_svec_create
(
lun
);
dev
->
app_id
=
wrn_readl
(
dev
,
BASE_CPU_CSR
+
WRN_CPU_CSR_REG_APP_ID
);
DBG
(
"wrn_open: application ID = 0x%08x
\n
"
,
dev
->
app_id
);
init_cpus
(
dev
);
init_hmq
(
dev
);
start_update_thread
(
dev
);
start_update_thread
(
dev
);
return
dev
;
}
uint32_t
wrn_get_app_id
(
struct
wrn_dev
*
dev
)
{
return
dev
->
app_id
;
...
...
@@ -171,7 +169,7 @@ int wrn_cpu_reset ( struct wrn_dev *dev, uint32_t mask )
int
wrn_cpu_load_application
(
struct
wrn_dev
*
dev
,
int
cpu
,
const
void
*
code
,
size_t
code_size
)
{
int
i
;
wrn_cpu_stop
(
dev
,
(
1
<<
cpu
));
wrn_writel
(
dev
,
cpu
,
BASE_CPU_CSR
+
WRN_CPU_CSR_REG_CORE_SEL
);
...
...
@@ -180,7 +178,6 @@ int wrn_cpu_load_application ( struct wrn_dev *dev, int cpu, const void *code, s
uint32_t
*
code_c
=
(
uint32_t
*
)
code
;
for
(
i
=
0
;
i
<
8192
;
i
++
)
// fixme: memsize
{
wrn_writel
(
dev
,
i
,
BASE_CPU_CSR
+
WRN_CPU_CSR_REG_UADDR
);
...
...
@@ -235,8 +232,7 @@ static void *load_binary ( const char *filename, int *size )
return
buf
;
}
int
wrn_cpu_load_file
(
struct
wrn_dev
*
dev
,
int
cpu
,
const
char
*
filename
)
int
wrn_cpu_load_file
(
struct
wrn_dev
*
dev
,
int
cpu
,
const
char
*
filename
)
{
int
size
;
void
*
p
=
load_binary
(
filename
,
&
size
);
...
...
@@ -249,7 +245,6 @@ int wrn_cpu_load_file ( struct wrn_dev *dev, int cpu, const char *filename)
return
rv
;
}
//#define SLOT_OUT_MASK 0xffff
static
bool
do_rx
(
struct
wrn_dev
*
dev
,
wrn_message
&
msg
,
int
&
slot
)
...
...
@@ -287,7 +282,7 @@ static bool do_rx(struct wrn_dev *dev, wrn_message& msg, int& slot)
}
return
true
;
}
}
}
}
return
false
;
...
...
@@ -297,6 +292,7 @@ static bool do_rx(struct wrn_dev *dev, wrn_message& msg, int& slot)
bool
tx_ready
(
struct
wrn_dev
*
dev
,
int
slot
)
{
uint32_t
slot_stat
=
hmq_readl
(
dev
,
MQUEUE_BASE_IN
(
slot
),
MQUEUE_SLOT_STATUS
);
return
!
(
slot_stat
&
MQUEUE_SLOT_STATUS_FULL
);
}
...
...
@@ -311,8 +307,6 @@ void do_tx(struct wrn_dev *dev, const wrn_message& msg, int slot )
hmq_writel
(
dev
,
MQUEUE_BASE_IN
(
slot
),
MQUEUE_CMD_READY
,
MQUEUE_SLOT_COMMAND
);
}
int
update_mqueues
(
struct
wrn_dev
*
dev
)
{
wrn_message
msg
;
...
...
@@ -363,7 +357,6 @@ wrn_buffer::wrn_buffer (int slot_)
pthread_mutex_init
(
&
mutex
,
NULL
);
}
bool
wrn_buffer
::
lock
(
bool
blocking
)
{
if
(
blocking
)
...
...
@@ -385,9 +378,6 @@ wrn_buffer::~wrn_buffer()
pthread_mutex_destroy
(
&
mutex
);
}
int
wrn_open_slot
(
struct
wrn_dev
*
dev
,
int
slot
,
int
flags
)
{
int
fd
=
fd_base
;
...
...
@@ -399,10 +389,10 @@ int wrn_open_slot ( struct wrn_dev *dev, int slot, int flags )
conn
->
out
=
NULL
;
if
(
flags
&
WRN_SLOT_OUTGOING
)
conn
->
out
=
new
wrn_buffer
(
slot
);
if
(
flags
&
WRN_SLOT_INCOMING
)
conn
->
in
=
new
wrn_buffer
(
slot
);
dev
->
fds
[
fd
]
=
conn
;
DBG
(
"open slot %d, fd = %d
\n
"
,
slot
,
fd
);
return
fd
;
...
...
@@ -443,11 +433,11 @@ int wrn_recv ( struct wrn_dev *dev, int fd, uint32_t *buffer, size_t buf_size, i
usleep
(
1
);
}
conn
->
out
->
lock
(
true
);
conn
->
out
->
lock
(
true
);
wrn_message
msg
=
conn
->
out
->
pop
();
conn
->
out
->
unlock
();
int
n
=
std
::
min
(
buf_size
,
msg
.
size
());
for
(
int
i
=
0
;
i
<
n
;
i
++
)
buffer
[
i
]
=
msg
[
i
];
...
...
@@ -461,18 +451,15 @@ int wrn_send ( struct wrn_dev *dev, int fd, uint32_t *buffer, size_t buf_size, i
wrn_message
msg
;
for
(
int
i
=
0
;
i
<
buf_size
;
i
++
)
msg
.
push_back
(
buffer
[
i
]);
conn
->
in
->
lock
(
true
);
conn
->
in
->
lock
(
true
);
conn
->
in
->
push
(
msg
);
conn
->
in
->
unlock
();
return
buf_size
;
}
void
*
update_thread_entry
(
void
*
data
)
{
wrn_dev
*
dev
=
(
wrn_dev
*
)
data
;
...
...
list/lib/wrn-lib.h
View file @
f17ee1e6
...
...
@@ -39,7 +39,7 @@ void wrn_close_slot ( struct wrn_dev *, int slot );
#define WRN_FILTER_NOT 3
struct
wrn_message_filter
{
struct
rule
{
int
op
;
int
word_offset
;
...
...
@@ -58,7 +58,6 @@ int wrn_send ( struct wrn_dev *, int fd, uint32_t *buffer, size_t buf_size, int
//void wrn_update_mqueues( struct wrn_dev * dev );
#ifdef __cplusplus
};
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment