1286667Smarcel/*-
2286667Smarcel * Copyright (c) 2015 Marcel Moolenaar
3286667Smarcel * All rights reserved.
4286667Smarcel *
5286667Smarcel * Redistribution and use in source and binary forms, with or without
6286667Smarcel * modification, are permitted provided that the following conditions
7286667Smarcel * are met:
8286667Smarcel *
9286667Smarcel * 1. Redistributions of source code must retain the above copyright
10286667Smarcel *    notice, this list of conditions and the following disclaimer.
11286667Smarcel * 2. Redistributions in binary form must reproduce the above copyright
12286667Smarcel *    notice, this list of conditions and the following disclaimer in the
13286667Smarcel *    documentation and/or other materials provided with the distribution.
14286667Smarcel *
15286667Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16286667Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17286667Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18286667Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19286667Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20286667Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21286667Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22286667Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23286667Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24286667Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25286667Smarcel */
26286667Smarcel
27286667Smarcel#include <sys/cdefs.h>
28286667Smarcel__FBSDID("$FreeBSD$");
29286667Smarcel
30286667Smarcel#include <sys/param.h>
31286667Smarcel#include <sys/systm.h>
32286667Smarcel#include <x86/bus.h>
33286667Smarcel
34286667Smarcel#include <vm/vm.h>
35286667Smarcel#include <vm/pmap.h>
36286667Smarcel
37286667Smarcel/*
38286667Smarcel * Implementation of bus_space_map(), which effectively is a thin
39286667Smarcel * wrapper around pmap_mapdev() for memory mapped I/O space. It's
40286667Smarcel * implemented here and not in <x86/bus.h> to avoid pollution.
41286667Smarcel */
42286667Smarcelint
43286667Smarcelbus_space_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size,
44286667Smarcel    int flags __unused, bus_space_handle_t *bshp)
45286667Smarcel{
46286667Smarcel
47286667Smarcel	*bshp = (tag == X86_BUS_SPACE_MEM)
48286667Smarcel	    ? (uintptr_t)pmap_mapdev(addr, size)
49286667Smarcel	    : addr;
50286667Smarcel	return (0);
51286667Smarcel}
52286667Smarcel
53286667Smarcelvoid
54286667Smarcelbus_space_unmap(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t size)
55286667Smarcel{
56286667Smarcel
57286667Smarcel	if (tag == X86_BUS_SPACE_MEM)
58286667Smarcel		pmap_unmapdev(bsh, size);
59286667Smarcel}
60