vga_isa.c (142716) | vga_isa.c (142833) |
---|---|
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 --- 11 unchanged lines hidden (view full) --- 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 */ 26 27#include <sys/cdefs.h> | 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 --- 11 unchanged lines hidden (view full) --- 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 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/isa/vga_isa.c 142716 2005-02-27 22:16:30Z phk $"); | 28__FBSDID("$FreeBSD: head/sys/isa/vga_isa.c 142833 2005-02-28 21:06:14Z iedowse $"); |
29 30#include "opt_vga.h" 31#include "opt_fb.h" 32#include "opt_syscons.h" /* should be removed in the future, XXX */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> | 29 30#include "opt_vga.h" 31#include "opt_fb.h" 32#include "opt_syscons.h" /* should be removed in the future, XXX */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> |
37#include <sys/malloc.h> |
|
37#include <sys/module.h> 38#include <sys/conf.h> 39#include <sys/bus.h> 40#include <sys/fbio.h> 41 42#include <machine/bus.h> 43#include <machine/resource.h> 44 --- 109 unchanged lines hidden (view full) --- 154#if experimental 155 device_add_child(dev, "fb", -1); 156 bus_generic_attach(dev); 157#endif 158 159 return 0; 160} 161 | 38#include <sys/module.h> 39#include <sys/conf.h> 40#include <sys/bus.h> 41#include <sys/fbio.h> 42 43#include <machine/bus.h> 44#include <machine/resource.h> 45 --- 109 unchanged lines hidden (view full) --- 155#if experimental 156 device_add_child(dev, "fb", -1); 157 bus_generic_attach(dev); 158#endif 159 160 return 0; 161} 162 |
163static int 164isavga_suspend(device_t dev) 165{ 166 vga_softc_t *sc; 167 int err, nbytes; 168 169 sc = device_get_softc(dev); 170 err = bus_generic_suspend(dev); 171 if (err) 172 return (err); 173 174 /* Save the video state across the suspend. */ 175 if (sc->state_buf != NULL) { 176 free(sc->state_buf, M_TEMP); 177 sc->state_buf = NULL; 178 } 179 nbytes = (*vidsw[sc->adp->va_index]->save_state)(sc->adp, NULL, 0); 180 if (nbytes <= 0) 181 return (0); 182 sc->state_buf = malloc(nbytes, M_TEMP, M_NOWAIT | M_ZERO); 183 if (sc->state_buf == NULL) 184 return (0); 185 if (bootverbose) 186 device_printf(dev, "saving %d bytes of video state\n", nbytes); 187 if ((*vidsw[sc->adp->va_index]->save_state)(sc->adp, sc->state_buf, 188 nbytes) != 0) { 189 device_printf(dev, "failed to save state (nbytes=%d)\n", 190 nbytes); 191 free(sc->state_buf, M_TEMP); 192 sc->state_buf = NULL; 193 } 194 return (0); 195} 196 197static int 198isavga_resume(device_t dev) 199{ 200 vga_softc_t *sc; 201 202 sc = device_get_softc(dev); 203 if (sc->state_buf != NULL) { 204 if ((*vidsw[sc->adp->va_index]->load_state)(sc->adp, 205 sc->state_buf) != 0) 206 device_printf(dev, "failed to reload state\n"); 207 free(sc->state_buf, M_TEMP); 208 sc->state_buf = NULL; 209 } 210 211 bus_generic_resume(dev); 212 return 0; 213} 214 |
|
162#ifdef FB_INSTALL_CDEV 163 164static int 165isavga_open(struct cdev *dev, int flag, int mode, struct thread *td) 166{ 167 return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); 168} 169 --- 28 unchanged lines hidden (view full) --- 198} 199 200#endif /* FB_INSTALL_CDEV */ 201 202static device_method_t isavga_methods[] = { 203 DEVMETHOD(device_identify, isavga_identify), 204 DEVMETHOD(device_probe, isavga_probe), 205 DEVMETHOD(device_attach, isavga_attach), | 215#ifdef FB_INSTALL_CDEV 216 217static int 218isavga_open(struct cdev *dev, int flag, int mode, struct thread *td) 219{ 220 return vga_open(dev, VGA_SOFTC(VGA_UNIT(dev)), flag, mode, td); 221} 222 --- 28 unchanged lines hidden (view full) --- 251} 252 253#endif /* FB_INSTALL_CDEV */ 254 255static device_method_t isavga_methods[] = { 256 DEVMETHOD(device_identify, isavga_identify), 257 DEVMETHOD(device_probe, isavga_probe), 258 DEVMETHOD(device_attach, isavga_attach), |
259 DEVMETHOD(device_suspend, isavga_suspend), 260 DEVMETHOD(device_resume, isavga_resume), |
|
206 207 DEVMETHOD(bus_print_child, bus_generic_print_child), 208 { 0, 0 } 209}; 210 211static driver_t isavga_driver = { 212 VGA_DRIVER_NAME, 213 isavga_methods, 214 sizeof(vga_softc_t), 215}; 216 217DRIVER_MODULE(vga, isa, isavga_driver, isavga_devclass, 0, 0); | 261 262 DEVMETHOD(bus_print_child, bus_generic_print_child), 263 { 0, 0 } 264}; 265 266static driver_t isavga_driver = { 267 VGA_DRIVER_NAME, 268 isavga_methods, 269 sizeof(vga_softc_t), 270}; 271 272DRIVER_MODULE(vga, isa, isavga_driver, isavga_devclass, 0, 0); |