[a522999] | 1 | /*
|
---|
| 2 | * Copyright (c) 2009 Vineeth Pillai
|
---|
| 3 | * Copyright (c) 2012 Jakub Jermar
|
---|
| 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
[c5429fe] | 30 | /** @addtogroup kernel_mips32
|
---|
[a522999] | 31 | * @{
|
---|
| 32 | */
|
---|
| 33 | /** @file
|
---|
| 34 | * @brief Definitions of machine specific functions.
|
---|
| 35 | *
|
---|
| 36 | * These functions allow us to support various kinds of mips32 machines
|
---|
| 37 | * in a unified way.
|
---|
| 38 | */
|
---|
| 39 |
|
---|
[e29e44bf] | 40 | #include <stddef.h>
|
---|
[a522999] | 41 | #include <arch/machine_func.h>
|
---|
| 42 | #if defined(MACHINE_msim)
|
---|
| 43 | #include <arch/mach/msim/msim.h>
|
---|
| 44 | #elif defined(MACHINE_lmalta) || defined(MACHINE_bmalta)
|
---|
| 45 | #include <arch/mach/malta/malta.h>
|
---|
| 46 | #endif
|
---|
| 47 |
|
---|
| 48 | /** Pointer to machine_ops structure being used. */
|
---|
| 49 | struct mips32_machine_ops *machine_ops;
|
---|
| 50 |
|
---|
| 51 | /** Initialize machine_ops pointer. */
|
---|
| 52 | void machine_ops_init(void)
|
---|
| 53 | {
|
---|
| 54 | #if defined(MACHINE_msim)
|
---|
| 55 | machine_ops = &msim_machine_ops;
|
---|
| 56 | #elif defined(MACHINE_lmalta) || defined(MACHINE_bmalta)
|
---|
| 57 | machine_ops = &malta_machine_ops;
|
---|
| 58 | #else
|
---|
| 59 | #error Machine type not defined.
|
---|
| 60 | #endif
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | void machine_init(void)
|
---|
| 64 | {
|
---|
| 65 | (machine_ops->machine_init)();
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | /** Halts CPU. */
|
---|
| 69 | void machine_cpu_halt(void)
|
---|
| 70 | {
|
---|
| 71 | (machine_ops->machine_cpu_halt)();
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | /** Get extents of available memory.
|
---|
| 75 | *
|
---|
| 76 | * @param start Place to store memory start address.
|
---|
| 77 | * @param size Place to store memory size.
|
---|
| 78 | */
|
---|
| 79 | void machine_get_memory_extents(uintptr_t *start, size_t *size)
|
---|
| 80 | {
|
---|
| 81 | (machine_ops->machine_get_memory_extents)(start, size);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /*
|
---|
| 85 | * Machine specific frame initialization
|
---|
| 86 | */
|
---|
| 87 | void machine_frame_init(void)
|
---|
| 88 | {
|
---|
| 89 | (machine_ops->machine_frame_init)();
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /*
|
---|
| 93 | * configure the output device.
|
---|
| 94 | */
|
---|
| 95 | void machine_output_init(void)
|
---|
| 96 | {
|
---|
| 97 | (machine_ops->machine_output_init)();
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | /*
|
---|
| 101 | * configure the input device.
|
---|
| 102 | */
|
---|
| 103 | void machine_input_init(void)
|
---|
| 104 | {
|
---|
| 105 | (machine_ops->machine_input_init)();
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | const char *machine_get_platform_name(void)
|
---|
| 109 | {
|
---|
| 110 | if (machine_ops->machine_get_platform_name)
|
---|
| 111 | return machine_ops->machine_get_platform_name();
|
---|
| 112 | return NULL;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | /** @}
|
---|
| 116 | */
|
---|