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
df5bd3bf
Commit
df5bd3bf
authored
Jul 17, 2019
by
Soby Mathew
Committed by
TrustedFirmware Code Review
Jul 17, 2019
Browse files
Merge "console: update skeleton" into integration
parents
7cdd55af
52e91081
Changes
3
Hide whitespace changes
Inline
Side-by-side
drivers/console/aarch32/skeleton_console.S
View file @
df5bd3bf
/*
/*
*
Copyright
(
c
)
2016
-
201
7
,
ARM
Limited
and
Contributors
.
All
rights
reserved
.
*
Copyright
(
c
)
2016
-
201
9
,
ARM
Limited
and
Contributors
.
All
rights
reserved
.
*
*
*
SPDX
-
License
-
Identifier
:
BSD
-
3
-
Clause
*
SPDX
-
License
-
Identifier
:
BSD
-
3
-
Clause
*/
*/
#include <asm_macros.S>
#include <asm_macros.S>
#include <console_macros.S>
/
*
/
*
*
This
file
contains
a
skeleton
console
implementation
that
can
*
This
file
contains
a
skeleton
console
driver
that
can
be
used
as
a
*
be
used
as
basis
for
a
real
console
implementation
by
platforms
*
basis
for
a
real
console
driver
.
Console
drivers
in
Trusted
Firmware
*
that
do
not
contain
PL011
hardware
.
*
can
be
instantiated
multiple
times
.
Each
instance
is
described
by
a
*
separate
console_t
structure
which
must
be
registered
with
the
common
*
console
framework
via
console_register
()
.
Console
drivers
should
*
define
a
console_xxx_register
()
function
that
initializes
a
new
*
console_t
structure
passed
in
from
the
caller
and
registers
it
after
*
initializing
the
console
hardware
.
Drivers
may
define
their
own
*
structures
extending
console_t
to
store
private
driver
information
.
*
Console
drivers
*
MUST
*
ensure
that
the
console
callbacks
they
*
implement
only
change
registers
allowed
in
the
clobber
lists
defined
*
in
this
file
.
(
Note
that
in
addition
to
the
explicit
clobber
lists
,
*
any
function
may
always
clobber
the
intra
-
procedure
-
call
register
*
r12
,
but
may
never
depend
on
it
retaining
its
value
across
any
*
function
call
.
)
*/
*/
.
globl
console_
core_init
.
globl
console_
xxx_register
.
globl
console_
core
_putc
.
globl
console_
xxx
_putc
.
globl
console_
core
_getc
.
globl
console_
xxx
_getc
.
globl
console_
core
_flush
.
globl
console_
xxx
_flush
/
*
-----------------------------------------------
/
*
-----------------------------------------------
*
int
console_
core_init
(
uintptr_t
base_addr
,
*
int
console_
xxx_register
(
console_xxx_t
*
console
,
*
unsigned
int
uart_clk
,
unsigned
int
baud_rate
)
*
...
additional
parameters
as
desired
...
)
*
Function
to
initialize
the
console
without
a
*
Function
to
initialize
and
register
the
console
.
*
C
Runtime
to
print
debug
information
.
This
*
The
caller
needs
to
pass
an
empty
console_xxx_t
*
function
will
be
accessed
by
console_init
and
*
structure
in
which
*
MUST
*
be
allocated
in
*
crash
reporting
.
*
persistent
memory
(
e
.
g
.
a
global
or
static
local
*
In
:
r0
-
console
base
address
*
variable
,
*
NOT
*
on
the
stack
)
.
*
r1
-
Uart
clock
in
Hz
*
In
:
r0
-
pointer
to
empty
console_t
structure
*
r2
-
Baud
rate
*
r1
through
r7
:
additional
parameters
as
desired
*
Out
:
r
eturn
1
on
success
else
0
on
error
*
Out
:
r
0
-
1
on
success
,
0
on
error
*
Clobber
list
:
r
1
,
r
2
*
Clobber
list
:
r
0
-
r
7
*
-----------------------------------------------
*
-----------------------------------------------
*/
*/
func
console_core_init
func
console_xxx_register
/
*
Check
the
input
base
address
*/
/
*
cmp
r0
,
#
0
*
Store
parameters
(
e
.
g
.
hardware
base
address
)
in
driver
-
specific
beq
core_init_fail
*
console_xxx_t
structure
field
if
they
will
need
to
be
retrieved
/
*
Check
baud
rate
and
uart
clock
for
sanity
*/
*
by
later
console
callback
(
e
.
g
.
putc
)
.
cmp
r1
,
#
0
*
Example
:
beq
core_init_fail
*/
cmp
r2
,
#
0
str
r1
,
[
r0
,
#
CONSOLE_T_XXX_BASE
]
beq
core_init_fail
str
r2
,
[
r0
,
#
CONSOLE_T_XXX_SOME_OTHER_VALUE
]
/
*
Insert
implementation
here
*/
mov
r0
,
#
1
/
*
bx
lr
*
Initialize
console
hardware
,
using
r1
-
r7
parameters
as
needed
.
core_init_fail
:
*
Keep
console_t
pointer
in
r0
for
later
.
*/
/
*
*
Macro
to
finish
up
registration
and
return
(
needs
valid
r0
+
lr
)
.
*
If
any
of
the
argument
is
unspecified
,
then
the
corresponding
*
entry
in
console_t
is
set
to
0
.
*/
finish_console_register
xxx
putc
=
1
,
getc
=
1
,
flush
=
1
/
*
Jump
here
if
hardware
init
fails
or
parameters
are
invalid
.
*/
register_fail
:
mov
r0
,
#
0
mov
r0
,
#
0
bx
lr
bx
lr
endfunc
console_
core_init
endfunc
console_
xxx_register
/
*
--------------------------------------------------------
/
*
--------------------------------------------------------
*
int
console_
core
_putc
(
int
c
,
uintptr_t
base_addr
)
*
int
console_
xxx
_putc
(
int
c
,
console_xxx_t
*
console
)
*
Function
to
output
a
character
over
the
console
.
It
*
Function
to
output
a
character
over
the
console
.
It
*
returns
the
character
printed
on
success
or
-
1
on
error
.
*
returns
the
character
printed
on
success
or
-
1
on
error
.
*
In
:
r0
-
character
to
be
printed
*
In
:
r0
-
character
to
be
printed
*
r1
-
console
base
address
*
r1
-
pointer
to
console_t
struct
*
Out
:
r
eturn
-
1
on
error
else
return
characte
r
.
*
Out
:
r
0
-
printed
character
on
success
,
<
0
on
erro
r
.
*
Clobber
list
:
r2
*
Clobber
list
:
r0
,
r1
,
r2
*
--------------------------------------------------------
*
--------------------------------------------------------
*/
*/
func
console_core_putc
func
console_xxx_putc
/
*
Check
the
input
parameter
*/
/
*
cmp
r1
,
#
0
*
Retrieve
values
we
need
(
e
.
g
.
hardware
base
address
)
from
beq
putc_error
*
console_xxx_t
structure
pointed
to
by
r1
.
/
*
Insert
implementation
here
*/
*
Example
:
*/
ldr
r1
,
[
r1
,
#
CONSOLE_T_XXX_BASE
]
/
*
*
Write
r0
to
hardware
.
*/
bx
lr
bx
lr
/
*
Jump
here
if
output
fails
for
any
reason
.
*/
putc_error
:
putc_error
:
mov
r0
,
#-
1
mov
r0
,
#-
1
bx
lr
bx
lr
endfunc
console_
core
_putc
endfunc
console_
xxx
_putc
/
*
---------------------------------------------
/
*
---------------------------------------------
*
int
console_
core
_getc
(
uintptr_t
base_addr
)
*
int
console_
xxx
_getc
(
console_xxx_t
*
console
)
*
Function
to
get
a
character
from
the
console
.
*
Function
to
get
a
character
from
the
console
.
*
It
returns
the
character
grabbed
on
success
*
Even
though
console_getc
()
is
blocking
,
this
*
or
-
1
on
error
.
*
callback
has
to
be
non
-
blocking
and
always
*
In
:
r0
-
console
base
address
*
return
immediately
to
allow
polling
multiple
*
drivers
concurrently
.
*
Returns
the
character
grabbed
on
success
,
*
ERROR_NO_PENDING_CHAR
if
no
character
was
*
available
at
this
time
,
or
any
value
*
between
-
2
and
-
127
if
there
was
an
error
.
*
In
:
r0
-
pointer
to
console_t
struct
*
Out
:
r0
-
character
on
success
,
*
ERROR_NO_PENDING_CHAR
if
no
char
,
*
<
-
1
on
error
*
Clobber
list
:
r0
,
r1
*
Clobber
list
:
r0
,
r1
*
---------------------------------------------
*
---------------------------------------------
*/
*/
func
console_core_getc
func
console_xxx_getc
cmp
r0
,
#
0
/
*
beq
getc_error
*
Retrieve
values
we
need
(
e
.
g
.
hardware
base
address
)
from
/
*
Insert
implementation
here
*/
*
console_xxx_t
structure
pointed
to
by
r0
.
*
Example
:
*/
ldr
r1
,
[
r0
,
#
CONSOLE_T_XXX_BASE
]
/
*
*
Try
to
read
character
into
r0
from
hardware
.
*/
bx
lr
bx
lr
/
*
Jump
here
if
there
is
no
character
available
at
this
time
.
*/
getc_no_char
:
mov
r0
,
#
ERROR_NO_PENDING_CHAR
bx
lr
/
*
Jump
here
if
there
was
any
hardware
error
.
*/
getc_error
:
getc_error
:
mov
r0
,
#-
1
mov
r0
,
#-
2
/*
may
pick
error
codes
between
-
2
and
-
127
*/
bx
lr
bx
lr
endfunc
console_
core
_getc
endfunc
console_
xxx
_getc
/
*
---------------------------------------------
/
*
---------------------------------------------
*
int
console_
core
_flush
(
uintptr_t
base_addr
)
*
int
console_
xxx
_flush
(
console_xxx_t
*
console
)
*
Function
to
force
a
write
of
all
buffered
*
Function
to
force
a
write
of
all
buffered
*
data
that
hasn
't been output.
*
data
that
hasn
't been output.
*
In
:
r0
-
console
base
address
*
In
:
r0
-
pointer
to
console_xxx_t
struct
*
Out
:
r
eturn
-
1
on
error
else
return
0
.
*
Out
:
r
0
-
0
on
success
,
<
0
on
error
*
Clobber
list
:
r0
,
r1
*
Clobber
list
:
r0
,
r1
,
r2
,
r3
,
r4
,
r5
*
---------------------------------------------
*
---------------------------------------------
*/
*/
func
console_core_flush
func
console_xxx_flush
cmp
r0
,
#
0
/
*
beq
flush_error
*
Retrieve
values
we
need
(
e
.
g
.
hardware
base
address
)
from
/
*
Insert
implementation
here
*/
*
console_xxx_t
structure
pointed
to
by
r0
.
*
Example
:
*/
ldr
r1
,
[
r0
,
#
CONSOLE_T_XXX_BASE
]
/
*
*
Flush
all
remaining
output
from
hardware
FIFOs
.
Do
not
return
until
*
all
data
has
been
flushed
or
there
was
an
unrecoverable
error
.
*/
mov
r0
,
#
0
mov
r0
,
#
0
bx
lr
bx
lr
/
*
Jump
here
if
an
unrecoverable
error
has
been
encountered
.
*/
flush_error
:
flush_error
:
mov
r0
,
#-
1
mov
r0
,
#-
1
bx
lr
bx
lr
endfunc
console_
core
_flush
endfunc
console_
xxx
_flush
drivers/console/aarch64/skeleton_console.S
View file @
df5bd3bf
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include <console_macros.S>
#include <console_macros.S>
/
*
/
*
*
This
file
contains
a
skeleton
console
driver
that
can
be
used
as
*
This
file
contains
a
skeleton
console
driver
that
can
be
used
as
a
*
basis
for
a
real
console
driver
.
Console
drivers
in
Trusted
Firmware
*
basis
for
a
real
console
driver
.
Console
drivers
in
Trusted
Firmware
*
can
be
instantiated
multiple
times
.
Each
instance
is
described
by
a
*
can
be
instantiated
multiple
times
.
Each
instance
is
described
by
a
*
separate
console_t
structure
which
must
be
registered
with
the
common
*
separate
console_t
structure
which
must
be
registered
with
the
common
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
*
console_t
structure
passed
in
from
the
caller
and
registers
it
after
*
console_t
structure
passed
in
from
the
caller
and
registers
it
after
*
initializing
the
console
hardware
.
Drivers
may
define
their
own
*
initializing
the
console
hardware
.
Drivers
may
define
their
own
*
structures
extending
console_t
to
store
private
driver
information
.
*
structures
extending
console_t
to
store
private
driver
information
.
*
Console
drivers
*
MUST
*
take
ca
re
that
the
console
callbacks
they
*
Console
drivers
*
MUST
*
ensu
re
that
the
console
callbacks
they
*
implement
only
change
registers
allowed
in
the
clobber
lists
defined
*
implement
only
change
registers
allowed
in
the
clobber
lists
defined
*
in
this
file
.
(
Note
that
in
addition
to
the
explicit
clobber
lists
,
*
in
this
file
.
(
Note
that
in
addition
to
the
explicit
clobber
lists
,
*
any
function
may
always
clobber
the
intra
-
procedure
-
call
registers
*
any
function
may
always
clobber
the
intra
-
procedure
-
call
registers
...
...
include/arch/aarch32/console_macros.S
View file @
df5bd3bf
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*
default
consoles
are
enabled
for
the
"boot"
and
"crash"
states
,
this
can
be
*
default
consoles
are
enabled
for
the
"boot"
and
"crash"
states
,
this
can
be
*
changed
after
registration
with
the
console_set_scope
()
function
)
.
It
ends
*
changed
after
registration
with
the
console_set_scope
()
function
)
.
It
ends
*
with
a
tail
call
that
will
include
return
to
the
caller
.
*
with
a
tail
call
that
will
include
return
to
the
caller
.
*
REQUIRES
console_t
pointer
in
x
0
and
a
valid
return
address
in
x30
.
*
REQUIRES
console_t
pointer
in
r
0
and
a
valid
return
address
in
lr
.
*/
*/
.
macro
finish_console_register
_driver
,
putc
=
0
,
getc
=
0
,
flush
=
0
.
macro
finish_console_register
_driver
,
putc
=
0
,
getc
=
0
,
flush
=
0
/
*
/
*
...
...
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