1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 #ifndef _NVSWITCH_EXPORT_H_ 25 #define _NVSWITCH_EXPORT_H_ 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 #include "nv_stdarg.h" 32 #include "nvlink_common.h" 33 #include "ioctl_common_nvswitch.h" 34 35 #define NVSWITCH_DRIVER_NAME "nvidia-nvswitch" 36 37 #define NVSWITCH_MAX_BARS 1 38 39 #define NVSWITCH_DEVICE_INSTANCE_MAX 64 40 41 #define PCI_CLASS_BRIDGE_NVSWITCH 0x0680 42 43 #ifndef PCI_VENDOR_ID_NVIDIA 44 #define PCI_VENDOR_ID_NVIDIA 0x10DE 45 #endif 46 47 #define PCI_ADDR_OFFSET_VENDOR 0 48 #define PCI_ADDR_OFFSET_DEVID 2 49 50 #define NVSWITCH_NSEC_PER_SEC 1000000000ULL 51 52 #define NVSWITCH_DBG_LEVEL_MMIO 0x0 53 #define NVSWITCH_DBG_LEVEL_NOISY 0x1 54 #define NVSWITCH_DBG_LEVEL_INFO 0x2 55 #define NVSWITCH_DBG_LEVEL_SETUP 0x3 56 #define NVSWITCH_DBG_LEVEL_WARN 0x4 57 #define NVSWITCH_DBG_LEVEL_ERROR 0x5 58 59 #define NVSWITCH_LOG_BUFFER_SIZE 512 60 61 #define NVSWITCH_DMA_DIR_TO_SYSMEM 0 62 #define NVSWITCH_DMA_DIR_FROM_SYSMEM 1 63 #define NVSWITCH_DMA_DIR_BIDIRECTIONAL 2 64 65 #define NVSWITCH_I2C_CMD_READ 0 66 #define NVSWITCH_I2C_CMD_WRITE 1 67 #define NVSWITCH_I2C_CMD_SMBUS_READ 2 68 #define NVSWITCH_I2C_CMD_SMBUS_WRITE 3 69 #define NVSWITCH_I2C_CMD_SMBUS_QUICK_READ 4 70 #define NVSWITCH_I2C_CMD_SMBUS_QUICK_WRITE 5 71 72 typedef struct nvswitch_device nvswitch_device; 73 typedef struct NVSWITCH_CLIENT_EVENT NVSWITCH_CLIENT_EVENT; 74 75 /* 76 * @Brief : The interface will check if the client's version is supported by the 77 * driver. 78 * 79 * @param[in] user_version Version of the interface that the client is 80 * compiled with. 81 * @param[out] kernel_version Version of the interface that the kernel driver 82 * is compiled with. This information will be 83 * filled even if the CTRL call returns 84 * -NVL_ERR_NOT_SUPPORTED due to version mismatch. 85 * @param[in] length Version string buffer length 86 * 87 * @returns NVL_SUCCESS if the client is using compatible 88 * interface. 89 * -NVL_ERR_NOT_SUPPORTED if the client is using 90 * incompatible interface. 91 * Or, Other NVL_XXX status value. 92 */ 93 NvlStatus 94 nvswitch_lib_check_api_version 95 ( 96 const char *user_version, 97 char *kernel_version, 98 NvU32 length 99 ); 100 101 /* 102 * @Brief : Allocate a new nvswitch lib device instance. 103 * 104 * @Description : Creates and registers a new nvswitch device and registers 105 * with the nvlink library. This only initializes software state, 106 * it does not initialize the hardware state. 107 * 108 * @param[in] pci_domain pci domain of the device 109 * @param[in] pci_bus pci bus of the device 110 * @param[in] pci_device pci device of the device 111 * @param[in] pci_func pci function of the device 112 * @param[in] device_id pci device ID of the device 113 * @param[in] os_handle Device handle used to interact with OS layer 114 * @param[in] os_instance instance number of this device 115 * @param[out] device return device handle for interfacing with library 116 * 117 * @returns NVL_SUCCESS if the action succeeded 118 * an NVL error code otherwise 119 */ 120 NvlStatus 121 nvswitch_lib_register_device 122 ( 123 NvU16 pci_domain, 124 NvU8 pci_bus, 125 NvU8 pci_device, 126 NvU8 pci_func, 127 NvU16 device_id, 128 void *os_handle, 129 NvU32 os_instance, 130 nvswitch_device **device 131 ); 132 133 /* 134 * @Brief : Clean-up the software state for a nvswitch device. 135 * 136 * @Description : 137 * 138 * @param[in] device device handle to destroy 139 * 140 * @returns none 141 */ 142 void 143 nvswitch_lib_unregister_device 144 ( 145 nvswitch_device *device 146 ); 147 148 /* 149 * @Brief : Initialize the hardware for a nvswitch device. 150 * 151 * @Description : 152 * 153 * @param[in] device a reference to the device to initialize 154 * 155 * @returns NVL_SUCCESS if the action succeeded 156 * -NVL_BAD_ARGS if bad arguments provided 157 * -NVL_PCI_ERROR if bar info unable to be retrieved 158 */ 159 NvlStatus 160 nvswitch_lib_initialize_device 161 ( 162 nvswitch_device *device 163 ); 164 165 /* 166 * @Brief : Shutdown the hardware for a nvswitch device. 167 * 168 * @Description : 169 * 170 * @param[in] device a reference to the device to initialize 171 * 172 * @returns NVL_SUCCESS if the action succeeded 173 * -NVL_BAD_ARGS if bad arguments provided 174 * -NVL_PCI_ERROR if bar info unable to be retrieved 175 */ 176 NvlStatus 177 nvswitch_lib_shutdown_device 178 ( 179 nvswitch_device *device 180 ); 181 182 /* 183 * @Brief Control call (ioctl) interface. 184 * 185 * @param[in] device device to operate on 186 * @param[in] cmd Enumerated command to execute. 187 * @param[in] params Params structure to pass to the command. 188 * @param[in] params_size Size of the parameter structure. 189 * @param[in] osPrivate The private data structure for OS. 190 * 191 * @return NVL_SUCCESS on a successful command 192 * -NVL_NOT_FOUND if target device unable to be found 193 * -NVL_BAD_ARGS if an invalid cmd is provided 194 * -NVL_BAD_ARGS if a null arg is provided 195 * -NVL_ERR_GENERIC otherwise 196 */ 197 NvlStatus nvswitch_lib_ctrl 198 ( 199 nvswitch_device *device, 200 NvU32 cmd, 201 void *params, 202 NvU64 size, 203 void *osPrivate 204 ); 205 206 /* 207 * @Brief: Retrieve PCI information for a switch based from device instance 208 * 209 * @Description : 210 * 211 * @param[in] lib_handle device to query 212 * @param[out] pciInfo return pointer to nvswitch lib copy of device info 213 */ 214 void nvswitch_lib_get_device_info 215 ( 216 nvswitch_device *lib_handle, 217 struct nvlink_pci_info **pciInfo 218 ); 219 220 /* 221 * @Brief: Retrieve BIOS version for an nvswitch device 222 * 223 * @Description: For devices with a BIOS, this retrieves the BIOS version. 224 * 225 * @param[in] device device to query 226 * @param[out] version BIOS version is stored here 227 * 228 * @returns NVL_SUCCESS BIOS version was retrieved successfully 229 * -NVL_BAD_ARGS an invalid device is provided 230 * -NVL_ERR_INVALID_STATE an error occurred reading BIOS info 231 * -NVL_ERR_NOT_SUPPORTED device doesn't support this feature 232 */ 233 234 NvlStatus 235 nvswitch_lib_get_bios_version 236 ( 237 nvswitch_device *device, 238 NvU64 *version 239 ); 240 241 242 /* 243 * @Brief: Retrieve whether the device supports PCI pin interrupts 244 * 245 * @Description: Returns whether the device can use PCI pin IRQs 246 * 247 * 248 * @returns NV_TRUE device can use PCI pin IRQs 249 * NV_FALSE device cannot use PCI pin IRQs 250 */ 251 252 NvlStatus 253 nvswitch_lib_use_pin_irq 254 ( 255 nvswitch_device *device 256 ); 257 258 259 /* 260 * @Brief: Load platform information (emulation, simulation etc.). 261 * 262 * @param[in] lib_handle device 263 * 264 * @return NVL_SUCCESS on a successful command 265 * -NVL_BAD_ARGS if an invalid device is provided 266 */ 267 NvlStatus nvswitch_lib_load_platform_info 268 ( 269 nvswitch_device *lib_handle 270 ); 271 272 /* 273 * @Brief : Enable interrupts for this device 274 * 275 * @Description : 276 * 277 * @param[in] device device to enable 278 * 279 * @returns NVL_SUCCESS 280 * -NVL_PCI_ERROR if there was a register access error 281 */ 282 void 283 nvswitch_lib_enable_interrupts 284 ( 285 nvswitch_device *device 286 ); 287 288 /* 289 * @Brief : Disable interrupts for this device 290 * 291 * @Description : 292 * 293 * @param[in] device device to enable 294 * 295 * @returns NVL_SUCCESS 296 * -NVL_PCI_ERROR if there was a register access error 297 */ 298 void 299 nvswitch_lib_disable_interrupts 300 ( 301 nvswitch_device *device 302 ); 303 304 /* 305 * @Brief : Check if interrupts are pending on this device 306 * 307 * @Description : 308 * 309 * @param[in] device device to check 310 * 311 * @returns NVL_SUCCESS if there were no errors and interrupts were handled 312 * -NVL_BAD_ARGS if bad arguments provided 313 * -NVL_PCI_ERROR if there was a register access error 314 * -NVL_MORE_PROCESSING_REQUIRED no interrupts were found for this device 315 */ 316 NvlStatus 317 nvswitch_lib_check_interrupts 318 ( 319 nvswitch_device *device 320 ); 321 322 /* 323 * @Brief : Services interrupts for this device 324 * 325 * @Description : 326 * 327 * @param[in] device device to service 328 * 329 * @returns NVL_SUCCESS if there were no errors and interrupts were handled 330 * -NVL_BAD_ARGS if bad arguments provided 331 * -NVL_PCI_ERROR if there was a register access error 332 * -NVL_MORE_PROCESSING_REQUIRED no interrupts were found for this device 333 */ 334 NvlStatus 335 nvswitch_lib_service_interrupts 336 ( 337 nvswitch_device *device 338 ); 339 340 /* 341 * @Brief : Get depth of error logs and port event log 342 * 343 * @Description : 344 * 345 * @param[in] device device to check 346 * 347 * @param[out] fatal Count of fatal errors 348 * @param[out] nonfatal Count of non-fatal errors 349 * @param[out] portEvent Count of port events 350 * 351 * @returns NVL_SUCCESS if there were no errors and interrupts were handled 352 * -NVL_NOT_FOUND if bad arguments provided 353 */ 354 NvlStatus 355 nvswitch_lib_get_log_count 356 ( 357 nvswitch_device *device, 358 NvU32 *fatal, NvU32 *nonfatal, NvU32 *portEvent 359 ); 360 361 /* 362 * @Brief : Periodic thread-based dispatcher for kernel functions 363 * 364 * @Description : Its purpose is to do any background subtasks (data collection, thermal 365 * monitoring, etc. These subtasks may need to run at varying intervals, and 366 * may even wish to adjust their execution period based on other factors. 367 * Each subtask's entry notes the last time it was executed and its desired 368 * execution period. This function returns back to the dispatcher the desired 369 * time interval before it should be called again. 370 * 371 * @param[in] device The device to run background tasks on 372 * 373 * @returns nsec interval to wait before the next call. 374 */ 375 NvU64 376 nvswitch_lib_deferred_task_dispatcher 377 ( 378 nvswitch_device *device 379 ); 380 381 /* 382 * @Brief : Perform post init tasks 383 * 384 * @Description : Any device initialization/tests which need the device to be 385 * initialized to a sane state go here. 386 * 387 * @param[in] device The device to run the post-init on 388 * 389 * @returns returns NvlStatus code, see nvlink_errors.h 390 */ 391 NvlStatus 392 nvswitch_lib_post_init_device 393 ( 394 nvswitch_device *device 395 ); 396 397 /* 398 * @Brief : Perform post init tasks for a blacklisted device 399 * 400 * @Description : Any initialization tasks that should be run after a 401 * blacklisted item should go here. 402 * 403 * @param[in] device The device to run the post-init-blacklist on 404 * 405 * @returns void 406 */ 407 void 408 nvswitch_lib_post_init_blacklist_device 409 ( 410 nvswitch_device *device 411 ); 412 413 /* 414 * @Brief : Get the UUID of the device 415 * 416 * @Description : Copies out the device's UUID into the uuid field 417 * 418 * @param[in] device The device to get the UUID from 419 * 420 * @param[out] uuid A pointer to a uuid struct in which the UUID is written to 421 * 422 * @returns void 423 */ 424 void 425 nvswitch_lib_get_uuid 426 ( 427 nvswitch_device *device, 428 NvUuid *uuid 429 ); 430 431 /* 432 * @Brief : Get the Physical ID of the device 433 * 434 * @Description : Copies out the device's Physical ID into the phys_id field 435 * 436 * @param[in] device The device to get the UUID from 437 * 438 * @param[out] phys_id A pointer to a NvU32 which the physical ID is written to 439 * 440 * @returns NVL_SUCCESS if successful 441 * -NVL_BAD_ARGS if bad arguments provided 442 */ 443 NvlStatus 444 nvswitch_lib_get_physid 445 ( 446 nvswitch_device *device, 447 NvU32 *phys_id 448 ); 449 450 /* 451 * @Brief : Read the Fabric State for a nvswitch device. 452 * 453 * @Description : Returns the Fabric State for the device 454 * 455 * @param[in] device a reference to the device 456 * @param[in] *ptrs references to the fabric state 457 * 458 * @returns NVL_SUCCESS if the action succeeded 459 * -NVL_BAD_ARGS if bad arguments provided 460 */ 461 NvlStatus 462 nvswitch_lib_read_fabric_state 463 ( 464 nvswitch_device *device, 465 NVSWITCH_DEVICE_FABRIC_STATE *device_fabric_state, 466 NVSWITCH_DEVICE_BLACKLIST_REASON *device_blacklist_reason, 467 NVSWITCH_DRIVER_FABRIC_STATE *driver_fabric_state 468 ); 469 470 /* 471 * @Brief : Validates PCI device id 472 * 473 * @Description : Validates PCI device id 474 * 475 * @param[in] device The device id to be validated 476 * 477 * @returns True if device id is valid 478 */ 479 NvBool 480 nvswitch_lib_validate_device_id 481 ( 482 NvU32 device_id 483 ); 484 485 /* 486 * @Brief : Gets an event if it exists in the Event list 487 * 488 * @Description : Gets an event if it is in the Device's Client 489 * Event list 490 * 491 * @param[in] device Device to operate on 492 * @param[in] osPrivate The private data structure for the OS 493 * @param[out] ppClientEvent Double pointer to client event 494 * 495 * @returns NVL_SUCCESS if client event found 496 * -NVL_BAD_ARGS if bad arguments provided 497 * -NVL_NOT_FOUND if no client event found 498 */ 499 NvlStatus 500 nvswitch_lib_get_client_event 501 ( 502 nvswitch_device *device, 503 void *osPrivate, 504 NVSWITCH_CLIENT_EVENT **ppClientEvent 505 ); 506 507 /* 508 * @Brief : Adds a single entry into the Event list 509 * 510 * @Description : Adds an entry into the front of the Device's 511 * Client Event List 512 * 513 * @param[in] device Device to operate on 514 * @param[in] osPrivate The private data structure for OS 515 * @param[in] pParams The parameters for the client event 516 * 517 * @returns NVL_SUCCESS if event added 518 * -NVL_BAD_ARGS if bad arguments provided 519 * -NVL_NO_MEM if allocation fails 520 */ 521 NvlStatus 522 nvswitch_lib_add_client_event 523 ( 524 nvswitch_device *device, 525 void *osPrivate, 526 NvU32 eventId 527 ); 528 529 /* 530 * @Brief : Removes entries from the Event list 531 * 532 * @Description : Removes the entries associated with osPrivate 533 * from the Device's Client Event List 534 * 535 * @param[in] device Device to operate on 536 * @param[in] osPrivate The private data structure for OS 537 * 538 * @returns NVL_SUCCESS if event removed 539 */ 540 NvlStatus 541 nvswitch_lib_remove_client_events 542 ( 543 nvswitch_device *device, 544 void *osPrivate 545 ); 546 547 /* 548 * @Brief : Notifies all events with a matching event Id in the Client Event list 549 * 550 * @Description : Notifies all events with a matching event Id in the Client Event list 551 * 552 * @param[in] device Device to operate on 553 * @param[in] eventId The event ID to notify 554 * 555 * @returns NVL_SUCCESS if arguments are valid 556 * -NVL_BAD_ARGS if bad arguments provided 557 */ 558 NvlStatus 559 nvswitch_lib_notify_client_events 560 ( 561 nvswitch_device *device, 562 NvU32 eventId 563 ); 564 565 /* 566 * @Brief : Gets a mask of valid I2C ports for the device 567 * 568 * @Description : Gets a mask of valid I2C ports for the device 569 * 570 * @param[in] device Device to operate on 571 * @param[out] validPortsMask A pointer to a mask of valid ports 572 * 573 * @returns NVL_SUCCESS if successfuly 574 * -NVL_BAD_ARGS if bad arguments provided 575 */ 576 NvlStatus 577 nvswitch_lib_get_valid_ports_mask 578 ( 579 nvswitch_device *device, 580 NvU32 *validPortsMask 581 ); 582 583 /* 584 * @Brief : Returns a boolean if the I2C interface is supported for the device 585 * 586 * @Description : Returns a boolean if the I2C interface is supported for the device 587 * 588 * @param[in] device Device to operate on 589 * 590 * @returns NV_TRUE device can use the I2C interface 591 * NV_FALSE device cannot use the I2C interface 592 */ 593 NvBool 594 nvswitch_lib_is_i2c_supported 595 ( 596 nvswitch_device *device 597 ); 598 599 /* 600 * @Brief : Performs an I2C transaction 601 * 602 * @Description : Performs an I2C transaction 603 * 604 * @param[in] device Device to operate on 605 * @param[in] port Port to issue I2C transaction 606 * @param[in] type Type of I2C transaction 607 * @param[in] addr Device address to perform I2C transaction on 608 * @param[in] command I2C command to perform on 609 * @param[in] len Length of the I2C transaction message 610 * @param[in/out] pData A pointer to the buffer containing the input/output data 611 * 612 * @returns NVL_SUCCESS if I2C transaction completes 613 * -NVL_BAD_ARGS if bad arguments provided 614 * -NVL_ERR_INVALID_STATE if something internal went wrong 615 */ 616 NvlStatus 617 nvswitch_lib_i2c_transfer 618 ( 619 nvswitch_device *device, 620 NvU32 port, 621 NvU8 type, 622 NvU8 addr, 623 NvU8 command, 624 NvU32 len, 625 NvU8 *pData 626 ); 627 628 /* 629 * Returns count of registered NvSwitch devices. 630 */ 631 NvU32 632 nvswitch_os_get_device_count 633 ( 634 void 635 ); 636 637 /* 638 * Get current time in nanoseconds 639 * The time is since epoch time (midnight UTC of January 1, 1970) 640 */ 641 NvU64 642 nvswitch_os_get_platform_time 643 ( 644 void 645 ); 646 647 NvU64 648 nvswitch_os_get_platform_time_epoch 649 ( 650 void 651 ); 652 653 #if (defined(_WIN32) || defined(_WIN64)) 654 #define NVSWITCH_PRINT_ATTRIB(str, arg1) 655 #else 656 #define NVSWITCH_PRINT_ATTRIB(str, arg1) \ 657 __attribute__ ((format (printf, (str), (arg1)))) 658 #endif // (defined(_WIN32) || defined(_WIN64)) 659 660 /* 661 * printf wrapper 662 */ 663 void 664 NVSWITCH_PRINT_ATTRIB(2, 3) 665 nvswitch_os_print 666 ( 667 int log_level, 668 const char *pFormat, 669 ... 670 ); 671 672 /* 673 * "Registry" interface for dword 674 */ 675 NvlStatus 676 nvswitch_os_read_registry_dword 677 ( 678 void *os_handle, 679 const char *name, 680 NvU32 *data 681 ); 682 683 /* 684 * "Registry" interface for binary data 685 */ 686 NvlStatus 687 nvswitch_os_read_registery_binary 688 ( 689 void *os_handle, 690 const char *name, 691 NvU8 *data, 692 NvU32 length 693 ); 694 695 NvBool 696 nvswitch_os_is_uuid_in_blacklist 697 ( 698 NvUuid *uuid 699 ); 700 701 702 /* 703 * Override platform/simulation settings for cases 704 */ 705 void 706 nvswitch_os_override_platform 707 ( 708 void *os_handle, 709 NvBool *rtlsim 710 ); 711 712 /* 713 * Memory management interface 714 */ 715 NvlStatus 716 nvswitch_os_alloc_contig_memory 717 ( 718 void *os_handle, 719 void **virt_addr, 720 NvU32 size, 721 NvBool force_dma32 722 ); 723 724 void 725 nvswitch_os_free_contig_memory 726 ( 727 void *os_handle, 728 void *virt_addr, 729 NvU32 size 730 ); 731 732 NvlStatus 733 nvswitch_os_map_dma_region 734 ( 735 void *os_handle, 736 void *cpu_addr, 737 NvU64 *dma_handle, 738 NvU32 size, 739 NvU32 direction 740 ); 741 742 NvlStatus 743 nvswitch_os_unmap_dma_region 744 ( 745 void *os_handle, 746 void *cpu_addr, 747 NvU64 dma_handle, 748 NvU32 size, 749 NvU32 direction 750 ); 751 752 NvlStatus 753 nvswitch_os_set_dma_mask 754 ( 755 void *os_handle, 756 NvU32 dma_addr_width 757 ); 758 759 NvlStatus 760 nvswitch_os_sync_dma_region_for_cpu 761 ( 762 void *os_handle, 763 NvU64 dma_handle, 764 NvU32 size, 765 NvU32 direction 766 ); 767 768 NvlStatus 769 nvswitch_os_sync_dma_region_for_device 770 ( 771 void *os_handle, 772 NvU64 dma_handle, 773 NvU32 size, 774 NvU32 direction 775 ); 776 777 void * 778 nvswitch_os_malloc_trace 779 ( 780 NvLength size, 781 const char *file, 782 NvU32 line 783 ); 784 785 void 786 nvswitch_os_free 787 ( 788 void *pMem 789 ); 790 791 NvLength 792 nvswitch_os_strlen 793 ( 794 const char *str 795 ); 796 797 char* 798 nvswitch_os_strncpy 799 ( 800 char *pDest, 801 const char *pSrc, 802 NvLength length 803 ); 804 805 int 806 nvswitch_os_strncmp 807 ( 808 const char *s1, 809 const char *s2, 810 NvLength length 811 ); 812 813 char* 814 nvswitch_os_strncat 815 ( 816 char *s1, 817 const char *s2, 818 NvLength length 819 ); 820 821 void * 822 nvswitch_os_memset 823 ( 824 void *pDest, 825 int value, 826 NvLength size 827 ); 828 829 void * 830 nvswitch_os_memcpy 831 ( 832 void *pDest, 833 const void *pSrc, 834 NvLength size 835 ); 836 837 int 838 nvswitch_os_memcmp 839 ( 840 const void *s1, 841 const void *s2, 842 NvLength size 843 ); 844 845 /* 846 * Memory read / write interface 847 */ 848 NvU32 849 nvswitch_os_mem_read32 850 ( 851 const volatile void * pAddress 852 ); 853 854 void 855 nvswitch_os_mem_write32 856 ( 857 volatile void *pAddress, 858 NvU32 data 859 ); 860 861 NvU64 862 nvswitch_os_mem_read64 863 ( 864 const volatile void *pAddress 865 ); 866 867 void 868 nvswitch_os_mem_write64 869 ( 870 volatile void *pAddress, 871 NvU64 data 872 ); 873 874 /* 875 * Interface to write formatted output to sized buffer 876 */ 877 int 878 nvswitch_os_snprintf 879 ( 880 char *pString, 881 NvLength size, 882 const char *pFormat, 883 ... 884 ); 885 886 /* 887 * Interface to write formatted output to sized buffer 888 */ 889 int 890 nvswitch_os_vsnprintf 891 ( 892 char *buf, 893 NvLength size, 894 const char *fmt, 895 va_list arglist 896 ); 897 898 /* 899 * Debug assert and log interface 900 */ 901 void 902 nvswitch_os_assert_log 903 ( 904 const char *pFormat, 905 ... 906 ); 907 908 /* 909 * Interface to sleep for specified milliseconds. Yields the CPU to scheduler. 910 */ 911 void 912 nvswitch_os_sleep 913 ( 914 unsigned int ms 915 ); 916 917 NvlStatus 918 nvswitch_os_acquire_fabric_mgmt_cap 919 ( 920 void *osPrivate, 921 NvU64 capDescriptor 922 ); 923 924 int 925 nvswitch_os_is_fabric_manager 926 ( 927 void *osPrivate 928 ); 929 930 int 931 nvswitch_os_is_admin 932 ( 933 void 934 ); 935 936 NvlStatus 937 nvswitch_os_get_os_version 938 ( 939 NvU32 *pMajorVer, 940 NvU32 *pMinorVer, 941 NvU32 *pBuildNum 942 ); 943 944 NvlStatus 945 nvswitch_os_get_pid 946 ( 947 NvU32 *pPid 948 ); 949 950 void 951 nvswitch_lib_smbpbi_log_sxid 952 ( 953 nvswitch_device *device, 954 NvU32 sxid, 955 const char *pFormat, 956 ... 957 ); 958 959 /*! 960 * @brief: OS Specific handling to add an event. 961 */ 962 NvlStatus 963 nvswitch_os_add_client_event 964 ( 965 void *osHandle, 966 void *osPrivate, 967 NvU32 eventId 968 ); 969 970 /*! 971 * @brief: OS specific handling to remove all events corresponding to osPrivate. 972 */ 973 NvlStatus 974 nvswitch_os_remove_client_event 975 ( 976 void *osHandle, 977 void *osPrivate 978 ); 979 980 /*! 981 * @brief: OS specific handling to notify an event. 982 */ 983 NvlStatus 984 nvswitch_os_notify_client_event 985 ( 986 void *osHandle, 987 void *osPrivate, 988 NvU32 eventId 989 ); 990 991 /*! 992 * @brief: Gets OS specific support for the REGISTER_EVENTS ioctl 993 */ 994 NvlStatus 995 nvswitch_os_get_supported_register_events_params 996 ( 997 NvBool *bSupportsManyEvents, 998 NvBool *bUserSuppliesOsData 999 ); 1000 1001 #ifdef __cplusplus 1002 } 1003 #endif 1004 #endif //_NVSWITCH_EXPORT_H_ 1005