/* * fbvga device driver OPEN entry point */ rtems_device_driver frame_buffer_open( rtems_device_major_number major, rtems_device_minor_number minor, void *arg ) { if (pthread_mutex_trylock(&mutex)== 0){ /* restore previous state. for VGA this means return to text mode. * leave out if graphics hardware has been initialized in * frame_buffer_initialize() */ ega_hwinit(); printk( "FBVGA open called.\n" ); return RTEMS_SUCCESSFUL; } return RTEMS_UNSATISFIED; }
static PSD VGA_open(PSD psd) { #if _MINIX int s; struct mio_ldt86 mldt86; struct segdesc_s { /* segment descriptor for protected mode */ u16_t limit_low; u16_t base_low; u8_t base_middle; u8_t access; /* |P|DL|1|X|E|R|A| */ u8_t granularity; /* |G|X|0|A|LIMT| */ u8_t base_high; } *dp; int fd; unsigned long vidmem = 0xA0000; fd = open("/dev/mem", O_RDONLY); dp = (struct segdesc_s *) mldt86.entry; mldt86.idx = 1; s = ioctl(fd, MIOCGLDT86, &mldt86); dp->limit_low = 0xFFFF; dp->base_low = (vidmem >> 0) & 0xFFFF; dp->base_middle = (vidmem >> 16) & 0xFF; dp->base_high = (vidmem >> 24) & 0xFF; dp->granularity |= 0x80; mldt86.idx = 2; s = ioctl(fd, MIOCSLDT86, &mldt86); close(fd); #endif /* setup operating mode from environment variable*/ if(getenv("EGAMODE")) VGAMODE = FALSE; else VGAMODE = TRUE; #if ELKS /* disallow console switching while in graphics mode*/ if(ioctl(0, DCGET_GRAPH) != 0) return NULL; #endif #if HWINIT /* enter graphics mode*/ ega_hwinit(); #else /* init bios graphics mode*/ int10(VGAMODE? FNGR640x480: FNGR640x350, 0); #endif /* init driver variables depending on ega/vga mode*/ psd->xres = psd->xvirtres = 640; psd->yres = psd->yvirtres = VGAMODE? 480: 350; psd->planes = 4; psd->bpp = 4; psd->ncolors = 16; psd->pixtype = MWPF_PALETTE; #if HAVEBLIT psd->flags = PSF_SCREEN | PSF_HAVEBLIT; #else psd->flags = PSF_SCREEN; #endif /* init planes driver (sets psd->addr and psd->linelen)*/ ega_init(psd); #if ROMFONT /* init pc rom font routines*/ pcrom_init(psd); #endif #if 0 ROM_CHAR_HEIGHT = VGAMODE? 16: 14; #endif /* FIXME: add palette code*/ return psd; }