1149871Sscottl/* 2149871Sscottl * Copyright (c) 2004-2005 HighPoint Technologies, Inc. 3136849Sscottl * All rights reserved. 4136849Sscottl * 5136849Sscottl * Redistribution and use in source and binary forms, with or without 6136849Sscottl * modification, are permitted provided that the following conditions 7136849Sscottl * are met: 8136849Sscottl * 1. Redistributions of source code must retain the above copyright 9136849Sscottl * notice, this list of conditions and the following disclaimer. 10136849Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11136849Sscottl * notice, this list of conditions and the following disclaimer in the 12136849Sscottl * documentation and/or other materials provided with the distribution. 13136849Sscottl * 14136849Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15136849Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16136849Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17136849Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18136849Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19136849Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20136849Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21136849Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22136849Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23136849Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24136849Sscottl * SUCH DAMAGE. 25136849Sscottl * 26136849Sscottl * $FreeBSD$ 27136849Sscottl */ 28136849Sscottl#include <sys/param.h> 29136849Sscottl#include <sys/systm.h> 30149871Sscottl 31149871Sscottl#include <sys/time.h> 32136849Sscottl#include <sys/kernel.h> 33149871Sscottl#include <sys/bus.h> 34149871Sscottl#include <machine/resource.h> 35136849Sscottl 36149871Sscottl#if __FreeBSD_version >= 500043 37149871Sscottl#include <machine/pci_cfgreg.h> 38149871Sscottl#endif 39136849Sscottl 40149871Sscottl#if (__FreeBSD_version < 500043) 41149871Sscottl#include <sys/bus_private.h> 42149871Sscottl#endif 43149871Sscottl 44149871Sscottl#if (__FreeBSD_version < 500000) 45149871Sscottl#include <machine/clock.h> 46149871Sscottl#endif 47149871Sscottl 48149871Sscottl#ifndef __KERNEL__ 49149871Sscottl#define __KERNEL__ 50149871Sscottl#endif 51149871Sscottl 52136849Sscottl#include <dev/hptmv/global.h> 53136849Sscottl#include <dev/hptmv/hptintf.h> 54136849Sscottl#include <dev/hptmv/mvOs.h> 55136849Sscottl#include <dev/hptmv/osbsd.h> 56136849Sscottl 57149871Sscottl 58136849Sscottlvoid HPTLIBAPI 59136849SscottlMV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset, MV_U8 val) 60149871Sscottl{ 61149871Sscottl writeb((void *)((ULONG_PTR)base + offset), val); 62136849Sscottl} 63136849Sscottl 64136849Sscottlvoid HPTLIBAPI 65136849SscottlMV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U16 val) 66149871Sscottl{ 67149871Sscottl writew((void *)((ULONG_PTR)base + offset), val); 68136849Sscottl} 69136849Sscottl 70136849Sscottlvoid HPTLIBAPI 71136849SscottlMV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U32 val) 72136849Sscottl{ 73149871Sscottl writel((void *)((ULONG_PTR)base + offset), val); 74136849Sscottl} 75136849Sscottl 76149871SscottlMV_U8 HPTLIBAPI 77149871SscottlMV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset) 78136849Sscottl{ 79149871Sscottl return readb((void *)((ULONG_PTR)base + offset)); 80136849Sscottl} 81136849Sscottl 82149871SscottlMV_U16 HPTLIBAPI 83149871SscottlMV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset) 84136849Sscottl{ 85149871Sscottl return readw((void *)((ULONG_PTR)base + offset)); 86136849Sscottl} 87136849Sscottl 88149871SscottlMV_U32 HPTLIBAPI 89149871SscottlMV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset) 90136849Sscottl{ 91149871Sscottl return readl((void *)((ULONG_PTR)base + offset)); 92136849Sscottl} 93136849Sscottl 94136849Sscottlint HPTLIBAPI 95136849Sscottlos_memcmp(const void *cs, const void *ct, unsigned len) 96136849Sscottl{ 97136849Sscottl return memcmp(cs, ct, len); 98136849Sscottl} 99136849Sscottl 100136849Sscottlvoid HPTLIBAPI 101136849Sscottlos_memcpy(void *to, const void *from, unsigned len) 102136849Sscottl{ 103136849Sscottl memcpy(to, from, len); 104136849Sscottl} 105136849Sscottl 106149871Sscottlvoid HPTLIBAPI 107149871Sscottlos_memset(void *s, char c, unsigned len) 108136849Sscottl{ 109136849Sscottl memset(s, c, len); 110136849Sscottl} 111136849Sscottl 112149871Sscottlunsigned HPTLIBAPI 113149871Sscottlos_strlen(const char *s) 114136849Sscottl{ 115136849Sscottl return strlen(s); 116136849Sscottl} 117136849Sscottl 118149871Sscottlvoid HPTLIBAPI 119149871SscottlmvMicroSecondsDelay(MV_U32 msecs) 120136849Sscottl{ 121136849Sscottl DELAY(msecs); 122136849Sscottl} 123136849Sscottl 124149871SscottlULONG_PTR HPTLIBAPI 125149871SscottlfOsPhysicalAddress(void *addr) 126136849Sscottl{ 127136849Sscottl return (ULONG_PTR)(vtophys(addr)); 128136849Sscottl} 129