pci_cfgreg.c revision 84412
1195534Sscottl/*- 2238805Smav * Copyright (c) 2001 Doug Rabson 3195534Sscottl * All rights reserved. 4195534Sscottl * 5195534Sscottl * Redistribution and use in source and binary forms, with or without 6195534Sscottl * modification, are permitted provided that the following conditions 7195534Sscottl * are met: 8195534Sscottl * 1. Redistributions of source code must retain the above copyright 9195534Sscottl * notice, this list of conditions and the following disclaimer. 10195534Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11195534Sscottl * notice, this list of conditions and the following disclaimer in the 12195534Sscottl * documentation and/or other materials provided with the distribution. 13195534Sscottl * 14195534Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15195534Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16195534Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17195534Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18195534Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19195534Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20195534Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21195534Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22195534Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23195534Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24195534Sscottl * SUCH DAMAGE. 25195534Sscottl * 26195534Sscottl * $FreeBSD: head/sys/ia64/pci/pci_cfgreg.c 84412 2001-10-03 08:25:58Z dfr $ 27195534Sscottl */ 28195534Sscottl 29195534Sscottl#include <sys/param.h> 30195534Sscottl#include <machine/pci_cfgreg.h> 31195534Sscottl#include <machine/sal.h> 32195534Sscottl 33195534Sscottl#define SAL_PCI_ADDRESS(bus, slot, func, reg) \ 34195534Sscottl (((bus) << 16) | ((slot) << 11) | ((func) << 8) | (reg)) 35220576Smav 36195534Sscottlint 37195534Sscottlpci_cfgregopen(void) 38195534Sscottl{ 39195534Sscottl return 1; 40195534Sscottl} 41195534Sscottl 42195534Sscottlu_int32_t 43195534Sscottlpci_cfgregread(int bus, int slot, int func, int reg, int bytes) 44195534Sscottl{ 45195534Sscottl struct ia64_sal_result res; 46195534Sscottl 47195534Sscottl res = ia64_sal_entry(SAL_PCI_CONFIG_READ, 48271146Simp SAL_PCI_ADDRESS(bus, slot, func, reg), 49271146Simp bytes, 0, 0, 0, 0, 0); 50195534Sscottl if (res.sal_status < 0) 51199176Smav return (~0); 52199176Smav else 53203030Smav return (res.sal_result[0]); 54199176Smav} 55199322Smav 56199176Smavvoid 57271146Simppci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes) 58271146Simp{ 59271146Simp struct ia64_sal_result res; 60271146Simp 61271146Simp res = ia64_sal_entry(SAL_PCI_CONFIG_WRITE, 62271146Simp SAL_PCI_ADDRESS(bus, slot, func, reg), 63271146Simp bytes, data, 0, 0, 0, 0); 64271146Simp} 65271146Simp