[84176f3] | 1 | /*
|
---|
| 2 | * Copyright (c) 2016 Petr Pavlu
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup kernel_arm64
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief Definitions of machine specific functions.
|
---|
| 34 | *
|
---|
| 35 | * These functions enable to differentiate more kinds of ARM platforms.
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | #include <arch/machine_func.h>
|
---|
[06f10ac] | 39 | #include <arch/mach/hikey960/hikey960.h>
|
---|
[84176f3] | 40 | #include <arch/mach/virt/virt.h>
|
---|
| 41 |
|
---|
| 42 | /** Pointer to machine_ops structure being used. */
|
---|
| 43 | static struct arm_machine_ops *machine_ops;
|
---|
| 44 |
|
---|
| 45 | /** Initialize machine_ops pointer. */
|
---|
| 46 | void machine_ops_init(void)
|
---|
| 47 | {
|
---|
| 48 | #if defined(MACHINE_virt)
|
---|
| 49 | machine_ops = &virt_machine_ops;
|
---|
[06f10ac] | 50 | #elif defined(MACHINE_hikey960)
|
---|
| 51 | machine_ops = &hikey960_machine_ops;
|
---|
[84176f3] | 52 | #else
|
---|
| 53 | #error Machine type not defined.
|
---|
| 54 | #endif
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | /** Perform machine-specific initialization. */
|
---|
| 58 | void machine_init(void)
|
---|
| 59 | {
|
---|
| 60 | machine_ops->machine_init();
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | /** Interrupt exception handler.
|
---|
| 64 | *
|
---|
| 65 | * @param exc_no Interrupt exception number.
|
---|
| 66 | * @param istate Saved processor state.
|
---|
| 67 | */
|
---|
| 68 | void machine_irq_exception(unsigned int exc_no, istate_t *istate)
|
---|
| 69 | {
|
---|
| 70 | machine_ops->machine_irq_exception(exc_no, istate);
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | /** Configure the output device. */
|
---|
| 74 | void machine_output_init(void)
|
---|
| 75 | {
|
---|
| 76 | machine_ops->machine_output_init();
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | /** Configure the input device. */
|
---|
| 80 | void machine_input_init(void)
|
---|
| 81 | {
|
---|
| 82 | machine_ops->machine_input_init();
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | /** Get IRQ number range used by machine. */
|
---|
| 86 | size_t machine_get_irq_count(void)
|
---|
| 87 | {
|
---|
| 88 | return machine_ops->machine_get_irq_count();
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | /** Enable virtual timer interrupt and return its number. */
|
---|
| 92 | inr_t machine_enable_vtimer_irq(void)
|
---|
| 93 | {
|
---|
| 94 | return machine_ops->machine_enable_vtimer_irq();
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | /** Get platform identifier. */
|
---|
| 98 | const char *machine_get_platform_name(void)
|
---|
| 99 | {
|
---|
| 100 | return machine_ops->machine_get_platform_name();
|
---|
| 101 | }
|
---|
| 102 |
|
---|
[ebb3538] | 103 | /** Early debugging output. */
|
---|
| 104 | void machine_early_uart_output(char32_t c)
|
---|
| 105 | {
|
---|
| 106 | if (machine_ops->machine_early_uart_output != NULL)
|
---|
| 107 | machine_ops->machine_early_uart_output(c);
|
---|
| 108 | }
|
---|
| 109 |
|
---|
[84176f3] | 110 | /** @}
|
---|
| 111 | */
|
---|