Example #1
0
static __inline__ int enable_os_io(void)
{
#if defined(SI86IOPL)
    sysi86(SI86IOPL, 3);
#else
    sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
#endif
    return(0);
}
Example #2
0
static __inline__ int disable_os_io(void)
{
#if defined(SI86IOPL)
    sysi86(SI86IOPL, 0);
#else
    sysi86(SI86V86, V86SC_IOPL, 0);
#endif
    return 0;
}
Example #3
0
_X_EXPORT void xf86EnableInterrupts(void)
{
#if defined(i386) || defined(__x86)
	if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
		return;

#ifdef __GNUC__
	__asm__ __volatile__("sti");
#else
	asm("sti");
#endif /* __GNUC__ */

	if (!ExtendedEnabled)
		sysi86(SI86V86, V86SC_IOPL, 0);
#endif /* i386 */
}
Example #4
0
void xf86DisableIO(void)
{
    if (!IOEnabled)
        return;

    sysi86(SI86V86, V86SC_IOPL, 0);
    IOEnabled = FALSE;
}
Example #5
0
void xf86EnableInterrupts()
{
    if (!IOEnabled) {
        if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
            return;
    }

#ifdef __GNUC__
    __asm__ __volatile__("sti");
#else
    asm("sti");
#endif /* __GNUC__ */

    if (!IOEnabled) {
        sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
    }
}
Example #6
0
Bool xf86DisableInterrupts(void)
{
#ifdef i386
	if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
		return FALSE;

#ifdef __GNUC__
	__asm__ __volatile__("cli");
#else
	asm("cli");
#endif /* __GNUC__ */

	if (!ExtendedEnabled)
		sysi86(SI86V86, V86SC_IOPL, 0);
#endif /* i386 */

	return TRUE;
}
Example #7
0
void xf86EnableIO(void)
{
    if (IOEnabled)
        return;

    if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
        FatalError("Failed to set IOPL for extended I/O\n");
    IOEnabled = TRUE;
}
Example #8
0
Bool xf86DisableInterrupts()
{
    if (!IOEnabled) {
        if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
            return FALSE;
    }

#ifdef __GNUC__
    __asm__ __volatile__("cli");
#else
    asm("cli");
#endif /* __GNUC__ */

    if (!IOEnabled) {
        sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
    }

    return(TRUE);
}
Example #9
0
static int release_io_perms(void *p)
{
#if defined (__sun)
	sysi86(SI86V86, V86SC_IOPL, 0);
#elif IS_BSD
	close(io_fd);
#elif IS_LINUX || IS_MACOSX
	iopl(0);
#endif
	return 0;
}
Example #10
0
_X_EXPORT void
xf86DisableIO(void)
{
#if defined(i386) || defined(__x86)
	if(!ExtendedEnabled)
		return;

	sysi86(SI86V86, V86SC_IOPL, 0);

	ExtendedEnabled = FALSE;
#endif /* i386 */
}
Example #11
0
void
xf86DisableIO(void)
{
#ifdef i386
	if(!ExtendedEnabled)
		return;

	sysi86(SI86V86, V86SC_IOPL, 0);

	ExtendedEnabled = FALSE;
#endif /* i386 */
}
Example #12
0
void
xf86EnableIO(void)
{
#ifdef i386
	if (ExtendedEnabled)
		return;

	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
		FatalError("xf86EnableIOPorts: Failed to set IOPL for I/O\n");

	ExtendedEnabled = TRUE;
#endif /* i386 */
}
Example #13
0
_X_EXPORT Bool
xf86EnableIO(void)
{
	if (IOEnabled)
		return TRUE;

	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
		xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n");
		return FALSE;
	}
	
	IOEnabled = TRUE;
	return TRUE;
}
Example #14
0
_X_EXPORT Bool
xf86EnableIO(void)
{
#if defined(i386) || defined(__x86)
	if (ExtendedEnabled)
		return TRUE;

	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
		xf86Msg(X_WARNING,"xf86EnableIOPorts: Failed to set IOPL for I/O\n");
		return FALSE;
	}
	ExtendedEnabled = TRUE;
#endif /* i386 */
	return TRUE;
}
Example #15
0
/* Get I/O permissions with automatic permission release on shutdown. */
int rget_io_perms(void)
{
#if IS_X86 && !(defined(__DJGPP__) || defined(__LIBPAYLOAD__))
#if defined (__sun)
	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
#elif IS_BSD
	if ((io_fd = open("/dev/io", O_RDWR)) < 0) {
#elif IS_LINUX || IS_MACOSX
	if (iopl(3) != 0) {
#endif
		msg_perr("ERROR: Could not get I/O privileges (%s).\n"
			"You need to be root.\n", strerror(errno));
#if defined (__OpenBSD__)
		msg_perr("Please set securelevel=-1 in /etc/rc.securelevel and reboot, or reboot into \n");
		msg_perr("single user mode.\n");
#endif
		return 1;
	} else {
		register_shutdown(release_io_perms, NULL);
	}
#else
	/* DJGPP and libpayload environments have full PCI port I/O permissions by default. */
	/* PCI port I/O support is unimplemented on PPC/MIPS and unavailable on ARM. */
#endif
	return 0;
}

void mmio_writeb(uint8_t val, void *addr)
{
	*(volatile uint8_t *) addr = val;
	sync_primitive();
}

void mmio_writew(uint16_t val, void *addr)
{
	*(volatile uint16_t *) addr = val;
	sync_primitive();
}
Example #16
0
void get_io_perms(void)
{
#if defined(__DJGPP__) || defined(__LIBPAYLOAD__) || defined(__DOS__)
	/* We have full permissions by default. */
	return;
#else
#if defined (__sun) && (defined(__i386) || defined(__amd64))
	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
#elif defined(__FreeBSD__) || defined (__DragonFly__)
	if ((io_fd = open("/dev/io", O_RDWR)) < 0) {
#else 
	if (iopl(3) != 0) {
#endif
		msg_perr("ERROR: Could not get I/O privileges (%s).\n"
			"You need to be root.\n", strerror(errno));
#if defined (__OpenBSD__)
		msg_perr("Please set securelevel=-1 in /etc/rc.securelevel "
			   "and reboot, or reboot into \n");
		msg_perr("single user mode.\n");
#endif
		exit(1);
	}
#endif
}

void release_io_perms(void)
{
#if defined(__FreeBSD__) || defined(__DragonFly__)
	close(io_fd);
#endif
}

#elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__)

static inline void sync_primitive(void)
{
	/* Prevent reordering and/or merging of reads/writes to hardware.
	 * Such reordering and/or merging would break device accesses which
	 * depend on the exact access order.
	 */
	asm("eieio" : : : "memory");
}

/* PCI port I/O is not yet implemented on PowerPC. */
void get_io_perms(void)
{
}

/* PCI port I/O is not yet implemented on PowerPC. */
void release_io_perms(void)
{
}

#elif defined (__mips) || defined (__mips__) || defined (_mips) || defined (mips)

/* sync primitive is not needed because /dev/mem on MIPS uses uncached accesses
 * in mode 2 which has a strongly ordered memory model.
 */
static inline void sync_primitive(void)
{
}

/* PCI port I/O is not yet implemented on MIPS. */
void get_io_perms(void)
{
}

/* PCI port I/O is not yet implemented on MIPS. */
void release_io_perms(void)
{
}

#else

#error Unknown architecture

#endif

void mmio_writeb(uint8_t val, void *addr)
{
	*(volatile uint8_t *) addr = val;
	sync_primitive();
}
Example #17
0
char *
format_next_process(caddr_t handle, char *(*get_userid) ())

{
	register struct proc *pp;
	register time_t cputime;
	register double pct;
	int			where;
	struct user u;
	struct handle *hp;
	char		command[29];
	char	   *process;
	char	   *process2;

	/* find and remember the next proc structure */
	hp = (struct handle *) handle;
	pp = *(hp->next_proc++);
	hp->remaining--;

	/* get the process's user struct and set cputime */
	if ((where = sysi86(RDUBLK, pp->p_pid, &u, sizeof(struct user))) != -1)
		where = (pp->p_flag & SLOAD) ? 0 : 1;
	if (where == -1)
	{
		strcpy(command, "<swapped>");
		cputime = 0;
	}
	else
	{
		/* set u_comm for system processes */
		if (u.u_comm[0] == '\0')
		{
			if (pp->p_pid == 0)
				strcpy(command, "Swapper");
			else if (pp->p_pid == 2)
				strcpy(command, "Pager");
			else if (pp->p_pid == 3)
				strcpy(command, "Sync'er");
		}
		else if (where == 1)
		{
			/* print swapped processes as <pname> */
			register char *s1;

			u.u_psargs[28 - 3] = '\0';
			strcpy(command, "<");
			strcat(command, strtok(u.u_psargs, " "));
			strcat(command, ">");
			while (s1 = (char *) strtok(NULL, " "))
				strcat(command, s1);
		}
		else
		{
			sprintf(command, "%s", u.u_psargs);
		}
		cputime = u.u_utime + u.u_stime;
/*	   cputime = pp->p_utime + pp->p_stime;  */
	}
	/* calculate the base for cpu percentages */
	pct = pctdouble(pp->p_cpu);

	/*
	 * psargs gives the absolute path of the process... strip it to only the
	 * command - [Changes by D. Currie & M. Muldner Aitt NS Canada]
	 */
	process = printable(command);
#if NO_COMMAND_ARGS
	strtok(process, " ");
#endif
	process2 = strrchr(process, '/');
	if (process2)
	{
		process = process2;
		process++;
	}


	/* format this entry */
	sprintf(fmt,
			Proc_format,
			pp->p_pid,
			(*get_userid) (pp->p_uid),
			pp->p_pri - PZERO,
			pp->p_nice - NZERO,
			format_k(PROCSIZE(&u)),		/* same as	pp->p_size * 4 */
			proc_residentsize(pp),
			state_abbrev[pp->p_stat],
			format_time(cputime / Hz),
			printable(process));

	return (fmt);
}