1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_PX_LIB4V_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_PX_LIB4V_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * SUN4V IO API - Version 1.11 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate /* 41*7c478bd9Sstevel@tonic-gate * The device handle uniquely identifies a SUN4V device. 42*7c478bd9Sstevel@tonic-gate * It consists of the lower 28-bits of the hi-cell of the 43*7c478bd9Sstevel@tonic-gate * first entry of the SUN4V device's "reg" property as 44*7c478bd9Sstevel@tonic-gate * defined by the SUN4V Bus Binding to Open Firmware. 45*7c478bd9Sstevel@tonic-gate */ 46*7c478bd9Sstevel@tonic-gate #define DEVHDLE_MASK 0xFFFFFFF 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_config_get(devhandle_t dev_hdl, pci_device_t bdf, 49*7c478bd9Sstevel@tonic-gate pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t *data_p); 50*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_config_put(devhandle_t dev_hdl, pci_device_t bdf, 51*7c478bd9Sstevel@tonic-gate pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t data); 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_map(devhandle_t dev_hdl, tsbid_t tsbid, 54*7c478bd9Sstevel@tonic-gate pages_t pages, io_attributes_t io_attributes, 55*7c478bd9Sstevel@tonic-gate io_page_list_t *io_page_list_p, pages_t *pages_mapped); 56*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_demap(devhandle_t dev_hdl, tsbid_t tsbid, 57*7c478bd9Sstevel@tonic-gate pages_t pages, pages_t *pages_demapped); 58*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getmap(devhandle_t dev_hdl, tsbid_t tsbid, 59*7c478bd9Sstevel@tonic-gate io_attributes_t *attributes_p, r_addr_t *r_addr_p); 60*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra, 61*7c478bd9Sstevel@tonic-gate io_attributes_t io_attributes, io_addr_t *io_addr_p); 62*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_dma_sync(devhandle_t dev_hdl, r_addr_t ra, 63*7c478bd9Sstevel@tonic-gate size_t num_bytes, io_sync_direction_t io_sync_direction, 64*7c478bd9Sstevel@tonic-gate size_t *bytes_synched); 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate /* 67*7c478bd9Sstevel@tonic-gate * MSIQ Functions: 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_conf(devhandle_t dev_hdl, msiqid_t msiq_id, 70*7c478bd9Sstevel@tonic-gate r_addr_t ra, uint_t msiq_rec_cnt); 71*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_info(devhandle_t dev_hdl, msiqid_t msiq_id, 72*7c478bd9Sstevel@tonic-gate r_addr_t *ra_p, uint_t *msiq_rec_cnt_p); 73*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getvalid(devhandle_t dev_hdl, msiqid_t msiq_id, 74*7c478bd9Sstevel@tonic-gate pci_msiq_valid_state_t *msiq_valid_state); 75*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setvalid(devhandle_t dev_hdl, msiqid_t msiq_id, 76*7c478bd9Sstevel@tonic-gate pci_msiq_valid_state_t msiq_valid_state); 77*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getstate(devhandle_t dev_hdl, msiqid_t msiq_id, 78*7c478bd9Sstevel@tonic-gate pci_msiq_state_t *msiq_state); 79*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setstate(devhandle_t dev_hdl, msiqid_t msiq_id, 80*7c478bd9Sstevel@tonic-gate pci_msiq_state_t msiq_state); 81*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gethead(devhandle_t dev_hdl, msiqid_t msiq_id, 82*7c478bd9Sstevel@tonic-gate msiqhead_t *msiq_head); 83*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_sethead(devhandle_t dev_hdl, msiqid_t msiq_id, 84*7c478bd9Sstevel@tonic-gate msiqhead_t msiq_head); 85*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gettail(devhandle_t dev_hdl, msiqid_t msiq_id, 86*7c478bd9Sstevel@tonic-gate msiqtail_t *msiq_tail); 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * MSI Functions: 90*7c478bd9Sstevel@tonic-gate */ 91*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getmsiq(devhandle_t dev_hdl, msinum_t msi_num, 92*7c478bd9Sstevel@tonic-gate msiqid_t *msiq_id); 93*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setmsiq(devhandle_t dev_hdl, msinum_t msi_num, 94*7c478bd9Sstevel@tonic-gate msiqid_t msiq_id, msi_type_t msitype); 95*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getvalid(devhandle_t dev_hdl, msinum_t msi_num, 96*7c478bd9Sstevel@tonic-gate pci_msi_valid_state_t *msi_valid_state); 97*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setvalid(devhandle_t dev_hdl, msinum_t msi_num, 98*7c478bd9Sstevel@tonic-gate pci_msi_valid_state_t msi_valid_state); 99*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getstate(devhandle_t dev_hdl, msinum_t msi_num, 100*7c478bd9Sstevel@tonic-gate pci_msi_state_t *msi_state); 101*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setstate(devhandle_t dev_hdl, msinum_t msi_num, 102*7c478bd9Sstevel@tonic-gate pci_msi_state_t msi_state); 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate /* 105*7c478bd9Sstevel@tonic-gate * MSG Functions: 106*7c478bd9Sstevel@tonic-gate */ 107*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 108*7c478bd9Sstevel@tonic-gate msiqid_t *msiq_id); 109*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 110*7c478bd9Sstevel@tonic-gate msiqid_t msiq_id); 111*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 112*7c478bd9Sstevel@tonic-gate pcie_msg_valid_state_t *msg_valid_state); 113*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type, 114*7c478bd9Sstevel@tonic-gate pcie_msg_valid_state_t msg_valid_state); 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate typedef struct px_config_acc_pvt { 117*7c478bd9Sstevel@tonic-gate dev_info_t *dip; 118*7c478bd9Sstevel@tonic-gate uint32_t raddr; 119*7c478bd9Sstevel@tonic-gate uint32_t vaddr; 120*7c478bd9Sstevel@tonic-gate } px_config_acc_pvt_t; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate /* 123*7c478bd9Sstevel@tonic-gate * Peek/poke functionality: 124*7c478bd9Sstevel@tonic-gate */ 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_peek(devhandle_t dev_hdl, r_addr_t ra, size_t size, 127*7c478bd9Sstevel@tonic-gate uint32_t *status, uint64_t *data_p); 128*7c478bd9Sstevel@tonic-gate extern uint64_t hvio_poke(devhandle_t dev_hdl, r_addr_t ra, size_t size, 129*7c478bd9Sstevel@tonic-gate uint64_t data, pci_device_t bdf, uint32_t *wrt_stat); 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 132*7c478bd9Sstevel@tonic-gate } 133*7c478bd9Sstevel@tonic-gate #endif 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate #endif /* _SYS_PX_LIB4V_H */ 136