| 1 | /*
|
|---|
| 2 | * Copyright (c) 2005 Jakub Jermar
|
|---|
| 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 sparc64
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | #ifndef KERN_sparc64_ASM_H_
|
|---|
| 36 | #define KERN_sparc64_ASM_H_
|
|---|
| 37 |
|
|---|
| 38 | #include <arch/arch.h>
|
|---|
| 39 | #include <typedefs.h>
|
|---|
| 40 | #include <align.h>
|
|---|
| 41 | #include <arch/register.h>
|
|---|
| 42 | #include <config.h>
|
|---|
| 43 | #include <arch/stack.h>
|
|---|
| 44 | #include <arch/barrier.h>
|
|---|
| 45 | #include <trace.h>
|
|---|
| 46 |
|
|---|
| 47 | NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
|
|---|
| 48 | {
|
|---|
| 49 | *port = v;
|
|---|
| 50 | memory_barrier();
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
|
|---|
| 54 | {
|
|---|
| 55 | *port = v;
|
|---|
| 56 | memory_barrier();
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
|
|---|
| 60 | {
|
|---|
| 61 | *port = v;
|
|---|
| 62 | memory_barrier();
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
|
|---|
| 66 | {
|
|---|
| 67 | uint8_t rv = *port;
|
|---|
| 68 | memory_barrier();
|
|---|
| 69 | return rv;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
|
|---|
| 73 | {
|
|---|
| 74 | uint16_t rv = *port;
|
|---|
| 75 | memory_barrier();
|
|---|
| 76 | return rv;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
|
|---|
| 80 | {
|
|---|
| 81 | uint32_t rv = *port;
|
|---|
| 82 | memory_barrier();
|
|---|
| 83 | return rv;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | /** Read Processor State register.
|
|---|
| 87 | *
|
|---|
| 88 | * @return Value of PSTATE register.
|
|---|
| 89 | *
|
|---|
| 90 | */
|
|---|
| 91 | NO_TRACE static inline uint64_t pstate_read(void)
|
|---|
| 92 | {
|
|---|
| 93 | uint64_t v;
|
|---|
| 94 |
|
|---|
| 95 | asm volatile (
|
|---|
| 96 | "rdpr %%pstate, %[v]\n"
|
|---|
| 97 | : [v] "=r" (v)
|
|---|
| 98 | );
|
|---|
| 99 |
|
|---|
| 100 | return v;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | /** Write Processor State register.
|
|---|
| 104 | *
|
|---|
| 105 | * @param v New value of PSTATE register.
|
|---|
| 106 | *
|
|---|
| 107 | */
|
|---|
| 108 | NO_TRACE static inline void pstate_write(uint64_t v)
|
|---|
| 109 | {
|
|---|
| 110 | asm volatile (
|
|---|
| 111 | "wrpr %[v], %[zero], %%pstate\n"
|
|---|
| 112 | :: [v] "r" (v),
|
|---|
| 113 | [zero] "i" (0)
|
|---|
| 114 | );
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | /** Read TICK_compare Register.
|
|---|
| 118 | *
|
|---|
| 119 | * @return Value of TICK_comapre register.
|
|---|
| 120 | *
|
|---|
| 121 | */
|
|---|
| 122 | NO_TRACE static inline uint64_t tick_compare_read(void)
|
|---|
| 123 | {
|
|---|
| 124 | uint64_t v;
|
|---|
| 125 |
|
|---|
| 126 | asm volatile (
|
|---|
| 127 | "rd %%tick_cmpr, %[v]\n"
|
|---|
| 128 | : [v] "=r" (v)
|
|---|
| 129 | );
|
|---|
| 130 |
|
|---|
| 131 | return v;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | /** Write TICK_compare Register.
|
|---|
| 135 | *
|
|---|
| 136 | * @param v New value of TICK_comapre register.
|
|---|
| 137 | *
|
|---|
| 138 | */
|
|---|
| 139 | NO_TRACE static inline void tick_compare_write(uint64_t v)
|
|---|
| 140 | {
|
|---|
| 141 | asm volatile (
|
|---|
| 142 | "wr %[v], %[zero], %%tick_cmpr\n"
|
|---|
| 143 | :: [v] "r" (v),
|
|---|
| 144 | [zero] "i" (0)
|
|---|
| 145 | );
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | /** Read STICK_compare Register.
|
|---|
| 149 | *
|
|---|
| 150 | * @return Value of STICK_compare register.
|
|---|
| 151 | *
|
|---|
| 152 | */
|
|---|
| 153 | NO_TRACE static inline uint64_t stick_compare_read(void)
|
|---|
| 154 | {
|
|---|
| 155 | uint64_t v;
|
|---|
| 156 |
|
|---|
| 157 | asm volatile (
|
|---|
| 158 | "rd %%asr25, %[v]\n"
|
|---|
| 159 | : [v] "=r" (v)
|
|---|
| 160 | );
|
|---|
| 161 |
|
|---|
| 162 | return v;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | /** Write STICK_compare Register.
|
|---|
| 166 | *
|
|---|
| 167 | * @param v New value of STICK_comapre register.
|
|---|
| 168 | *
|
|---|
| 169 | */
|
|---|
| 170 | NO_TRACE static inline void stick_compare_write(uint64_t v)
|
|---|
| 171 | {
|
|---|
| 172 | asm volatile (
|
|---|
| 173 | "wr %[v], %[zero], %%asr25\n"
|
|---|
| 174 | :: [v] "r" (v),
|
|---|
| 175 | [zero] "i" (0)
|
|---|
| 176 | );
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | /** Read TICK Register.
|
|---|
| 180 | *
|
|---|
| 181 | * @return Value of TICK register.
|
|---|
| 182 | *
|
|---|
| 183 | */
|
|---|
| 184 | NO_TRACE static inline uint64_t tick_read(void)
|
|---|
| 185 | {
|
|---|
| 186 | uint64_t v;
|
|---|
| 187 |
|
|---|
| 188 | asm volatile (
|
|---|
| 189 | "rdpr %%tick, %[v]\n"
|
|---|
| 190 | : [v] "=r" (v)
|
|---|
| 191 | );
|
|---|
| 192 |
|
|---|
| 193 | return v;
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | /** Write TICK Register.
|
|---|
| 197 | *
|
|---|
| 198 | * @param v New value of TICK register.
|
|---|
| 199 | *
|
|---|
| 200 | */
|
|---|
| 201 | NO_TRACE static inline void tick_write(uint64_t v)
|
|---|
| 202 | {
|
|---|
| 203 | asm volatile (
|
|---|
| 204 | "wrpr %[v], %[zero], %%tick\n"
|
|---|
| 205 | :: [v] "r" (v),
|
|---|
| 206 | [zero] "i" (0)
|
|---|
| 207 | );
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | /** Read FPRS Register.
|
|---|
| 211 | *
|
|---|
| 212 | * @return Value of FPRS register.
|
|---|
| 213 | *
|
|---|
| 214 | */
|
|---|
| 215 | NO_TRACE static inline uint64_t fprs_read(void)
|
|---|
| 216 | {
|
|---|
| 217 | uint64_t v;
|
|---|
| 218 |
|
|---|
| 219 | asm volatile (
|
|---|
| 220 | "rd %%fprs, %[v]\n"
|
|---|
| 221 | : [v] "=r" (v)
|
|---|
| 222 | );
|
|---|
| 223 |
|
|---|
| 224 | return v;
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | /** Write FPRS Register.
|
|---|
| 228 | *
|
|---|
| 229 | * @param v New value of FPRS register.
|
|---|
| 230 | *
|
|---|
| 231 | */
|
|---|
| 232 | NO_TRACE static inline void fprs_write(uint64_t v)
|
|---|
| 233 | {
|
|---|
| 234 | asm volatile (
|
|---|
| 235 | "wr %[v], %[zero], %%fprs\n"
|
|---|
| 236 | :: [v] "r" (v),
|
|---|
| 237 | [zero] "i" (0)
|
|---|
| 238 | );
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | /** Read SOFTINT Register.
|
|---|
| 242 | *
|
|---|
| 243 | * @return Value of SOFTINT register.
|
|---|
| 244 | *
|
|---|
| 245 | */
|
|---|
| 246 | NO_TRACE static inline uint64_t softint_read(void)
|
|---|
| 247 | {
|
|---|
| 248 | uint64_t v;
|
|---|
| 249 |
|
|---|
| 250 | asm volatile (
|
|---|
| 251 | "rd %%softint, %[v]\n"
|
|---|
| 252 | : [v] "=r" (v)
|
|---|
| 253 | );
|
|---|
| 254 |
|
|---|
| 255 | return v;
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | /** Write SOFTINT Register.
|
|---|
| 259 | *
|
|---|
| 260 | * @param v New value of SOFTINT register.
|
|---|
| 261 | *
|
|---|
| 262 | */
|
|---|
| 263 | NO_TRACE static inline void softint_write(uint64_t v)
|
|---|
| 264 | {
|
|---|
| 265 | asm volatile (
|
|---|
| 266 | "wr %[v], %[zero], %%softint\n"
|
|---|
| 267 | :: [v] "r" (v),
|
|---|
| 268 | [zero] "i" (0)
|
|---|
| 269 | );
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | /** Write CLEAR_SOFTINT Register.
|
|---|
| 273 | *
|
|---|
| 274 | * Bits set in CLEAR_SOFTINT register will be cleared in SOFTINT register.
|
|---|
| 275 | *
|
|---|
| 276 | * @param v New value of CLEAR_SOFTINT register.
|
|---|
| 277 | *
|
|---|
| 278 | */
|
|---|
| 279 | NO_TRACE static inline void clear_softint_write(uint64_t v)
|
|---|
| 280 | {
|
|---|
| 281 | asm volatile (
|
|---|
| 282 | "wr %[v], %[zero], %%clear_softint\n"
|
|---|
| 283 | :: [v] "r" (v),
|
|---|
| 284 | [zero] "i" (0)
|
|---|
| 285 | );
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | /** Write SET_SOFTINT Register.
|
|---|
| 289 | *
|
|---|
| 290 | * Bits set in SET_SOFTINT register will be set in SOFTINT register.
|
|---|
| 291 | *
|
|---|
| 292 | * @param v New value of SET_SOFTINT register.
|
|---|
| 293 | *
|
|---|
| 294 | */
|
|---|
| 295 | NO_TRACE static inline void set_softint_write(uint64_t v)
|
|---|
| 296 | {
|
|---|
| 297 | asm volatile (
|
|---|
| 298 | "wr %[v], %[zero], %%set_softint\n"
|
|---|
| 299 | :: [v] "r" (v),
|
|---|
| 300 | [zero] "i" (0)
|
|---|
| 301 | );
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | /** Enable interrupts.
|
|---|
| 305 | *
|
|---|
| 306 | * Enable interrupts and return previous
|
|---|
| 307 | * value of IPL.
|
|---|
| 308 | *
|
|---|
| 309 | * @return Old interrupt priority level.
|
|---|
| 310 | *
|
|---|
| 311 | */
|
|---|
| 312 | NO_TRACE static inline ipl_t interrupts_enable(void) {
|
|---|
| 313 | pstate_reg_t pstate;
|
|---|
| 314 | uint64_t value = pstate_read();
|
|---|
| 315 |
|
|---|
| 316 | pstate.value = value;
|
|---|
| 317 | pstate.ie = true;
|
|---|
| 318 | pstate_write(pstate.value);
|
|---|
| 319 |
|
|---|
| 320 | return (ipl_t) value;
|
|---|
| 321 | }
|
|---|
| 322 |
|
|---|
| 323 | /** Disable interrupts.
|
|---|
| 324 | *
|
|---|
| 325 | * Disable interrupts and return previous
|
|---|
| 326 | * value of IPL.
|
|---|
| 327 | *
|
|---|
| 328 | * @return Old interrupt priority level.
|
|---|
| 329 | *
|
|---|
| 330 | */
|
|---|
| 331 | NO_TRACE static inline ipl_t interrupts_disable(void) {
|
|---|
| 332 | pstate_reg_t pstate;
|
|---|
| 333 | uint64_t value = pstate_read();
|
|---|
| 334 |
|
|---|
| 335 | pstate.value = value;
|
|---|
| 336 | pstate.ie = false;
|
|---|
| 337 | pstate_write(pstate.value);
|
|---|
| 338 |
|
|---|
| 339 | return (ipl_t) value;
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | /** Restore interrupt priority level.
|
|---|
| 343 | *
|
|---|
| 344 | * Restore IPL.
|
|---|
| 345 | *
|
|---|
| 346 | * @param ipl Saved interrupt priority level.
|
|---|
| 347 | *
|
|---|
| 348 | */
|
|---|
| 349 | NO_TRACE static inline void interrupts_restore(ipl_t ipl) {
|
|---|
| 350 | pstate_reg_t pstate;
|
|---|
| 351 |
|
|---|
| 352 | pstate.value = pstate_read();
|
|---|
| 353 | pstate.ie = ((pstate_reg_t) ipl).ie;
|
|---|
| 354 | pstate_write(pstate.value);
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | /** Return interrupt priority level.
|
|---|
| 358 | *
|
|---|
| 359 | * Return IPL.
|
|---|
| 360 | *
|
|---|
| 361 | * @return Current interrupt priority level.
|
|---|
| 362 | *
|
|---|
| 363 | */
|
|---|
| 364 | NO_TRACE static inline ipl_t interrupts_read(void) {
|
|---|
| 365 | return (ipl_t) pstate_read();
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | /** Check interrupts state.
|
|---|
| 369 | *
|
|---|
| 370 | * @return True if interrupts are disabled.
|
|---|
| 371 | *
|
|---|
| 372 | */
|
|---|
| 373 | NO_TRACE static inline bool interrupts_disabled(void)
|
|---|
| 374 | {
|
|---|
| 375 | pstate_reg_t pstate;
|
|---|
| 376 |
|
|---|
| 377 | pstate.value = pstate_read();
|
|---|
| 378 | return !pstate.ie;
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | /** Return base address of current stack.
|
|---|
| 382 | *
|
|---|
| 383 | * Return the base address of the current stack.
|
|---|
| 384 | * The stack is assumed to be STACK_SIZE bytes long.
|
|---|
| 385 | * The stack must start on page boundary.
|
|---|
| 386 | *
|
|---|
| 387 | */
|
|---|
| 388 | NO_TRACE static inline uintptr_t get_stack_base(void)
|
|---|
| 389 | {
|
|---|
| 390 | uintptr_t unbiased_sp;
|
|---|
| 391 |
|
|---|
| 392 | asm volatile (
|
|---|
| 393 | "add %%sp, %[stack_bias], %[unbiased_sp]\n"
|
|---|
| 394 | : [unbiased_sp] "=r" (unbiased_sp)
|
|---|
| 395 | : [stack_bias] "i" (STACK_BIAS)
|
|---|
| 396 | );
|
|---|
| 397 |
|
|---|
| 398 | return ALIGN_DOWN(unbiased_sp, STACK_SIZE);
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | /** Read Version Register.
|
|---|
| 402 | *
|
|---|
| 403 | * @return Value of VER register.
|
|---|
| 404 | *
|
|---|
| 405 | */
|
|---|
| 406 | NO_TRACE static inline uint64_t ver_read(void)
|
|---|
| 407 | {
|
|---|
| 408 | uint64_t v;
|
|---|
| 409 |
|
|---|
| 410 | asm volatile (
|
|---|
| 411 | "rdpr %%ver, %[v]\n"
|
|---|
| 412 | : [v] "=r" (v)
|
|---|
| 413 | );
|
|---|
| 414 |
|
|---|
| 415 | return v;
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | /** Read Trap Program Counter register.
|
|---|
| 419 | *
|
|---|
| 420 | * @return Current value in TPC.
|
|---|
| 421 | *
|
|---|
| 422 | */
|
|---|
| 423 | NO_TRACE static inline uint64_t tpc_read(void)
|
|---|
| 424 | {
|
|---|
| 425 | uint64_t v;
|
|---|
| 426 |
|
|---|
| 427 | asm volatile (
|
|---|
| 428 | "rdpr %%tpc, %[v]\n"
|
|---|
| 429 | : [v] "=r" (v)
|
|---|
| 430 | );
|
|---|
| 431 |
|
|---|
| 432 | return v;
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | /** Read Trap Level register.
|
|---|
| 436 | *
|
|---|
| 437 | * @return Current value in TL.
|
|---|
| 438 | *
|
|---|
| 439 | */
|
|---|
| 440 | NO_TRACE static inline uint64_t tl_read(void)
|
|---|
| 441 | {
|
|---|
| 442 | uint64_t v;
|
|---|
| 443 |
|
|---|
| 444 | asm volatile (
|
|---|
| 445 | "rdpr %%tl, %[v]\n"
|
|---|
| 446 | : [v] "=r" (v)
|
|---|
| 447 | );
|
|---|
| 448 |
|
|---|
| 449 | return v;
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | /** Read Trap Base Address register.
|
|---|
| 453 | *
|
|---|
| 454 | * @return Current value in TBA.
|
|---|
| 455 | *
|
|---|
| 456 | */
|
|---|
| 457 | NO_TRACE static inline uint64_t tba_read(void)
|
|---|
| 458 | {
|
|---|
| 459 | uint64_t v;
|
|---|
| 460 |
|
|---|
| 461 | asm volatile (
|
|---|
| 462 | "rdpr %%tba, %[v]\n"
|
|---|
| 463 | : [v] "=r" (v)
|
|---|
| 464 | );
|
|---|
| 465 |
|
|---|
| 466 | return v;
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 | /** Write Trap Base Address register.
|
|---|
| 470 | *
|
|---|
| 471 | * @param v New value of TBA.
|
|---|
| 472 | *
|
|---|
| 473 | */
|
|---|
| 474 | NO_TRACE static inline void tba_write(uint64_t v)
|
|---|
| 475 | {
|
|---|
| 476 | asm volatile (
|
|---|
| 477 | "wrpr %[v], %[zero], %%tba\n"
|
|---|
| 478 | :: [v] "r" (v),
|
|---|
| 479 | [zero] "i" (0)
|
|---|
| 480 | );
|
|---|
| 481 | }
|
|---|
| 482 |
|
|---|
| 483 | /** Load uint64_t from alternate space.
|
|---|
| 484 | *
|
|---|
| 485 | * @param asi ASI determining the alternate space.
|
|---|
| 486 | * @param va Virtual address within the ASI.
|
|---|
| 487 | *
|
|---|
| 488 | * @return Value read from the virtual address in
|
|---|
| 489 | * the specified address space.
|
|---|
| 490 | *
|
|---|
| 491 | */
|
|---|
| 492 | NO_TRACE static inline uint64_t asi_u64_read(asi_t asi, uintptr_t va)
|
|---|
| 493 | {
|
|---|
| 494 | uint64_t v;
|
|---|
| 495 |
|
|---|
| 496 | asm volatile (
|
|---|
| 497 | "ldxa [%[va]] %[asi], %[v]\n"
|
|---|
| 498 | : [v] "=r" (v)
|
|---|
| 499 | : [va] "r" (va),
|
|---|
| 500 | [asi] "i" ((unsigned int) asi)
|
|---|
| 501 | );
|
|---|
| 502 |
|
|---|
| 503 | return v;
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | /** Store uint64_t to alternate space.
|
|---|
| 507 | *
|
|---|
| 508 | * @param asi ASI determining the alternate space.
|
|---|
| 509 | * @param va Virtual address within the ASI.
|
|---|
| 510 | * @param v Value to be written.
|
|---|
| 511 | *
|
|---|
| 512 | */
|
|---|
| 513 | NO_TRACE static inline void asi_u64_write(asi_t asi, uintptr_t va, uint64_t v)
|
|---|
| 514 | {
|
|---|
| 515 | asm volatile (
|
|---|
| 516 | "stxa %[v], [%[va]] %[asi]\n"
|
|---|
| 517 | :: [v] "r" (v),
|
|---|
| 518 | [va] "r" (va),
|
|---|
| 519 | [asi] "i" ((unsigned int) asi)
|
|---|
| 520 | : "memory"
|
|---|
| 521 | );
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 | /** Flush all valid register windows to memory. */
|
|---|
| 525 | NO_TRACE static inline void flushw(void)
|
|---|
| 526 | {
|
|---|
| 527 | asm volatile ("flushw\n");
|
|---|
| 528 | }
|
|---|
| 529 |
|
|---|
| 530 | /** Switch to nucleus by setting TL to 1. */
|
|---|
| 531 | NO_TRACE static inline void nucleus_enter(void)
|
|---|
| 532 | {
|
|---|
| 533 | asm volatile ("wrpr %g0, 1, %tl\n");
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | /** Switch from nucleus by setting TL to 0. */
|
|---|
| 537 | NO_TRACE static inline void nucleus_leave(void)
|
|---|
| 538 | {
|
|---|
| 539 | asm volatile ("wrpr %g0, %g0, %tl\n");
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | extern void cpu_halt(void) __attribute__((noreturn));
|
|---|
| 543 | extern void cpu_sleep(void);
|
|---|
| 544 | extern void asm_delay_loop(const uint32_t usec);
|
|---|
| 545 |
|
|---|
| 546 | extern uint64_t read_from_ag_g6(void);
|
|---|
| 547 | extern uint64_t read_from_ag_g7(void);
|
|---|
| 548 | extern void write_to_ag_g6(uint64_t val);
|
|---|
| 549 | extern void write_to_ag_g7(uint64_t val);
|
|---|
| 550 | extern void write_to_ig_g6(uint64_t val);
|
|---|
| 551 |
|
|---|
| 552 | extern void switch_to_userspace(uint64_t pc, uint64_t sp, uint64_t uarg);
|
|---|
| 553 |
|
|---|
| 554 | #endif
|
|---|
| 555 |
|
|---|
| 556 | /** @}
|
|---|
| 557 | */
|
|---|