1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer as 10 * the first lines of this file unmodified. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 *
| 1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer as 10 * the first lines of this file unmodified. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 *
|
85}; 86 87#endif /* FB_INSTALL_CDEV */ 88 89static void 90isavga_identify(driver_t *driver, device_t parent) 91{ 92 BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, VGA_DRIVER_NAME, 0); 93} 94 95static int 96isavga_probe(device_t dev) 97{ 98 video_adapter_t adp; 99 device_t bus; 100 int error; 101 102 /* No pnp support */ 103 if (isa_get_vendorid(dev)) 104 return (ENXIO); 105 106 device_set_desc(dev, "Generic ISA VGA"); 107 error = vga_probe_unit(device_get_unit(dev), &adp, device_get_flags(dev)); 108 if (error == 0) { 109 bus = device_get_parent(dev); 110 bus_set_resource(dev, SYS_RES_IOPORT, 0, 111 adp.va_io_base, adp.va_io_size); 112 bus_set_resource(dev, SYS_RES_MEMORY, 0, 113 adp.va_mem_base, adp.va_mem_size); 114#if 0 115 isa_set_port(dev, adp.va_io_base); 116 isa_set_portsize(dev, adp.va_io_size); 117 isa_set_maddr(dev, adp.va_mem_base); 118 isa_set_msize(dev, adp.va_mem_size); 119#endif 120 } 121 return error; 122} 123 124static int 125isavga_attach(device_t dev) 126{ 127 vga_softc_t *sc; 128 struct resource *port; 129 struct resource *mem; 130 int unit; 131 int rid; 132 int error; 133 134 unit = device_get_unit(dev); 135 sc = device_get_softc(dev); 136 137 rid = 0; 138 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 139 0, ~0, 0, RF_ACTIVE | RF_SHAREABLE); 140 rid = 0; 141 mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 142 0, ~0, 0, RF_ACTIVE | RF_SHAREABLE); 143 144 error = vga_attach_unit(unit, sc, device_get_flags(dev)); 145 if (error) 146 return error; 147 148#ifdef FB_INSTALL_CDEV 149 /* attach a virtual frame buffer device */ 150 error = fb_attach(makedev(0, VGA_MKMINOR(unit)), sc->adp, &isavga_cdevsw); 151 if (error) 152 return error; 153#endif /* FB_INSTALL_CDEV */ 154 155 if (bootverbose) 156 (*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose); 157 158#if experimental 159 device_add_child(dev, "fb", -1); 160 bus_generic_attach(dev); 161#endif 162 163 return 0; 164} 165 166#ifdef FB_INSTALL_CDEV 167 168static int 169isavga_open(dev_t dev, int flag, int mode, struct thread *td) 170{ 171 return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); 172} 173 174static int 175isavga_close(dev_t dev, int flag, int mode, struct thread *td) 176{ 177 return vga_close(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); 178} 179 180static int 181isavga_read(dev_t dev, struct uio *uio, int flag) 182{ 183 return vga_read(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag); 184} 185 186static int 187isavga_write(dev_t dev, struct uio *uio, int flag) 188{ 189 return vga_write(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag); 190} 191 192static int 193isavga_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) 194{ 195 return vga_ioctl(dev, VGA_SOFTC(VGA_UNIT(dev)), cmd, arg, flag, td); 196} 197 198static int 199isavga_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot) 200{ 201 return vga_mmap(dev, VGA_SOFTC(VGA_UNIT(dev)), offset, paddr, prot); 202} 203 204#endif /* FB_INSTALL_CDEV */ 205 206static device_method_t isavga_methods[] = { 207 DEVMETHOD(device_identify, isavga_identify), 208 DEVMETHOD(device_probe, isavga_probe), 209 DEVMETHOD(device_attach, isavga_attach), 210 211 DEVMETHOD(bus_print_child, bus_generic_print_child), 212 { 0, 0 } 213}; 214 215static driver_t isavga_driver = { 216 VGA_DRIVER_NAME, 217 isavga_methods, 218 sizeof(vga_softc_t), 219}; 220 221DRIVER_MODULE(vga, isa, isavga_driver, isavga_devclass, 0, 0);
| 80}; 81 82#endif /* FB_INSTALL_CDEV */ 83 84static void 85isavga_identify(driver_t *driver, device_t parent) 86{ 87 BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, VGA_DRIVER_NAME, 0); 88} 89 90static int 91isavga_probe(device_t dev) 92{ 93 video_adapter_t adp; 94 device_t bus; 95 int error; 96 97 /* No pnp support */ 98 if (isa_get_vendorid(dev)) 99 return (ENXIO); 100 101 device_set_desc(dev, "Generic ISA VGA"); 102 error = vga_probe_unit(device_get_unit(dev), &adp, device_get_flags(dev)); 103 if (error == 0) { 104 bus = device_get_parent(dev); 105 bus_set_resource(dev, SYS_RES_IOPORT, 0, 106 adp.va_io_base, adp.va_io_size); 107 bus_set_resource(dev, SYS_RES_MEMORY, 0, 108 adp.va_mem_base, adp.va_mem_size); 109#if 0 110 isa_set_port(dev, adp.va_io_base); 111 isa_set_portsize(dev, adp.va_io_size); 112 isa_set_maddr(dev, adp.va_mem_base); 113 isa_set_msize(dev, adp.va_mem_size); 114#endif 115 } 116 return error; 117} 118 119static int 120isavga_attach(device_t dev) 121{ 122 vga_softc_t *sc; 123 struct resource *port; 124 struct resource *mem; 125 int unit; 126 int rid; 127 int error; 128 129 unit = device_get_unit(dev); 130 sc = device_get_softc(dev); 131 132 rid = 0; 133 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 134 0, ~0, 0, RF_ACTIVE | RF_SHAREABLE); 135 rid = 0; 136 mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 137 0, ~0, 0, RF_ACTIVE | RF_SHAREABLE); 138 139 error = vga_attach_unit(unit, sc, device_get_flags(dev)); 140 if (error) 141 return error; 142 143#ifdef FB_INSTALL_CDEV 144 /* attach a virtual frame buffer device */ 145 error = fb_attach(makedev(0, VGA_MKMINOR(unit)), sc->adp, &isavga_cdevsw); 146 if (error) 147 return error; 148#endif /* FB_INSTALL_CDEV */ 149 150 if (bootverbose) 151 (*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose); 152 153#if experimental 154 device_add_child(dev, "fb", -1); 155 bus_generic_attach(dev); 156#endif 157 158 return 0; 159} 160 161#ifdef FB_INSTALL_CDEV 162 163static int 164isavga_open(dev_t dev, int flag, int mode, struct thread *td) 165{ 166 return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); 167} 168 169static int 170isavga_close(dev_t dev, int flag, int mode, struct thread *td) 171{ 172 return vga_close(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); 173} 174 175static int 176isavga_read(dev_t dev, struct uio *uio, int flag) 177{ 178 return vga_read(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag); 179} 180 181static int 182isavga_write(dev_t dev, struct uio *uio, int flag) 183{ 184 return vga_write(dev, VGA_SOFTC(VGA_UNIT(dev)), uio, flag); 185} 186 187static int 188isavga_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td) 189{ 190 return vga_ioctl(dev, VGA_SOFTC(VGA_UNIT(dev)), cmd, arg, flag, td); 191} 192 193static int 194isavga_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot) 195{ 196 return vga_mmap(dev, VGA_SOFTC(VGA_UNIT(dev)), offset, paddr, prot); 197} 198 199#endif /* FB_INSTALL_CDEV */ 200 201static device_method_t isavga_methods[] = { 202 DEVMETHOD(device_identify, isavga_identify), 203 DEVMETHOD(device_probe, isavga_probe), 204 DEVMETHOD(device_attach, isavga_attach), 205 206 DEVMETHOD(bus_print_child, bus_generic_print_child), 207 { 0, 0 } 208}; 209 210static driver_t isavga_driver = { 211 VGA_DRIVER_NAME, 212 isavga_methods, 213 sizeof(vga_softc_t), 214}; 215 216DRIVER_MODULE(vga, isa, isavga_driver, isavga_devclass, 0, 0);
|