Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
openocd
Commits
28f088dc
Commit
28f088dc
authored
Aug 10, 2011
by
Stefan Mahr
Committed by
Øyvind Harboe
Aug 12, 2011
Browse files
target: add helper functions to get/set u16 or u32 array from/to buffer
parent
85cf2986
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/target/target.c
View file @
28f088dc
...
...
@@ -348,6 +348,38 @@ static void target_buffer_set_u8(struct target *target, uint8_t *buffer, uint8_t
*
buffer
=
value
;
}
/* write a uint32_t array to a buffer in target memory endianness */
void
target_buffer_get_u32_array
(
struct
target
*
target
,
const
uint8_t
*
buffer
,
uint32_t
count
,
uint32_t
*
dstbuf
)
{
uint32_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
dstbuf
[
i
]
=
target_buffer_get_u32
(
target
,
&
buffer
[
i
*
4
]);
}
/* write a uint16_t array to a buffer in target memory endianness */
void
target_buffer_get_u16_array
(
struct
target
*
target
,
const
uint8_t
*
buffer
,
uint32_t
count
,
uint16_t
*
dstbuf
)
{
uint32_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
dstbuf
[
i
]
=
target_buffer_get_u16
(
target
,
&
buffer
[
i
*
2
]);
}
/* write a uint32_t array to a buffer in target memory endianness */
void
target_buffer_set_u32_array
(
struct
target
*
target
,
uint8_t
*
buffer
,
uint32_t
count
,
uint32_t
*
srcbuf
)
{
uint32_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
target_buffer_set_u32
(
target
,
&
buffer
[
i
*
4
],
srcbuf
[
i
]);
}
/* write a uint16_t array to a buffer in target memory endianness */
void
target_buffer_set_u16_array
(
struct
target
*
target
,
uint8_t
*
buffer
,
uint32_t
count
,
uint16_t
*
srcbuf
)
{
uint32_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
target_buffer_set_u16
(
target
,
&
buffer
[
i
*
2
],
srcbuf
[
i
]);
}
/* return a pointer to a configured target; id is name or number */
struct
target
*
get_target
(
const
char
*
id
)
{
...
...
src/target/target.h
View file @
28f088dc
...
...
@@ -524,6 +524,11 @@ void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t valu
void
target_buffer_set_u24
(
struct
target
*
target
,
uint8_t
*
buffer
,
uint32_t
value
);
void
target_buffer_set_u16
(
struct
target
*
target
,
uint8_t
*
buffer
,
uint16_t
value
);
void
target_buffer_get_u32_array
(
struct
target
*
target
,
const
uint8_t
*
buffer
,
uint32_t
count
,
uint32_t
*
dstbuf
);
void
target_buffer_get_u16_array
(
struct
target
*
target
,
const
uint8_t
*
buffer
,
uint32_t
count
,
uint16_t
*
dstbuf
);
void
target_buffer_set_u32_array
(
struct
target
*
target
,
uint8_t
*
buffer
,
uint32_t
count
,
uint32_t
*
srcbuf
);
void
target_buffer_set_u16_array
(
struct
target
*
target
,
uint8_t
*
buffer
,
uint32_t
count
,
uint16_t
*
srcbuf
);
int
target_read_u32
(
struct
target
*
target
,
uint32_t
address
,
uint32_t
*
value
);
int
target_read_u16
(
struct
target
*
target
,
uint32_t
address
,
uint16_t
*
value
);
int
target_read_u8
(
struct
target
*
target
,
uint32_t
address
,
uint8_t
*
value
);
...
...
Write
Preview
Supports
Markdown
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