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
1a2ee045
Commit
1a2ee045
authored
Oct 26, 2015
by
danh-arm
Browse files
Merge pull request #414 from jcastillo-arm/jc/io_ret_values
Use standard error code definitions
parents
84ab33e1
78460a05
Changes
5
Show whitespace changes
Inline
Side-by-side
bl2/bl2_main.c
View file @
1a2ee045
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include <auth_mod.h>
#include <auth_mod.h>
#include <bl_common.h>
#include <bl_common.h>
#include <debug.h>
#include <debug.h>
#include <errno.h>
#include <platform.h>
#include <platform.h>
#include <platform_def.h>
#include <platform_def.h>
#include <stdint.h>
#include <stdint.h>
...
@@ -239,7 +240,7 @@ void bl2_main(void)
...
@@ -239,7 +240,7 @@ void bl2_main(void)
e
=
load_bl32
(
bl2_to_bl31_params
);
e
=
load_bl32
(
bl2_to_bl31_params
);
if
(
e
)
{
if
(
e
)
{
if
(
e
==
LOAD_AUTH_ERR
)
{
if
(
e
==
-
EAUTH
)
{
ERROR
(
"Failed to authenticate BL3-2
\n
"
);
ERROR
(
"Failed to authenticate BL3-2
\n
"
);
panic
();
panic
();
}
else
{
}
else
{
...
...
common/bl_common.c
View file @
1a2ee045
...
@@ -207,7 +207,7 @@ int load_image(meminfo_t *mem_layout,
...
@@ -207,7 +207,7 @@ int load_image(meminfo_t *mem_layout,
uintptr_t
image_spec
;
uintptr_t
image_spec
;
size_t
image_size
;
size_t
image_size
;
size_t
bytes_read
;
size_t
bytes_read
;
int
io_result
=
IO_FAIL
;
int
io_result
;
assert
(
mem_layout
!=
NULL
);
assert
(
mem_layout
!=
NULL
);
assert
(
image_data
!=
NULL
);
assert
(
image_data
!=
NULL
);
...
@@ -215,7 +215,7 @@ int load_image(meminfo_t *mem_layout,
...
@@ -215,7 +215,7 @@ int load_image(meminfo_t *mem_layout,
/* Obtain a reference to the image by querying the platform layer */
/* Obtain a reference to the image by querying the platform layer */
io_result
=
plat_get_image_source
(
image_id
,
&
dev_handle
,
&
image_spec
);
io_result
=
plat_get_image_source
(
image_id
,
&
dev_handle
,
&
image_spec
);
if
(
io_result
!=
IO_SUCCESS
)
{
if
(
io_result
!=
0
)
{
WARN
(
"Failed to obtain reference to image id=%u (%i)
\n
"
,
WARN
(
"Failed to obtain reference to image id=%u (%i)
\n
"
,
image_id
,
io_result
);
image_id
,
io_result
);
return
io_result
;
return
io_result
;
...
@@ -223,7 +223,7 @@ int load_image(meminfo_t *mem_layout,
...
@@ -223,7 +223,7 @@ int load_image(meminfo_t *mem_layout,
/* Attempt to access the image */
/* Attempt to access the image */
io_result
=
io_open
(
dev_handle
,
image_spec
,
&
image_handle
);
io_result
=
io_open
(
dev_handle
,
image_spec
,
&
image_handle
);
if
(
io_result
!=
IO_SUCCESS
)
{
if
(
io_result
!=
0
)
{
WARN
(
"Failed to access image id=%u (%i)
\n
"
,
WARN
(
"Failed to access image id=%u (%i)
\n
"
,
image_id
,
io_result
);
image_id
,
io_result
);
return
io_result
;
return
io_result
;
...
@@ -233,7 +233,7 @@ int load_image(meminfo_t *mem_layout,
...
@@ -233,7 +233,7 @@ int load_image(meminfo_t *mem_layout,
/* Find the size of the image */
/* Find the size of the image */
io_result
=
io_size
(
image_handle
,
&
image_size
);
io_result
=
io_size
(
image_handle
,
&
image_size
);
if
((
io_result
!=
IO_SUCCESS
)
||
(
image_size
==
0
))
{
if
((
io_result
!=
0
)
||
(
image_size
==
0
))
{
WARN
(
"Failed to determine the size of the image id=%u (%i)
\n
"
,
WARN
(
"Failed to determine the size of the image id=%u (%i)
\n
"
,
image_id
,
io_result
);
image_id
,
io_result
);
goto
exit
;
goto
exit
;
...
@@ -252,7 +252,7 @@ int load_image(meminfo_t *mem_layout,
...
@@ -252,7 +252,7 @@ int load_image(meminfo_t *mem_layout,
/* We have enough space so load the image now */
/* We have enough space so load the image now */
/* TODO: Consider whether to try to recover/retry a partially successful read */
/* TODO: Consider whether to try to recover/retry a partially successful read */
io_result
=
io_read
(
image_handle
,
image_base
,
image_size
,
&
bytes_read
);
io_result
=
io_read
(
image_handle
,
image_base
,
image_size
,
&
bytes_read
);
if
((
io_result
!=
IO_SUCCESS
)
||
(
bytes_read
<
image_size
))
{
if
((
io_result
!=
0
)
||
(
bytes_read
<
image_size
))
{
WARN
(
"Failed to load image id=%u (%i)
\n
"
,
image_id
,
io_result
);
WARN
(
"Failed to load image id=%u (%i)
\n
"
,
image_id
,
io_result
);
goto
exit
;
goto
exit
;
}
}
...
@@ -319,7 +319,7 @@ int load_auth_image(meminfo_t *mem_layout,
...
@@ -319,7 +319,7 @@ int load_auth_image(meminfo_t *mem_layout,
if
(
rc
==
0
)
{
if
(
rc
==
0
)
{
rc
=
load_auth_image
(
mem_layout
,
parent_id
,
image_base
,
rc
=
load_auth_image
(
mem_layout
,
parent_id
,
image_base
,
image_data
,
NULL
);
image_data
,
NULL
);
if
(
rc
!=
LOAD_SUCCESS
)
{
if
(
rc
!=
0
)
{
return
rc
;
return
rc
;
}
}
}
}
...
@@ -328,8 +328,8 @@ int load_auth_image(meminfo_t *mem_layout,
...
@@ -328,8 +328,8 @@ int load_auth_image(meminfo_t *mem_layout,
/* Load the image */
/* Load the image */
rc
=
load_image
(
mem_layout
,
image_id
,
image_base
,
image_data
,
rc
=
load_image
(
mem_layout
,
image_id
,
image_base
,
image_data
,
entry_point_info
);
entry_point_info
);
if
(
rc
!=
IO_SUCCESS
)
{
if
(
rc
!=
0
)
{
return
LOAD_ERR
;
return
rc
;
}
}
#if TRUSTED_BOARD_BOOT
#if TRUSTED_BOARD_BOOT
...
@@ -342,7 +342,7 @@ int load_auth_image(meminfo_t *mem_layout,
...
@@ -342,7 +342,7 @@ int load_auth_image(meminfo_t *mem_layout,
image_data
->
image_size
);
image_data
->
image_size
);
flush_dcache_range
(
image_data
->
image_base
,
flush_dcache_range
(
image_data
->
image_base
,
image_data
->
image_size
);
image_data
->
image_size
);
return
LOAD_AUTH_ERR
;
return
-
EAUTH
;
}
}
/* After working with data, invalidate the data cache */
/* After working with data, invalidate the data cache */
...
@@ -350,5 +350,5 @@ int load_auth_image(meminfo_t *mem_layout,
...
@@ -350,5 +350,5 @@ int load_auth_image(meminfo_t *mem_layout,
(
size_t
)
image_data
->
image_size
);
(
size_t
)
image_data
->
image_size
);
#endif
/* TRUSTED_BOARD_BOOT */
#endif
/* TRUSTED_BOARD_BOOT */
return
LOAD_SUCCESS
;
return
0
;
}
}
docs/porting-guide.md
View file @
1a2ee045
...
@@ -358,13 +358,12 @@ must also be defined:
...
@@ -358,13 +358,12 @@ must also be defined:
Defines the maximum number of registered IO devices. Attempting to register
Defines the maximum number of registered IO devices. Attempting to register
more devices than this value using `io_register_device()` will fail with
more devices than this value using `io_register_device()` will fail with
IO_RESOURCES_EXHAUSTED
.
-ENOMEM
.
*
**#define : MAX_IO_HANDLES**
*
**#define : MAX_IO_HANDLES**
Defines the maximum number of open IO handles. Attempting to open more IO
Defines the maximum number of open IO handles. Attempting to open more IO
entities than this value using `io_open()` will fail with
entities than this value using `io_open()` will fail with -ENOMEM.
IO_RESOURCES_EXHAUSTED.
If the platform needs to allocate data within the per-cpu data framework in
If the platform needs to allocate data within the per-cpu data framework in
BL3-1, it should define the following macro. Currently this is only required if
BL3-1, it should define the following macro. Currently this is only required if
...
...
include/common/bl_common.h
View file @
1a2ee045
...
@@ -202,15 +202,6 @@ typedef struct bl31_params {
...
@@ -202,15 +202,6 @@ typedef struct bl31_params {
image_info_t
*
bl33_image_info
;
image_info_t
*
bl33_image_info
;
}
bl31_params_t
;
}
bl31_params_t
;
/*
* load_auth_image() return values
*/
enum
{
LOAD_SUCCESS
,
/* Load + authentication success */
LOAD_ERR
,
/* Load error */
LOAD_AUTH_ERR
/* Authentication error */
};
/*
/*
* Compile time assertions related to the 'entry_point_info' structure to
* Compile time assertions related to the 'entry_point_info' structure to
...
...
include/drivers/io/io_storage.h
View file @
1a2ee045
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#ifndef __IO_H__
#ifndef __IO_H__
#define __IO_H__
#define __IO_H__
#include <errno.h>
#include <stdint.h>
#include <stdint.h>
#include <stdio.h>
/* For ssize_t */
#include <stdio.h>
/* For ssize_t */
#include <uuid.h>
#include <uuid.h>
...
@@ -88,11 +89,13 @@ typedef struct io_block_spec {
...
@@ -88,11 +89,13 @@ typedef struct io_block_spec {
#define IO_MODE_RW (1 << 1)
#define IO_MODE_RW (1 << 1)
/* Return codes reported by 'io_*' APIs */
/* Return codes reported by 'io_*' APIs.
* IMPORTANT: these definitions are deprecated. Callers should use standard
* errno definitions when checking the return value of io_* APIs. */
#define IO_SUCCESS (0)
#define IO_SUCCESS (0)
#define IO_FAIL (-
1
)
#define IO_FAIL (-
ENOENT
)
#define IO_NOT_SUPPORTED (-
2
)
#define IO_NOT_SUPPORTED (-
ENODEV
)
#define IO_RESOURCES_EXHAUSTED (-
3
)
#define IO_RESOURCES_EXHAUSTED (-
ENOMEM
)
/* Open a connection to a device */
/* Open a connection to a device */
...
...
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