exca.c (97708) | exca.c (100703) |
---|---|
1/* $FreeBSD: head/sys/dev/exca/exca.c 97708 2002-06-01 16:21:26Z alfred $ */ | 1/* $FreeBSD: head/sys/dev/exca/exca.c 100703 2002-07-26 08:01:08Z imp $ */ |
2 3/* 4 * Copyright (c) 2002 M Warner Losh. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 67 unchanged lines hidden (view full) --- 77#ifdef EXCA_DEBUG 78#define DEVPRINTF(dev, fmt, args...) device_printf((dev), (fmt), ## args) 79#define DPRINTF(fmt, args...) printf(fmt, ## args) 80#else 81#define DEVPRINTF(dev, fmt, args...) 82#define DPRINTF(fmt, args...) 83#endif 84 | 2 3/* 4 * Copyright (c) 2002 M Warner Losh. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 67 unchanged lines hidden (view full) --- 77#ifdef EXCA_DEBUG 78#define DEVPRINTF(dev, fmt, args...) device_printf((dev), (fmt), ## args) 79#define DPRINTF(fmt, args...) printf(fmt, ## args) 80#else 81#define DEVPRINTF(dev, fmt, args...) 82#define DPRINTF(fmt, args...) 83#endif 84 |
85 | |
86/* memory */ 87 88#define EXCA_MEMINFO(NUM) { \ 89 EXCA_SYSMEM_ADDR ## NUM ## _START_LSB, \ 90 EXCA_SYSMEM_ADDR ## NUM ## _START_MSB, \ 91 EXCA_SYSMEM_ADDR ## NUM ## _STOP_LSB, \ 92 EXCA_SYSMEM_ADDR ## NUM ## _STOP_MSB, \ 93 EXCA_SYSMEM_ADDR ## NUM ## _WIN, \ --- 99 unchanged lines hidden (view full) --- 193 for (win = 0; win < EXCA_MEM_WINS; win++) { 194 if ((sc->memalloc & (1 << win)) == 0) { 195 sc->memalloc |= (1 << win); 196 break; 197 } 198 } 199 if (win >= EXCA_MEM_WINS) 200 return (1); | 85/* memory */ 86 87#define EXCA_MEMINFO(NUM) { \ 88 EXCA_SYSMEM_ADDR ## NUM ## _START_LSB, \ 89 EXCA_SYSMEM_ADDR ## NUM ## _START_MSB, \ 90 EXCA_SYSMEM_ADDR ## NUM ## _STOP_LSB, \ 91 EXCA_SYSMEM_ADDR ## NUM ## _STOP_MSB, \ 92 EXCA_SYSMEM_ADDR ## NUM ## _WIN, \ --- 99 unchanged lines hidden (view full) --- 192 for (win = 0; win < EXCA_MEM_WINS; win++) { 193 if ((sc->memalloc & (1 << win)) == 0) { 194 sc->memalloc |= (1 << win); 195 break; 196 } 197 } 198 if (win >= EXCA_MEM_WINS) 199 return (1); |
200 if (((rman_get_start(res) >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff) != 0 && 201 (sc->flags & EXCA_HAS_MEMREG_WIN) == 0) { 202 device_printf(sc->dev, "Does not support mapping above 24M."); 203 return (1); 204 } |
|
201 202 sc->mem[win].cardaddr = 0; 203 sc->mem[win].memt = rman_get_bustag(res); 204 sc->mem[win].memh = rman_get_bushandle(res); 205 sc->mem[win].addr = rman_get_start(res); 206 sc->mem[win].size = rman_get_end(res) - sc->mem[win].addr + 1; 207 sc->mem[win].realsize = sc->mem[win].size + EXCA_MEM_PAGESIZE - 1; 208 sc->mem[win].realsize = sc->mem[win].realsize - --- 341 unchanged lines hidden (view full) --- 550 if (sc->ioalloc & (1 << win)) 551 exca_do_io_map(sc, win); 552} 553 554/* 555 * Initialize the exca_softc data structure for the first time. 556 */ 557void | 205 206 sc->mem[win].cardaddr = 0; 207 sc->mem[win].memt = rman_get_bustag(res); 208 sc->mem[win].memh = rman_get_bushandle(res); 209 sc->mem[win].addr = rman_get_start(res); 210 sc->mem[win].size = rman_get_end(res) - sc->mem[win].addr + 1; 211 sc->mem[win].realsize = sc->mem[win].size + EXCA_MEM_PAGESIZE - 1; 212 sc->mem[win].realsize = sc->mem[win].realsize - --- 341 unchanged lines hidden (view full) --- 554 if (sc->ioalloc & (1 << win)) 555 exca_do_io_map(sc, win); 556} 557 558/* 559 * Initialize the exca_softc data structure for the first time. 560 */ 561void |
558exca_init(struct exca_softc *sc, device_t dev, exca_write_t *wrfn, 559 exca_read_t *rdfn, bus_space_tag_t bst, bus_space_handle_t bsh, 560 uint32_t offset) | 562exca_init(struct exca_softc *sc, device_t dev, 563 bus_space_tag_t bst, bus_space_handle_t bsh, uint32_t offset) |
561{ 562 sc->dev = dev; | 564{ 565 sc->dev = dev; |
563 sc->write_exca = wrfn; 564 sc->read_exca = rdfn; | |
565 sc->memalloc = 0; 566 sc->ioalloc = 0; 567 sc->bst = bst; 568 sc->bsh = bsh; 569 sc->offset = offset; 570 sc->flags = 0; 571} 572 573/* 574 * Probe the expected slots. We maybe should set the ID for each of these 575 * slots too while we're at it. But maybe that belongs to a separate 576 * function. 577 * 578 * Callers must charantee that there are at least EXCA_NSLOTS (4) in 579 * the array that they pass the address of the first element in the 580 * "exca" parameter. 581 */ 582int | 566 sc->memalloc = 0; 567 sc->ioalloc = 0; 568 sc->bst = bst; 569 sc->bsh = bsh; 570 sc->offset = offset; 571 sc->flags = 0; 572} 573 574/* 575 * Probe the expected slots. We maybe should set the ID for each of these 576 * slots too while we're at it. But maybe that belongs to a separate 577 * function. 578 * 579 * Callers must charantee that there are at least EXCA_NSLOTS (4) in 580 * the array that they pass the address of the first element in the 581 * "exca" parameter. 582 */ 583int |
583exca_probe_slots(device_t dev, struct exca_softc *exca, exca_write_t writefnp, 584 exca_read_t readfnp) | 584exca_probe_slots(device_t dev, struct exca_softc *exca) |
585{ 586 int rid; 587 struct resource *res; 588 int err; 589 bus_space_tag_t iot; 590 bus_space_handle_t ioh; 591 int i; 592 593 err = ENXIO; 594 rid = 0; 595 res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, EXCA_IOSIZE, 596 RF_ACTIVE); 597 if (res == NULL) 598 return (ENXIO); 599 iot = rman_get_bustag(res); 600 ioh = rman_get_bushandle(res); 601 for (i = 0; i < EXCA_NSLOTS; i++) { | 585{ 586 int rid; 587 struct resource *res; 588 int err; 589 bus_space_tag_t iot; 590 bus_space_handle_t ioh; 591 int i; 592 593 err = ENXIO; 594 rid = 0; 595 res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, EXCA_IOSIZE, 596 RF_ACTIVE); 597 if (res == NULL) 598 return (ENXIO); 599 iot = rman_get_bustag(res); 600 ioh = rman_get_bushandle(res); 601 for (i = 0; i < EXCA_NSLOTS; i++) { |
602 exca_init(&exca[i], dev, writefnp, readfnp, iot, ioh, 603 i * EXCA_SOCKET_SIZE); | 602 exca_init(&exca[i], dev, iot, ioh, i * EXCA_SOCKET_SIZE); |
604 if (exca_is_pcic(&exca[i])) { 605 err = 0; 606 exca[i].flags |= EXCA_SOCKET_PRESENT; 607 } 608 } 609 bus_release_resource(dev, SYS_RES_IOPORT, rid, res); 610 return (err); 611} --- 14 unchanged lines hidden --- | 603 if (exca_is_pcic(&exca[i])) { 604 err = 0; 605 exca[i].flags |= EXCA_SOCKET_PRESENT; 606 } 607 } 608 bus_release_resource(dev, SYS_RES_IOPORT, rid, res); 609 return (err); 610} --- 14 unchanged lines hidden --- |