| 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>
|
|---|
| 41 | #include <arch/mach/integratorcp/integratorcp.h>
|
|---|
| 42 | #include <arch/mach/testarm/testarm.h>
|
|---|
| 43 |
|
|---|
| 44 | /** Pointer to machine_ops structure being used. */
|
|---|
| 45 | struct arm_machine_ops *machine_ops;
|
|---|
| 46 |
|
|---|
| 47 | /** Initialize machine_ops pointer. */
|
|---|
| 48 | void machine_ops_init(void)
|
|---|
| 49 | {
|
|---|
| 50 | #if defined(MACHINE_testarm)
|
|---|
| 51 | machine_ops = &gxemul_machine_ops;
|
|---|
| 52 | #elif defined(MACHINE_integratorcp)
|
|---|
| 53 | machine_ops = &icp_machine_ops;
|
|---|
| 54 | #else
|
|---|
| 55 | #error Machine type not defined.
|
|---|
| 56 | #endif
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | /** Maps HW devices to the kernel address space using #hw_map. */
|
|---|
| 60 | void machine_init(void)
|
|---|
| 61 | {
|
|---|
| 62 | (machine_ops->machine_init)();
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | /** Starts timer. */
|
|---|
| 67 | void machine_timer_irq_start(void)
|
|---|
| 68 | {
|
|---|
| 69 | (machine_ops->machine_timer_irq_start)();
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | /** Halts CPU. */
|
|---|
| 74 | void machine_cpu_halt(void)
|
|---|
| 75 | {
|
|---|
| 76 | (machine_ops->machine_cpu_halt)();
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | /** Returns size of available memory.
|
|---|
| 81 | *
|
|---|
| 82 | * @return Size of available memory.
|
|---|
| 83 | */
|
|---|
| 84 | uintptr_t machine_get_memory_size(void)
|
|---|
| 85 | {
|
|---|
| 86 | return (machine_ops->machine_get_memory_size)();
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | /** Interrupt exception handler.
|
|---|
| 90 | *
|
|---|
| 91 | * @param exc_no Interrupt exception number.
|
|---|
| 92 | * @param istate Saved processor state.
|
|---|
| 93 | */
|
|---|
| 94 | void machine_irq_exception(unsigned int exc_no, istate_t *istate)
|
|---|
| 95 | {
|
|---|
| 96 | (machine_ops->machine_irq_exception)(exc_no, istate);
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 | /*
|
|---|
| 101 | * Machine specific frame initialization
|
|---|
| 102 | */
|
|---|
| 103 | void machine_frame_init(void)
|
|---|
| 104 | {
|
|---|
| 105 | (machine_ops->machine_frame_init)();
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | /*
|
|---|
| 109 | * configure the output device.
|
|---|
| 110 | */
|
|---|
| 111 | void machine_output_init(void)
|
|---|
| 112 | {
|
|---|
| 113 | (machine_ops->machine_output_init)();
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | /*
|
|---|
| 117 | * configure the input device.
|
|---|
| 118 | */
|
|---|
| 119 | void machine_input_init(void)
|
|---|
| 120 | {
|
|---|
| 121 | (machine_ops->machine_input_init)();
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | /** @}
|
|---|
| 125 | */
|
|---|