Statistics
| Branch: | Revision:

root / hw / isa_mmio.c @ 40f16dd1

History | View | Annotate | Download (2.6 kB)

1 aef445bd pbrook
/*
2 aef445bd pbrook
 * Memory mapped access to ISA IO space.
3 aef445bd pbrook
 *
4 aef445bd pbrook
 * Copyright (c) 2006 Fabrice Bellard
5 5fafdf24 ths
 *
6 aef445bd pbrook
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 aef445bd pbrook
 * of this software and associated documentation files (the "Software"), to deal
8 aef445bd pbrook
 * in the Software without restriction, including without limitation the rights
9 aef445bd pbrook
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 aef445bd pbrook
 * copies of the Software, and to permit persons to whom the Software is
11 aef445bd pbrook
 * furnished to do so, subject to the following conditions:
12 aef445bd pbrook
 *
13 aef445bd pbrook
 * The above copyright notice and this permission notice shall be included in
14 aef445bd pbrook
 * all copies or substantial portions of the Software.
15 aef445bd pbrook
 *
16 aef445bd pbrook
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 aef445bd pbrook
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 aef445bd pbrook
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 aef445bd pbrook
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 aef445bd pbrook
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 aef445bd pbrook
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 aef445bd pbrook
 * THE SOFTWARE.
23 aef445bd pbrook
 */
24 aef445bd pbrook
25 87ecb68b pbrook
#include "hw.h"
26 87ecb68b pbrook
#include "isa.h"
27 aef445bd pbrook
28 c227f099 Anthony Liguori
static void isa_mmio_writeb (void *opaque, target_phys_addr_t addr,
29 aef445bd pbrook
                                  uint32_t val)
30 aef445bd pbrook
{
31 afcea8cb Blue Swirl
    cpu_outb(addr & IOPORTS_MASK, val);
32 aef445bd pbrook
}
33 aef445bd pbrook
34 968d683c Alexander Graf
static void isa_mmio_writew(void *opaque, target_phys_addr_t addr,
35 84108e12 Blue Swirl
                               uint32_t val)
36 aef445bd pbrook
{
37 afcea8cb Blue Swirl
    cpu_outw(addr & IOPORTS_MASK, val);
38 aef445bd pbrook
}
39 aef445bd pbrook
40 968d683c Alexander Graf
static void isa_mmio_writel(void *opaque, target_phys_addr_t addr,
41 84108e12 Blue Swirl
                               uint32_t val)
42 84108e12 Blue Swirl
{
43 afcea8cb Blue Swirl
    cpu_outl(addr & IOPORTS_MASK, val);
44 aef445bd pbrook
}
45 aef445bd pbrook
46 c227f099 Anthony Liguori
static uint32_t isa_mmio_readb (void *opaque, target_phys_addr_t addr)
47 aef445bd pbrook
{
48 968d683c Alexander Graf
    return cpu_inb(addr & IOPORTS_MASK);
49 aef445bd pbrook
}
50 aef445bd pbrook
51 968d683c Alexander Graf
static uint32_t isa_mmio_readw(void *opaque, target_phys_addr_t addr)
52 aef445bd pbrook
{
53 968d683c Alexander Graf
    return cpu_inw(addr & IOPORTS_MASK);
54 aef445bd pbrook
}
55 aef445bd pbrook
56 968d683c Alexander Graf
static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr)
57 84108e12 Blue Swirl
{
58 968d683c Alexander Graf
    return cpu_inl(addr & IOPORTS_MASK);
59 84108e12 Blue Swirl
}
60 84108e12 Blue Swirl
61 968d683c Alexander Graf
static CPUWriteMemoryFunc * const isa_mmio_write[] = {
62 aef445bd pbrook
    &isa_mmio_writeb,
63 968d683c Alexander Graf
    &isa_mmio_writew,
64 968d683c Alexander Graf
    &isa_mmio_writel,
65 aef445bd pbrook
};
66 aef445bd pbrook
67 968d683c Alexander Graf
static CPUReadMemoryFunc * const isa_mmio_read[] = {
68 aef445bd pbrook
    &isa_mmio_readb,
69 968d683c Alexander Graf
    &isa_mmio_readw,
70 968d683c Alexander Graf
    &isa_mmio_readl,
71 aef445bd pbrook
};
72 aef445bd pbrook
73 968d683c Alexander Graf
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
74 aef445bd pbrook
{
75 968d683c Alexander Graf
    int isa_mmio_iomemtype;
76 968d683c Alexander Graf
77 968d683c Alexander Graf
    isa_mmio_iomemtype = cpu_register_io_memory(isa_mmio_read,
78 968d683c Alexander Graf
                                                isa_mmio_write,
79 968d683c Alexander Graf
                                                NULL,
80 968d683c Alexander Graf
                                                DEVICE_LITTLE_ENDIAN);
81 aef445bd pbrook
    cpu_register_physical_memory(base, size, isa_mmio_iomemtype);
82 aef445bd pbrook
}