Submitter | Jonathan A. Kollasch |
---|---|
Date | 2010-10-17 14:39:06 |
Message ID | <20101017143906.GA1206@tarantulon.kollasch.net> |
Download | mbox | patch |
Permalink | /patch/2127/ |
State | Accepted |
Delegated to: | Warren Turkal |
Headers | show |
Comments
2010/10/17 Jonathan A. Kollasch <jakllsch@kollasch.net>:
> Provide for I/O space access on NetBSD.
It seems that it's time for flashrom maintainers to reconsider their
opinion regarding autotools since the complexity and number of nesting
levels of ifdefs within flashrom sources becomes more and more
difficult to read and understand.
Yes, I suppose you can do this with autotools. I've never seen autotools as necessary or sufficient. Not necessary, because I use far more complex projects (see swtch.com/plan9ports, which is a complete Plan 9 operating system including graphics; or the Go language from Google) that somehow manage to get along without all the overhead that comes with autotools. Not sufficient, because I've lost track of the number of times autotools have failed me on one system or another. I think this #ifdef might be done a bit better but its existence is not a strong case for autotools. ron
on 17/10/2010 17:43 Peter Lemenkov said the following: > 2010/10/17 Jonathan A. Kollasch <jakllsch@kollasch.net>: >> Provide for I/O space access on NetBSD. > > It seems that it's time for flashrom maintainers to reconsider their > opinion regarding autotools since the complexity and number of nesting > levels of ifdefs within flashrom sources becomes more and more > difficult to read and understand. > BTW: http://sourceforge.net/projects/mk-configure/
On Sunday, October 17, 2010 07:39:06 am Jonathan A. Kollasch wrote: > Provide for I/O space access on NetBSD. > > Signed-off-by: Jonathan Kollasch <jakllsch@kollasch.net> > --- It might be better to use "inline" instead of "__inline" and define a macro to use the real name you want on certain platorms since c99 reserves the keyword "inline" for this purpose. Having said that, do those functions really need to be inlined? Thanks, wt
On Sun, Oct 17, 2010 at 10:51:06PM -0700, Warren Turkal wrote: > On Sunday, October 17, 2010 07:39:06 am Jonathan A. Kollasch wrote: > > Provide for I/O space access on NetBSD. > > > > Signed-off-by: Jonathan Kollasch <jakllsch@kollasch.net> > > --- > > It might be better to use "inline" instead of "__inline" and define a macro to > use the real name you want on certain platorms since c99 reserves the keyword > "inline" for this purpose. Well, the Makefile gives the compiler -ansi ... > Having said that, do those functions really need to be inlined? Maybe, they aren't used that much, and may as well flow right into the code IMO. Jonathan Kollasch
Jonathan A. Kollasch wrote: > Provide for I/O space access on NetBSD. > > Signed-off-by: Jonathan Kollasch <jakllsch@kollasch.net> > --- > +++ Makefile (working copy) Please keep in mind to generate patches from the top-level checkout directory so that it's always clear which files are being touched. Thanks! Acked-by: Peter Stuge <peter@stuge.se>
On Mon, Oct 18, 2010 at 6:42 AM, Jonathan A. Kollasch <jakllsch@kollasch.net> wrote: > On Sun, Oct 17, 2010 at 10:51:06PM -0700, Warren Turkal wrote: >> It might be better to use "inline" instead of "__inline" and define a macro to >> use the real name you want on certain platorms since c99 reserves the keyword >> "inline" for this purpose. > > Well, the Makefile gives the compiler -ansi ... The Makefile can be changed. >> Having said that, do those functions really need to be inlined? > > Maybe, they aren't used that much, and may as well flow right into > the code IMO. Two counters: * GCC can inline functions that don't declare themselves inline, and it can refuse to inline one that use the __inline attribute. I think it'd be better to rely on compiler optimizations than to explicitly state that it's inline. * Superiotool isn't some long running process, so an optimization that makes the code less readable is not really useful. I believe that it makes the code less readable by embedding functional code (i.e. not just prototypes and macros) in a header file.' Thanks, wt
On Tue, Oct 19, 2010 at 03:21:18AM +0200, Peter Stuge wrote: > Jonathan A. Kollasch wrote: > > Provide for I/O space access on NetBSD. > > > > Signed-off-by: Jonathan Kollasch <jakllsch@kollasch.net> > > --- > > > +++ Makefile (working copy) > > Please keep in mind to generate patches from the top-level checkout > directory so that it's always clear which files are being touched. > Thanks! > > Acked-by: Peter Stuge <peter@stuge.se> r5982 But s/__inline/&__/g per comments from Uwe.
Patch
Index: Makefile =================================================================== --- Makefile (revision 4892) +++ Makefile (working copy) @@ -38,6 +38,9 @@ ifeq ($(OS_ARCH), Darwin) LDFLAGS = -framework IOKit -framework DirectIO -lpci -lz endif +ifeq ($(OS_ARCH), NetBSD) +LDFLAGS = -l$(shell uname -p) +endif all: $(PROGRAM) Index: superiotool.h =================================================================== --- superiotool.h (revision 4892) +++ superiotool.h (working copy) @@ -55,6 +55,55 @@ #define INL inl #endif +#if defined(__NetBSD__) && 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 + +static __inline void +outb(uint8_t value, uint16_t port) +{ + __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); +} + +static __inline void +outw(uint16_t value, uint16_t port) +{ + __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); +} + +static __inline void +outl(uint32_t value, uint16_t port) +{ + __asm__ __volatile__ ("outl %0,%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 uint16_t inw(uint16_t port) +{ + uint16_t value; + __asm__ __volatile__ ("inw %w1,%0":"=a" (value):"Nd" (port)); + return value; +} + +static __inline uint32_t inl(uint16_t port) +{ + uint32_t value; + __asm__ __volatile__ ("inl %1,%0":"=a" (value):"Nd" (port)); + return value; +} +#endif + #define USAGE "Usage: superiotool [-d] [-e] [-l] [-V] [-v] [-h]\n\n\ -d | --dump Dump Super I/O register contents\n\ -e | --extra-dump Dump secondary registers too (e.g. EC registers)\n\
Provide for I/O space access on NetBSD. Signed-off-by: Jonathan Kollasch <jakllsch@kollasch.net> ---