| 1 | /*
|
|---|
| 2 | * Copyright (c) 2010 Martin Decky
|
|---|
| 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 abs32le
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | #ifndef KERN_abs32le_ASM_H_
|
|---|
| 36 | #define KERN_abs32le_ASM_H_
|
|---|
| 37 |
|
|---|
| 38 | #include <typedefs.h>
|
|---|
| 39 | #include <config.h>
|
|---|
| 40 |
|
|---|
| 41 | static inline void asm_delay_loop(uint32_t usec)
|
|---|
| 42 | {
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | static inline __attribute__((noreturn)) void cpu_halt(void)
|
|---|
| 46 | {
|
|---|
| 47 | /* On real hardware this should stop processing further
|
|---|
| 48 | instructions on the CPU (and possibly putting it into
|
|---|
| 49 | low-power mode) without any possibility of exitting
|
|---|
| 50 | this function. */
|
|---|
| 51 |
|
|---|
| 52 | while (true);
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | static inline void cpu_sleep(void)
|
|---|
| 56 | {
|
|---|
| 57 | /* On real hardware this should put the CPU into low-power
|
|---|
| 58 | mode. However, the CPU is free to continue processing
|
|---|
| 59 | futher instructions any time. The CPU also wakes up
|
|---|
| 60 | upon an interrupt. */
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | static inline void pio_write_8(ioport8_t *port, uint8_t val)
|
|---|
| 64 | {
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | /** Word to port
|
|---|
| 68 | *
|
|---|
| 69 | * Output word to port
|
|---|
| 70 | *
|
|---|
| 71 | * @param port Port to write to
|
|---|
| 72 | * @param val Value to write
|
|---|
| 73 | *
|
|---|
| 74 | */
|
|---|
| 75 | static inline void pio_write_16(ioport16_t *port, uint16_t val)
|
|---|
| 76 | {
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | /** Double word to port
|
|---|
| 80 | *
|
|---|
| 81 | * Output double word to port
|
|---|
| 82 | *
|
|---|
| 83 | * @param port Port to write to
|
|---|
| 84 | * @param val Value to write
|
|---|
| 85 | *
|
|---|
| 86 | */
|
|---|
| 87 | static inline void pio_write_32(ioport32_t *port, uint32_t val)
|
|---|
| 88 | {
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | /** Byte from port
|
|---|
| 92 | *
|
|---|
| 93 | * Get byte from port
|
|---|
| 94 | *
|
|---|
| 95 | * @param port Port to read from
|
|---|
| 96 | * @return Value read
|
|---|
| 97 | *
|
|---|
| 98 | */
|
|---|
| 99 | static inline uint8_t pio_read_8(ioport8_t *port)
|
|---|
| 100 | {
|
|---|
| 101 | return 0;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | /** Word from port
|
|---|
| 105 | *
|
|---|
| 106 | * Get word from port
|
|---|
| 107 | *
|
|---|
| 108 | * @param port Port to read from
|
|---|
| 109 | * @return Value read
|
|---|
| 110 | *
|
|---|
| 111 | */
|
|---|
| 112 | static inline uint16_t pio_read_16(ioport16_t *port)
|
|---|
| 113 | {
|
|---|
| 114 | return 0;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | /** Double word from port
|
|---|
| 118 | *
|
|---|
| 119 | * Get double word from port
|
|---|
| 120 | *
|
|---|
| 121 | * @param port Port to read from
|
|---|
| 122 | * @return Value read
|
|---|
| 123 | *
|
|---|
| 124 | */
|
|---|
| 125 | static inline uint32_t pio_read_32(ioport32_t *port)
|
|---|
| 126 | {
|
|---|
| 127 | return 0;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | static inline ipl_t interrupts_enable(void)
|
|---|
| 131 | {
|
|---|
| 132 | /* On real hardware this unconditionally enables preemption
|
|---|
| 133 | by internal and external interrupts.
|
|---|
| 134 |
|
|---|
| 135 | The return value stores the previous interrupt level. */
|
|---|
| 136 |
|
|---|
| 137 | return 0;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | static inline ipl_t interrupts_disable(void)
|
|---|
| 141 | {
|
|---|
| 142 | /* On real hardware this disables preemption by the usual
|
|---|
| 143 | set of internal and external interrupts. This does not
|
|---|
| 144 | apply to special non-maskable interrupts and sychronous
|
|---|
| 145 | CPU exceptions.
|
|---|
| 146 |
|
|---|
| 147 | The return value stores the previous interrupt level. */
|
|---|
| 148 |
|
|---|
| 149 | return 0;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | static inline void interrupts_restore(ipl_t ipl)
|
|---|
| 153 | {
|
|---|
| 154 | /* On real hardware this either enables or disables preemption
|
|---|
| 155 | according to the interrupt level value from the argument. */
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | static inline ipl_t interrupts_read(void)
|
|---|
| 159 | {
|
|---|
| 160 | /* On real hardware the return value stores the current interrupt
|
|---|
| 161 | level. */
|
|---|
| 162 |
|
|---|
| 163 | return 0;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | static inline bool interrupts_disabled(void)
|
|---|
| 167 | {
|
|---|
| 168 | /* On real hardware the return value is true iff interrupts are
|
|---|
| 169 | disabled. */
|
|---|
| 170 | return false;
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | static inline uintptr_t get_stack_base(void)
|
|---|
| 174 | {
|
|---|
| 175 | /* On real hardware this returns the address of the bottom
|
|---|
| 176 | of the current CPU stack. The the_t structure is stored
|
|---|
| 177 | on the bottom of stack and this is used to identify the
|
|---|
| 178 | current CPU, current task, current thread and current
|
|---|
| 179 | address space. */
|
|---|
| 180 |
|
|---|
| 181 | return 0;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | #endif
|
|---|
| 185 |
|
|---|
| 186 | /** @}
|
|---|
| 187 | */
|
|---|