Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
6058ee6a
Commit
6058ee6a
authored
Jul 17, 2015
by
danh-arm
Browse files
Merge pull request #335 from jcastillo-arm/jc/sh_write
Fix bug in semihosting write function
parents
1f06ca8a
31833aff
Changes
2
Hide whitespace changes
Inline
Side-by-side
drivers/io/io_semihosting.c
View file @
6058ee6a
...
@@ -183,7 +183,6 @@ static int sh_file_read(io_entity_t *entity, uintptr_t buffer, size_t length,
...
@@ -183,7 +183,6 @@ static int sh_file_read(io_entity_t *entity, uintptr_t buffer, size_t length,
static
int
sh_file_write
(
io_entity_t
*
entity
,
const
uintptr_t
buffer
,
static
int
sh_file_write
(
io_entity_t
*
entity
,
const
uintptr_t
buffer
,
size_t
length
,
size_t
*
length_written
)
size_t
length
,
size_t
*
length_written
)
{
{
int
result
=
IO_FAIL
;
long
sh_result
=
-
1
;
long
sh_result
=
-
1
;
long
file_handle
;
long
file_handle
;
size_t
bytes
=
length
;
size_t
bytes
=
length
;
...
@@ -196,13 +195,9 @@ static int sh_file_write(io_entity_t *entity, const uintptr_t buffer,
...
@@ -196,13 +195,9 @@ static int sh_file_write(io_entity_t *entity, const uintptr_t buffer,
sh_result
=
semihosting_file_write
(
file_handle
,
&
bytes
,
buffer
);
sh_result
=
semihosting_file_write
(
file_handle
,
&
bytes
,
buffer
);
if
(
sh_result
>=
0
)
{
*
length_written
=
length
-
bytes
;
*
length_written
=
sh_result
;
result
=
IO_SUCCESS
;
}
else
result
=
IO_FAIL
;
return
result
;
return
(
sh_
result
==
0
)
?
IO_SUCCESS
:
IO_FAIL
;
}
}
...
...
lib/semihosting/semihosting.c
View file @
6058ee6a
...
@@ -125,6 +125,7 @@ long semihosting_file_write(long file_handle,
...
@@ -125,6 +125,7 @@ long semihosting_file_write(long file_handle,
const
uintptr_t
buffer
)
const
uintptr_t
buffer
)
{
{
smh_file_read_write_block_t
write_block
;
smh_file_read_write_block_t
write_block
;
long
result
=
-
EINVAL
;
if
((
length
==
NULL
)
||
(
buffer
==
(
uintptr_t
)
NULL
))
if
((
length
==
NULL
)
||
(
buffer
==
(
uintptr_t
)
NULL
))
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -133,10 +134,12 @@ long semihosting_file_write(long file_handle,
...
@@ -133,10 +134,12 @@ long semihosting_file_write(long file_handle,
write_block
.
buffer
=
(
uintptr_t
)
buffer
;
/* cast away const */
write_block
.
buffer
=
(
uintptr_t
)
buffer
;
/* cast away const */
write_block
.
length
=
*
length
;
write_block
.
length
=
*
length
;
*
length
=
semihosting_call
(
SEMIHOSTING_SYS_WRITE
,
result
=
semihosting_call
(
SEMIHOSTING_SYS_WRITE
,
(
void
*
)
&
write_block
);
(
void
*
)
&
write_block
);
return
*
length
;
*
length
=
result
;
return
(
result
==
0
)
?
0
:
-
EINVAL
;
}
}
long
semihosting_file_close
(
long
file_handle
)
long
semihosting_file_close
(
long
file_handle
)
...
...
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