1718cf2ccSPedro F. Giffuni /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni *
4d2bd3ab9SScott Long * Copyright (c) 2004-2005 HighPoint Technologies, Inc.
51713e81bSScott Long * All rights reserved.
61713e81bSScott Long *
71713e81bSScott Long * Redistribution and use in source and binary forms, with or without
81713e81bSScott Long * modification, are permitted provided that the following conditions
91713e81bSScott Long * are met:
101713e81bSScott Long * 1. Redistributions of source code must retain the above copyright
111713e81bSScott Long * notice, this list of conditions and the following disclaimer.
121713e81bSScott Long * 2. Redistributions in binary form must reproduce the above copyright
131713e81bSScott Long * notice, this list of conditions and the following disclaimer in the
141713e81bSScott Long * documentation and/or other materials provided with the distribution.
151713e81bSScott Long *
161713e81bSScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
171713e81bSScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
181713e81bSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
191713e81bSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
201713e81bSScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
211713e81bSScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
221713e81bSScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
231713e81bSScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
241713e81bSScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
251713e81bSScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261713e81bSScott Long * SUCH DAMAGE.
271713e81bSScott Long */
281713e81bSScott Long #include <sys/param.h>
291713e81bSScott Long #include <sys/systm.h>
301713e81bSScott Long
31d2bd3ab9SScott Long #include <sys/time.h>
32d2bd3ab9SScott Long #include <sys/kernel.h>
33d2bd3ab9SScott Long #include <sys/bus.h>
34d2bd3ab9SScott Long #include <machine/resource.h>
35d2bd3ab9SScott Long
36d2bd3ab9SScott Long #include <machine/pci_cfgreg.h>
37d2bd3ab9SScott Long
38d2bd3ab9SScott Long #ifndef __KERNEL__
39d2bd3ab9SScott Long #define __KERNEL__
40d2bd3ab9SScott Long #endif
411713e81bSScott Long
421713e81bSScott Long #include <dev/hptmv/global.h>
431713e81bSScott Long #include <dev/hptmv/hptintf.h>
441713e81bSScott Long #include <dev/hptmv/mvOs.h>
451713e81bSScott Long #include <dev/hptmv/osbsd.h>
461713e81bSScott Long
47d2bd3ab9SScott Long
481713e81bSScott Long void HPTLIBAPI
MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base,MV_U32 offset,MV_U8 val)491713e81bSScott Long MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset, MV_U8 val)
501713e81bSScott Long {
51d2bd3ab9SScott Long writeb((void *)((ULONG_PTR)base + offset), val);
521713e81bSScott Long }
531713e81bSScott Long
541713e81bSScott Long void HPTLIBAPI
MV_REG_WRITE_WORD(MV_BUS_ADDR_T base,MV_U32 offset,MV_U16 val)551713e81bSScott Long MV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U16 val)
561713e81bSScott Long {
57d2bd3ab9SScott Long writew((void *)((ULONG_PTR)base + offset), val);
581713e81bSScott Long }
591713e81bSScott Long
601713e81bSScott Long void HPTLIBAPI
MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base,MV_U32 offset,MV_U32 val)611713e81bSScott Long MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U32 val)
621713e81bSScott Long {
63d2bd3ab9SScott Long writel((void *)((ULONG_PTR)base + offset), val);
641713e81bSScott Long }
651713e81bSScott Long
66d2bd3ab9SScott Long MV_U8 HPTLIBAPI
MV_REG_READ_BYTE(MV_BUS_ADDR_T base,MV_U32 offset)67d2bd3ab9SScott Long MV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset)
681713e81bSScott Long {
69d2bd3ab9SScott Long return readb((void *)((ULONG_PTR)base + offset));
701713e81bSScott Long }
711713e81bSScott Long
72d2bd3ab9SScott Long MV_U16 HPTLIBAPI
MV_REG_READ_WORD(MV_BUS_ADDR_T base,MV_U32 offset)73d2bd3ab9SScott Long MV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset)
741713e81bSScott Long {
75d2bd3ab9SScott Long return readw((void *)((ULONG_PTR)base + offset));
761713e81bSScott Long }
771713e81bSScott Long
78d2bd3ab9SScott Long MV_U32 HPTLIBAPI
MV_REG_READ_DWORD(MV_BUS_ADDR_T base,MV_U32 offset)79d2bd3ab9SScott Long MV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset)
801713e81bSScott Long {
81d2bd3ab9SScott Long return readl((void *)((ULONG_PTR)base + offset));
821713e81bSScott Long }
831713e81bSScott Long
841713e81bSScott Long int HPTLIBAPI
os_memcmp(const void * cs,const void * ct,unsigned len)851713e81bSScott Long os_memcmp(const void *cs, const void *ct, unsigned len)
861713e81bSScott Long {
871713e81bSScott Long return memcmp(cs, ct, len);
881713e81bSScott Long }
891713e81bSScott Long
901713e81bSScott Long void HPTLIBAPI
os_memcpy(void * to,const void * from,unsigned len)911713e81bSScott Long os_memcpy(void *to, const void *from, unsigned len)
921713e81bSScott Long {
931713e81bSScott Long memcpy(to, from, len);
941713e81bSScott Long }
951713e81bSScott Long
96d2bd3ab9SScott Long void HPTLIBAPI
os_memset(void * s,char c,unsigned len)97d2bd3ab9SScott Long os_memset(void *s, char c, unsigned len)
981713e81bSScott Long {
991713e81bSScott Long memset(s, c, len);
1001713e81bSScott Long }
1011713e81bSScott Long
102d2bd3ab9SScott Long unsigned HPTLIBAPI
os_strlen(const char * s)103d2bd3ab9SScott Long os_strlen(const char *s)
1041713e81bSScott Long {
1051713e81bSScott Long return strlen(s);
1061713e81bSScott Long }
1071713e81bSScott Long
108d2bd3ab9SScott Long void HPTLIBAPI
mvMicroSecondsDelay(MV_U32 msecs)109d2bd3ab9SScott Long mvMicroSecondsDelay(MV_U32 msecs)
1101713e81bSScott Long {
1111713e81bSScott Long DELAY(msecs);
1121713e81bSScott Long }
1131713e81bSScott Long
114d2bd3ab9SScott Long ULONG_PTR HPTLIBAPI
fOsPhysicalAddress(void * addr)115d2bd3ab9SScott Long fOsPhysicalAddress(void *addr)
1161713e81bSScott Long {
1171713e81bSScott Long return (ULONG_PTR)(vtophys(addr));
1181713e81bSScott Long }
119