Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
| 9 | #include <assert_macros.S> |
| 10 | #include <platform_def.h> |
| 11 | |
| 12 | .globl plat_my_core_pos |
| 13 | .globl plat_get_my_entrypoint |
| 14 | .globl platform_mem_init |
| 15 | .globl plat_qemu_calc_core_pos |
| 16 | .globl plat_crash_console_init |
| 17 | .globl plat_crash_console_putc |
| 18 | .globl plat_secondary_cold_boot_setup |
| 19 | .globl plat_get_my_entrypoint |
| 20 | .globl plat_is_my_cpu_primary |
| 21 | |
| 22 | |
| 23 | func plat_my_core_pos |
| 24 | mrs x0, mpidr_el1 |
| 25 | b plat_qemu_calc_core_pos |
| 26 | endfunc plat_my_core_pos |
| 27 | |
| 28 | /* |
| 29 | * unsigned int plat_qemu_calc_core_pos(u_register_t mpidr); |
| 30 | * With this function: CorePos = (ClusterId * 4) + CoreId |
| 31 | */ |
| 32 | func plat_qemu_calc_core_pos |
| 33 | and x1, x0, #MPIDR_CPU_MASK |
| 34 | and x0, x0, #MPIDR_CLUSTER_MASK |
| 35 | add x0, x1, x0, LSR #6 |
| 36 | ret |
| 37 | endfunc plat_qemu_calc_core_pos |
| 38 | |
| 39 | /* ----------------------------------------------------- |
| 40 | * unsigned int plat_is_my_cpu_primary (void); |
| 41 | * |
| 42 | * Find out whether the current cpu is the primary |
| 43 | * cpu. |
| 44 | * ----------------------------------------------------- |
| 45 | */ |
| 46 | func plat_is_my_cpu_primary |
| 47 | mrs x0, mpidr_el1 |
| 48 | and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK) |
| 49 | cmp x0, #QEMU_PRIMARY_CPU |
| 50 | cset w0, eq |
| 51 | ret |
| 52 | endfunc plat_is_my_cpu_primary |
| 53 | |
| 54 | /* ----------------------------------------------------- |
| 55 | * void plat_secondary_cold_boot_setup (void); |
| 56 | * |
| 57 | * This function performs any platform specific actions |
| 58 | * needed for a secondary cpu after a cold reset e.g |
| 59 | * mark the cpu's presence, mechanism to place it in a |
| 60 | * holding pen etc. |
| 61 | * ----------------------------------------------------- |
| 62 | */ |
| 63 | func plat_secondary_cold_boot_setup |
| 64 | /* Calculate address of our hold entry */ |
| 65 | bl plat_my_core_pos |
| 66 | mov_imm x2, PLAT_QEMU_HOLD_BASE |
| 67 | |
| 68 | /* Wait until we have a go */ |
| 69 | poll_mailbox: |
| 70 | ldr x1, [x2, x0] |
| 71 | cbz x1, 1f |
| 72 | mov_imm x0, PLAT_QEMU_TRUSTED_MAILBOX_BASE |
| 73 | ldr x1, [x0] |
| 74 | br x1 |
| 75 | 1: |
| 76 | wfe |
| 77 | b poll_mailbox |
| 78 | endfunc plat_secondary_cold_boot_setup |
| 79 | |
| 80 | func plat_get_my_entrypoint |
| 81 | /* TODO support warm boot */ |
| 82 | mov x0, #0 |
| 83 | ret |
| 84 | endfunc plat_get_my_entrypoint |
| 85 | |
| 86 | func platform_mem_init |
| 87 | ret |
| 88 | endfunc platform_mem_init |
| 89 | |
| 90 | /* --------------------------------------------- |
| 91 | * int plat_crash_console_init(void) |
| 92 | * Function to initialize the crash console |
| 93 | * without a C Runtime to print crash report. |
| 94 | * Clobber list : x0, x1, x2 |
| 95 | * --------------------------------------------- |
| 96 | */ |
| 97 | func plat_crash_console_init |
| 98 | mov_imm x0, PLAT_QEMU_CRASH_UART_BASE |
| 99 | mov_imm x1, PLAT_QEMU_CRASH_UART_CLK_IN_HZ |
| 100 | mov_imm x2, PLAT_QEMU_CONSOLE_BAUDRATE |
| 101 | b console_core_init |
| 102 | endfunc plat_crash_console_init |
| 103 | |
| 104 | /* --------------------------------------------- |
| 105 | * int plat_crash_console_putc(int c) |
| 106 | * Function to print a character on the crash |
| 107 | * console without a C Runtime. |
| 108 | * Clobber list : x1, x2 |
| 109 | * --------------------------------------------- |
| 110 | */ |
| 111 | func plat_crash_console_putc |
| 112 | mov_imm x1, PLAT_QEMU_CRASH_UART_BASE |
| 113 | b console_core_putc |
| 114 | endfunc plat_crash_console_putc |
| 115 | |
| 116 | |