loader/i386: replace ugly inb/outb re-implementations with cpufunc.h
Use of __builtin_constant_p in a function that is only called via a pointer is a good example of how out-of-date it was. Suggested by: bde MFC after: 1 week
This commit is contained in:
parent
154fc7b6c7
commit
a80a10b13b
@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <machine/bootinfo.h>
|
#include <machine/bootinfo.h>
|
||||||
|
#include <machine/cpufunc.h>
|
||||||
#include <machine/psl.h>
|
#include <machine/psl.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
|
|
||||||
@ -321,34 +322,19 @@ command_heap(int argc, char *argv[])
|
|||||||
return(CMD_OK);
|
return(CMD_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ISA bus access functions for PnP, derived from <machine/cpufunc.h> */
|
/* ISA bus access functions for PnP. */
|
||||||
static int
|
static int
|
||||||
isa_inb(int port)
|
isa_inb(int port)
|
||||||
{
|
{
|
||||||
u_char data;
|
|
||||||
|
|
||||||
if (__builtin_constant_p(port) &&
|
return (inb(port));
|
||||||
(((port) & 0xffff) < 0x100) &&
|
|
||||||
((port) < 0x10000)) {
|
|
||||||
__asm __volatile("inb %1,%0" : "=a" (data) : "id" ((u_short)(port)));
|
|
||||||
} else {
|
|
||||||
__asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
|
|
||||||
}
|
|
||||||
return(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
isa_outb(int port, int value)
|
isa_outb(int port, int value)
|
||||||
{
|
{
|
||||||
u_char al = value;
|
|
||||||
|
|
||||||
if (__builtin_constant_p(port) &&
|
outb(port, value);
|
||||||
(((port) & 0xffff) < 0x100) &&
|
|
||||||
((port) < 0x10000)) {
|
|
||||||
__asm __volatile("outb %0,%1" : : "a" (al), "id" ((u_short)(port)));
|
|
||||||
} else {
|
|
||||||
__asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOADER_ZFS_SUPPORT
|
#ifdef LOADER_ZFS_SUPPORT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user