/* * Copyright (c) 2014, STMicroelectronics International N.V. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include static void main_fiq(void); static void stm_tee_entry_std(struct thread_smc_args *smc_args); static const struct thread_handlers handlers = { .std_smc = stm_tee_entry_std, .fast_smc = tee_entry_fast, .fiq = main_fiq, .cpu_on = pm_panic, .cpu_off = pm_panic, .cpu_suspend = pm_panic, .cpu_resume = pm_panic, .system_off = pm_panic, .system_reset = pm_panic, }; const struct thread_handlers *generic_boot_get_handlers(void) { return &handlers; } static int boot_is_completed; static void stm_tee_entry_std(struct thread_smc_args *smc_args) { boot_is_completed = 1; tee_entry_std(smc_args); } static void main_fiq(void) { panic(); } static vaddr_t console_base(void) { /* in case it's used before .bss is cleared */ static void *va __early_bss; if (cpu_mmu_enabled()) { if (!va) va = phys_to_virt(UART_CONSOLE_BASE, MEM_AREA_IO_NSEC); return (vaddr_t)va; } return UART_CONSOLE_BASE; } void console_init(void) { } void console_putc(int ch) { if (!boot_is_completed) return; __asc_xmit_char((char)ch, console_base()); } void console_flush(void) { if (!boot_is_completed) return; __asc_flush(console_base()); } vaddr_t pl310_base(void) { /* in case it's used before .bss is cleared */ static void *va __early_bss; if (cpu_mmu_enabled()) { if (!va) va = phys_to_virt(PL310_BASE, MEM_AREA_IO_NSEC); return (vaddr_t)va; } return PL310_BASE; }