_ioperm (unsigned long from, unsigned long num, int turn_on)
_ioperm (unsigned long int from, unsigned long int num, int turn_on)
_ioperm (unsigned long from, unsigned long num, int turn_on){  unsigned long addr, len;  int prot;  if (!io.swp && init_iosys () < 0)    return -1;  /* this test isn't as silly as it may look like; consider overflows! */  if (from >= MAX_PORT || from + num > MAX_PORT)    {      __set_errno (EINVAL);      return -1;    }  if (turn_on)    {      if (!io.base)	{	  unsigned long base;	  int fd;	  io.hae.reg   = 0;		/* not used in user-level */	  io.hae.cache = 0;	  __sethae (io.hae.cache);	/* synchronize with hw */	  fd = open ("/dev/mem", O_RDWR);	  if (fd < 0)	    return fd;	  switch (io.sys)	    {	    case IOSYS_JENSEN:	base = JENSEN_IO_BASE; break;	    case IOSYS_APECS:	base = APECS_IO_BASE; break;	    case IOSYS_CIA:	base = CIA_IO_BASE; break;	    default:	      __set_errno (ENODEV);	      return -1;	    }	  addr  = port_to_cpu_addr (from, io.sys, 1);	  addr &= PAGE_MASK;	  len = port_to_cpu_addr (MAX_PORT, io.sys, 1) - addr;	  io.base =	    (unsigned long) __mmap (0, len, PROT_NONE, MAP_SHARED, fd, base);	  close (fd);	  if ((long) io.base == -1)	    return -1;	}      prot = PROT_READ | PROT_WRITE;    }  else    {      if (!io.base)	return 0;	/* never was turned on... */      /* turnoff access to relevant pages: */      prot = PROT_NONE;    }  addr  = port_to_cpu_addr (from, io.sys, 1);  addr &= PAGE_MASK;  len = port_to_cpu_addr (from + num, io.sys, 1) - addr;  return mprotect ((void *) addr, len, prot);}