Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
Beam Positoning Monitor - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
Beam Positoning Monitor - Software
Commits
d08e75c4
Commit
d08e75c4
authored
Feb 20, 2015
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hal/*: WIP 2 on github issue #79
parent
662deb67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
19 deletions
+51
-19
dev_io_core.c
hal/dev_io/dev_io_core.c
+18
-9
hal_utils.c
hal/hal_utils/hal_utils.c
+27
-8
hal_utils.h
hal/hal_utils/hal_utils.h
+6
-2
No files found.
hal/dev_io/dev_io_core.c
View file @
d08e75c4
...
...
@@ -289,8 +289,13 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint32_t base,
/* Stringify ID */
DBE_DEBUG
(
DBG_DEV_IO
|
DBG_LVL_TRACE
,
"[dev_io_core:register_sm] Stringify hash ID
\n
"
);
char
*
key
=
halutils_concat_strings
(
smio_mod_dispatch
[
th_args
->
smio_id
].
name
,
inst_id
,
''
);
char
*
inst_id_str
=
halutils_stringify_dec_key
(
inst_id
);
ASSERT_ALLOC
(
inst_id_str
,
err_inst_id_str_alloc
);
char
*
key
=
halutils_concat_strings_no_sep
(
smio_mod_dispatch
[
th_args
->
smio_id
].
name
,
inst_id_str
);
/* We don't need this anymore */
free
(
inst_id_str
);
inst_id_str
=
NULL
;
ASSERT_ALLOC
(
key
,
err_key_alloc
);
DBE_DEBUG
(
DBG_DEV_IO
|
DBG_LVL_TRACE
,
...
...
@@ -342,6 +347,8 @@ err_smio_service_alloc:
err_pipe_hash_insert:
free
(
key
);
err_key_alloc:
free
(
inst_id_str
);
err_inst_id_str_alloc:
/* This is safe to call more than once */
_devio_destroy_smio
(
self
,
smio_id
);
err_spawn_smio_thread:
...
...
@@ -358,13 +365,11 @@ devio_err_e devio_register_all_sm (devio_t *self)
return
DEVIO_ERR_FUNC_NOT_IMPL
;
}
devio_err_e
devio_unregister_sm
(
devio_t
*
self
,
uint32_t
smio_id
,
uint32_t
inst_id
)
devio_err_e
devio_unregister_sm
(
devio_t
*
self
,
const
char
*
smio_key
)
{
(
void
)
self
;
(
void
)
smio_id
;
(
void
)
inst_id
;
return
DEVIO_ERR_FUNC_NOT_IMPL
;
_devio_destroy_smio
(
self
,
smio_key
);
return
DEVIO_ERR_FUNC_NOT_IMPL
;
}
devio_err_e
devio_unregister_all_sm
(
devio_t
*
self
)
...
...
@@ -540,6 +545,8 @@ err_hash_keys_alloc:
return
;
}
/* smio_key is the name of the SMIO + instance number, e.g.,
* FMC130M_4CH0*/
static
void
_devio_destroy_smio
(
devio_t
*
self
,
const
char
*
smio_key
)
{
assert
(
self
);
...
...
@@ -559,14 +566,16 @@ static void _devio_destroy_smio (devio_t *self, const char *smio_key)
ASSERT_TEST
(
zerr
==
0
,
"Could not send self-destruct message to SMIO instance"
,
err_send_msg
);
DBE_DEBUG
(
DBG_DEV_MNGR
|
DBG_LVL_INFO
,
"[dev_io_core] Self-destruct message "
"to SMIO %s sent"
,
smio_key
);
/* Finally, remove the pipe from hash */
zhash_delete
(
self
->
sm_io_h
,
key_c
);
zhash_delete
(
self
->
sm_io_h
,
smio_key
);
err_send_msg:
zmsg_destroy
(
&
send_msg
);
err_msg_alloc:
err_hash_lookup:
free
(
key_c
);
err_key_alloc:
return
;
}
...
...
hal/hal_utils/hal_utils.c
View file @
d08e75c4
...
...
@@ -36,7 +36,7 @@
halutils_err_str (err_type))
static
char
*
_halutils_concat_strings_raw
(
const
char
*
str1
,
const
char
*
str2
,
const
char
*
str3
,
char
sep
);
const
char
*
str3
,
bool
with_sep
,
char
sep
)
uint32_t
num_to_str_len
(
uint32_t
key
,
uint32_t
base
)
{
...
...
@@ -91,23 +91,37 @@ char *halutils_stringify_hex_key (uint32_t key)
#define SEPARATOR_BYTES 1
/* FIXME: poorly written */
static
char
*
_halutils_concat_strings_raw
(
const
char
*
str1
,
const
char
*
str2
,
const
char
*
str3
,
char
sep
)
const
char
*
str3
,
bool
with_sep
,
char
sep
)
{
assert
(
str1
);
assert
(
str2
);
uint32_t
num_sep_bytes
=
(
with_sep
)
?
SEPARATOR_BYTES
:
0
;
char
*
str
=
NULL
;
if
(
str3
!=
NULL
)
{
str
=
zmalloc
(
strlen
(
str1
)
+
strlen
(
str2
)
+
strlen
(
str3
)
+
SEPARATOR_BYTES
/* separator length */
+
1
/* \0 */
);
num_sep_bytes
/* separator length */
+
1
/* \0 */
);
ASSERT_ALLOC
(
str
,
err_str3_alloc
);
sprintf
(
str
,
"%s%c%s%s"
,
str1
,
sep
,
str2
,
str3
);
if
(
with_sep
)
{
sprintf
(
str
,
"%s%c%s%s"
,
str1
,
sep
,
str2
,
str3
);
}
else
{
sprintf
(
str
,
"%s%s%s"
,
str1
,
str2
,
str3
);
}
}
else
{
str
=
zmalloc
(
strlen
(
str1
)
+
strlen
(
str2
)
+
SEPARATOR_BYTES
/* separator length */
+
1
/* \0 */
);
num_sep_bytes
/* separator length */
+
1
/* \0 */
);
ASSERT_ALLOC
(
str
,
err_str2_alloc
);
sprintf
(
str
,
"%s%c%s"
,
str1
,
sep
,
str2
);
if
(
with_sep
)
{
sprintf
(
str
,
"%s%c%s"
,
str1
,
sep
,
str2
);
}
else
{
sprintf
(
str
,
"%s%s"
,
str1
,
str2
);
}
}
return
str
;
...
...
@@ -119,11 +133,16 @@ err_str2_alloc:
char
*
halutils_concat_strings
(
const
char
*
str1
,
const
char
*
str2
,
char
sep
)
{
return
_halutils_concat_strings_raw
(
str1
,
str2
,
NULL
,
sep
);
return
_halutils_concat_strings_raw
(
str1
,
str2
,
NULL
,
true
,
sep
);
}
char
*
halutils_concat_strings_no_sep
(
const
char
*
str1
,
const
char
*
str2
)
{
return
_halutils_concat_strings_raw
(
str1
,
str2
,
NULL
,
false
,
0
);
}
char
*
halutils_concat_strings3
(
const
char
*
str1
,
const
char
*
str2
,
const
char
*
str3
,
char
sep
)
{
return
_halutils_concat_strings_raw
(
str1
,
str2
,
str3
,
sep
);
return
_halutils_concat_strings_raw
(
str1
,
str2
,
str3
,
true
,
sep
);
}
hal/hal_utils/hal_utils.h
View file @
d08e75c4
...
...
@@ -31,11 +31,15 @@ char *halutils_stringify_dec_key (uint32_t key);
/* Allocates a string with the necessary size to fit an hexadecimal key */
char
*
halutils_stringify_hex_key
(
uint32_t
key
);
/* Concatenates 2 strings tog
het
er with a separator. returns the string if
/* Concatenates 2 strings tog
eth
er with a separator. returns the string if
* OK, NULL in case of error */
char
*
halutils_concat_strings
(
const
char
*
str1
,
const
char
*
str2
,
char
sep
);
/* Concatenates 3 strings togheter with a separator between the first and second
/* Concatenates 2 strings together without a separator. returns the string if
* OK, NULL in case of error */
char
*
halutils_concat_strings_no_sep
(
const
char
*
str1
,
const
char
*
str2
);
/* Concatenates 3 strings together with a separator between the first and second
* strings. returns the string if OK, NULL in case of error */
char
*
halutils_concat_strings3
(
const
char
*
str1
,
const
char
*
str2
,
const
char
*
str3
,
char
sep
);
...
...
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