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
b9273b04
Commit
b9273b04
authored
Aug 06, 2016
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sm_io/protocols/*/*_bsmp: restrict ops pointer access to inner class
parent
5127b1d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
7 deletions
+60
-7
bpm_server_classes.h
include/bpm_server_classes.h
+2
-0
sm_pr_bsmp.h
include/sm_pr_bsmp.h
+11
-4
sm_pr_bsmp.c
src/sm_io/protocols/ops/sm_pr_bsmp.c
+47
-3
No files found.
include/bpm_server_classes.h
View file @
b9273b04
...
...
@@ -81,6 +81,8 @@ typedef struct _smpr_t smpr_t;
typedef
struct
_smpr_spi_t
smpr_spi_t
;
/* Opaque smpr_i2c_t structure */
typedef
struct
_smpr_i2c_t
smpr_i2c_t
;
/* Opaque smpr_bsmp_t structure */
typedef
struct
_smpr_bsmp_t
smpr_bsmp_t
;
/* Forward smch_err_e declaration enumeration */
typedef
enum
_smch_err_e
smch_err_e
;
...
...
include/sm_pr_bsmp.h
View file @
b9273b04
...
...
@@ -12,10 +12,7 @@
extern
"C"
{
#endif
/* For use by llio_t general structure */
extern
const
smpr_proto_ops_t
smpr_proto_ops_bsmp
;
/***************** SMPR proto BSMP methods ************************************/
/***************** SMPR proto BSMP methods **********************/
/* Read/Write to RFFE vars by ID */
smpr_err_e
smpr_bsmp_read_var_by_id
(
smpr_t
*
self
,
uint32_t
id
,
uint8_t
*
data
,
...
...
@@ -29,6 +26,16 @@ smpr_err_e smpr_bsmp_func_exec_by_id (smpr_t *self, uint32_t id, uint8_t *write_
smpr_err_e
smpr_bsmp_read_curve_by_id
(
smpr_t
*
self
,
uint32_t
id
,
uint8_t
*
read_data
,
size_t
size
,
size_t
*
valid_bytes
);
/************************* Our Methods **************************/
/* Creates a new instance of the proto_bsmp */
smpr_bsmp_t
*
smpr_bsmp_new
();
/* Destroy an instance of the bsmp */
smpr_err_e
smpr_bsmp_destroy
(
smpr_bsmp_t
**
self_p
);
/* Get BSMP operations */
const
smpr_proto_ops_t
*
smpr_bsmp_get_ops
(
smpr_bsmp_t
*
self
);
#ifdef __cplusplus
}
#endif
...
...
src/sm_io/protocols/ops/sm_pr_bsmp.c
View file @
b9273b04
...
...
@@ -51,6 +51,12 @@ typedef struct {
struct
bsmp_group_list
*
groups_list
;
/* BSMP groups handler */
}
smpr_proto_bsmp_t
;
/* Protocol object specification */
struct
_smpr_bsmp_t
{
/* Must be located first */
smpr_proto_ops_t
proto_ops
;
/* BSMP protocol operations */
};
static
smpr_err_e
_smpr_proto_bsmp_get_handlers
(
smpr_t
*
self
);
static
int
_smpr_proto_bsmp_send
(
uint8_t
*
data
,
uint32_t
*
count
);
static
int
_smpr_proto_bsmp_recv
(
uint8_t
*
data
,
uint32_t
*
count
);
...
...
@@ -95,7 +101,7 @@ static smpr_err_e smpr_proto_bsmp_destroy (smpr_proto_bsmp_t **self_p)
/************ smpr_proto_ops_bsmp Implementation **********/
/* Open BSMP protocol */
int
bsmp_open
(
smpr_t
*
self
,
uint64_t
base
,
void
*
args
)
static
int
bsmp_open
(
smpr_t
*
self
,
uint64_t
base
,
void
*
args
)
{
(
void
)
args
;
assert
(
self
);
...
...
@@ -146,7 +152,7 @@ err_proto_handler_alloc:
}
/* Release BSMP protocol device */
int
bsmp_release
(
smpr_t
*
self
)
static
int
bsmp_release
(
smpr_t
*
self
)
{
assert
(
self
);
...
...
@@ -482,7 +488,7 @@ err_packet_header:
return
err
;
}
const
smpr_proto_ops_t
smpr_proto_ops_bsmp
=
{
static
const
smpr_proto_ops_t
smpr_proto_ops_bsmp
=
{
.
proto_name
=
"BSMP"
,
/* Protocol name */
.
proto_open
=
bsmp_open
,
/* Open device */
.
proto_release
=
bsmp_release
,
/* Release device */
...
...
@@ -501,3 +507,41 @@ const smpr_proto_ops_t smpr_proto_ops_bsmp = {
.
proto_write_dma
=
NULL
/* Write arbitrary block size data via DMA,
parameter size in bytes */
};
/************ Our methods implementation **********/
/* Creates a new instance of the proto_bsmp */
smpr_bsmp_t
*
smpr_bsmp_new
()
{
smpr_bsmp_t
*
self
=
(
smpr_bsmp_t
*
)
zmalloc
(
sizeof
*
self
);
ASSERT_ALLOC
(
self
,
err_smpr_bsmp_alloc
);
/* copy BSMP operations */
self
->
proto_ops
=
smpr_proto_ops_bsmp
;
return
self
;
err_smpr_bsmp_alloc:
return
NULL
;
}
/* Destroy an instance of the bsmp */
smpr_err_e
smpr_bsmp_destroy
(
smpr_bsmp_t
**
self_p
)
{
assert
(
self_p
);
if
(
*
self_p
)
{
smpr_bsmp_t
*
self
=
*
self_p
;
free
(
self
);
self_p
=
NULL
;
}
return
SMPR_SUCCESS
;
}
const
smpr_proto_ops_t
*
smpr_bsmp_get_ops
(
smpr_bsmp_t
*
self
)
{
assert
(
self
);
return
&
self
->
proto_ops
;
}
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