[e76fed9] | 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 sparc32
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
[32e8cd1] | 33 | * @brief Definitions of machine specific functions.
|
---|
[e76fed9] | 34 | *
|
---|
[32e8cd1] | 35 | * These functions enable to differentiate more kinds of SPARC emulators
|
---|
| 36 | * or CPUs. It's the same concept as "arch" functions on the architecture
|
---|
| 37 | * level.
|
---|
[e76fed9] | 38 | */
|
---|
| 39 |
|
---|
| 40 | #include <arch/machine_func.h>
|
---|
| 41 | #include <arch/machine/leon3/leon3.h>
|
---|
| 42 |
|
---|
| 43 | /** Pointer to machine_ops structure being used. */
|
---|
| 44 | struct sparc_machine_ops *machine_ops;
|
---|
| 45 |
|
---|
| 46 | /** Initialize machine_ops pointer. */
|
---|
| 47 | void machine_ops_init(void)
|
---|
| 48 | {
|
---|
| 49 | #if defined(MACHINE_leon3)
|
---|
| 50 | machine_ops = &leon3_machine_ops;
|
---|
| 51 | #else
|
---|
| 52 | #error Machine type not defined.
|
---|
| 53 | #endif
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[32e8cd1] | 56 | /** Map HW devices to the kernel address space using #hw_map. */
|
---|
[e76fed9] | 57 | void machine_init(bootinfo_t *bootinfo)
|
---|
| 58 | {
|
---|
[32e8cd1] | 59 | machine_ops->machine_init(bootinfo);
|
---|
[e76fed9] | 60 | }
|
---|
| 61 |
|
---|
[32e8cd1] | 62 | /** Start timer. */
|
---|
[e76fed9] | 63 | void machine_timer_irq_start(void)
|
---|
| 64 | {
|
---|
[32e8cd1] | 65 | machine_ops->machine_timer_irq_start();
|
---|
[e76fed9] | 66 | }
|
---|
| 67 |
|
---|
[32e8cd1] | 68 | /** Halt CPU. */
|
---|
[e76fed9] | 69 | void machine_cpu_halt(void)
|
---|
| 70 | {
|
---|
[32e8cd1] | 71 | machine_ops->machine_cpu_halt();
|
---|
[e76fed9] | 72 | }
|
---|
| 73 |
|
---|
| 74 | /** Get extents of available memory.
|
---|
| 75 | *
|
---|
[32e8cd1] | 76 | * @param start Place to store memory start address.
|
---|
| 77 | * @param size Place to store memory size.
|
---|
| 78 | *
|
---|
[e76fed9] | 79 | */
|
---|
| 80 | void machine_get_memory_extents(uintptr_t *start, size_t *size)
|
---|
| 81 | {
|
---|
[32e8cd1] | 82 | machine_ops->machine_get_memory_extents(start, size);
|
---|
[e76fed9] | 83 | }
|
---|
| 84 |
|
---|
| 85 | /** Interrupt exception handler.
|
---|
| 86 | *
|
---|
[32e8cd1] | 87 | * @param exc Interrupt exception number.
|
---|
[e76fed9] | 88 | * @param istate Saved processor state.
|
---|
[32e8cd1] | 89 | *
|
---|
[e76fed9] | 90 | */
|
---|
[32e8cd1] | 91 | void machine_irq_exception(unsigned int exc, istate_t *istate)
|
---|
[e76fed9] | 92 | {
|
---|
[32e8cd1] | 93 | machine_ops->machine_irq_exception(exc, istate);
|
---|
[e76fed9] | 94 | }
|
---|
| 95 |
|
---|
[32e8cd1] | 96 | /** Configure the output device. */
|
---|
[e76fed9] | 97 | void machine_output_init(void)
|
---|
| 98 | {
|
---|
[32e8cd1] | 99 | machine_ops->machine_output_init();
|
---|
[e76fed9] | 100 | }
|
---|
| 101 |
|
---|
[32e8cd1] | 102 | /** Configure the input device. */
|
---|
[e76fed9] | 103 | void machine_input_init(void)
|
---|
| 104 | {
|
---|
[32e8cd1] | 105 | machine_ops->machine_input_init();
|
---|
[e76fed9] | 106 | }
|
---|
| 107 |
|
---|
| 108 | /** Get IRQ number range used by machine. */
|
---|
| 109 | size_t machine_get_irq_count(void)
|
---|
| 110 | {
|
---|
[32e8cd1] | 111 | return machine_ops->machine_get_irq_count();
|
---|
[e76fed9] | 112 | }
|
---|
| 113 |
|
---|
[32e8cd1] | 114 | const char *machine_get_platform_name(void)
|
---|
[e76fed9] | 115 | {
|
---|
| 116 | if (machine_ops->machine_get_platform_name)
|
---|
| 117 | return machine_ops->machine_get_platform_name();
|
---|
[32e8cd1] | 118 |
|
---|
[e76fed9] | 119 | return NULL;
|
---|
| 120 | }
|
---|
[32e8cd1] | 121 |
|
---|
[e76fed9] | 122 | /** @}
|
---|
| 123 | */
|
---|