diff --git a/Makefile b/Makefile index 8a9c13f782dd4d890930dab2e92a67e478d5a998..d2f04ec3e73ecbb0c3019448524ba4ea59029df5 100644 --- a/Makefile +++ b/Makefile @@ -178,6 +178,10 @@ PROGRAMMER_OBJS += pcidev.o physmap.o internal.o #FIXME: We need to move stuff # into internal-programmer-only stuff # and a support lib for all internal+pci # based stuff. +ifeq ($(OS_ARCH), NetBSD) +LIBS += -lpciutils # The libpci we want. +LIBS += -l$(shell uname -m) # For (i386|x86_64)_iopl(2). +endif endif ifeq ($(CONFIG_PRINT_WIKI), yes) diff --git a/README b/README index 1712bc3c43743b8f30e5d445ff6bada9ef394f00..3082f71069ecf33672b7cd2dcf6c04d1e0bee9f8 100644 --- a/README +++ b/README @@ -65,10 +65,10 @@ To compile on Solaris, use: gmake LDFLAGS="-L$pathtolibpci" CC="gcc -I$pathtopciheaders" CFLAGS=-O2 -To compile on DragonFly BSD, use: +To compile on NetBSD or DragonFly BSD, use: ln -s /usr/pkg/include/pciutils pci - gmake CFLAGS=-I. LDFLAGS="-L/usr/pkg/lib" + gmake CFLAGS=-I. LDFLAGS="-L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib" To compile and run on Darwin/Mac OS X: diff --git a/hwaccess.h b/hwaccess.h index edf1738291130dc279c44435106f7010d060c6c1..2bc2927b07bd043e4ddf1f466cbef1b5f7d999d6 100644 --- a/hwaccess.h +++ b/hwaccess.h @@ -76,6 +76,63 @@ #endif #endif +#if defined(__NetBSD__) + #define off64_t off_t + #define lseek64 lseek + #if defined(__i386__) || defined(__x86_64__) + #include <sys/types.h> + #include <machine/sysarch.h> + #if defined(__i386__) + #define iopl i386_iopl + #elif defined(__x86_64__) + #define iopl x86_64_iopl + #endif + #include <stdint.h> + +static inline void +outb(uint8_t value, uint16_t port) +{ + asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (port)); +} + +static inline uint8_t +inb(uint16_t port) +{ + uint8_t value; + asm volatile ("inb %w1,%0":"=a" (value):"Nd" (port)); + return value; +} + +static inline void +outw(uint16_t value, uint16_t port) +{ + asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (port)); +} + +static inline uint16_t +inw(uint16_t port) +{ + uint16_t value; + asm volatile ("inw %w1,%0":"=a" (value):"Nd" (port)); + return value; +} + +static inline void +outl(uint32_t value, uint16_t port) +{ + asm volatile ("outl %0,%w1": :"a" (value), "Nd" (port)); +} + +static inline uint32_t +inl(uint16_t port) +{ + uint32_t value; + asm volatile ("inl %1,%0":"=a" (value):"Nd" (port)); + return value; +} + #endif +#endif + #if defined(__FreeBSD__) || defined(__DragonFly__) extern int io_fd; #endif