dbullis@cognos.UUCP (Dave Bullis) (04/04/91)
I am trying to set my Herculus mono-graphics board into graphics mode with following code. However the 'ioctl(0,MCAIO,&arg)' call fails with 'Invalid argument' on the first call to outb(). 'ioctl(0,KDDISPTYPE,)' tell me that 0x3bf is a valid port, so what's going on? (The code is adapted from the GL plot package posted some years ago) #include <stdio.h> #include <sys/types.h> #ifdef ISC #include <sys/at_ansi.h> #include <sys/kd.h> #endif void outb( port, data ) int port; int data; { struct port_io_arg arg; int old_errno; arg.args[0].dir = OUT_ON_PORT; arg.args[0].port = port; arg.args[0].data = data; arg.args[1].port = arg.args[2].port = arg.args[3].port = 0; if (ioctl( 0, MCAIO, &arg )==-1) { >>>> perror("ioctl(,MCAIO, &arg)"); <<<< exit(1); } } setmode(mode) int mode; { register int i; struct kd_disparam disparam; switch (mode) { case 8: if(ioctl(0,KDENABIO,0)==-1) { perror("ioctl(0,KDENABIO,0)"); exit(1); } outb(0x3bf, 0x03); /* "hgc full" */ for (i = 0; i < 12; i++) { outb(0x3b4, i); outb(0x3b5, gmode[i]); } outb(0x3b8, 0x0A); /* enable graphics page 0 */ break; . . . -- Dave Bullis Cognos, Inc VOICE: (613) 738-1440 FAX: (613) 738-0002 3755 Riverside Dr. P.O. Box 9707 WORK: uunet!mitel!cunews!cognos!dbullis Ottawa, Ontario, CANADA K1G 3Z4 HOME: dave@sillub.ocunix.on.ca "I didn't know the terminals were haunted. The salesman didn't tell us."
john@axis-design.fr (John Hughes) (04/10/91)
In article <9492@cognos.UUCP> dbullis@cognos.UUCP (Dave Bullis) writes: I am trying to set my Herculus mono-graphics board into graphics mode with following code. However the 'ioctl(0,MCAIO,&arg)' call fails with 'Invalid argument' on the first call to outb(). 'ioctl(0,KDDISPTYPE,)' tell me that 0x3bf is a valid port, so what's going on? It took me AGES! to figure this one out a year or so ago. The answer is simple, forget about MCAIO and just do the "outb" instruction yourself. When you map the Herc memory in with KDMAPDISP set the "kd.ioflag" flag. You will then be allowed to issue outb instructions to the Herc I/O ports. If you're using cc include <sys/inline.h> to get the "outb" instruction, if you're using gcc then you can use this: static inline void outb (unsigned short port, unsigned char val) { asm volatile ("outb (%0)" : : "d" (port), "a" (val)); } static inline unsigned char inb (unsigned short port) { unsigned char val; asm volatile ("inb (%1)" : "=a" (val) : "d" (port)); return val; } John Hughes (john@axis-design.fr, maybe)