Changeset f9c1e117 in rtems


Ignore:
Timestamp:
Jul 4, 2016, 9:05:55 AM (3 years ago)
Author:
Pavel Pisa <pisa@…>
Branches:
4.11
Children:
404f659
Parents:
8add2b6
git-author:
Pavel Pisa <pisa@…> (07/04/16 09:05:55)
git-committer:
Pavel Pisa <pisa@…> (10/02/16 08:40:34)
Message:

bsps/arm: Support recent bootloaders starting kernel in HYP mode

When HYP mode is detected at startup then setup HYP mode
vectors table (for future extensions) clean exceptions
switching to HYP mode and switch CPU to ARM SVC mode.

BSPs which want to use this support need to include next option
in their configure.ac

RTEMS_BSPOPTS_SET([BSP_START_IN_HYP_SUPPORT],[*],[1])
RTEMS_BSPOPTS_HELP([BSP_START_IN_HYP_SUPPORT], [Support start of BSP in ARM HYP mode])
AM_CONDITIONAL(BSP_START_IN_HYP_SUPPORT,test "$BSP_START_IN_HYP_SUPPORT" = "1")

and need to include next lines in corresponding Makefile.am

if BSP_START_IN_HYP_SUPPORT
libbsp_a_SOURCES += ../shared/startup/bsp-start-in-hyp-support.S
endif

Updates #2783

Location:
c/src/lib/libbsp/arm/shared
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/shared/include/linker-symbols.h

    r8add2b6 rf9c1e117  
    5959LINKER_SYMBOL(bsp_stack_und_end)
    6060LINKER_SYMBOL(bsp_stack_und_size)
     61
     62LINKER_SYMBOL(bsp_stack_hyp_begin)
     63LINKER_SYMBOL(bsp_stack_hyp_end)
     64LINKER_SYMBOL(bsp_stack_hyp_size)
    6165
    6266LINKER_SYMBOL(bsp_stack_svc_begin)
  • c/src/lib/libbsp/arm/shared/include/start.h

    r8add2b6 rf9c1e117  
    4646#define BSP_START_DATA_SECTION __attribute__((section(".bsp_start_data")))
    4747
     48/*
     49* Many ARM boot loaders pass arguments to loaded OS kernel
     50*/
     51#ifdef BSP_START_HOOKS_WITH_LOADER_ARGS
     52#define BSP_START_HOOKS_LOADER_ARGS int saved_psr, int saved_machid, int saved_dtb_adr
     53#else
     54#define BSP_START_HOOKS_LOADER_ARGS void
     55#endif
     56
    4857/**
    4958* @brief System start entry.
     
    5867* vectors.
    5968*/
    60 void bsp_start_hook_0(void);
     69void bsp_start_hook_0(BSP_START_HOOKS_LOADER_ARGS);
    6170
    6271/**
     
    6675* exception vectors but before the call to boot_card().
    6776*/
    68 void bsp_start_hook_1(void);
     77void bsp_start_hook_1(BSP_START_HOOKS_LOADER_ARGS);
    6978
    7079/**
  • c/src/lib/libbsp/arm/shared/start/start.S

    r8add2b6 rf9c1e117  
    5555#endif
    5656
     57#ifdef BSP_START_IN_HYP_SUPPORT
     58        .extern bsp_start_arm_drop_hyp_mode
     59        .globl  bsp_start_hyp_vector_table_begin
     60#endif
     61
    5762        /* Global symbols */
    5863        .globl  _start
     
    125130bsp_start_vector_table_end:
    126131
     132#ifdef BSP_START_IN_HYP_SUPPORT
     133bsp_start_hyp_vector_table_begin:
     134        ldr     pc, handler_addr_hyp_reset
     135        ldr     pc, handler_addr_hyp_undef
     136        ldr     pc, handler_addr_hyp_swi
     137        ldr     pc, handler_addr_hyp_prefetch
     138        ldr     pc, handler_addr_hyp_abort
     139        ldr     pc, handler_addr_hyp_hyp
     140        ldr     pc, handler_addr_hyp_irq
     141        ldr     pc, handler_addr_hyp_fiq
     142
     143handler_addr_hyp_reset:
     144        .word   _ARMV4_Exception_reserved_default
     145
     146handler_addr_hyp_undef:
     147        .word   _ARMV4_Exception_reserved_default
     148
     149handler_addr_hyp_swi:
     150        .word   _ARMV4_Exception_reserved_default
     151
     152handler_addr_hyp_prefetch:
     153        .word   _ARMV4_Exception_reserved_default
     154
     155handler_addr_hyp_abort:
     156        .word   _ARMV4_Exception_reserved_default
     157
     158handler_addr_hyp_hyp:
     159        .word   _ARMV4_Exception_reserved_default
     160
     161handler_addr_hyp_irq:
     162        .word   _ARMV4_Exception_reserved_default
     163
     164handler_addr_hyp_fiq:
     165        .word   _ARMV4_Exception_reserved_default
     166
     167bsp_start_hyp_vector_table_end:
     168#endif
     169
    127170/* Start entry */
    128171
     
    131174        /*
    132175         * We do not save the context since we do not return to the boot
    133          * loader.
    134          */
    135 
    136 #ifdef BSP_START_NEEDS_REGISTER_INITIALIZATION
     176         * loader but preserve r1 and r2 to allow access to bootloader parameters
     177         */
     178#ifndef BSP_START_NEEDS_REGISTER_INITIALIZATION
     179        mov     r5, r1          /* machine type number or ~0 for DT boot */
     180        mov     r6, r2          /* physical address of ATAGs or DTB */
     181#else /* BSP_START_NEEDS_REGISTER_INITIALIZATION */
    137182        bl bsp_start_init_registers_core
    138183#endif
     
    148193#endif
    149194
     195        mrs     r4, cpsr        /* save original procesor status value  */
     196#ifdef BSP_START_IN_HYP_SUPPORT
     197        orr     r0, r4, #(ARM_PSR_I | ARM_PSR_F)
     198        msr     cpsr, r4
     199
     200        and     r0, r4, #ARM_PSR_M_MASK
     201        cmp     r0, #ARM_PSR_M_HYP
     202        bne     bsp_start_skip_hyp_svc_switch
     203
     204        /* Boot loader stats kernel in HYP mode, switch to SVC necessary */
     205        ldr     sp, =bsp_stack_hyp_end
     206#ifdef RTEMS_SMP
     207        add     sp, r1
     208#endif
     209        bl      bsp_start_arm_drop_hyp_mode
     210
     211bsp_start_skip_hyp_svc_switch:
     212#endif
    150213        /*
    151214         * Set SVC mode, disable interrupts and enable ARM instructions.
     
    248311        SWITCH_FROM_ARM_TO_THUMB        r0
    249312
     313        mov     r0, r4          /* original cpsr value */
     314        mov     r1, r5          /* machine type number or ~0 for DT boot */
     315        mov     r2, r6          /* physical address of ATAGs or DTB */
     316
    250317        b       bsp_start_hook_0
    251318
     
    258325         * vectors and the pointers to the default exception handlers.
    259326         */
     327
     328        stmdb   sp!, {r4, r5, r6}
    260329
    261330        ldr     r0, =bsp_vector_table_begin
     
    270339bsp_vector_table_copy_done:
    271340
    272         SWITCH_FROM_ARM_TO_THUMB        r0
     341        ldmia   sp!, {r0, r1, r2}
     342
     343        SWITCH_FROM_ARM_TO_THUMB        r3
    273344
    274345        /* Branch to start hook 1 */
  • c/src/lib/libbsp/arm/shared/startup/linkcmds.base

    r8add2b6 rf9c1e117  
    5454bsp_stack_und_size = ALIGN (bsp_stack_und_size, bsp_stack_align);
    5555
     56bsp_stack_hyp_size = DEFINED (bsp_stack_hyp_size) ? bsp_stack_hyp_size : 0;
     57bsp_stack_hyp_size = ALIGN (bsp_stack_hyp_size, bsp_stack_align);
     58
    5659bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 0;
    5760bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
    5861
    59 bsp_stack_all_size = bsp_stack_abt_size + bsp_stack_fiq_size + bsp_stack_irq_size + bsp_stack_svc_size + bsp_stack_und_size + bsp_stack_main_size;
     62bsp_stack_all_size = bsp_stack_abt_size + bsp_stack_fiq_size + bsp_stack_irq_size + bsp_stack_svc_size + bsp_stack_und_size + bsp_stack_hyp_size + bsp_stack_main_size;
    6063
    6164bsp_processor_count = DEFINED (bsp_processor_count) ? bsp_processor_count : 1;
     
    312315                . = . + bsp_stack_und_size;
    313316                bsp_stack_und_end = .;
     317
     318                bsp_stack_hyp_begin = .;
     319                . = . + bsp_stack_hyp_size;
     320                bsp_stack_hyp_end = .;
    314321
    315322                bsp_stack_abt_begin = .;
Note: See TracChangeset for help on using the changeset viewer.