| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: mainbus.c,v 1.50 2009/05/21 20:59:11 skrll Exp $ */ | | 1 | /* $NetBSD: mainbus.c,v 1.51 2009/05/24 15:27:08 skrll Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Matthew Fredette. | | 8 | * by Matthew Fredette. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -53,27 +53,27 @@ | | | @@ -53,27 +53,27 @@ |
53 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 53 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
54 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 54 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
55 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | | 55 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, |
56 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 56 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
57 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 57 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
58 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 58 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
60 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | | 60 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
61 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | 61 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
62 | * THE POSSIBILITY OF SUCH DAMAGE. | | 62 | * THE POSSIBILITY OF SUCH DAMAGE. |
63 | */ | | 63 | */ |
64 | | | 64 | |
65 | #include <sys/cdefs.h> | | 65 | #include <sys/cdefs.h> |
66 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.50 2009/05/21 20:59:11 skrll Exp $"); | | 66 | __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.51 2009/05/24 15:27:08 skrll Exp $"); |
67 | | | 67 | |
68 | #include "locators.h" | | 68 | #include "locators.h" |
69 | #include "power.h" | | 69 | #include "power.h" |
70 | | | 70 | |
71 | #include <sys/param.h> | | 71 | #include <sys/param.h> |
72 | #include <sys/systm.h> | | 72 | #include <sys/systm.h> |
73 | #include <sys/device.h> | | 73 | #include <sys/device.h> |
74 | #include <sys/reboot.h> | | 74 | #include <sys/reboot.h> |
75 | #include <sys/extent.h> | | 75 | #include <sys/extent.h> |
76 | #include <sys/mbuf.h> | | 76 | #include <sys/mbuf.h> |
77 | | | 77 | |
78 | #include <uvm/uvm_page.h> | | 78 | #include <uvm/uvm_page.h> |
79 | #include <uvm/uvm.h> | | 79 | #include <uvm/uvm.h> |
| @@ -185,27 +185,26 @@ mbus_add_mapping(bus_addr_t bpa, bus_siz | | | @@ -185,27 +185,26 @@ mbus_add_mapping(bus_addr_t bpa, bus_siz |
185 | /* | | 185 | /* |
186 | * We must be called with a page-aligned address in | | 186 | * We must be called with a page-aligned address in |
187 | * I/O space, and with a multiple of the page size. | | 187 | * I/O space, and with a multiple of the page size. |
188 | */ | | 188 | */ |
189 | KASSERT((bpa & PGOFSET) == 0); | | 189 | KASSERT((bpa & PGOFSET) == 0); |
190 | KASSERT(bpa >= HPPA_IOSPACE); | | 190 | KASSERT(bpa >= HPPA_IOSPACE); |
191 | KASSERT((size & PGOFSET) == 0); | | 191 | KASSERT((size & PGOFSET) == 0); |
192 | | | 192 | |
193 | /* | | 193 | /* |
194 | * Assume that this will succeed. | | 194 | * Assume that this will succeed. |
195 | */ | | 195 | */ |
196 | *bshp = bpa; | | 196 | *bshp = bpa; |
197 | | | 197 | |
198 | printf("%s: bpa 0x%016llx size 0x%016llx\n", __func__, (unsigned long long)bpa, (unsigned long long)size); | | | |
199 | /* | | 198 | /* |
200 | * Loop while there is space left to map. | | 199 | * Loop while there is space left to map. |
201 | */ | | 200 | */ |
202 | frames = size >> PGSHIFT; | | 201 | frames = size >> PGSHIFT; |
203 | while (frames > 0) { | | 202 | while (frames > 0) { |
204 | | | 203 | |
205 | /* | | 204 | /* |
206 | * If this mapping is more than eight pages long, | | 205 | * If this mapping is more than eight pages long, |
207 | * try to add a BTLB entry. | | 206 | * try to add a BTLB entry. |
208 | */ | | 207 | */ |
209 | #ifdef USE_BTLB | | 208 | #ifdef USE_BTLB |
210 | if (frames > 8 && | | 209 | if (frames > 8 && |
211 | frames >= hppa_btlb_size_min) { | | 210 | frames >= hppa_btlb_size_min) { |
| @@ -220,27 +219,27 @@ printf("%s: bpa 0x%016llx size 0x%016llx | | | @@ -220,27 +219,27 @@ printf("%s: bpa 0x%016llx size 0x%016llx |
220 | if (error == 0) { | | 219 | if (error == 0) { |
221 | bpa += btlb_size; | | 220 | bpa += btlb_size; |
222 | frames -= (btlb_size >> PGSHIFT); | | 221 | frames -= (btlb_size >> PGSHIFT); |
223 | continue; | | 222 | continue; |
224 | } | | 223 | } |
225 | else if (error != ENOMEM) | | 224 | else if (error != ENOMEM) |
226 | return error; | | 225 | return error; |
227 | } | | 226 | } |
228 | #endif /* USE_BTLB */ | | 227 | #endif /* USE_BTLB */ |
229 | | | 228 | |
230 | /* | | 229 | /* |
231 | * Enter another single-page mapping. | | 230 | * Enter another single-page mapping. |
232 | */ | | 231 | */ |
233 | pmap_kenter_pa(bpa, bpa, VM_PROT_READ | VM_PROT_WRITE | PMAP_NC); | | 232 | pmap_kenter_pa(bpa, bpa, VM_PROT_READ | VM_PROT_WRITE); |
234 | bpa += PAGE_SIZE; | | 233 | bpa += PAGE_SIZE; |
235 | frames--; | | 234 | frames--; |
236 | } | | 235 | } |
237 | | | 236 | |
238 | /* Success. */ | | 237 | /* Success. */ |
239 | return 0; | | 238 | return 0; |
240 | } | | 239 | } |
241 | | | 240 | |
242 | /* | | 241 | /* |
243 | * This removes a mapping added by mbus_add_mapping. | | 242 | * This removes a mapping added by mbus_add_mapping. |
244 | */ | | 243 | */ |
245 | int | | 244 | int |
246 | mbus_remove_mapping(bus_space_handle_t bsh, bus_size_t size, bus_addr_t *bpap) | | 245 | mbus_remove_mapping(bus_space_handle_t bsh, bus_size_t size, bus_addr_t *bpap) |
| @@ -1488,77 +1487,52 @@ mb_cpu_mem_callback(device_t self, struc | | | @@ -1488,77 +1487,52 @@ mb_cpu_mem_callback(device_t self, struc |
1488 | ca->ca_type.iodc_type == HPPA_TYPE_MEMORY)) | | 1487 | ca->ca_type.iodc_type == HPPA_TYPE_MEMORY)) |
1489 | config_found_sm_loc(self, "gedoens", NULL, ca, mbprint, | | 1488 | config_found_sm_loc(self, "gedoens", NULL, ca, mbprint, |
1490 | mbsubmatch); | | 1489 | mbsubmatch); |
1491 | } | | 1490 | } |
1492 | | | 1491 | |
1493 | void | | 1492 | void |
1494 | mbattach(device_t parent, device_t self, void *aux) | | 1493 | mbattach(device_t parent, device_t self, void *aux) |
1495 | { | | 1494 | { |
1496 | struct mainbus_softc *sc = device_private(self); | | 1495 | struct mainbus_softc *sc = device_private(self); |
1497 | struct confargs nca; | | 1496 | struct confargs nca; |
1498 | bus_space_handle_t ioh; | | 1497 | bus_space_handle_t ioh; |
1499 | hppa_hpa_t hpabase; | | 1498 | hppa_hpa_t hpabase; |
1500 | | | 1499 | |
1501 | struct iomod_openbsd { | | | |
1502 | /* SRS (Supervisor Register Set) */ | | | |
1503 | u_int io_eir; /* (WO) interrupt CPU; set bits in EIR CR */ | | | |
1504 | u_int io_eim; /* (WO) External Interrupt Message address */ | | | |
1505 | u_int io_dc_rw; /* write address of IODC to read IODC data */ | | | |
1506 | u_int io_ii_rw; /* read/clear external intrpt msg (bit-26) */ | | | |
1507 | u_int io_dma_link; /* pointer to "next quad" in DMA chain */ | | | |
1508 | u_int io_dma_command; /* (RO) chain command to exec on "next quad" */ | | | |
1509 | u_int io_dma_address; /* (RO) start of DMA */ | | | |
1510 | u_int io_dma_count; /* (RO) number of bytes remaining to xfer */ | | | |
1511 | u_int io_flex; /* (WO) HPA flex addr, LSB: bus master flag */ | | | |
1512 | } *fred; | | | |
1513 | | | | |
1514 | | | | |
1515 | sc->sc_dv = self; | | 1500 | sc->sc_dv = self; |
1516 | | | 1501 | |
1517 | mb_attached = 1; | | 1502 | mb_attached = 1; |
1518 | | | 1503 | |
1519 | /* fetch the "default" cpu hpa */ | | 1504 | /* fetch the "default" cpu hpa */ |
1520 | if (pdc_call((iodcio_t)pdc, 0, PDC_HPA, PDC_HPA_DFLT, &pdc_hpa) < 0) | | 1505 | if (pdc_call((iodcio_t)pdc, 0, PDC_HPA, PDC_HPA_DFLT, &pdc_hpa) < 0) |
1521 | panic("mbattach: PDC_HPA failed"); | | 1506 | panic("mbattach: PDC_HPA failed"); |
1522 | | | 1507 | |
1523 | /* | | 1508 | /* |
1524 | * Map all of Fixed Physical, Local Broadcast, and | | 1509 | * Map all of Fixed Physical, Local Broadcast, and |
1525 | * Global Broadcast space. These spaces are adjacent | | 1510 | * Global Broadcast space. These spaces are adjacent |
1526 | * and in that order and run to the end of the address | | 1511 | * and in that order and run to the end of the address |
1527 | * space. | | 1512 | * space. |
1528 | */ | | 1513 | */ |
1529 | /* | | 1514 | /* |
1530 | * XXX fredette - this may be a copout, or it may | | 1515 | * XXX fredette - this may be a copout, or it may |
1531 | * be a great idea. I'm not sure which yet. | | 1516 | * be a great idea. I'm not sure which yet. |
1532 | */ | | 1517 | */ |
1533 | if (bus_space_map(&hppa_bustag, pdc_hpa.hpa, 0 - pdc_hpa.hpa, 0, &ioh)) | | 1518 | if (bus_space_map(&hppa_bustag, pdc_hpa.hpa, 0 - pdc_hpa.hpa, 0, &ioh)) |
1534 | panic("mbattach: can't map mainbus IO space"); | | 1519 | panic("mbattach: can't map mainbus IO space"); |
1535 | | | 1520 | |
1536 | /* | | 1521 | /* |
1537 | * Local-Broadcast the HPA to all modules on the bus | | 1522 | * Local-Broadcast the HPA to all modules on the bus |
1538 | */ | | 1523 | */ |
1539 | #if 0 | | | |
1540 | fred = (struct iomod_openbsd *)HPPA_LBCAST; | | | |
1541 | | | | |
1542 | fred->io_flex = | | | |
1543 | (pdc_hpa.hpa & FLEX_MASK) | DMA_ENABLE; | | | |
1544 | #else | | | |
1545 | fred = (struct iomod_openbsd *)HPPA_LBCAST; | | | |
1546 | printf("fred->io_flex %p\n", &fred->io_flex); | | | |
1547 | ((struct iomod *)(pdc_hpa.hpa & FLEX_MASK))[FPA_IOMOD].io_flex = | | 1524 | ((struct iomod *)(pdc_hpa.hpa & FLEX_MASK))[FPA_IOMOD].io_flex = |
1548 | (void *)((pdc_hpa.hpa & FLEX_MASK) | DMA_ENABLE); | | 1525 | (void *)((pdc_hpa.hpa & FLEX_MASK) | DMA_ENABLE); |
1549 | #endif | | | |
1550 | | | | |
1551 | | | | |
1552 | | | 1526 | |
1553 | sc->sc_hpa = pdc_hpa.hpa; | | 1527 | sc->sc_hpa = pdc_hpa.hpa; |
1554 | aprint_normal(" [flex %lx]\n", pdc_hpa.hpa & FLEX_MASK); | | 1528 | aprint_normal(" [flex %lx]\n", pdc_hpa.hpa & FLEX_MASK); |
1555 | | | 1529 | |
1556 | /* PDC first */ | | 1530 | /* PDC first */ |
1557 | memset(&nca, 0, sizeof(nca)); | | 1531 | memset(&nca, 0, sizeof(nca)); |
1558 | nca.ca_name = "pdc"; | | 1532 | nca.ca_name = "pdc"; |
1559 | nca.ca_hpa = 0; | | 1533 | nca.ca_hpa = 0; |
1560 | nca.ca_iot = &hppa_bustag; | | 1534 | nca.ca_iot = &hppa_bustag; |
1561 | nca.ca_dmatag = &hppa_dmatag; | | 1535 | nca.ca_dmatag = &hppa_dmatag; |
1562 | config_found(self, &nca, mbprint); | | 1536 | config_found(self, &nca, mbprint); |
1563 | | | 1537 | |
1564 | #if NPOWER > 0 | | 1538 | #if NPOWER > 0 |