Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 1 | /* |
Vikram Kanigiri | 7208419 | 2016-02-08 16:29:30 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | #include <arch.h> |
| 31 | #include <asm_macros.S> |
| 32 | #include <cpu_macros.S> |
| 33 | #include <css_def.h> |
| 34 | |
| 35 | .weak plat_secondary_cold_boot_setup |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 36 | .weak plat_get_my_entrypoint |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 37 | .globl css_calc_core_pos_swap_cluster |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 38 | .weak plat_is_my_cpu_primary |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 39 | |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 40 | /* --------------------------------------------------------------------- |
| 41 | * void plat_secondary_cold_boot_setup(void); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 42 | * |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 43 | * In the normal boot flow, cold-booting secondary CPUs is not yet |
| 44 | * implemented and they panic. |
| 45 | * |
| 46 | * When booting an EL3 payload, secondary CPUs are placed in a holding |
| 47 | * pen, waiting for their mailbox to be populated. Note that all CPUs |
| 48 | * share the same mailbox ; therefore, populating it will release all |
| 49 | * CPUs from their holding pen. If finer-grained control is needed then |
| 50 | * this should be handled in the code that secondary CPUs jump to. |
| 51 | * --------------------------------------------------------------------- |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 52 | */ |
| 53 | func plat_secondary_cold_boot_setup |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 54 | #ifndef EL3_PAYLOAD_BASE |
| 55 | /* TODO: Implement secondary CPU cold boot setup on CSS platforms */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 56 | cb_panic: |
| 57 | b cb_panic |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 58 | #else |
| 59 | mov_imm x0, PLAT_ARM_TRUSTED_MAILBOX_BASE |
| 60 | |
| 61 | /* Wait until the mailbox gets populated */ |
| 62 | poll_mailbox: |
| 63 | ldr x1, [x0] |
| 64 | cbz x1, 1f |
| 65 | br x1 |
| 66 | 1: |
| 67 | wfe |
| 68 | b poll_mailbox |
| 69 | #endif /* EL3_PAYLOAD_BASE */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 70 | endfunc plat_secondary_cold_boot_setup |
| 71 | |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 72 | /* --------------------------------------------------------------------- |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 73 | * uintptr_t plat_get_my_entrypoint (void); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 74 | * |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 75 | * Main job of this routine is to distinguish between a cold and a warm |
| 76 | * boot. On CSS platforms, this distinction is based on the contents of |
| 77 | * the Trusted Mailbox. It is initialised to zero by the SCP before the |
| 78 | * AP cores are released from reset. Therefore, a zero mailbox means |
| 79 | * it's a cold reset. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 80 | * |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 81 | * This functions returns the contents of the mailbox, i.e.: |
| 82 | * - 0 for a cold boot; |
| 83 | * - the warm boot entrypoint for a warm boot. |
| 84 | * --------------------------------------------------------------------- |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 85 | */ |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 86 | func plat_get_my_entrypoint |
Soby Mathew | feac8fc | 2015-09-29 15:47:16 +0100 | [diff] [blame] | 87 | mov_imm x0, PLAT_ARM_TRUSTED_MAILBOX_BASE |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 88 | ldr x0, [x0] |
| 89 | ret |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 90 | endfunc plat_get_my_entrypoint |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 91 | |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 92 | /* ----------------------------------------------------------- |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 93 | * unsigned int css_calc_core_pos_swap_cluster(u_register_t mpidr) |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 94 | * Utility function to calculate the core position by |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 95 | * swapping the cluster order. This is necessary in order to |
| 96 | * match the format of the boot information passed by the SCP |
Soby Mathew | eb3bbf1 | 2015-06-08 12:32:50 +0100 | [diff] [blame] | 97 | * and read in plat_is_my_cpu_primary below. |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 98 | * ----------------------------------------------------------- |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 99 | */ |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 100 | func css_calc_core_pos_swap_cluster |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 101 | and x1, x0, #MPIDR_CPU_MASK |
| 102 | and x0, x0, #MPIDR_CLUSTER_MASK |
| 103 | eor x0, x0, #(1 << MPIDR_AFFINITY_BITS) // swap cluster order |
| 104 | add x0, x1, x0, LSR #6 |
| 105 | ret |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 106 | endfunc css_calc_core_pos_swap_cluster |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 107 | |
| 108 | /* ----------------------------------------------------- |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 109 | * unsigned int plat_is_my_cpu_primary (void); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 110 | * |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 111 | * Find out whether the current cpu is the primary |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 112 | * cpu (applicable ony after a cold boot) |
| 113 | * ----------------------------------------------------- |
| 114 | */ |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 115 | func plat_is_my_cpu_primary |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 116 | mov x9, x30 |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 117 | bl plat_my_core_pos |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 118 | ldr x1, =SCP_BOOT_CFG_ADDR |
| 119 | ldr x1, [x1] |
Vikram Kanigiri | 7208419 | 2016-02-08 16:29:30 +0000 | [diff] [blame] | 120 | ubfx x1, x1, #PLAT_CSS_PRIMARY_CPU_SHIFT, \ |
| 121 | #PLAT_CSS_PRIMARY_CPU_BIT_WIDTH |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 122 | cmp x0, x1 |
Soby Mathew | eb3bbf1 | 2015-06-08 12:32:50 +0100 | [diff] [blame] | 123 | cset w0, eq |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 124 | ret x9 |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 125 | endfunc plat_is_my_cpu_primary |