| [f761f1eb] | 1 | /*
|
|---|
| [df4ed85] | 2 | * Copyright (c) 2001-2004 Jakub Jermar
|
|---|
| 3 | * Copyright (c) 2005 Sergey Bondari
|
|---|
| [f761f1eb] | 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 |
|
|---|
| [add04f7] | 30 | /** @addtogroup ia32
|
|---|
| [b45c443] | 31 | * @{
|
|---|
| 32 | */
|
|---|
| 33 | /** @file
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| [06e1e95] | 36 | #ifndef KERN_ia32_ASM_H_
|
|---|
| 37 | #define KERN_ia32_ASM_H_
|
|---|
| [f761f1eb] | 38 |
|
|---|
| [897ad60] | 39 | #include <arch/pm.h>
|
|---|
| [2b4a9f26] | 40 | #include <arch/cpu.h>
|
|---|
| [c22e964] | 41 | #include <typedefs.h>
|
|---|
| [361635c] | 42 | #include <config.h>
|
|---|
| [7a0359b] | 43 | #include <trace.h>
|
|---|
| [f761f1eb] | 44 |
|
|---|
| [18e0a6c] | 45 | /** Halt CPU
|
|---|
| 46 | *
|
|---|
| [3a1c048] | 47 | * Halt the current CPU.
|
|---|
| [add04f7] | 48 | *
|
|---|
| [18e0a6c] | 49 | */
|
|---|
| [7a0359b] | 50 | NO_TRACE static inline __attribute__((noreturn)) void cpu_halt(void)
|
|---|
| [e7b7be3f] | 51 | {
|
|---|
| [82474ef] | 52 | while (true) {
|
|---|
| 53 | asm volatile (
|
|---|
| 54 | "hlt\n"
|
|---|
| 55 | );
|
|---|
| 56 | }
|
|---|
| [60133d0] | 57 | }
|
|---|
| [e7b7be3f] | 58 |
|
|---|
| [7a0359b] | 59 | NO_TRACE static inline void cpu_sleep(void)
|
|---|
| [e7b7be3f] | 60 | {
|
|---|
| [7a0359b] | 61 | asm volatile (
|
|---|
| 62 | "hlt\n"
|
|---|
| 63 | );
|
|---|
| [60133d0] | 64 | }
|
|---|
| [f761f1eb] | 65 |
|
|---|
| [96b02eb9] | 66 | #define GEN_READ_REG(reg) NO_TRACE static inline sysarg_t read_ ##reg (void) \
|
|---|
| [add04f7] | 67 | { \
|
|---|
| [96b02eb9] | 68 | sysarg_t res; \
|
|---|
| [add04f7] | 69 | asm volatile ( \
|
|---|
| 70 | "movl %%" #reg ", %[res]" \
|
|---|
| 71 | : [res] "=r" (res) \
|
|---|
| 72 | ); \
|
|---|
| 73 | return res; \
|
|---|
| 74 | }
|
|---|
| [0f4e706] | 75 |
|
|---|
| [96b02eb9] | 76 | #define GEN_WRITE_REG(reg) NO_TRACE static inline void write_ ##reg (sysarg_t regn) \
|
|---|
| [add04f7] | 77 | { \
|
|---|
| 78 | asm volatile ( \
|
|---|
| 79 | "movl %[regn], %%" #reg \
|
|---|
| 80 | :: [regn] "r" (regn) \
|
|---|
| 81 | ); \
|
|---|
| 82 | }
|
|---|
| [18e0a6c] | 83 |
|
|---|
| [60133d0] | 84 | GEN_READ_REG(cr0)
|
|---|
| 85 | GEN_READ_REG(cr2)
|
|---|
| 86 | GEN_READ_REG(cr3)
|
|---|
| 87 | GEN_WRITE_REG(cr3)
|
|---|
| 88 |
|
|---|
| 89 | GEN_READ_REG(dr0)
|
|---|
| 90 | GEN_READ_REG(dr1)
|
|---|
| 91 | GEN_READ_REG(dr2)
|
|---|
| 92 | GEN_READ_REG(dr3)
|
|---|
| 93 | GEN_READ_REG(dr6)
|
|---|
| 94 | GEN_READ_REG(dr7)
|
|---|
| 95 |
|
|---|
| 96 | GEN_WRITE_REG(dr0)
|
|---|
| 97 | GEN_WRITE_REG(dr1)
|
|---|
| 98 | GEN_WRITE_REG(dr2)
|
|---|
| 99 | GEN_WRITE_REG(dr3)
|
|---|
| 100 | GEN_WRITE_REG(dr6)
|
|---|
| 101 | GEN_WRITE_REG(dr7)
|
|---|
| [18e0a6c] | 102 |
|
|---|
| [667a4f8] | 103 | #define IO_SPACE_BOUNDARY ((void *) (64 * 1024))
|
|---|
| 104 |
|
|---|
| [a5556b4] | 105 | /** Byte to port
|
|---|
| 106 | *
|
|---|
| 107 | * Output byte to port
|
|---|
| 108 | *
|
|---|
| 109 | * @param port Port to write to
|
|---|
| 110 | * @param val Value to write
|
|---|
| [add04f7] | 111 | *
|
|---|
| [a5556b4] | 112 | */
|
|---|
| [7a0359b] | 113 | NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t val)
|
|---|
| [e7b7be3f] | 114 | {
|
|---|
| [abf04a54] | 115 | if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
|
|---|
| [667a4f8] | 116 | asm volatile (
|
|---|
| 117 | "outb %b[val], %w[port]\n"
|
|---|
| 118 | :: [val] "a" (val), [port] "d" (port)
|
|---|
| 119 | );
|
|---|
| [c22531fc] | 120 | } else
|
|---|
| [abf04a54] | 121 | *port = val;
|
|---|
| [e7b7be3f] | 122 | }
|
|---|
| [a5556b4] | 123 |
|
|---|
| [714675b] | 124 | /** Word to port
|
|---|
| 125 | *
|
|---|
| 126 | * Output word to port
|
|---|
| 127 | *
|
|---|
| 128 | * @param port Port to write to
|
|---|
| 129 | * @param val Value to write
|
|---|
| [add04f7] | 130 | *
|
|---|
| [714675b] | 131 | */
|
|---|
| [7a0359b] | 132 | NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t val)
|
|---|
| [e7b7be3f] | 133 | {
|
|---|
| [abf04a54] | 134 | if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
|
|---|
| [667a4f8] | 135 | asm volatile (
|
|---|
| 136 | "outw %w[val], %w[port]\n"
|
|---|
| 137 | :: [val] "a" (val), [port] "d" (port)
|
|---|
| 138 | );
|
|---|
| [c22531fc] | 139 | } else
|
|---|
| [abf04a54] | 140 | *port = val;
|
|---|
| [e7b7be3f] | 141 | }
|
|---|
| [714675b] | 142 |
|
|---|
| 143 | /** Double word to port
|
|---|
| 144 | *
|
|---|
| 145 | * Output double word to port
|
|---|
| 146 | *
|
|---|
| 147 | * @param port Port to write to
|
|---|
| 148 | * @param val Value to write
|
|---|
| [add04f7] | 149 | *
|
|---|
| [714675b] | 150 | */
|
|---|
| [7a0359b] | 151 | NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t val)
|
|---|
| [e7b7be3f] | 152 | {
|
|---|
| [abf04a54] | 153 | if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
|
|---|
| [667a4f8] | 154 | asm volatile (
|
|---|
| 155 | "outl %[val], %w[port]\n"
|
|---|
| 156 | :: [val] "a" (val), [port] "d" (port)
|
|---|
| 157 | );
|
|---|
| [c22531fc] | 158 | } else
|
|---|
| [abf04a54] | 159 | *port = val;
|
|---|
| [e7b7be3f] | 160 | }
|
|---|
| [a5556b4] | 161 |
|
|---|
| [105a0dc] | 162 | /** Byte from port
|
|---|
| 163 | *
|
|---|
| 164 | * Get byte from port
|
|---|
| 165 | *
|
|---|
| 166 | * @param port Port to read from
|
|---|
| 167 | * @return Value read
|
|---|
| [add04f7] | 168 | *
|
|---|
| [105a0dc] | 169 | */
|
|---|
| [7a0359b] | 170 | NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
|
|---|
| [e7b7be3f] | 171 | {
|
|---|
| [667a4f8] | 172 | if (((void *)port) < IO_SPACE_BOUNDARY) {
|
|---|
| 173 | uint8_t val;
|
|---|
| [c22531fc] | 174 |
|
|---|
| [667a4f8] | 175 | asm volatile (
|
|---|
| 176 | "inb %w[port], %b[val]\n"
|
|---|
| 177 | : [val] "=a" (val)
|
|---|
| 178 | : [port] "d" (port)
|
|---|
| 179 | );
|
|---|
| [c22531fc] | 180 |
|
|---|
| [667a4f8] | 181 | return val;
|
|---|
| [c22531fc] | 182 | } else
|
|---|
| [667a4f8] | 183 | return (uint8_t) *port;
|
|---|
| [e7b7be3f] | 184 | }
|
|---|
| [105a0dc] | 185 |
|
|---|
| 186 | /** Word from port
|
|---|
| 187 | *
|
|---|
| 188 | * Get word from port
|
|---|
| 189 | *
|
|---|
| 190 | * @param port Port to read from
|
|---|
| 191 | * @return Value read
|
|---|
| [add04f7] | 192 | *
|
|---|
| [105a0dc] | 193 | */
|
|---|
| [7a0359b] | 194 | NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
|
|---|
| [e7b7be3f] | 195 | {
|
|---|
| [667a4f8] | 196 | if (((void *)port) < IO_SPACE_BOUNDARY) {
|
|---|
| 197 | uint16_t val;
|
|---|
| [c22531fc] | 198 |
|
|---|
| [667a4f8] | 199 | asm volatile (
|
|---|
| 200 | "inw %w[port], %w[val]\n"
|
|---|
| 201 | : [val] "=a" (val)
|
|---|
| 202 | : [port] "d" (port)
|
|---|
| 203 | );
|
|---|
| [c22531fc] | 204 |
|
|---|
| [667a4f8] | 205 | return val;
|
|---|
| [c22531fc] | 206 | } else
|
|---|
| [667a4f8] | 207 | return (uint16_t) *port;
|
|---|
| [e7b7be3f] | 208 | }
|
|---|
| [105a0dc] | 209 |
|
|---|
| 210 | /** Double word from port
|
|---|
| 211 | *
|
|---|
| 212 | * Get double word from port
|
|---|
| 213 | *
|
|---|
| 214 | * @param port Port to read from
|
|---|
| 215 | * @return Value read
|
|---|
| [add04f7] | 216 | *
|
|---|
| [105a0dc] | 217 | */
|
|---|
| [7a0359b] | 218 | NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
|
|---|
| [e7b7be3f] | 219 | {
|
|---|
| [667a4f8] | 220 | if (((void *)port) < IO_SPACE_BOUNDARY) {
|
|---|
| 221 | uint32_t val;
|
|---|
| [c22531fc] | 222 |
|
|---|
| [667a4f8] | 223 | asm volatile (
|
|---|
| 224 | "inl %w[port], %[val]\n"
|
|---|
| 225 | : [val] "=a" (val)
|
|---|
| 226 | : [port] "d" (port)
|
|---|
| 227 | );
|
|---|
| [c22531fc] | 228 |
|
|---|
| [667a4f8] | 229 | return val;
|
|---|
| [c22531fc] | 230 | } else
|
|---|
| [667a4f8] | 231 | return (uint32_t) *port;
|
|---|
| [e7b7be3f] | 232 | }
|
|---|
| [105a0dc] | 233 |
|
|---|
| [22f7769] | 234 | /** Enable interrupts.
|
|---|
| [18e0a6c] | 235 | *
|
|---|
| 236 | * Enable interrupts and return previous
|
|---|
| 237 | * value of EFLAGS.
|
|---|
| [22f7769] | 238 | *
|
|---|
| 239 | * @return Old interrupt priority level.
|
|---|
| [add04f7] | 240 | *
|
|---|
| [18e0a6c] | 241 | */
|
|---|
| [7a0359b] | 242 | NO_TRACE static inline ipl_t interrupts_enable(void)
|
|---|
| [0259524] | 243 | {
|
|---|
| [22f7769] | 244 | ipl_t v;
|
|---|
| [add04f7] | 245 |
|
|---|
| [e7b7be3f] | 246 | asm volatile (
|
|---|
| [add04f7] | 247 | "pushf\n"
|
|---|
| 248 | "popl %[v]\n"
|
|---|
| [18e0a6c] | 249 | "sti\n"
|
|---|
| [add04f7] | 250 | : [v] "=r" (v)
|
|---|
| [18e0a6c] | 251 | );
|
|---|
| [add04f7] | 252 |
|
|---|
| [18e0a6c] | 253 | return v;
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| [22f7769] | 256 | /** Disable interrupts.
|
|---|
| [18e0a6c] | 257 | *
|
|---|
| 258 | * Disable interrupts and return previous
|
|---|
| 259 | * value of EFLAGS.
|
|---|
| [22f7769] | 260 | *
|
|---|
| 261 | * @return Old interrupt priority level.
|
|---|
| [add04f7] | 262 | *
|
|---|
| [18e0a6c] | 263 | */
|
|---|
| [7a0359b] | 264 | NO_TRACE static inline ipl_t interrupts_disable(void)
|
|---|
| [0259524] | 265 | {
|
|---|
| [22f7769] | 266 | ipl_t v;
|
|---|
| [add04f7] | 267 |
|
|---|
| [e7b7be3f] | 268 | asm volatile (
|
|---|
| [add04f7] | 269 | "pushf\n"
|
|---|
| 270 | "popl %[v]\n"
|
|---|
| [18e0a6c] | 271 | "cli\n"
|
|---|
| [add04f7] | 272 | : [v] "=r" (v)
|
|---|
| [18e0a6c] | 273 | );
|
|---|
| [add04f7] | 274 |
|
|---|
| [18e0a6c] | 275 | return v;
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| [22f7769] | 278 | /** Restore interrupt priority level.
|
|---|
| [18e0a6c] | 279 | *
|
|---|
| 280 | * Restore EFLAGS.
|
|---|
| [22f7769] | 281 | *
|
|---|
| 282 | * @param ipl Saved interrupt priority level.
|
|---|
| [add04f7] | 283 | *
|
|---|
| [18e0a6c] | 284 | */
|
|---|
| [7a0359b] | 285 | NO_TRACE static inline void interrupts_restore(ipl_t ipl)
|
|---|
| [0259524] | 286 | {
|
|---|
| [e7b7be3f] | 287 | asm volatile (
|
|---|
| [add04f7] | 288 | "pushl %[ipl]\n"
|
|---|
| [18e0a6c] | 289 | "popf\n"
|
|---|
| [add04f7] | 290 | :: [ipl] "r" (ipl)
|
|---|
| [18e0a6c] | 291 | );
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| [22f7769] | 294 | /** Return interrupt priority level.
|
|---|
| [18e0a6c] | 295 | *
|
|---|
| [22f7769] | 296 | * @return EFLAFS.
|
|---|
| [add04f7] | 297 | *
|
|---|
| [18e0a6c] | 298 | */
|
|---|
| [7a0359b] | 299 | NO_TRACE static inline ipl_t interrupts_read(void)
|
|---|
| [0259524] | 300 | {
|
|---|
| [22f7769] | 301 | ipl_t v;
|
|---|
| [add04f7] | 302 |
|
|---|
| [e7b7be3f] | 303 | asm volatile (
|
|---|
| [add04f7] | 304 | "pushf\n"
|
|---|
| 305 | "popl %[v]\n"
|
|---|
| 306 | : [v] "=r" (v)
|
|---|
| [18e0a6c] | 307 | );
|
|---|
| [add04f7] | 308 |
|
|---|
| [18e0a6c] | 309 | return v;
|
|---|
| 310 | }
|
|---|
| [c9b8c5c] | 311 |
|
|---|
| [2b4a9f26] | 312 | /** Check interrupts state.
|
|---|
| 313 | *
|
|---|
| 314 | * @return True if interrupts are disabled.
|
|---|
| 315 | *
|
|---|
| 316 | */
|
|---|
| [7a0359b] | 317 | NO_TRACE static inline bool interrupts_disabled(void)
|
|---|
| [2b4a9f26] | 318 | {
|
|---|
| 319 | ipl_t v;
|
|---|
| 320 |
|
|---|
| 321 | asm volatile (
|
|---|
| 322 | "pushf\n"
|
|---|
| 323 | "popl %[v]\n"
|
|---|
| 324 | : [v] "=r" (v)
|
|---|
| 325 | );
|
|---|
| 326 |
|
|---|
| 327 | return ((v & EFLAGS_IF) == 0);
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| [8c15255] | 330 | #ifndef PROCESSOR_i486
|
|---|
| [1c99eae] | 331 |
|
|---|
| [f2ef7fd] | 332 | /** Write to MSR */
|
|---|
| [7a0359b] | 333 | NO_TRACE static inline void write_msr(uint32_t msr, uint64_t value)
|
|---|
| [f2ef7fd] | 334 | {
|
|---|
| [add04f7] | 335 | asm volatile (
|
|---|
| 336 | "wrmsr"
|
|---|
| [7a0359b] | 337 | :: "c" (msr),
|
|---|
| 338 | "a" ((uint32_t) (value)),
|
|---|
| [add04f7] | 339 | "d" ((uint32_t) (value >> 32))
|
|---|
| 340 | );
|
|---|
| [f2ef7fd] | 341 | }
|
|---|
| 342 |
|
|---|
| [7a0359b] | 343 | NO_TRACE static inline uint64_t read_msr(uint32_t msr)
|
|---|
| [f2ef7fd] | 344 | {
|
|---|
| 345 | uint32_t ax, dx;
|
|---|
| [add04f7] | 346 |
|
|---|
| 347 | asm volatile (
|
|---|
| 348 | "rdmsr"
|
|---|
| [7a0359b] | 349 | : "=a" (ax),
|
|---|
| 350 | "=d" (dx)
|
|---|
| [add04f7] | 351 | : "c" (msr)
|
|---|
| 352 | );
|
|---|
| 353 |
|
|---|
| 354 | return ((uint64_t) dx << 32) | ax;
|
|---|
| [f2ef7fd] | 355 | }
|
|---|
| [1c99eae] | 356 |
|
|---|
| 357 | #endif /* PROCESSOR_i486 */
|
|---|
| [f2ef7fd] | 358 |
|
|---|
| 359 |
|
|---|
| [361635c] | 360 | /** Return base address of current stack
|
|---|
| 361 | *
|
|---|
| 362 | * Return the base address of the current stack.
|
|---|
| 363 | * The stack is assumed to be STACK_SIZE bytes long.
|
|---|
| [1fbbcd6] | 364 | * The stack must start on page boundary.
|
|---|
| [add04f7] | 365 | *
|
|---|
| [361635c] | 366 | */
|
|---|
| [7a0359b] | 367 | NO_TRACE static inline uintptr_t get_stack_base(void)
|
|---|
| [361635c] | 368 | {
|
|---|
| [7f1c620] | 369 | uintptr_t v;
|
|---|
| [361635c] | 370 |
|
|---|
| [7f043c0] | 371 | asm volatile (
|
|---|
| [add04f7] | 372 | "andl %%esp, %[v]\n"
|
|---|
| 373 | : [v] "=r" (v)
|
|---|
| [7f043c0] | 374 | : "0" (~(STACK_SIZE - 1))
|
|---|
| 375 | );
|
|---|
| [361635c] | 376 |
|
|---|
| 377 | return v;
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| [7910cff] | 380 | /** Invalidate TLB Entry.
|
|---|
| 381 | *
|
|---|
| 382 | * @param addr Address on a page whose TLB entry is to be invalidated.
|
|---|
| [add04f7] | 383 | *
|
|---|
| [7910cff] | 384 | */
|
|---|
| [7a0359b] | 385 | NO_TRACE static inline void invlpg(uintptr_t addr)
|
|---|
| [7910cff] | 386 | {
|
|---|
| [add04f7] | 387 | asm volatile (
|
|---|
| 388 | "invlpg %[addr]\n"
|
|---|
| [96b02eb9] | 389 | :: [addr] "m" (*(sysarg_t *) addr)
|
|---|
| [add04f7] | 390 | );
|
|---|
| [7910cff] | 391 | }
|
|---|
| 392 |
|
|---|
| [897ad60] | 393 | /** Load GDTR register from memory.
|
|---|
| 394 | *
|
|---|
| 395 | * @param gdtr_reg Address of memory from where to load GDTR.
|
|---|
| [add04f7] | 396 | *
|
|---|
| [897ad60] | 397 | */
|
|---|
| [7a0359b] | 398 | NO_TRACE static inline void gdtr_load(ptr_16_32_t *gdtr_reg)
|
|---|
| [897ad60] | 399 | {
|
|---|
| [add04f7] | 400 | asm volatile (
|
|---|
| 401 | "lgdtl %[gdtr_reg]\n"
|
|---|
| 402 | :: [gdtr_reg] "m" (*gdtr_reg)
|
|---|
| 403 | );
|
|---|
| [897ad60] | 404 | }
|
|---|
| 405 |
|
|---|
| 406 | /** Store GDTR register to memory.
|
|---|
| 407 | *
|
|---|
| 408 | * @param gdtr_reg Address of memory to where to load GDTR.
|
|---|
| [add04f7] | 409 | *
|
|---|
| [897ad60] | 410 | */
|
|---|
| [7a0359b] | 411 | NO_TRACE static inline void gdtr_store(ptr_16_32_t *gdtr_reg)
|
|---|
| [897ad60] | 412 | {
|
|---|
| [add04f7] | 413 | asm volatile (
|
|---|
| 414 | "sgdtl %[gdtr_reg]\n"
|
|---|
| [c4d11c5] | 415 | : [gdtr_reg] "=m" (*gdtr_reg)
|
|---|
| [add04f7] | 416 | );
|
|---|
| [897ad60] | 417 | }
|
|---|
| 418 |
|
|---|
| 419 | /** Load IDTR register from memory.
|
|---|
| 420 | *
|
|---|
| 421 | * @param idtr_reg Address of memory from where to load IDTR.
|
|---|
| [add04f7] | 422 | *
|
|---|
| [897ad60] | 423 | */
|
|---|
| [7a0359b] | 424 | NO_TRACE static inline void idtr_load(ptr_16_32_t *idtr_reg)
|
|---|
| [897ad60] | 425 | {
|
|---|
| [add04f7] | 426 | asm volatile (
|
|---|
| 427 | "lidtl %[idtr_reg]\n"
|
|---|
| 428 | :: [idtr_reg] "m" (*idtr_reg)
|
|---|
| 429 | );
|
|---|
| [897ad60] | 430 | }
|
|---|
| 431 |
|
|---|
| 432 | /** Load TR from descriptor table.
|
|---|
| 433 | *
|
|---|
| 434 | * @param sel Selector specifying descriptor of TSS segment.
|
|---|
| [add04f7] | 435 | *
|
|---|
| [897ad60] | 436 | */
|
|---|
| [7a0359b] | 437 | NO_TRACE static inline void tr_load(uint16_t sel)
|
|---|
| [897ad60] | 438 | {
|
|---|
| [add04f7] | 439 | asm volatile (
|
|---|
| 440 | "ltr %[sel]"
|
|---|
| 441 | :: [sel] "r" (sel)
|
|---|
| 442 | );
|
|---|
| [897ad60] | 443 | }
|
|---|
| 444 |
|
|---|
| [7a0359b] | 445 | extern void paging_on(void);
|
|---|
| 446 | extern void enable_l_apic_in_msr(void);
|
|---|
| 447 |
|
|---|
| 448 | extern void asm_delay_loop(uint32_t);
|
|---|
| 449 | extern void asm_fake_loop(uint32_t);
|
|---|
| 450 |
|
|---|
| [44c69b66] | 451 | extern uintptr_t int_syscall;
|
|---|
| 452 |
|
|---|
| [b808660] | 453 | extern uintptr_t int_0;
|
|---|
| 454 | extern uintptr_t int_1;
|
|---|
| 455 | extern uintptr_t int_2;
|
|---|
| 456 | extern uintptr_t int_3;
|
|---|
| 457 | extern uintptr_t int_4;
|
|---|
| 458 | extern uintptr_t int_5;
|
|---|
| 459 | extern uintptr_t int_6;
|
|---|
| 460 | extern uintptr_t int_7;
|
|---|
| 461 | extern uintptr_t int_8;
|
|---|
| 462 | extern uintptr_t int_9;
|
|---|
| 463 | extern uintptr_t int_10;
|
|---|
| 464 | extern uintptr_t int_11;
|
|---|
| 465 | extern uintptr_t int_12;
|
|---|
| 466 | extern uintptr_t int_13;
|
|---|
| 467 | extern uintptr_t int_14;
|
|---|
| 468 | extern uintptr_t int_15;
|
|---|
| 469 | extern uintptr_t int_16;
|
|---|
| 470 | extern uintptr_t int_17;
|
|---|
| 471 | extern uintptr_t int_18;
|
|---|
| 472 | extern uintptr_t int_19;
|
|---|
| 473 | extern uintptr_t int_20;
|
|---|
| 474 | extern uintptr_t int_21;
|
|---|
| 475 | extern uintptr_t int_22;
|
|---|
| 476 | extern uintptr_t int_23;
|
|---|
| 477 | extern uintptr_t int_24;
|
|---|
| 478 | extern uintptr_t int_25;
|
|---|
| 479 | extern uintptr_t int_26;
|
|---|
| 480 | extern uintptr_t int_27;
|
|---|
| 481 | extern uintptr_t int_28;
|
|---|
| 482 | extern uintptr_t int_29;
|
|---|
| 483 | extern uintptr_t int_30;
|
|---|
| 484 | extern uintptr_t int_31;
|
|---|
| 485 | extern uintptr_t int_32;
|
|---|
| 486 | extern uintptr_t int_33;
|
|---|
| 487 | extern uintptr_t int_34;
|
|---|
| 488 | extern uintptr_t int_35;
|
|---|
| 489 | extern uintptr_t int_36;
|
|---|
| 490 | extern uintptr_t int_37;
|
|---|
| 491 | extern uintptr_t int_38;
|
|---|
| 492 | extern uintptr_t int_39;
|
|---|
| 493 | extern uintptr_t int_40;
|
|---|
| 494 | extern uintptr_t int_41;
|
|---|
| 495 | extern uintptr_t int_42;
|
|---|
| 496 | extern uintptr_t int_43;
|
|---|
| 497 | extern uintptr_t int_44;
|
|---|
| 498 | extern uintptr_t int_45;
|
|---|
| 499 | extern uintptr_t int_46;
|
|---|
| 500 | extern uintptr_t int_47;
|
|---|
| 501 | extern uintptr_t int_48;
|
|---|
| 502 | extern uintptr_t int_49;
|
|---|
| 503 | extern uintptr_t int_50;
|
|---|
| 504 | extern uintptr_t int_51;
|
|---|
| 505 | extern uintptr_t int_52;
|
|---|
| 506 | extern uintptr_t int_53;
|
|---|
| 507 | extern uintptr_t int_54;
|
|---|
| 508 | extern uintptr_t int_55;
|
|---|
| 509 | extern uintptr_t int_56;
|
|---|
| 510 | extern uintptr_t int_57;
|
|---|
| 511 | extern uintptr_t int_58;
|
|---|
| 512 | extern uintptr_t int_59;
|
|---|
| 513 | extern uintptr_t int_60;
|
|---|
| 514 | extern uintptr_t int_61;
|
|---|
| 515 | extern uintptr_t int_62;
|
|---|
| 516 | extern uintptr_t int_63;
|
|---|
| 517 |
|
|---|
| [f761f1eb] | 518 | #endif
|
|---|
| [b45c443] | 519 |
|
|---|
| [06e1e95] | 520 | /** @}
|
|---|
| [b45c443] | 521 | */
|
|---|