1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28/* 29 * Hypervisor calls 30 */ 31 32#include <sys/asm_linkage.h> 33#include <sys/machasi.h> 34#include <sys/machparam.h> 35#include <sys/hypervisor_api.h> 36 37#if defined(lint) || defined(__lint) 38 39/*ARGSUSED*/ 40int64_t 41hv_cnputchar(uint8_t ch) 42{ return (0); } 43 44/*ARGSUSED*/ 45int64_t 46hv_cngetchar(uint8_t *ch) 47{ return (0); } 48 49/*ARGSUSED*/ 50uint64_t 51hv_tod_get(uint64_t *seconds) 52{ return (0); } 53 54/*ARGSUSED*/ 55uint64_t 56hv_tod_set(uint64_t seconds) 57{ return (0);} 58 59/*ARGSUSED*/ 60uint64_t 61hv_mmu_map_perm_addr(void *vaddr, int ctx, uint64_t tte, int flags) 62{ return (0); } 63 64/*ARGSUSED*/ 65uint64_t 66hv_mmu_unmap_perm_addr(void *vaddr, int ctx, int flags) 67{ return (0); } 68 69/*ARGSUSED*/ 70uint64_t 71hv_set_ctx0(uint64_t ntsb_descriptor, uint64_t desc_ra) 72{ return (0); } 73 74/*ARGSUSED*/ 75uint64_t 76hv_set_ctxnon0(uint64_t ntsb_descriptor, uint64_t desc_ra) 77{ return (0); } 78 79#ifdef SET_MMU_STATS 80/*ARGSUSED*/ 81uint64_t 82hv_mmu_set_stat_area(uint64_t rstatarea, uint64_t size) 83{ return (0); } 84#endif /* SET_MMU_STATS */ 85 86/*ARGSUSED*/ 87uint64_t 88hv_cpu_qconf(int queue, uint64_t paddr, int size) 89{ return (0); } 90 91/*ARGSUSED*/ 92uint64_t 93hvio_intr_devino_to_sysino(uint64_t dev_hdl, uint32_t devino, uint64_t *sysino) 94{ return (0); } 95 96/*ARGSUSED*/ 97uint64_t 98hvio_intr_getvalid(uint64_t sysino, int *intr_valid_state) 99{ return (0); } 100 101/*ARGSUSED*/ 102uint64_t 103hvio_intr_setvalid(uint64_t sysino, int intr_valid_state) 104{ return (0); } 105 106/*ARGSUSED*/ 107uint64_t 108hvio_intr_getstate(uint64_t sysino, int *intr_state) 109{ return (0); } 110 111/*ARGSUSED*/ 112uint64_t 113hvio_intr_setstate(uint64_t sysino, int intr_state) 114{ return (0); } 115 116/*ARGSUSED*/ 117uint64_t 118hvio_intr_gettarget(uint64_t sysino, uint32_t *cpuid) 119{ return (0); } 120 121/*ARGSUSED*/ 122uint64_t 123hvio_intr_settarget(uint64_t sysino, uint32_t cpuid) 124{ return (0); } 125 126uint64_t 127hv_cpu_yield(void) 128{ return (0); } 129 130/*ARGSUSED*/ 131uint64_t 132hv_service_recv(uint64_t s_id, uint64_t buf_pa, uint64_t size, 133 uint64_t *recv_bytes) 134{ return (0); } 135 136/*ARGSUSED*/ 137uint64_t 138hv_service_send(uint64_t s_id, uint64_t buf_pa, uint64_t size, 139 uint64_t *send_bytes) 140{ return (0); } 141 142/*ARGSUSED*/ 143uint64_t 144hv_service_getstatus(uint64_t s_id, uint64_t *vreg) 145{ return (0); } 146 147/*ARGSUSED*/ 148uint64_t 149hv_service_setstatus(uint64_t s_id, uint64_t bits) 150{ return (0); } 151 152/*ARGSUSED*/ 153uint64_t 154hv_service_clrstatus(uint64_t s_id, uint64_t bits) 155{ return (0); } 156 157/*ARGSUSED*/ 158uint64_t 159hv_cpu_state(uint64_t cpuid, uint64_t *cpu_state) 160{ return (0); } 161 162/*ARGSUSED*/ 163uint64_t 164hv_dump_buf_update(uint64_t paddr, uint64_t size, uint64_t *minsize) 165{ return (0); } 166 167/*ARGSUSED*/ 168uint64_t 169hv_mem_scrub(uint64_t real_addr, uint64_t length, uint64_t *scrubbed_len) 170{ return (0); } 171 172/*ARGSUSED*/ 173uint64_t 174hv_mem_sync(uint64_t real_addr, uint64_t length, uint64_t *flushed_len) 175{ return (0); } 176 177/*ARGSUSED*/ 178uint64_t 179hv_ttrace_buf_conf(uint64_t paddr, uint64_t size, uint64_t *size1) 180{ return (0); } 181 182/*ARGSUSED*/ 183uint64_t 184hv_ttrace_buf_info(uint64_t *paddr, uint64_t *size) 185{ return (0); } 186 187/*ARGSUSED*/ 188uint64_t 189hv_ttrace_enable(uint64_t enable, uint64_t *prev_enable) 190{ return (0); } 191 192/*ARGSUSED*/ 193uint64_t 194hv_ttrace_freeze(uint64_t freeze, uint64_t *prev_freeze) 195{ return (0); } 196 197/*ARGSUSED*/ 198uint64_t 199hv_mach_desc(uint64_t buffer_ra, uint64_t *buffer_sizep) 200{ return (0); } 201 202/*ARGSUSED*/ 203uint64_t 204hv_ra2pa(uint64_t ra) 205{ return (0); } 206 207/*ARGSUSED*/ 208uint64_t 209hv_hpriv(void *func, uint64_t arg1, uint64_t arg2, uint64_t arg3) 210{ return (0); } 211 212#else /* lint || __lint */ 213 214 /* 215 * %o0 - character 216 */ 217 ENTRY(hv_cnputchar) 218 mov CONS_WRITE, %o5 219 ta FAST_TRAP 220 tst %o0 221 retl 222 movnz %xcc, -1, %o0 223 SET_SIZE(hv_cnputchar) 224 225 /* 226 * %o0 pointer to character buffer 227 * return values: 228 * 0 success 229 * hv_errno failure 230 */ 231 ENTRY(hv_cngetchar) 232 mov %o0, %o2 233 mov CONS_READ, %o5 234 ta FAST_TRAP 235 brnz,a %o0, 1f ! failure, just return error 236 mov 1, %o0 237 238 cmp %o1, H_BREAK 239 be 1f 240 mov %o1, %o0 241 242 cmp %o1, H_HUP 243 be 1f 244 mov %o1, %o0 245 246 stb %o1, [%o2] ! success, save character and return 0 247 mov 0, %o0 2481: 249 retl 250 nop 251 SET_SIZE(hv_cngetchar) 252 253 ENTRY(hv_tod_get) 254 mov %o0, %o4 255 mov TOD_GET, %o5 256 ta FAST_TRAP 257 retl 258 stx %o1, [%o4] 259 SET_SIZE(hv_tod_get) 260 261 ENTRY(hv_tod_set) 262 mov TOD_SET, %o5 263 ta FAST_TRAP 264 retl 265 nop 266 SET_SIZE(hv_tod_set) 267 268 /* 269 * Map permanent address 270 * arg0 vaddr (%o0) 271 * arg1 context (%o1) 272 * arg2 tte (%o2) 273 * arg3 flags (%o3) 0x1=d 0x2=i 274 */ 275 ENTRY(hv_mmu_map_perm_addr) 276 mov MAP_PERM_ADDR, %o5 277 ta FAST_TRAP 278 retl 279 nop 280 SET_SIZE(hv_mmu_map_perm_addr) 281 282 /* 283 * Unmap permanent address 284 * arg0 vaddr (%o0) 285 * arg1 context (%o1) 286 * arg2 flags (%o2) 0x1=d 0x2=i 287 */ 288 ENTRY(hv_mmu_unmap_perm_addr) 289 mov UNMAP_PERM_ADDR, %o5 290 ta FAST_TRAP 291 retl 292 nop 293 SET_SIZE(hv_mmu_unmap_perm_addr) 294 295 /* 296 * Set TSB for context 0 297 * arg0 ntsb_descriptor (%o0) 298 * arg1 desc_ra (%o1) 299 */ 300 ENTRY(hv_set_ctx0) 301 mov MMU_TSB_CTX0, %o5 302 ta FAST_TRAP 303 retl 304 nop 305 SET_SIZE(hv_set_ctx0) 306 307 /* 308 * Set TSB for context non0 309 * arg0 ntsb_descriptor (%o0) 310 * arg1 desc_ra (%o1) 311 */ 312 ENTRY(hv_set_ctxnon0) 313 mov MMU_TSB_CTXNON0, %o5 314 ta FAST_TRAP 315 retl 316 nop 317 SET_SIZE(hv_set_ctxnon0) 318 319#ifdef SET_MMU_STATS 320 /* 321 * Returns old stat area on success 322 */ 323 ENTRY(hv_mmu_set_stat_area) 324 mov MMU_STAT_AREA, %o5 325 ta FAST_TRAP 326 retl 327 nop 328 SET_SIZE(hv_mmu_set_stat_area) 329#endif /* SET_MMU_STATS */ 330 331 /* 332 * CPU Q Configure 333 * arg0 queue (%o0) 334 * arg1 Base address RA (%o1) 335 * arg2 Size (%o2) 336 */ 337 ENTRY(hv_cpu_qconf) 338 mov CPU_QCONF, %o5 339 ta FAST_TRAP 340 retl 341 nop 342 SET_SIZE(hv_cpu_qconf) 343 344 /* 345 * arg0 - devhandle 346 * arg1 - devino 347 * 348 * ret0 - status 349 * ret1 - sysino 350 */ 351 ENTRY(hvio_intr_devino_to_sysino) 352 mov HVIO_INTR_DEVINO2SYSINO, %o5 353 ta FAST_TRAP 354 brz,a %o0, 1f 355 stx %o1, [%o2] 3561: retl 357 nop 358 SET_SIZE(hvio_intr_devino_to_sysino) 359 360 /* 361 * arg0 - sysino 362 * 363 * ret0 - status 364 * ret1 - intr_valid_state 365 */ 366 ENTRY(hvio_intr_getvalid) 367 mov %o1, %o2 368 mov HVIO_INTR_GETVALID, %o5 369 ta FAST_TRAP 370 brz,a %o0, 1f 371 stuw %o1, [%o2] 3721: retl 373 nop 374 SET_SIZE(hvio_intr_getvalid) 375 376 /* 377 * arg0 - sysino 378 * arg1 - intr_valid_state 379 * 380 * ret0 - status 381 */ 382 ENTRY(hvio_intr_setvalid) 383 mov HVIO_INTR_SETVALID, %o5 384 ta FAST_TRAP 385 retl 386 nop 387 SET_SIZE(hvio_intr_setvalid) 388 389 /* 390 * arg0 - sysino 391 * 392 * ret0 - status 393 * ret1 - intr_state 394 */ 395 ENTRY(hvio_intr_getstate) 396 mov %o1, %o2 397 mov HVIO_INTR_GETSTATE, %o5 398 ta FAST_TRAP 399 brz,a %o0, 1f 400 stuw %o1, [%o2] 4011: retl 402 nop 403 SET_SIZE(hvio_intr_getstate) 404 405 /* 406 * arg0 - sysino 407 * arg1 - intr_state 408 * 409 * ret0 - status 410 */ 411 ENTRY(hvio_intr_setstate) 412 mov HVIO_INTR_SETSTATE, %o5 413 ta FAST_TRAP 414 retl 415 nop 416 SET_SIZE(hvio_intr_setstate) 417 418 /* 419 * arg0 - sysino 420 * 421 * ret0 - status 422 * ret1 - cpu_id 423 */ 424 ENTRY(hvio_intr_gettarget) 425 mov %o1, %o2 426 mov HVIO_INTR_GETTARGET, %o5 427 ta FAST_TRAP 428 brz,a %o0, 1f 429 stuw %o1, [%o2] 4301: retl 431 nop 432 SET_SIZE(hvio_intr_gettarget) 433 434 /* 435 * arg0 - sysino 436 * arg1 - cpu_id 437 * 438 * ret0 - status 439 */ 440 ENTRY(hvio_intr_settarget) 441 mov HVIO_INTR_SETTARGET, %o5 442 ta FAST_TRAP 443 retl 444 nop 445 SET_SIZE(hvio_intr_settarget) 446 447 /* 448 * hv_cpu_yield(void) 449 */ 450 ENTRY(hv_cpu_yield) 451 mov HV_CPU_YIELD, %o5 452 ta FAST_TRAP 453 retl 454 nop 455 SET_SIZE(hv_cpu_yield) 456 457 /* 458 * hv_service_recv(uint64_t s_id, uint64_t buf_pa, 459 * uint64_t size, uint64_t *recv_bytes); 460 */ 461 ENTRY(hv_service_recv) 462 save %sp, -SA(MINFRAME), %sp 463 mov %i0, %o0 464 mov %i1, %o1 465 mov %i2, %o2 466 mov %i3, %o3 467 mov SVC_RECV, %o5 468 ta FAST_TRAP 469 brnz %o0, 1f 470 mov %o0, %i0 471 stx %o1, [%i3] 4721: 473 ret 474 restore 475 SET_SIZE(hv_service_recv) 476 477 /* 478 * hv_service_send(uint64_t s_id, uint64_t buf_pa, 479 * uint64_t size, uint64_t *recv_bytes); 480 */ 481 ENTRY(hv_service_send) 482 save %sp, -SA(MINFRAME), %sp 483 mov %i0, %o0 484 mov %i1, %o1 485 mov %i2, %o2 486 mov %i3, %o3 487 mov SVC_SEND, %o5 488 ta FAST_TRAP 489 brnz %o0, 1f 490 mov %o0, %i0 491 stx %o1, [%i3] 4921: 493 ret 494 restore 495 SET_SIZE(hv_service_send) 496 497 /* 498 * hv_service_getstatus(uint64_t s_id, uint64_t *vreg); 499 */ 500 ENTRY(hv_service_getstatus) 501 mov %o1, %o4 ! save datap 502 mov SVC_GETSTATUS, %o5 503 ta FAST_TRAP 504 brz,a %o0, 1f 505 stx %o1, [%o4] 5061: 507 retl 508 nop 509 SET_SIZE(hv_service_getstatus) 510 511 /* 512 * hv_service_setstatus(uint64_t s_id, uint64_t bits); 513 */ 514 ENTRY(hv_service_setstatus) 515 mov SVC_SETSTATUS, %o5 516 ta FAST_TRAP 517 retl 518 nop 519 SET_SIZE(hv_service_setstatus) 520 521 /* 522 * hv_service_clrstatus(uint64_t s_id, uint64_t bits); 523 */ 524 ENTRY(hv_service_clrstatus) 525 mov SVC_CLRSTATUS, %o5 526 ta FAST_TRAP 527 retl 528 nop 529 SET_SIZE(hv_service_clrstatus) 530 531 /* 532 * int hv_cpu_state(uint64_t cpuid, uint64_t *cpu_state); 533 */ 534 ENTRY(hv_cpu_state) 535 mov %o1, %o4 ! save datap 536 mov HV_CPU_STATE, %o5 537 ta FAST_TRAP 538 brz,a %o0, 1f 539 stx %o1, [%o4] 5401: 541 retl 542 nop 543 SET_SIZE(hv_cpu_state) 544 545 /* 546 * HV state dump zone Configure 547 * arg0 real adrs of dump buffer (%o0) 548 * arg1 size of dump buffer (%o1) 549 * ret0 status (%o0) 550 * ret1 size of buffer on success and min size on EINVAL (%o1) 551 * hv_dump_buf_update(uint64_t paddr, uint64_t size, uint64_t *ret_size) 552 */ 553 ENTRY(hv_dump_buf_update) 554 mov DUMP_BUF_UPDATE, %o5 555 ta FAST_TRAP 556 retl 557 stx %o1, [%o2] 558 SET_SIZE(hv_dump_buf_update) 559 560 561 /* 562 * For memory scrub 563 * int hv_mem_scrub(uint64_t real_addr, uint64_t length, 564 * uint64_t *scrubbed_len); 565 * Retun %o0 -- status 566 * %o1 -- bytes scrubbed 567 */ 568 ENTRY(hv_mem_scrub) 569 mov %o2, %o4 570 mov HV_MEM_SCRUB, %o5 571 ta FAST_TRAP 572 retl 573 stx %o1, [%o4] 574 SET_SIZE(hv_mem_scrub) 575 576 /* 577 * Flush ecache 578 * int hv_mem_sync(uint64_t real_addr, uint64_t length, 579 * uint64_t *flushed_len); 580 * Retun %o0 -- status 581 * %o1 -- bytes flushed 582 */ 583 ENTRY(hv_mem_sync) 584 mov %o2, %o4 585 mov HV_MEM_SYNC, %o5 586 ta FAST_TRAP 587 retl 588 stx %o1, [%o4] 589 SET_SIZE(hv_mem_sync) 590 591 /* 592 * TTRACE_BUF_CONF Configure 593 * arg0 RA base of buffer (%o0) 594 * arg1 buf size in no. of entries (%o1) 595 * ret0 status (%o0) 596 * ret1 minimum size in no. of entries on failure, 597 * actual size in no. of entries on success (%o1) 598 */ 599 ENTRY(hv_ttrace_buf_conf) 600 mov TTRACE_BUF_CONF, %o5 601 ta FAST_TRAP 602 retl 603 stx %o1, [%o2] 604 SET_SIZE(hv_ttrace_buf_conf) 605 606 /* 607 * TTRACE_BUF_INFO 608 * ret0 status (%o0) 609 * ret1 RA base of buffer (%o1) 610 * ret2 size in no. of entries (%o2) 611 */ 612 ENTRY(hv_ttrace_buf_info) 613 mov %o0, %o3 614 mov %o1, %o4 615 mov TTRACE_BUF_INFO, %o5 616 ta FAST_TRAP 617 stx %o1, [%o3] 618 retl 619 stx %o2, [%o4] 620 SET_SIZE(hv_ttrace_buf_info) 621 622 /* 623 * TTRACE_ENABLE 624 * arg0 enable/ disable (%o0) 625 * ret0 status (%o0) 626 * ret1 previous enable state (%o1) 627 */ 628 ENTRY(hv_ttrace_enable) 629 mov %o1, %o2 630 mov TTRACE_ENABLE, %o5 631 ta FAST_TRAP 632 retl 633 stx %o1, [%o2] 634 SET_SIZE(hv_ttrace_enable) 635 636 /* 637 * TTRACE_FREEZE 638 * arg0 enable/ freeze (%o0) 639 * ret0 status (%o0) 640 * ret1 previous freeze state (%o1) 641 */ 642 ENTRY(hv_ttrace_freeze) 643 mov %o1, %o2 644 mov TTRACE_FREEZE, %o5 645 ta FAST_TRAP 646 retl 647 stx %o1, [%o2] 648 SET_SIZE(hv_ttrace_freeze) 649 650 /* 651 * MACH_DESC 652 * arg0 buffer real address 653 * arg1 pointer to uint64_t for size of buffer 654 * ret0 status 655 * ret1 return required size of buffer / returned data size 656 */ 657 ENTRY(hv_mach_desc) 658 mov %o1, %o4 ! save datap 659 ldx [%o1], %o1 660 mov HV_MACH_DESC, %o5 661 ta FAST_TRAP 662 retl 663 stx %o1, [%o4] 664 SET_SIZE(hv_mach_desc) 665 666 /* 667 * hv_ra2pa(uint64_t ra) 668 * 669 * MACH_DESC 670 * arg0 Real address to convert 671 * ret0 Returned physical address or -1 on error 672 */ 673 ENTRY(hv_ra2pa) 674 mov HV_RA2PA, %o5 675 ta FAST_TRAP 676 cmp %o0, 0 677 move %xcc, %o1, %o0 678 movne %xcc, -1, %o0 679 retl 680 nop 681 SET_SIZE(hv_ra2pa) 682 683 /* 684 * hv_hpriv(void *func, uint64_t arg1, uint64_t arg2, uint64_t arg3) 685 * 686 * MACH_DESC 687 * arg0 OS function to call 688 * arg1 First arg to OS function 689 * arg2 Second arg to OS function 690 * arg3 Third arg to OS function 691 * ret0 Returned value from function 692 */ 693 694 ENTRY(hv_hpriv) 695 mov HV_HPRIV, %o5 696 ta FAST_TRAP 697 retl 698 nop 699 SET_SIZE(hv_hpriv) 700 701#endif /* lint || __lint */ 702