2008-08-22 Joel Sherrill <joel.sherrill@oarcorp.com>

* bsp_howto/init.t: Complete update.
This commit is contained in:
Joel Sherrill
2008-08-22 16:58:53 +00:00
parent 0eb595a839
commit 29910decc1
2 changed files with 54 additions and 116 deletions

View File

@@ -1,3 +1,7 @@
2008-08-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* bsp_howto/init.t: Complete update.
2008-08-22 Joel Sherrill <joel.sherrill@oarcorp.com> 2008-08-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* bsp_howto/Makefile.am, bsp_howto/init.t, bsp_howto/intro.t, * bsp_howto/Makefile.am, bsp_howto/init.t, bsp_howto/intro.t,

View File

@@ -244,107 +244,52 @@ file:
c/src/lib/libbsp/CPU/BSP/startup/bspstart.c c/src/lib/libbsp/CPU/BSP/startup/bspstart.c
@end example @end example
This routine is also responsible for overriding the default settings On older BSPs not using @code{boot_card()}'s support for allocating memory
in the CPU Configuration Table and setting port specific entries to the C Program Heap and RTEMS Workspace, one of the most important
in this table. This may include increasing the maximum number functions performed by this routine is determining where the RTEMS
of some types of RTEMS system objects to reflect the needs of Workspace is to be located in memory. All RTEMS objects and task stacks
the BSP and the base set of device drivers. This routine will will be allocated from this Workspace. The RTEMS Workspace is distinct
typically also install routines for one or more of the following from the application heap used for @code{malloc()}. Many BSPs place
initialization hooks: the RTEMS Workspace area at the end of RAM although this is certainly
not a requirement.
@itemize @bullet After completing execution, this routine returns to the @code{boot_card()}
@item BSP Pretasking Hook routine.
@item BSP Predriver Hook
@item BSP Postdriver Hook
@end itemize
One of the most important functions performed by this routine
is determining where the RTEMS Workspace is to be
located in memory. All RTEMS objects and task stacks will be
allocated from this Workspace. The RTEMS Workspace is distinct
from the application heap used for @code{malloc()}. Many BSPs
place the RTEMS Workspace area at the end of RAM although this is
certainly not a requirement.
After completing execution, this routine returns to the
@code{boot_card()} routine.
@subsection main() - C Main
This routine is the C main entry point. This is a special routine
and the GNU Compiler Suite treats it as such. The GNU C Compiler
recognizes @code{main()} and automatically inserts a call to the
compiler run-time support routine @code{__main()} as the first
code executed in @code{main()}.
The routine @code{__main()} initializes the compiler's basic run-time
support library and, most importantly, invokes the C++ global
constructors.
The precise placement of when @code{main()} is invoked in the
RTEMS initialization sequence ensures that C Library and non-blocking
calls can be made in global C++ constructors.
The shared implementation of this routine is located in the following file:
@example
c/src/lib/libbsp/shared/main.c
@end example
In addition to the implicit invocation of @code{__main}, this
routine performs some explicit initialization. This routine
sets the variable @code{rtems_progname} and initiates
multitasking via a call to the RTEMS directive
@code{rtems_initialize_executive_late}. It is important to note
that the executive does not return to this routine until the
RTEMS directive @code{rtems_shutdown_executive} is invoked.
The RTEMS initialization procedure is described in the @b{Initialization
Manager} chapter of the @b{RTEMS Application C User's Guide}.
Please refer to that manual for more information.
@subsection RTEMS Pretasking Callback @subsection RTEMS Pretasking Callback
The @code{pretasking_hook} entry in the RTEMS CPU Configuration The method @code{bsp_pretasking_hook()} is the BSP specific routine
Table may be the address of a user provided routine that is
invoked once RTEMS API initialization is complete but before interrupts invoked once RTEMS API initialization is complete but before interrupts
and tasking are enabled. No tasks -- not even the IDLE task -- have and tasking are enabled. No tasks -- not even the IDLE task -- have
been created when this hook is invoked. The pretasking hook is optional. been created when this hook is invoked. The pretasking hook is optional
and the user may use the shared version.
Although optional, most of the RTEMS BSPs provide a pretasking hook
callback. This routine is usually called @code{bsp_pretasking_hook}
and is found in the file:
@example
c/src/lib/libbsp/CPU/BSP/startup/bspstart.c
@end example
The @code{bsp_pretasking_hook()} routine is the appropriate place to The @code{bsp_pretasking_hook()} routine is the appropriate place to
initialize any support components which depend on the RTEMS APIs. initialize any support components which depend on the RTEMS APIs.
Most BSPs set the debug level for the system and initialize the Older BSPs that do not take full advantage of @code{boot_card()}
RTEMS C Library support in their may initialize the RTEMS C Library in their implementation of
implementation of @code{bsp_pretasking_hook()}. This initialization @code{bsp_pretasking_hook()}. This initialization includes the
includes the application heap used by the @code{malloc} family application heap used by the @code{malloc} family of routines as well
of routines as well as the reentrancy support for the C Library. as the reentrancy support for the C Library.
The routine @code{bsp_libc_init} routine invoked from the The routine @code{bsp_libc_init} routine invoked from the
@code{bsp_pretasking_hook()} routine is passed the starting either @code{boot_card()} or (less preferable) the BSP specific
address, length, and growth amount passed to @code{sbrk}. @code{bsp_pretasking_hook()} routine is passed the starting address,
This "sbrk amount" is only used if the heap runs out of length, and growth amount passed to @code{sbrk}. This "sbrk amount"
memory. In this case, the RTEMS malloc implementation will is only used if the heap runs out of memory. In this case, the RTEMS
invoked @code{sbrk} to obtain more memory. See malloc implementation will invoked @code{sbrk} to obtain more memory.
@ref{Miscellaneous Support Files sbrk() Implementation} for more details. See @ref{Miscellaneous Support Files sbrk() Implementation} for more
details.
@subsection RTEMS Predriver Callback @subsection RTEMS Predriver Callback
The @code{predriver_hook} entry in the RTEMS CPU Configuration The @code{bsp_predriver_hook()} method is the BSP specific routine that
Table may be the address of a user provided routine that is is is invoked immediately before the the device drivers and MPCI are
is invoked immediately before the the device drivers and MPCI initialized. RTEMS initialization is complete but interrupts and tasking
are initialized. RTEMS are disabled.
initialization is complete but interrupts and tasking are disabled.
This field may be NULL to indicate that the hook is not utilized.
Most BSPs do not use this callback. The BSP may use the shared version of this routine which is empty.
Most BSPs do not provide a specific implementation of this callback.
@subsection Device Driver Initialization @subsection Device Driver Initialization
@@ -378,26 +323,16 @@ channels in the UART).
@subsection RTEMS Postdriver Callback @subsection RTEMS Postdriver Callback
The @code{postdriver_hook} entry in the RTEMS CPU Configuration The @code{bsp_postdriver_hook()} BSP specific routine is invoked
Table may be the address of a user provided routine that is immediately after the the device drivers and MPCI are initialized.
invoked immediately after the the device drivers and MPCI are initialized. Interrupts and tasking are disabled.
Interrupts and tasking are disabled. The postdriver hook is optional.
Although optional, most of the RTEMS BSPs provide a postdriver hook Most BSPs use the shared implementation of this routine which is responsible for opening the device @code{/dev/console} for standard input, output and error if the application has configured the Console Device Driver. This file is located at:
callback. This routine is usually called @code{bsp_postdriver_hook}
and is found in the file:
@example @example
c/src/lib/libbsp/CPU/BSP/startup/bsppost.c c/src/lib/libbsp/shared/bsppost.c
@end example @end example
The @code{bsp_postdriver_hook()} routine is the appropriate place to
perform initialization that must be performed before the first task
executes but requires that a device driver be initialized. The
shared implementation of the postdriver hook opens the default
standard in, out, and error files and associates them with
@code{/dev/console}.
@section The Interrupt Vector Table @section The Interrupt Vector Table
The Interrupt Vector Table is called different things on different The Interrupt Vector Table is called different things on different
@@ -500,22 +435,21 @@ semaphores, etc.). It's used to allocate the size for the RTEMS inner data
structures. structures.
The RTEMS configuration table is application dependent, which means that The RTEMS configuration table is application dependent, which means that
one has to provide one per application. It is usually defined one has to provide one per application. It is usually defined by defining
by defining macros and including the header file @code{<rtems/confdefs.h>}. macros and including the header file @code{<rtems/confdefs.h>}. In simple
In simple applications such as the tests provided with RTEMS, it is applications such as the tests provided with RTEMS, it is commonly found
commonly found in the main module of the application. For more complex in the main module of the application. For more complex applications,
applications, it may be in a file by itself. it may be in a file by itself.
The header file @code{<rtems/confdefs.h>} defines a constant table named The header file @code{<rtems/confdefs.h>} defines a constant table
@code{Configuration}. With RTEMS 4.8 and older, it was named @code{Configuration}. With RTEMS 4.8 and older, it was accepted
accepted practice for the BSP to copy this table into a modifiable practice for the BSP to copy this table into a modifiable copy named
copy named @code{BSP_Configuration}. This copy of the table was modified @code{BSP_Configuration}. This copy of the table was modified to define
to define the base address of the RTEMS Executive Workspace as well as the base address of the RTEMS Executive Workspace as well as to reflect
to reflect any BSP and device driver requirements not automatically any BSP and device driver requirements not automatically handled by the
handled by the application. In 4.9 and newer, we have eliminated application. In 4.9 and newer, we have eliminated the BSP copies of the
the BSP copies of the configuration tables and are making efforts configuration tables and are making efforts to make the configuration
to make the configuration information generated by @code{<rtems/confdefs.h>} information generated by @code{<rtems/confdefs.h>} constant and read only.
constant and read only.
For more information on the RTEMS Configuration Table, refer to the For more information on the RTEMS Configuration Table, refer to the
@b{RTEMS Application C User's Guide}. @b{RTEMS Application C User's Guide}.