root / hw / isa_mmio.c @ b0eb8449
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 | af956cad | Avi Kivity | #include "exec-memory.h" |
28 | aef445bd | pbrook | |
29 | c227f099 | Anthony Liguori | static void isa_mmio_writeb (void *opaque, target_phys_addr_t addr, |
30 | aef445bd | pbrook | uint32_t val) |
31 | aef445bd | pbrook | { |
32 | afcea8cb | Blue Swirl | cpu_outb(addr & IOPORTS_MASK, val); |
33 | aef445bd | pbrook | } |
34 | aef445bd | pbrook | |
35 | 968d683c | Alexander Graf | static void isa_mmio_writew(void *opaque, target_phys_addr_t addr, |
36 | 84108e12 | Blue Swirl | uint32_t val) |
37 | aef445bd | pbrook | { |
38 | afcea8cb | Blue Swirl | cpu_outw(addr & IOPORTS_MASK, val); |
39 | aef445bd | pbrook | } |
40 | aef445bd | pbrook | |
41 | 968d683c | Alexander Graf | static void isa_mmio_writel(void *opaque, target_phys_addr_t addr, |
42 | 84108e12 | Blue Swirl | uint32_t val) |
43 | 84108e12 | Blue Swirl | { |
44 | afcea8cb | Blue Swirl | cpu_outl(addr & IOPORTS_MASK, val); |
45 | aef445bd | pbrook | } |
46 | aef445bd | pbrook | |
47 | c227f099 | Anthony Liguori | static uint32_t isa_mmio_readb (void *opaque, target_phys_addr_t addr) |
48 | aef445bd | pbrook | { |
49 | 968d683c | Alexander Graf | return cpu_inb(addr & IOPORTS_MASK);
|
50 | aef445bd | pbrook | } |
51 | aef445bd | pbrook | |
52 | 968d683c | Alexander Graf | static uint32_t isa_mmio_readw(void *opaque, target_phys_addr_t addr) |
53 | aef445bd | pbrook | { |
54 | 968d683c | Alexander Graf | return cpu_inw(addr & IOPORTS_MASK);
|
55 | aef445bd | pbrook | } |
56 | aef445bd | pbrook | |
57 | 968d683c | Alexander Graf | static uint32_t isa_mmio_readl(void *opaque, target_phys_addr_t addr) |
58 | 84108e12 | Blue Swirl | { |
59 | 968d683c | Alexander Graf | return cpu_inl(addr & IOPORTS_MASK);
|
60 | 84108e12 | Blue Swirl | } |
61 | 84108e12 | Blue Swirl | |
62 | af956cad | Avi Kivity | static const MemoryRegionOps isa_mmio_ops = { |
63 | af956cad | Avi Kivity | .old_mmio = { |
64 | af956cad | Avi Kivity | .write = { isa_mmio_writeb, isa_mmio_writew, isa_mmio_writel }, |
65 | af956cad | Avi Kivity | .read = { isa_mmio_readb, isa_mmio_readw, isa_mmio_readl, }, |
66 | af956cad | Avi Kivity | }, |
67 | af956cad | Avi Kivity | .endianness = DEVICE_LITTLE_ENDIAN, |
68 | aef445bd | pbrook | }; |
69 | aef445bd | pbrook | |
70 | af956cad | Avi Kivity | void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size)
|
71 | af956cad | Avi Kivity | { |
72 | af956cad | Avi Kivity | memory_region_init_io(mr, &isa_mmio_ops, NULL, "isa-mmio", size); |
73 | af956cad | Avi Kivity | } |
74 | aef445bd | pbrook | |
75 | 968d683c | Alexander Graf | void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
|
76 | aef445bd | pbrook | { |
77 | 7267c094 | Anthony Liguori | MemoryRegion *mr = g_malloc(sizeof(*mr));
|
78 | 968d683c | Alexander Graf | |
79 | af956cad | Avi Kivity | isa_mmio_setup(mr, size); |
80 | af956cad | Avi Kivity | memory_region_add_subregion(get_system_memory(), base, mr); |
81 | aef445bd | pbrook | } |