[c32b1ef] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
[98eb7e78] | 4 | * @ingroup arm_start |
---|
[c32b1ef] | 5 | * |
---|
[98eb7e78] | 6 | * @brief Rasberry Pi startup code. |
---|
[c32b1ef] | 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
[5ceefe1] | 10 | * Copyright (c) 2013. Hesham AL-Matary |
---|
[c32b1ef] | 11 | * Copyright (c) 2013 by Alan Cudmore |
---|
| 12 | * based on work by: |
---|
| 13 | * Copyright (c) 2009 |
---|
| 14 | * embedded brains GmbH |
---|
| 15 | * Obere Lagerstr. 30 |
---|
| 16 | * D-82178 Puchheim |
---|
| 17 | * Germany |
---|
| 18 | * <rtems@embedded-brains.de> |
---|
| 19 | * |
---|
| 20 | * The license and distribution terms for this file may be |
---|
| 21 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 22 | * http://www.rtems.org/license/LICENSE |
---|
[c32b1ef] | 23 | */ |
---|
| 24 | |
---|
| 25 | #include <bspopts.h> |
---|
| 26 | #include <bsp/start.h> |
---|
| 27 | #include <bsp/raspberrypi.h> |
---|
[5ceefe1] | 28 | #include <bsp/mm.h> |
---|
[e706a9d] | 29 | #include <libcpu/arm-cp15.h> |
---|
[6b5df95] | 30 | #include <bsp.h> |
---|
| 31 | |
---|
[c32b1ef] | 32 | |
---|
| 33 | void BSP_START_TEXT_SECTION bsp_start_hook_0(void) |
---|
| 34 | { |
---|
[e706a9d] | 35 | uint32_t sctlr_val; |
---|
| 36 | |
---|
| 37 | sctlr_val = arm_cp15_get_control(); |
---|
| 38 | |
---|
| 39 | /* |
---|
| 40 | * Current U-boot loader seems to start kernel image |
---|
| 41 | * with I and D caches on and MMU enabled. |
---|
| 42 | * If RTEMS application image finds that cache is on |
---|
| 43 | * during startup then disable caches. |
---|
| 44 | */ |
---|
| 45 | if (sctlr_val & (ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M)) { |
---|
| 46 | if (sctlr_val & (ARM_CP15_CTRL_C | ARM_CP15_CTRL_M)) { |
---|
| 47 | /* |
---|
| 48 | * If the data cache is on then ensure that it is clean |
---|
| 49 | * before switching off to be extra carefull. |
---|
| 50 | */ |
---|
| 51 | arm_cp15_drain_write_buffer(); |
---|
| 52 | arm_cp15_data_cache_clean_and_invalidate(); |
---|
| 53 | } |
---|
| 54 | arm_cp15_flush_prefetch_buffer(); |
---|
| 55 | sctlr_val &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M | ARM_CP15_CTRL_A); |
---|
| 56 | arm_cp15_set_control(sctlr_val); |
---|
[c32b1ef] | 57 | |
---|
[e706a9d] | 58 | arm_cp15_tlb_invalidate(); |
---|
| 59 | arm_cp15_flush_prefetch_buffer(); |
---|
| 60 | arm_cp15_data_cache_invalidate(); |
---|
| 61 | arm_cp15_instruction_cache_invalidate(); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | /* Clear Translation Table Base Control Register */ |
---|
| 65 | arm_cp15_set_translation_table_base_control_register(0); |
---|
| 66 | |
---|
| 67 | /* Clear Secure or Non-secure Vector Base Address Register */ |
---|
| 68 | arm_cp15_set_vector_base_address(0); |
---|
| 69 | } |
---|
[c32b1ef] | 70 | |
---|
| 71 | void BSP_START_TEXT_SECTION bsp_start_hook_1(void) |
---|
| 72 | { |
---|
[f2e9d0d] | 73 | bsp_start_copy_sections(); |
---|
[5ceefe1] | 74 | bsp_memory_management_initialize(); |
---|
[f2e9d0d] | 75 | bsp_start_clear_bss(); |
---|
[6b5df95] | 76 | |
---|
| 77 | rpi_video_init(); |
---|
[c32b1ef] | 78 | } |
---|