[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>
|
---|
| 43 | #include <arch/mach/testarm/testarm.h>
|
---|
[6038368] | 44 | #include <arch/mach/beagleboardxm/beagleboardxm.h>
|
---|
[6ac14a70] | 45 |
|
---|
[66fcba2] | 46 | /** Pointer to machine_ops structure being used. */
|
---|
| 47 | struct arm_machine_ops *machine_ops;
|
---|
| 48 |
|
---|
| 49 | /** Initialize machine_ops pointer. */
|
---|
| 50 | void machine_ops_init(void)
|
---|
| 51 | {
|
---|
[7c866dc] | 52 | #if defined(MACHINE_gta02)
|
---|
| 53 | machine_ops = >a02_machine_ops;
|
---|
| 54 | #elif defined(MACHINE_testarm)
|
---|
[66fcba2] | 55 | machine_ops = &gxemul_machine_ops;
|
---|
| 56 | #elif defined(MACHINE_integratorcp)
|
---|
| 57 | machine_ops = &icp_machine_ops;
|
---|
[6038368] | 58 | #elif defined(MACHINE_beagleboardxm)
|
---|
| 59 | machine_ops = &bbxm_machine_ops;
|
---|
[66fcba2] | 60 | #else
|
---|
| 61 | #error Machine type not defined.
|
---|
| 62 | #endif
|
---|
| 63 | }
|
---|
[6ac14a70] | 64 |
|
---|
| 65 | /** Maps HW devices to the kernel address space using #hw_map. */
|
---|
| 66 | void machine_init(void)
|
---|
| 67 | {
|
---|
[66fcba2] | 68 | (machine_ops->machine_init)();
|
---|
[6ac14a70] | 69 | }
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | /** Starts timer. */
|
---|
| 73 | void machine_timer_irq_start(void)
|
---|
| 74 | {
|
---|
[66fcba2] | 75 | (machine_ops->machine_timer_irq_start)();
|
---|
[6ac14a70] | 76 | }
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | /** Halts CPU. */
|
---|
| 80 | void machine_cpu_halt(void)
|
---|
| 81 | {
|
---|
[66fcba2] | 82 | (machine_ops->machine_cpu_halt)();
|
---|
[6ac14a70] | 83 | }
|
---|
| 84 |
|
---|
[d7ef14b] | 85 | /** Get extents of available memory.
|
---|
[6ac14a70] | 86 | *
|
---|
[d7ef14b] | 87 | * @param start Place to store memory start address.
|
---|
| 88 | * @param size Place to store memory size.
|
---|
[6ac14a70] | 89 | */
|
---|
[2686705] | 90 | void machine_get_memory_extents(uintptr_t *start, size_t *size)
|
---|
[6ac14a70] | 91 | {
|
---|
[d7ef14b] | 92 | (machine_ops->machine_get_memory_extents)(start, size);
|
---|
[6ac14a70] | 93 | }
|
---|
| 94 |
|
---|
| 95 | /** Interrupt exception handler.
|
---|
| 96 | *
|
---|
| 97 | * @param exc_no Interrupt exception number.
|
---|
| 98 | * @param istate Saved processor state.
|
---|
| 99 | */
|
---|
[214ec25c] | 100 | void machine_irq_exception(unsigned int exc_no, istate_t *istate)
|
---|
[6ac14a70] | 101 | {
|
---|
[66fcba2] | 102 | (machine_ops->machine_irq_exception)(exc_no, istate);
|
---|
[6ac14a70] | 103 | }
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | /*
|
---|
| 107 | * Machine specific frame initialization
|
---|
| 108 | */
|
---|
| 109 | void machine_frame_init(void)
|
---|
| 110 | {
|
---|
[66fcba2] | 111 | (machine_ops->machine_frame_init)();
|
---|
[6ac14a70] | 112 | }
|
---|
| 113 |
|
---|
| 114 | /*
|
---|
| 115 | * configure the output device.
|
---|
| 116 | */
|
---|
| 117 | void machine_output_init(void)
|
---|
| 118 | {
|
---|
[66fcba2] | 119 | (machine_ops->machine_output_init)();
|
---|
[6ac14a70] | 120 | }
|
---|
| 121 |
|
---|
| 122 | /*
|
---|
| 123 | * configure the input device.
|
---|
| 124 | */
|
---|
| 125 | void machine_input_init(void)
|
---|
| 126 | {
|
---|
[66fcba2] | 127 | (machine_ops->machine_input_init)();
|
---|
[6ac14a70] | 128 | }
|
---|
| 129 |
|
---|
[0e796cc] | 130 | /** Get IRQ number range used by machine. */
|
---|
| 131 | size_t machine_get_irq_count(void)
|
---|
| 132 | {
|
---|
[ecf083dd] | 133 | return (machine_ops->machine_get_irq_count)();
|
---|
[0e796cc] | 134 | }
|
---|
| 135 |
|
---|
[6ac14a70] | 136 | /** @}
|
---|
| 137 | */
|
---|