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