pci_cfgreg.c revision 84124
184124Sdfr/*- 284124Sdfr * Copyright (c) 2001 Doug Rabson 384124Sdfr * All rights reserved. 484124Sdfr * 584124Sdfr * Redistribution and use in source and binary forms, with or without 684124Sdfr * modification, are permitted provided that the following conditions 784124Sdfr * are met: 884124Sdfr * 1. Redistributions of source code must retain the above copyright 984124Sdfr * notice, this list of conditions and the following disclaimer. 1084124Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1184124Sdfr * notice, this list of conditions and the following disclaimer in the 1284124Sdfr * documentation and/or other materials provided with the distribution. 1384124Sdfr * 1484124Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1584124Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1684124Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1784124Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1884124Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1984124Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2084124Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2184124Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2284124Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2384124Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2484124Sdfr * SUCH DAMAGE. 2584124Sdfr * 2684124Sdfr * $FreeBSD: head/sys/ia64/pci/pci_cfgreg.c 84124 2001-09-29 11:11:18Z dfr $ 2784124Sdfr */ 2884124Sdfr 2984124Sdfr#include <sys/param.h> 3084124Sdfr#include <machine/pci_cfgreg.h> 3184124Sdfr#include <machine/sal.h> 3284124Sdfr 3384124Sdfr#define SAL_PCI_ADDRESS(bus, slot, func, reg) \ 3484124Sdfr (((bus) << 23) | ((slot) << 11) | ((func) << 8) | (reg)) 3584124Sdfr 3684124Sdfrint 3784124Sdfrpci_cfgregopen(void) 3884124Sdfr{ 3984124Sdfr return 1; 4084124Sdfr} 4184124Sdfr 4284124Sdfru_int32_t 4384124Sdfrpci_cfgregread(int bus, int slot, int func, int reg, int bytes) 4484124Sdfr{ 4584124Sdfr struct ia64_sal_result res; 4684124Sdfr 4784124Sdfr res = ia64_sal_entry(SAL_PCI_CONFIG_READ, 4884124Sdfr SAL_PCI_ADDRESS(bus, slot, func, reg), 4984124Sdfr bytes, 0, 0, 0, 0, 0); 5084124Sdfr if (res.sal_status < 0) 5184124Sdfr return (~0); 5284124Sdfr else 5384124Sdfr return (res.sal_result[0]); 5484124Sdfr 5584124Sdfr 5684124Sdfr} 5784124Sdfrvoid 5884124Sdfrpci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes) 5984124Sdfr{ 6084124Sdfr struct ia64_sal_result res; 6184124Sdfr 6284124Sdfr res = ia64_sal_entry(SAL_PCI_CONFIG_WRITE, 6384124Sdfr SAL_PCI_ADDRESS(bus, slot, func, reg), 6484124Sdfr bytes, data, 0, 0, 0, 0); 6584124Sdfr} 66