[6ac14a70] | 1 | /*
|
---|
| 2 | * Copyright (c) 2009 Vineeth Pillai
|
---|
| 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 arm32
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief Definitions of machine specific functions.
|
---|
| 34 | *
|
---|
| 35 | * These functions enable to differentiate more kinds of ARM emulators
|
---|
| 36 | * or CPUs. It's the same concept as "arch" functions on the architecture
|
---|
| 37 | * level.
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | #include <arch/machine_func.h>
|
---|
[7c866dc] | 41 | #include <arch/mach/gta02/gta02.h>
|
---|
[66fcba2] | 42 | #include <arch/mach/integratorcp/integratorcp.h>
|
---|
[8ba5c67] | 43 | #include <arch/mach/beagleboardxm/beagleboardxm.h>
|
---|
[f92976f] | 44 | #include <arch/mach/beaglebone/beaglebone.h>
|
---|
[8f9d70b] | 45 | #include <arch/mach/raspberrypi/raspberrypi.h>
|
---|
[6ac14a70] | 46 |
|
---|
[66fcba2] | 47 | /** Pointer to machine_ops structure being used. */
|
---|
| 48 | struct arm_machine_ops *machine_ops;
|
---|
| 49 |
|
---|
| 50 | /** Initialize machine_ops pointer. */
|
---|
| 51 | void machine_ops_init(void)
|
---|
| 52 | {
|
---|
[7c866dc] | 53 | #if defined(MACHINE_gta02)
|
---|
| 54 | machine_ops = >a02_machine_ops;
|
---|
[66fcba2] | 55 | #elif defined(MACHINE_integratorcp)
|
---|
| 56 | machine_ops = &icp_machine_ops;
|
---|
[6038368] | 57 | #elif defined(MACHINE_beagleboardxm)
|
---|
| 58 | machine_ops = &bbxm_machine_ops;
|
---|
[f92976f] | 59 | #elif defined(MACHINE_beaglebone)
|
---|
| 60 | machine_ops = &bbone_machine_ops;
|
---|
[8f9d70b] | 61 | #elif defined(MACHINE_raspberrypi)
|
---|
| 62 | machine_ops = &raspberrypi_machine_ops;
|
---|
[66fcba2] | 63 | #else
|
---|
| 64 | #error Machine type not defined.
|
---|
| 65 | #endif
|
---|
| 66 | }
|
---|
[6ac14a70] | 67 |
|
---|
| 68 | /** Maps HW devices to the kernel address space using #hw_map. */
|
---|
| 69 | void machine_init(void)
|
---|
| 70 | {
|
---|
[66fcba2] | 71 | (machine_ops->machine_init)();
|
---|
[6ac14a70] | 72 | }
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | /** Starts timer. */
|
---|
| 76 | void machine_timer_irq_start(void)
|
---|
| 77 | {
|
---|
[66fcba2] | 78 | (machine_ops->machine_timer_irq_start)();
|
---|
[6ac14a70] | 79 | }
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | /** Halts CPU. */
|
---|
| 83 | void machine_cpu_halt(void)
|
---|
| 84 | {
|
---|
[66fcba2] | 85 | (machine_ops->machine_cpu_halt)();
|
---|
[6ac14a70] | 86 | }
|
---|
| 87 |
|
---|
[d7ef14b] | 88 | /** Get extents of available memory.
|
---|
[6ac14a70] | 89 | *
|
---|
[d7ef14b] | 90 | * @param start Place to store memory start address.
|
---|
| 91 | * @param size Place to store memory size.
|
---|
[6ac14a70] | 92 | */
|
---|
[2686705] | 93 | void machine_get_memory_extents(uintptr_t *start, size_t *size)
|
---|
[6ac14a70] | 94 | {
|
---|
[d7ef14b] | 95 | (machine_ops->machine_get_memory_extents)(start, size);
|
---|
[6ac14a70] | 96 | }
|
---|
| 97 |
|
---|
| 98 | /** Interrupt exception handler.
|
---|
| 99 | *
|
---|
| 100 | * @param exc_no Interrupt exception number.
|
---|
| 101 | * @param istate Saved processor state.
|
---|
| 102 | */
|
---|
[214ec25c] | 103 | void machine_irq_exception(unsigned int exc_no, istate_t *istate)
|
---|
[6ac14a70] | 104 | {
|
---|
[66fcba2] | 105 | (machine_ops->machine_irq_exception)(exc_no, istate);
|
---|
[6ac14a70] | 106 | }
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | /*
|
---|
| 110 | * Machine specific frame initialization
|
---|
| 111 | */
|
---|
| 112 | void machine_frame_init(void)
|
---|
| 113 | {
|
---|
[66fcba2] | 114 | (machine_ops->machine_frame_init)();
|
---|
[6ac14a70] | 115 | }
|
---|
| 116 |
|
---|
| 117 | /*
|
---|
| 118 | * configure the output device.
|
---|
| 119 | */
|
---|
| 120 | void machine_output_init(void)
|
---|
| 121 | {
|
---|
[66fcba2] | 122 | (machine_ops->machine_output_init)();
|
---|
[6ac14a70] | 123 | }
|
---|
| 124 |
|
---|
| 125 | /*
|
---|
| 126 | * configure the input device.
|
---|
| 127 | */
|
---|
| 128 | void machine_input_init(void)
|
---|
| 129 | {
|
---|
[66fcba2] | 130 | (machine_ops->machine_input_init)();
|
---|
[6ac14a70] | 131 | }
|
---|
| 132 |
|
---|
[0e796cc] | 133 | /** Get IRQ number range used by machine. */
|
---|
| 134 | size_t machine_get_irq_count(void)
|
---|
| 135 | {
|
---|
[ecf083dd] | 136 | return (machine_ops->machine_get_irq_count)();
|
---|
[0e796cc] | 137 | }
|
---|
| 138 |
|
---|
[a19dc957] | 139 | const char * machine_get_platform_name(void)
|
---|
| 140 | {
|
---|
| 141 | if (machine_ops->machine_get_platform_name)
|
---|
| 142 | return machine_ops->machine_get_platform_name();
|
---|
| 143 | return NULL;
|
---|
| 144 | }
|
---|
[6ac14a70] | 145 | /** @}
|
---|
| 146 | */
|
---|