redboot的启动流程

如下述:

以下是从ecos的官网文档中抄录下来的。但在浩瀚的文档中找到这些信息也非易事,在此记录下来,以备查用。

 

其中reset vector定义在packages/hal/arm/arch/v3_0/src/vector.S中。

 

PLATFORM_SETUP1定义在packages/hal/arm/arch/v3_0/include/hal_platform_setup.h中。

 

cyg_start定义在packages/redboot/v3_0/src/main.c中。

 

 

 

Getting RedBoot Going
=====================

Startup
=======

1. Reset entry point. At location 0.
   Transfer control to ROM entry point: reset_vector.

2. Here we call invoke PLATFORM_SETUP1 macro. This does the following:
   - disable interrupts
   - disable and clear caches
   - Init memory controllers. may involve discovery of what RAM is
     present.
   - Set up clock frequencies.
   - Init MMU table
     - sets up TTBR and DACR to default values
     - fills in MMU table to map
       - DRAM at 0x00000000 cacheable/buffered
       - Device registers elsewhere uncacheable/unbuffered usually 1-1
       - DRAM at 0xF0000000 uncacheable/unbuffered (1-1 in aaed2000)
       - remap ROM at 0 elsewhere
   - Enable MMU
   - Relocate image to RAM for ROMRAM startup
   - Any other CPU setup required
     
3. Jump to HAL startup.
   - Plant vector intructions at 0+
   - copy .data section to RAM
   - Init CPSR and SPSR
   - Set SP
   - Clear .bss
   - Call hal_hardware_init()
   - call initialize_stub() if GDB stubs included
   - call hal_ctrlc_isr_init()
   - call cyg_hal_invoke_constructors()
   - call cyg_start()


HAL Serial support
==================

Set up CDL in platform CDL file.
    CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
    number of channels usually 0, 1 or 2
    CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL
    channel to use for GDB
    CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_BAUD
    initial baud rate
    CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL
    channel to use for console
    CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD
    initial baud rate
    CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT
    default console channel

The code in hal_diag.c need to be converted to the new serial device.
If this the same as a device already supported, copy that.

Things that need to be written:

struct channel_data_t;
       Structure containing base address, timeout and ISR vector
       number for each serial device.

xxxx_ser_channels[];
    Array of channel_data_t, initialized with parameters of each
    channel.

void cyg_hal_plf_serial_init_channel(void *__ch_data)
    Initialize the serial device. parameter is a pointer to a
    channel_data_t.

void cyg_hal_plf_serial_putc(void * __ch_data, char *c)
        Send a character to the serial device.
    Poll for ready, write the char.
    Maybe poll for char sent.

bool cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch)
        Look for a character and return it if available.
    If none available, return false.

int cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t
__func, ...)
    An IOCTL-like function for controlling various aspects of the
    serial device.
    May need to do some work in __COMMCTL_IRQ_ENABLE and
    __COMMCTL_IRQ_DISABLE cases to enable/disable interrupts.

int cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc,
                       CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
        Interrupt handler, specifically for dealing with Ctrl-C.
    - Check for an incoming character.
    - Read the character and call cyg_hal_is_break().
    - If result is true, set *__ctrlc to 1.
    - return CYG_ISR_HANDLED;

void cyg_hal_plf_serial_init()
        Initialize each of the serial channels.
    - call cyg_hal_plf_serial_init_channel() for each channel.
    - call CYGACC_COMM_IF_* macros for each channel -
          cut/paste/edit these.

       
Interrupt Controller
====================

ARM platforms have interrupt controller access in functions in variant
or platform source file.

void hal_interrupt_mask(int vector)
        Manipulate interrupt controller to mask the interrupt.

void hal_interrupt_unmask(int vector)
        Manipulate interrupt controller to unmask the interrupt.

void hal_interrupt_acknowledge(int vector)
        Manipulate interrupt controller to acknowledge the interrupt.
    May not be needed in some platforms.

void hal_interrupt_configure(int vector, int level, int up)
        Set interrupt detection: level vs. edge; high/low
        rising/falling.
    Leave empty where not implemented.   

void hal_interrupt_set_level(int vector, int level)
        Set interrupt priority level.
    Leave empty where not implemented.   


Redboot Configuration
=====================

Having done all of the above, you should be in a position to get
RedBoot running.

If the platform you copied has redboot, there should be some .ecm
files in the misc directory. Named redboot_.ecm.

Choose a startup and edit the .ecm file.
       - remove any options that are not relevant
       - comment out FLASH, ETH and COMPRESS packages

Configure for redboot:

% setenv ECOS_REPOSITORY
% ecosconfig new xxxxxxxx redboot
% ecosconfig import $ECOS_REPOSITORY/hal/arm/arm9/xxxxxxxx/current/misc/redboot_ROM.ecm
% ecosconfig tree
% make

Repeat until successful.

你可能感兴趣的:(redboot的启动流程)