17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_PX_LIB4V_H 287c478bd9Sstevel@tonic-gate #define _SYS_PX_LIB4V_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * SUN4V IO API - Version 1.11 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * The device handle uniquely identifies a SUN4V device. 427c478bd9Sstevel@tonic-gate * It consists of the lower 28-bits of the hi-cell of the 437c478bd9Sstevel@tonic-gate * first entry of the SUN4V device's "reg" property as 447c478bd9Sstevel@tonic-gate * defined by the SUN4V Bus Binding to Open Firmware. 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate #define DEVHDLE_MASK 0xFFFFFFF 477c478bd9Sstevel@tonic-gate 488bc7d88aSet /* PX BDF Shift in a Phyiscal Address - used FMA Fabric only */ 498bc7d88aSet #define PX_RA_BDF_SHIFT 8 508bc7d88aSet 517c478bd9Sstevel@tonic-gate extern uint64_t hvio_config_get(devhandle_t dev_hdl, pci_device_t bdf, 527c478bd9Sstevel@tonic-gate pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t *data_p); 537c478bd9Sstevel@tonic-gate extern uint64_t hvio_config_put(devhandle_t dev_hdl, pci_device_t bdf, 547c478bd9Sstevel@tonic-gate pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t data); 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_map(devhandle_t dev_hdl, tsbid_t tsbid, 577c478bd9Sstevel@tonic-gate pages_t pages, io_attributes_t io_attributes, 587c478bd9Sstevel@tonic-gate io_page_list_t *io_page_list_p, pages_t *pages_mapped); 597c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_demap(devhandle_t dev_hdl, tsbid_t tsbid, 607c478bd9Sstevel@tonic-gate pages_t pages, pages_t *pages_demapped); 617c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getmap(devhandle_t dev_hdl, tsbid_t tsbid, 627c478bd9Sstevel@tonic-gate io_attributes_t *attributes_p, r_addr_t *r_addr_p); 637c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra, 647c478bd9Sstevel@tonic-gate io_attributes_t io_attributes, io_addr_t *io_addr_p); 657c478bd9Sstevel@tonic-gate extern uint64_t hvio_dma_sync(devhandle_t dev_hdl, r_addr_t ra, 667c478bd9Sstevel@tonic-gate size_t num_bytes, io_sync_direction_t io_sync_direction, 677c478bd9Sstevel@tonic-gate size_t *bytes_synched); 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate /* 707c478bd9Sstevel@tonic-gate * MSIQ Functions: 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_conf(devhandle_t dev_hdl, msiqid_t msiq_id, 737c478bd9Sstevel@tonic-gate r_addr_t ra, uint_t msiq_rec_cnt); 747c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_info(devhandle_t dev_hdl, msiqid_t msiq_id, 757c478bd9Sstevel@tonic-gate r_addr_t *ra_p, uint_t *msiq_rec_cnt_p); 767c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getvalid(devhandle_t dev_hdl, msiqid_t msiq_id, 777c478bd9Sstevel@tonic-gate pci_msiq_valid_state_t *msiq_valid_state); 787c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setvalid(devhandle_t dev_hdl, msiqid_t msiq_id, 797c478bd9Sstevel@tonic-gate pci_msiq_valid_state_t msiq_valid_state); 807c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getstate(devhandle_t dev_hdl, msiqid_t msiq_id, 817c478bd9Sstevel@tonic-gate pci_msiq_state_t *msiq_state); 827c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setstate(devhandle_t dev_hdl, msiqid_t msiq_id, 837c478bd9Sstevel@tonic-gate pci_msiq_state_t msiq_state); 847c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gethead(devhandle_t dev_hdl, msiqid_t msiq_id, 857c478bd9Sstevel@tonic-gate msiqhead_t *msiq_head); 867c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_sethead(devhandle_t dev_hdl, msiqid_t msiq_id, 877c478bd9Sstevel@tonic-gate msiqhead_t msiq_head); 887c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gettail(devhandle_t dev_hdl, msiqid_t msiq_id, 897c478bd9Sstevel@tonic-gate msiqtail_t *msiq_tail); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * MSI Functions: 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getmsiq(devhandle_t dev_hdl, msinum_t msi_num, 957c478bd9Sstevel@tonic-gate msiqid_t *msiq_id); 967c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setmsiq(devhandle_t dev_hdl, msinum_t msi_num, 977c478bd9Sstevel@tonic-gate msiqid_t msiq_id, msi_type_t msitype); 987c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getvalid(devhandle_t dev_hdl, msinum_t msi_num, 997c478bd9Sstevel@tonic-gate pci_msi_valid_state_t *msi_valid_state); 1007c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setvalid(devhandle_t dev_hdl, msinum_t msi_num, 1017c478bd9Sstevel@tonic-gate pci_msi_valid_state_t msi_valid_state); 1027c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getstate(devhandle_t dev_hdl, msinum_t msi_num, 1037c478bd9Sstevel@tonic-gate pci_msi_state_t *msi_state); 1047c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setstate(devhandle_t dev_hdl, msinum_t msi_num, 1057c478bd9Sstevel@tonic-gate pci_msi_state_t msi_state); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * MSG Functions: 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 1117c478bd9Sstevel@tonic-gate msiqid_t *msiq_id); 1127c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 1137c478bd9Sstevel@tonic-gate msiqid_t msiq_id); 1147c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 1157c478bd9Sstevel@tonic-gate pcie_msg_valid_state_t *msg_valid_state); 1167c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 1177c478bd9Sstevel@tonic-gate pcie_msg_valid_state_t msg_valid_state); 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate typedef struct px_config_acc_pvt { 1207c478bd9Sstevel@tonic-gate dev_info_t *dip; 1217c478bd9Sstevel@tonic-gate uint32_t raddr; 1227c478bd9Sstevel@tonic-gate uint32_t vaddr; 1237c478bd9Sstevel@tonic-gate } px_config_acc_pvt_t; 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * Peek/poke functionality: 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate extern uint64_t hvio_peek(devhandle_t dev_hdl, r_addr_t ra, size_t size, 1307c478bd9Sstevel@tonic-gate uint32_t *status, uint64_t *data_p); 1317c478bd9Sstevel@tonic-gate extern uint64_t hvio_poke(devhandle_t dev_hdl, r_addr_t ra, size_t size, 1327c478bd9Sstevel@tonic-gate uint64_t data, pci_device_t bdf, uint32_t *wrt_stat); 1337c478bd9Sstevel@tonic-gate 134*69cd775fSschwartz /* 135*69cd775fSschwartz * Priviledged physical access: 136*69cd775fSschwartz */ 137*69cd775fSschwartz extern uint64_t hv_ra2pa(uint64_t ra); 138*69cd775fSschwartz extern uint64_t hv_hpriv(void *func, uint64_t arg1, uint64_t arg2, 139*69cd775fSschwartz uint64_t arg3); 140*69cd775fSschwartz 1417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate #endif 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate #endif /* _SYS_PX_LIB4V_H */ 146