Submitter | Jonathan A. Kollasch |
---|---|
Date | 2011-02-07 21:15:36 |
Message ID | <20110207211536.GA8516@tarantulon.kollasch.net> |
Download | mbox | patch |
Permalink | /patch/2616/ |
State | Accepted |
Commit | r6338 |
Headers | show |
Comments
Am Montag, den 07.02.2011, 21:15 +0000 schrieb Jonathan A. Kollasch: > Add NetBSD support to nvramtool. > > Signed-off-by: <jakllsch@kollasch.net> Acked-by: Patrick Georgi <patrick.georgi@secunet.com> More general question (shouldn't stop anyone from committing this patch): Should we move hardware access code to directio and use its API on all platforms (not just Darwin, and - in theory - win32)? Though in that case, we might want to import directio to the coreboot tree. Patrick
Jonathan A. Kollasch wrote: > Add NetBSD support to nvramtool. > > Signed-off-by: <jakllsch@kollasch.net> Acked-by: Peter Stuge <peter@stuge.se>
r6338.
* Georgi, Patrick <Patrick.Georgi@secunet.com> [110208 11:26]: > More general question (shouldn't stop anyone from committing this > patch): Should we move hardware access code to directio and use its API > on all platforms (not just Darwin, and - in theory - win32)? > Though in that case, we might want to import directio to the coreboot > tree. +1
Patch
Index: util/nvramtool/accessors/cmos-hw-unix.c =================================================================== --- util/nvramtool/accessors/cmos-hw-unix.c (revision 6334) +++ util/nvramtool/accessors/cmos-hw-unix.c (working copy) @@ -17,6 +17,53 @@ #if (defined(__MACH__) && defined(__APPLE__)) #include <DirectIO/darwinio.h> #endif +#if defined(__NetBSD__) +#if defined(__i386__) || defined(__x86_64__) +#include <machine/sysarch.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 +#ifdef __x86_64__ +#define iopl x86_64_iopl +#endif +#ifdef __i386__ +#define iopl i386_iopl +#endif +#endif #define OUTB outb #define OUTW outw #define OUTL outl Index: util/nvramtool/Makefile =================================================================== --- util/nvramtool/Makefile (revision 6334) +++ util/nvramtool/Makefile (working copy) @@ -39,6 +39,9 @@ ifeq ($(OS_ARCH), Darwin) LDFLAGS = -framework DirectIO endif +ifeq ($(OS_ARCH), NetBSD) +LDFLAGS = -l$(shell uname -p) +endif all: dep $(PROGRAM)
Add NetBSD support to nvramtool. Signed-off-by: <jakllsch@kollasch.net>