viatool: add NetBSD support
Change-Id: I033044e4b781475d6d60a49a61313a720103ce38 Signed-off-by: Andrey Korolyov <andrey@xdel.ru> Reviewed-on: https://review.coreboot.org/12836 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
parent
4ba946c1e1
commit
0ff8f9048b
|
@ -40,6 +40,10 @@ CFLAGS += -I/usr/local/include
|
||||||
LDFLAGS += -L/usr/local/lib
|
LDFLAGS += -L/usr/local/lib
|
||||||
LIBS = -lz
|
LIBS = -lz
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(OS_ARCH), NetBSD)
|
||||||
|
CFLAGS += -I/usr/pkg/include
|
||||||
|
LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib -lz -lpciutils -lpci -l$(shell uname -p)
|
||||||
|
endif
|
||||||
|
|
||||||
all: pciutils dep $(PROGRAM)
|
all: pciutils dep $(PROGRAM)
|
||||||
|
|
||||||
|
@ -62,7 +66,11 @@ dep:
|
||||||
define LIBPCI_TEST
|
define LIBPCI_TEST
|
||||||
/* Avoid a failing test due to libpci header symbol shadowing breakage */
|
/* Avoid a failing test due to libpci header symbol shadowing breakage */
|
||||||
#define index shadow_workaround_index
|
#define index shadow_workaround_index
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
#include <pciutils/pci.h>
|
||||||
|
#else
|
||||||
#include <pci/pci.h>
|
#include <pci/pci.h>
|
||||||
|
#endif
|
||||||
struct pci_access *pacc;
|
struct pci_access *pacc;
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "viatool.h"
|
#include "viatool.h"
|
||||||
|
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
#include <machine/sysarch.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* http://pci-ids.ucw.cz/read/PC/8086
|
* http://pci-ids.ucw.cz/read/PC/8086
|
||||||
* http://en.wikipedia.org/wiki/Intel_Tick-Tock
|
* http://en.wikipedia.org/wiki/Intel_Tick-Tock
|
||||||
|
@ -146,6 +150,14 @@ int main(int argc, char *argv[])
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
if (open("/dev/io", O_RDWR) < 0) {
|
if (open("/dev/io", O_RDWR) < 0) {
|
||||||
perror("/dev/io");
|
perror("/dev/io");
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
# ifdef __i386__
|
||||||
|
if (i386_iopl(3)) {
|
||||||
|
perror("iopl");
|
||||||
|
# else
|
||||||
|
if (x86_64_iopl(3)) {
|
||||||
|
perror("iopl");
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
if (iopl(3)) {
|
if (iopl(3)) {
|
||||||
perror("iopl");
|
perror("iopl");
|
||||||
|
|
|
@ -28,13 +28,38 @@
|
||||||
#define __DARWIN__
|
#define __DARWIN__
|
||||||
#include <DirectHW/DirectHW.h>
|
#include <DirectHW/DirectHW.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
#include <pciutils/pci.h>
|
||||||
|
#else
|
||||||
#include <pci/pci.h>
|
#include <pci/pci.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This #include is needed for freebsd_{rd,wr}msr. */
|
/* This #include is needed for freebsd_{rd,wr}msr. */
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
#include <machine/cpufunc.h>
|
#include <machine/cpufunc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
static inline uint8_t inb(unsigned port)
|
||||||
|
{
|
||||||
|
uint8_t data;
|
||||||
|
__asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
static inline uint16_t inw(unsigned port)
|
||||||
|
{
|
||||||
|
uint16_t data;
|
||||||
|
__asm volatile("inw %w1,%0": "=a" (data) : "d" (port));
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
static inline uint32_t inl(unsigned port)
|
||||||
|
{
|
||||||
|
uint32_t data;
|
||||||
|
__asm volatile("inl %w1,%0": "=a" (data) : "d" (port));
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define VIATOOL_VERSION "1.0"
|
#define VIATOOL_VERSION "1.0"
|
||||||
|
|
Loading…
Reference in New Issue