diff mbox

[v4,10/19] Introduce asm-generic/*.h files

Message ID 1397149020-3501-11-git-send-email-drjones@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Jones April 10, 2014, 4:56 p.m. UTC
Architecture neutral code may need to call low-level io accessors,
or use spinlocks. Create a generic io.h to ensure those accessors
are defined, and a generic spinlock.h that complains when included,
as we can't write a generic spinlock. These files can be overridden
or extended by architecture specific versions placed in
lib/$ARCH/asm/.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
    add spinlock.h too
v3: wrt to io.h (was libio.[ch]) only
    - get rid of CONFIG_64BIT, replace with asserts
    - get rid of {read,write}_len() [libio.c]
    - fix bad *64_to_cpu macros
---
 .gitignore                 |   1 +
 Makefile                   |   6 +-
 configure                  |  11 ++++
 lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
 lib/asm-generic/spinlock.h |   4 ++
 5 files changed, 173 insertions(+), 3 deletions(-)
 create mode 100644 lib/asm-generic/io.h
 create mode 100644 lib/asm-generic/spinlock.h

Comments

Christoffer Dall June 6, 2014, 6:39 p.m. UTC | #1
On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
> Architecture neutral code may need to call low-level io accessors,
> or use spinlocks. Create a generic io.h to ensure those accessors
> are defined, and a generic spinlock.h that complains when included,
> as we can't write a generic spinlock. These files can be overridden
> or extended by architecture specific versions placed in
> lib/$ARCH/asm/.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
> v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
>     add spinlock.h too
> v3: wrt to io.h (was libio.[ch]) only
>     - get rid of CONFIG_64BIT, replace with asserts
>     - get rid of {read,write}_len() [libio.c]
>     - fix bad *64_to_cpu macros
> ---
>  .gitignore                 |   1 +
>  Makefile                   |   6 +-
>  configure                  |  11 ++++
>  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
>  lib/asm-generic/spinlock.h |   4 ++
>  5 files changed, 173 insertions(+), 3 deletions(-)
>  create mode 100644 lib/asm-generic/io.h
>  create mode 100644 lib/asm-generic/spinlock.h
> 
> diff --git a/.gitignore b/.gitignore
> index 775d0dfd8263e..e21939a8771e9 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -9,6 +9,7 @@ patches
>  .stgit-*
>  cscope.*
>  *.swp
> +/lib/asm
>  /config.mak
>  /*-run
>  /test.log
> diff --git a/Makefile b/Makefile
> index fba58e36f272f..51cacdac00615 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -76,11 +76,11 @@ libfdt_clean:
>  	$(LIBFDT_objdir)/.*.d
>  
>  distclean: clean libfdt_clean
> -	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> +	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
>  
> -cscope: common_dirs = lib lib/libfdt
> +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
>  cscope:
>  	$(RM) ./cscope.*
> -	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> +	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
>  		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
>  	cscope -bk
> diff --git a/configure b/configure
> index 6cfc64943f6e6..8a81bf92e27b7 100755
> --- a/configure
> +++ b/configure
> @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
>  fi
>  rm -f lib_test.c
>  
> +# link lib/asm for the architecture
> +rm -f lib/asm
> +asm=asm-generic
> +if [ -d lib/$arch/asm ]; then
> +	asm=$arch/asm
> +elif [ -d lib/$testdir/asm ]; then
> +	asm=$testdir/asm

why do you need this elif?  can you not make sure arch is always set?

> +fi
> +ln -s $asm lib/asm
> +
> +# create the config
>  cat <<EOF > config.mak
>  PREFIX=$prefix
>  KERNELDIR=$(readlink -f $kerneldir)

[...]

-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Jones June 9, 2014, 8:23 a.m. UTC | #2
On Fri, Jun 06, 2014 at 08:39:09PM +0200, Christoffer Dall wrote:
> On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
> > Architecture neutral code may need to call low-level io accessors,
> > or use spinlocks. Create a generic io.h to ensure those accessors
> > are defined, and a generic spinlock.h that complains when included,
> > as we can't write a generic spinlock. These files can be overridden
> > or extended by architecture specific versions placed in
> > lib/$ARCH/asm/.
> > 
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> > v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
> >     add spinlock.h too
> > v3: wrt to io.h (was libio.[ch]) only
> >     - get rid of CONFIG_64BIT, replace with asserts
> >     - get rid of {read,write}_len() [libio.c]
> >     - fix bad *64_to_cpu macros
> > ---
> >  .gitignore                 |   1 +
> >  Makefile                   |   6 +-
> >  configure                  |  11 ++++
> >  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
> >  lib/asm-generic/spinlock.h |   4 ++
> >  5 files changed, 173 insertions(+), 3 deletions(-)
> >  create mode 100644 lib/asm-generic/io.h
> >  create mode 100644 lib/asm-generic/spinlock.h
> > 
> > diff --git a/.gitignore b/.gitignore
> > index 775d0dfd8263e..e21939a8771e9 100644
> > --- a/.gitignore
> > +++ b/.gitignore
> > @@ -9,6 +9,7 @@ patches
> >  .stgit-*
> >  cscope.*
> >  *.swp
> > +/lib/asm
> >  /config.mak
> >  /*-run
> >  /test.log
> > diff --git a/Makefile b/Makefile
> > index fba58e36f272f..51cacdac00615 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -76,11 +76,11 @@ libfdt_clean:
> >  	$(LIBFDT_objdir)/.*.d
> >  
> >  distclean: clean libfdt_clean
> > -	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > +	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> >  
> > -cscope: common_dirs = lib lib/libfdt
> > +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
> >  cscope:
> >  	$(RM) ./cscope.*
> > -	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > +	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> >  		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
> >  	cscope -bk
> > diff --git a/configure b/configure
> > index 6cfc64943f6e6..8a81bf92e27b7 100755
> > --- a/configure
> > +++ b/configure
> > @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
> >  fi
> >  rm -f lib_test.c
> >  
> > +# link lib/asm for the architecture
> > +rm -f lib/asm
> > +asm=asm-generic
> > +if [ -d lib/$arch/asm ]; then
> > +	asm=$arch/asm
> > +elif [ -d lib/$testdir/asm ]; then
> > +	asm=$testdir/asm
> 
> why do you need this elif?  can you not make sure arch is always set?

arch is always set, but there's a chance some arch may not add it's own
lib/$arch dir. It's a pretty small chance... but the elif shouldn't hurt.

drew
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoffer Dall June 9, 2014, 9:08 a.m. UTC | #3
On Mon, Jun 09, 2014 at 10:23:27AM +0200, Andrew Jones wrote:
> On Fri, Jun 06, 2014 at 08:39:09PM +0200, Christoffer Dall wrote:
> > On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
> > > Architecture neutral code may need to call low-level io accessors,
> > > or use spinlocks. Create a generic io.h to ensure those accessors
> > > are defined, and a generic spinlock.h that complains when included,
> > > as we can't write a generic spinlock. These files can be overridden
> > > or extended by architecture specific versions placed in
> > > lib/$ARCH/asm/.
> > > 
> > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > ---
> > > v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
> > >     add spinlock.h too
> > > v3: wrt to io.h (was libio.[ch]) only
> > >     - get rid of CONFIG_64BIT, replace with asserts
> > >     - get rid of {read,write}_len() [libio.c]
> > >     - fix bad *64_to_cpu macros
> > > ---
> > >  .gitignore                 |   1 +
> > >  Makefile                   |   6 +-
> > >  configure                  |  11 ++++
> > >  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
> > >  lib/asm-generic/spinlock.h |   4 ++
> > >  5 files changed, 173 insertions(+), 3 deletions(-)
> > >  create mode 100644 lib/asm-generic/io.h
> > >  create mode 100644 lib/asm-generic/spinlock.h
> > > 
> > > diff --git a/.gitignore b/.gitignore
> > > index 775d0dfd8263e..e21939a8771e9 100644
> > > --- a/.gitignore
> > > +++ b/.gitignore
> > > @@ -9,6 +9,7 @@ patches
> > >  .stgit-*
> > >  cscope.*
> > >  *.swp
> > > +/lib/asm
> > >  /config.mak
> > >  /*-run
> > >  /test.log
> > > diff --git a/Makefile b/Makefile
> > > index fba58e36f272f..51cacdac00615 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -76,11 +76,11 @@ libfdt_clean:
> > >  	$(LIBFDT_objdir)/.*.d
> > >  
> > >  distclean: clean libfdt_clean
> > > -	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > +	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > >  
> > > -cscope: common_dirs = lib lib/libfdt
> > > +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
> > >  cscope:
> > >  	$(RM) ./cscope.*
> > > -	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > +	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > >  		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
> > >  	cscope -bk
> > > diff --git a/configure b/configure
> > > index 6cfc64943f6e6..8a81bf92e27b7 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
> > >  fi
> > >  rm -f lib_test.c
> > >  
> > > +# link lib/asm for the architecture
> > > +rm -f lib/asm
> > > +asm=asm-generic
> > > +if [ -d lib/$arch/asm ]; then
> > > +	asm=$arch/asm
> > > +elif [ -d lib/$testdir/asm ]; then
> > > +	asm=$testdir/asm
> > 
> > why do you need this elif?  can you not make sure arch is always set?
> 
> arch is always set, but there's a chance some arch may not add it's own
> lib/$arch dir. It's a pretty small chance... but the elif shouldn't hurt.
> 
If we don't have any code that uses this scheme now then let's now have
Makefile rules that encourages non-standard behavior (unless I'm missing
the point and this provides a 'feature' for specific archs or something
like that).

-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Jones June 9, 2014, 9:54 a.m. UTC | #4
On Mon, Jun 09, 2014 at 11:08:32AM +0200, Christoffer Dall wrote:
> On Mon, Jun 09, 2014 at 10:23:27AM +0200, Andrew Jones wrote:
> > On Fri, Jun 06, 2014 at 08:39:09PM +0200, Christoffer Dall wrote:
> > > On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
> > > > Architecture neutral code may need to call low-level io accessors,
> > > > or use spinlocks. Create a generic io.h to ensure those accessors
> > > > are defined, and a generic spinlock.h that complains when included,
> > > > as we can't write a generic spinlock. These files can be overridden
> > > > or extended by architecture specific versions placed in
> > > > lib/$ARCH/asm/.
> > > > 
> > > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > > ---
> > > > v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
> > > >     add spinlock.h too
> > > > v3: wrt to io.h (was libio.[ch]) only
> > > >     - get rid of CONFIG_64BIT, replace with asserts
> > > >     - get rid of {read,write}_len() [libio.c]
> > > >     - fix bad *64_to_cpu macros
> > > > ---
> > > >  .gitignore                 |   1 +
> > > >  Makefile                   |   6 +-
> > > >  configure                  |  11 ++++
> > > >  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
> > > >  lib/asm-generic/spinlock.h |   4 ++
> > > >  5 files changed, 173 insertions(+), 3 deletions(-)
> > > >  create mode 100644 lib/asm-generic/io.h
> > > >  create mode 100644 lib/asm-generic/spinlock.h
> > > > 
> > > > diff --git a/.gitignore b/.gitignore
> > > > index 775d0dfd8263e..e21939a8771e9 100644
> > > > --- a/.gitignore
> > > > +++ b/.gitignore
> > > > @@ -9,6 +9,7 @@ patches
> > > >  .stgit-*
> > > >  cscope.*
> > > >  *.swp
> > > > +/lib/asm
> > > >  /config.mak
> > > >  /*-run
> > > >  /test.log
> > > > diff --git a/Makefile b/Makefile
> > > > index fba58e36f272f..51cacdac00615 100644
> > > > --- a/Makefile
> > > > +++ b/Makefile
> > > > @@ -76,11 +76,11 @@ libfdt_clean:
> > > >  	$(LIBFDT_objdir)/.*.d
> > > >  
> > > >  distclean: clean libfdt_clean
> > > > -	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > > +	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > >  
> > > > -cscope: common_dirs = lib lib/libfdt
> > > > +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
> > > >  cscope:
> > > >  	$(RM) ./cscope.*
> > > > -	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > > +	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > >  		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
> > > >  	cscope -bk
> > > > diff --git a/configure b/configure
> > > > index 6cfc64943f6e6..8a81bf92e27b7 100755
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
> > > >  fi
> > > >  rm -f lib_test.c
> > > >  
> > > > +# link lib/asm for the architecture
> > > > +rm -f lib/asm
> > > > +asm=asm-generic
> > > > +if [ -d lib/$arch/asm ]; then
> > > > +	asm=$arch/asm
> > > > +elif [ -d lib/$testdir/asm ]; then
> > > > +	asm=$testdir/asm
> > > 
> > > why do you need this elif?  can you not make sure arch is always set?
> > 
> > arch is always set, but there's a chance some arch may not add it's own
> > lib/$arch dir. It's a pretty small chance... but the elif shouldn't hurt.
> > 
> If we don't have any code that uses this scheme now then let's now have
> Makefile rules that encourages non-standard behavior (unless I'm missing
> the point and this provides a 'feature' for specific archs or something
> like that).
>

It would be something of a feature for some imaginary arch. However, as
that imaginary arch doesn't exist right now, then I'm fine removing it.
Whoever makes the imaginary arch a reality can bring it back.

drew 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Jones June 9, 2014, 11:39 a.m. UTC | #5
On Mon, Jun 09, 2014 at 11:54:48AM +0200, Andrew Jones wrote:
> On Mon, Jun 09, 2014 at 11:08:32AM +0200, Christoffer Dall wrote:
> > On Mon, Jun 09, 2014 at 10:23:27AM +0200, Andrew Jones wrote:
> > > On Fri, Jun 06, 2014 at 08:39:09PM +0200, Christoffer Dall wrote:
> > > > On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
> > > > > Architecture neutral code may need to call low-level io accessors,
> > > > > or use spinlocks. Create a generic io.h to ensure those accessors
> > > > > are defined, and a generic spinlock.h that complains when included,
> > > > > as we can't write a generic spinlock. These files can be overridden
> > > > > or extended by architecture specific versions placed in
> > > > > lib/$ARCH/asm/.
> > > > > 
> > > > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > > > ---
> > > > > v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
> > > > >     add spinlock.h too
> > > > > v3: wrt to io.h (was libio.[ch]) only
> > > > >     - get rid of CONFIG_64BIT, replace with asserts
> > > > >     - get rid of {read,write}_len() [libio.c]
> > > > >     - fix bad *64_to_cpu macros
> > > > > ---
> > > > >  .gitignore                 |   1 +
> > > > >  Makefile                   |   6 +-
> > > > >  configure                  |  11 ++++
> > > > >  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
> > > > >  lib/asm-generic/spinlock.h |   4 ++
> > > > >  5 files changed, 173 insertions(+), 3 deletions(-)
> > > > >  create mode 100644 lib/asm-generic/io.h
> > > > >  create mode 100644 lib/asm-generic/spinlock.h
> > > > > 
> > > > > diff --git a/.gitignore b/.gitignore
> > > > > index 775d0dfd8263e..e21939a8771e9 100644
> > > > > --- a/.gitignore
> > > > > +++ b/.gitignore
> > > > > @@ -9,6 +9,7 @@ patches
> > > > >  .stgit-*
> > > > >  cscope.*
> > > > >  *.swp
> > > > > +/lib/asm
> > > > >  /config.mak
> > > > >  /*-run
> > > > >  /test.log
> > > > > diff --git a/Makefile b/Makefile
> > > > > index fba58e36f272f..51cacdac00615 100644
> > > > > --- a/Makefile
> > > > > +++ b/Makefile
> > > > > @@ -76,11 +76,11 @@ libfdt_clean:
> > > > >  	$(LIBFDT_objdir)/.*.d
> > > > >  
> > > > >  distclean: clean libfdt_clean
> > > > > -	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > > > +	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > > >  
> > > > > -cscope: common_dirs = lib lib/libfdt
> > > > > +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
> > > > >  cscope:
> > > > >  	$(RM) ./cscope.*
> > > > > -	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > > > +	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > > >  		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
> > > > >  	cscope -bk
> > > > > diff --git a/configure b/configure
> > > > > index 6cfc64943f6e6..8a81bf92e27b7 100755
> > > > > --- a/configure
> > > > > +++ b/configure
> > > > > @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
> > > > >  fi
> > > > >  rm -f lib_test.c
> > > > >  
> > > > > +# link lib/asm for the architecture
> > > > > +rm -f lib/asm
> > > > > +asm=asm-generic
> > > > > +if [ -d lib/$arch/asm ]; then
> > > > > +	asm=$arch/asm
> > > > > +elif [ -d lib/$testdir/asm ]; then
> > > > > +	asm=$testdir/asm
> > > > 
> > > > why do you need this elif?  can you not make sure arch is always set?
> > > 
> > > arch is always set, but there's a chance some arch may not add it's own
> > > lib/$arch dir. It's a pretty small chance... but the elif shouldn't hurt.
> > > 
> > If we don't have any code that uses this scheme now then let's now have
> > Makefile rules that encourages non-standard behavior (unless I'm missing
> > the point and this provides a 'feature' for specific archs or something
> > like that).
> >
> 
> It would be something of a feature for some imaginary arch. However, as
> that imaginary arch doesn't exist right now, then I'm fine removing it.
> Whoever makes the imaginary arch a reality can bring it back.
> 

Oh wait, it's actually not imaginary (just unused). x86 is an example of
such a testdir that doesn't == arch. So, if either i386 or x86_64 wanted
to use lib/asm, then they need this elif.

drew
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoffer Dall June 9, 2014, 12:34 p.m. UTC | #6
On Mon, Jun 09, 2014 at 01:39:06PM +0200, Andrew Jones wrote:
> On Mon, Jun 09, 2014 at 11:54:48AM +0200, Andrew Jones wrote:
> > On Mon, Jun 09, 2014 at 11:08:32AM +0200, Christoffer Dall wrote:
> > > On Mon, Jun 09, 2014 at 10:23:27AM +0200, Andrew Jones wrote:
> > > > On Fri, Jun 06, 2014 at 08:39:09PM +0200, Christoffer Dall wrote:
> > > > > On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
> > > > > > Architecture neutral code may need to call low-level io accessors,
> > > > > > or use spinlocks. Create a generic io.h to ensure those accessors
> > > > > > are defined, and a generic spinlock.h that complains when included,
> > > > > > as we can't write a generic spinlock. These files can be overridden
> > > > > > or extended by architecture specific versions placed in
> > > > > > lib/$ARCH/asm/.
> > > > > > 
> > > > > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > > > > ---
> > > > > > v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
> > > > > >     add spinlock.h too
> > > > > > v3: wrt to io.h (was libio.[ch]) only
> > > > > >     - get rid of CONFIG_64BIT, replace with asserts
> > > > > >     - get rid of {read,write}_len() [libio.c]
> > > > > >     - fix bad *64_to_cpu macros
> > > > > > ---
> > > > > >  .gitignore                 |   1 +
> > > > > >  Makefile                   |   6 +-
> > > > > >  configure                  |  11 ++++
> > > > > >  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
> > > > > >  lib/asm-generic/spinlock.h |   4 ++
> > > > > >  5 files changed, 173 insertions(+), 3 deletions(-)
> > > > > >  create mode 100644 lib/asm-generic/io.h
> > > > > >  create mode 100644 lib/asm-generic/spinlock.h
> > > > > > 
> > > > > > diff --git a/.gitignore b/.gitignore
> > > > > > index 775d0dfd8263e..e21939a8771e9 100644
> > > > > > --- a/.gitignore
> > > > > > +++ b/.gitignore
> > > > > > @@ -9,6 +9,7 @@ patches
> > > > > >  .stgit-*
> > > > > >  cscope.*
> > > > > >  *.swp
> > > > > > +/lib/asm
> > > > > >  /config.mak
> > > > > >  /*-run
> > > > > >  /test.log
> > > > > > diff --git a/Makefile b/Makefile
> > > > > > index fba58e36f272f..51cacdac00615 100644
> > > > > > --- a/Makefile
> > > > > > +++ b/Makefile
> > > > > > @@ -76,11 +76,11 @@ libfdt_clean:
> > > > > >  	$(LIBFDT_objdir)/.*.d
> > > > > >  
> > > > > >  distclean: clean libfdt_clean
> > > > > > -	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > > > > +	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > > > >  
> > > > > > -cscope: common_dirs = lib lib/libfdt
> > > > > > +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
> > > > > >  cscope:
> > > > > >  	$(RM) ./cscope.*
> > > > > > -	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > > > > +	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > > > >  		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
> > > > > >  	cscope -bk
> > > > > > diff --git a/configure b/configure
> > > > > > index 6cfc64943f6e6..8a81bf92e27b7 100755
> > > > > > --- a/configure
> > > > > > +++ b/configure
> > > > > > @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
> > > > > >  fi
> > > > > >  rm -f lib_test.c
> > > > > >  
> > > > > > +# link lib/asm for the architecture
> > > > > > +rm -f lib/asm
> > > > > > +asm=asm-generic
> > > > > > +if [ -d lib/$arch/asm ]; then
> > > > > > +	asm=$arch/asm
> > > > > > +elif [ -d lib/$testdir/asm ]; then
> > > > > > +	asm=$testdir/asm
> > > > > 
> > > > > why do you need this elif?  can you not make sure arch is always set?
> > > > 
> > > > arch is always set, but there's a chance some arch may not add it's own
> > > > lib/$arch dir. It's a pretty small chance... but the elif shouldn't hurt.
> > > > 
> > > If we don't have any code that uses this scheme now then let's now have
> > > Makefile rules that encourages non-standard behavior (unless I'm missing
> > > the point and this provides a 'feature' for specific archs or something
> > > like that).
> > >
> > 
> > It would be something of a feature for some imaginary arch. However, as
> > that imaginary arch doesn't exist right now, then I'm fine removing it.
> > Whoever makes the imaginary arch a reality can bring it back.
> > 
> 
> Oh wait, it's actually not imaginary (just unused). x86 is an example of
> such a testdir that doesn't == arch. So, if either i386 or x86_64 wanted
> to use lib/asm, then they need this elif.
> 
ah, ok.  I'll shut up then.
-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Jones June 9, 2014, 1:52 p.m. UTC | #7
On Mon, Jun 09, 2014 at 02:34:03PM +0200, Christoffer Dall wrote:
> On Mon, Jun 09, 2014 at 01:39:06PM +0200, Andrew Jones wrote:
> > On Mon, Jun 09, 2014 at 11:54:48AM +0200, Andrew Jones wrote:
> > > On Mon, Jun 09, 2014 at 11:08:32AM +0200, Christoffer Dall wrote:
> > > > On Mon, Jun 09, 2014 at 10:23:27AM +0200, Andrew Jones wrote:
> > > > > On Fri, Jun 06, 2014 at 08:39:09PM +0200, Christoffer Dall wrote:
> > > > > > On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
> > > > > > > Architecture neutral code may need to call low-level io accessors,
> > > > > > > or use spinlocks. Create a generic io.h to ensure those accessors
> > > > > > > are defined, and a generic spinlock.h that complains when included,
> > > > > > > as we can't write a generic spinlock. These files can be overridden
> > > > > > > or extended by architecture specific versions placed in
> > > > > > > lib/$ARCH/asm/.
> > > > > > > 
> > > > > > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > > > > > ---
> > > > > > > v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
> > > > > > >     add spinlock.h too
> > > > > > > v3: wrt to io.h (was libio.[ch]) only
> > > > > > >     - get rid of CONFIG_64BIT, replace with asserts
> > > > > > >     - get rid of {read,write}_len() [libio.c]
> > > > > > >     - fix bad *64_to_cpu macros
> > > > > > > ---
> > > > > > >  .gitignore                 |   1 +
> > > > > > >  Makefile                   |   6 +-
> > > > > > >  configure                  |  11 ++++
> > > > > > >  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
> > > > > > >  lib/asm-generic/spinlock.h |   4 ++
> > > > > > >  5 files changed, 173 insertions(+), 3 deletions(-)
> > > > > > >  create mode 100644 lib/asm-generic/io.h
> > > > > > >  create mode 100644 lib/asm-generic/spinlock.h
> > > > > > > 
> > > > > > > diff --git a/.gitignore b/.gitignore
> > > > > > > index 775d0dfd8263e..e21939a8771e9 100644
> > > > > > > --- a/.gitignore
> > > > > > > +++ b/.gitignore
> > > > > > > @@ -9,6 +9,7 @@ patches
> > > > > > >  .stgit-*
> > > > > > >  cscope.*
> > > > > > >  *.swp
> > > > > > > +/lib/asm
> > > > > > >  /config.mak
> > > > > > >  /*-run
> > > > > > >  /test.log
> > > > > > > diff --git a/Makefile b/Makefile
> > > > > > > index fba58e36f272f..51cacdac00615 100644
> > > > > > > --- a/Makefile
> > > > > > > +++ b/Makefile
> > > > > > > @@ -76,11 +76,11 @@ libfdt_clean:
> > > > > > >  	$(LIBFDT_objdir)/.*.d
> > > > > > >  
> > > > > > >  distclean: clean libfdt_clean
> > > > > > > -	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > > > > > +	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
> > > > > > >  
> > > > > > > -cscope: common_dirs = lib lib/libfdt
> > > > > > > +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
> > > > > > >  cscope:
> > > > > > >  	$(RM) ./cscope.*
> > > > > > > -	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > > > > > +	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
> > > > > > >  		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
> > > > > > >  	cscope -bk
> > > > > > > diff --git a/configure b/configure
> > > > > > > index 6cfc64943f6e6..8a81bf92e27b7 100755
> > > > > > > --- a/configure
> > > > > > > +++ b/configure
> > > > > > > @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
> > > > > > >  fi
> > > > > > >  rm -f lib_test.c
> > > > > > >  
> > > > > > > +# link lib/asm for the architecture
> > > > > > > +rm -f lib/asm
> > > > > > > +asm=asm-generic
> > > > > > > +if [ -d lib/$arch/asm ]; then
> > > > > > > +	asm=$arch/asm
> > > > > > > +elif [ -d lib/$testdir/asm ]; then
> > > > > > > +	asm=$testdir/asm
> > > > > > 
> > > > > > why do you need this elif?  can you not make sure arch is always set?
> > > > > 
> > > > > arch is always set, but there's a chance some arch may not add it's own
> > > > > lib/$arch dir. It's a pretty small chance... but the elif shouldn't hurt.
> > > > > 
> > > > If we don't have any code that uses this scheme now then let's now have
> > > > Makefile rules that encourages non-standard behavior (unless I'm missing
> > > > the point and this provides a 'feature' for specific archs or something
> > > > like that).
> > > >
> > > 
> > > It would be something of a feature for some imaginary arch. However, as
> > > that imaginary arch doesn't exist right now, then I'm fine removing it.
> > > Whoever makes the imaginary arch a reality can bring it back.
> > > 
> > 
> > Oh wait, it's actually not imaginary (just unused). x86 is an example of
> > such a testdir that doesn't == arch. So, if either i386 or x86_64 wanted
> > to use lib/asm, then they need this elif.
> > 
> ah, ok.  I'll shut up then.

Before you go completely silent on it, how about an Ack?

drew

> -Christoffer
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoffer Dall June 9, 2014, 3:34 p.m. UTC | #8
On 9 June 2014 15:52, Andrew Jones <drjones@redhat.com> wrote:
> On Mon, Jun 09, 2014 at 02:34:03PM +0200, Christoffer Dall wrote:
>> On Mon, Jun 09, 2014 at 01:39:06PM +0200, Andrew Jones wrote:
>> > On Mon, Jun 09, 2014 at 11:54:48AM +0200, Andrew Jones wrote:
>> > > On Mon, Jun 09, 2014 at 11:08:32AM +0200, Christoffer Dall wrote:
>> > > > On Mon, Jun 09, 2014 at 10:23:27AM +0200, Andrew Jones wrote:
>> > > > > On Fri, Jun 06, 2014 at 08:39:09PM +0200, Christoffer Dall wrote:
>> > > > > > On Thu, Apr 10, 2014 at 06:56:51PM +0200, Andrew Jones wrote:
>> > > > > > > Architecture neutral code may need to call low-level io accessors,
>> > > > > > > or use spinlocks. Create a generic io.h to ensure those accessors
>> > > > > > > are defined, and a generic spinlock.h that complains when included,
>> > > > > > > as we can't write a generic spinlock. These files can be overridden
>> > > > > > > or extended by architecture specific versions placed in
>> > > > > > > lib/$ARCH/asm/.
>> > > > > > >
>> > > > > > > Signed-off-by: Andrew Jones <drjones@redhat.com>
>> > > > > > > ---
>> > > > > > > v4: introduce lib/asm symlink to get rid of #ifdef __arm__,
>> > > > > > >     add spinlock.h too
>> > > > > > > v3: wrt to io.h (was libio.[ch]) only
>> > > > > > >     - get rid of CONFIG_64BIT, replace with asserts
>> > > > > > >     - get rid of {read,write}_len() [libio.c]
>> > > > > > >     - fix bad *64_to_cpu macros
>> > > > > > > ---
>> > > > > > >  .gitignore                 |   1 +
>> > > > > > >  Makefile                   |   6 +-
>> > > > > > >  configure                  |  11 ++++
>> > > > > > >  lib/asm-generic/io.h       | 154 +++++++++++++++++++++++++++++++++++++++++++++
>> > > > > > >  lib/asm-generic/spinlock.h |   4 ++
>> > > > > > >  5 files changed, 173 insertions(+), 3 deletions(-)
>> > > > > > >  create mode 100644 lib/asm-generic/io.h
>> > > > > > >  create mode 100644 lib/asm-generic/spinlock.h
>> > > > > > >
>> > > > > > > diff --git a/.gitignore b/.gitignore
>> > > > > > > index 775d0dfd8263e..e21939a8771e9 100644
>> > > > > > > --- a/.gitignore
>> > > > > > > +++ b/.gitignore
>> > > > > > > @@ -9,6 +9,7 @@ patches
>> > > > > > >  .stgit-*
>> > > > > > >  cscope.*
>> > > > > > >  *.swp
>> > > > > > > +/lib/asm
>> > > > > > >  /config.mak
>> > > > > > >  /*-run
>> > > > > > >  /test.log
>> > > > > > > diff --git a/Makefile b/Makefile
>> > > > > > > index fba58e36f272f..51cacdac00615 100644
>> > > > > > > --- a/Makefile
>> > > > > > > +++ b/Makefile
>> > > > > > > @@ -76,11 +76,11 @@ libfdt_clean:
>> > > > > > >   $(LIBFDT_objdir)/.*.d
>> > > > > > >
>> > > > > > >  distclean: clean libfdt_clean
>> > > > > > > - $(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
>> > > > > > > + $(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
>> > > > > > >
>> > > > > > > -cscope: common_dirs = lib lib/libfdt
>> > > > > > > +cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
>> > > > > > >  cscope:
>> > > > > > >   $(RM) ./cscope.*
>> > > > > > > - find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
>> > > > > > > + find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
>> > > > > > >           -name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
>> > > > > > >   cscope -bk
>> > > > > > > diff --git a/configure b/configure
>> > > > > > > index 6cfc64943f6e6..8a81bf92e27b7 100755
>> > > > > > > --- a/configure
>> > > > > > > +++ b/configure
>> > > > > > > @@ -95,6 +95,17 @@ if [ $exit -eq 0 ]; then
>> > > > > > >  fi
>> > > > > > >  rm -f lib_test.c
>> > > > > > >
>> > > > > > > +# link lib/asm for the architecture
>> > > > > > > +rm -f lib/asm
>> > > > > > > +asm=asm-generic
>> > > > > > > +if [ -d lib/$arch/asm ]; then
>> > > > > > > + asm=$arch/asm
>> > > > > > > +elif [ -d lib/$testdir/asm ]; then
>> > > > > > > + asm=$testdir/asm
>> > > > > >
>> > > > > > why do you need this elif?  can you not make sure arch is always set?
>> > > > >
>> > > > > arch is always set, but there's a chance some arch may not add it's own
>> > > > > lib/$arch dir. It's a pretty small chance... but the elif shouldn't hurt.
>> > > > >
>> > > > If we don't have any code that uses this scheme now then let's now have
>> > > > Makefile rules that encourages non-standard behavior (unless I'm missing
>> > > > the point and this provides a 'feature' for specific archs or something
>> > > > like that).
>> > > >
>> > >
>> > > It would be something of a feature for some imaginary arch. However, as
>> > > that imaginary arch doesn't exist right now, then I'm fine removing it.
>> > > Whoever makes the imaginary arch a reality can bring it back.
>> > >
>> >
>> > Oh wait, it's actually not imaginary (just unused). x86 is an example of
>> > such a testdir that doesn't == arch. So, if either i386 or x86_64 wanted
>> > to use lib/asm, then they need this elif.
>> >
>> ah, ok.  I'll shut up then.
>
> Before you go completely silent on it, how about an Ack?
>
ack

Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index 775d0dfd8263e..e21939a8771e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@  patches
 .stgit-*
 cscope.*
 *.swp
+/lib/asm
 /config.mak
 /*-run
 /test.log
diff --git a/Makefile b/Makefile
index fba58e36f272f..51cacdac00615 100644
--- a/Makefile
+++ b/Makefile
@@ -76,11 +76,11 @@  libfdt_clean:
 	$(LIBFDT_objdir)/.*.d
 
 distclean: clean libfdt_clean
-	$(RM) config.mak $(TEST_DIR)-run test.log msr.out cscope.*
+	$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
 
-cscope: common_dirs = lib lib/libfdt
+cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
 cscope:
 	$(RM) ./cscope.*
-	find $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
+	find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \
 		-name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files
 	cscope -bk
diff --git a/configure b/configure
index 6cfc64943f6e6..8a81bf92e27b7 100755
--- a/configure
+++ b/configure
@@ -95,6 +95,17 @@  if [ $exit -eq 0 ]; then
 fi
 rm -f lib_test.c
 
+# link lib/asm for the architecture
+rm -f lib/asm
+asm=asm-generic
+if [ -d lib/$arch/asm ]; then
+	asm=$arch/asm
+elif [ -d lib/$testdir/asm ]; then
+	asm=$testdir/asm
+fi
+ln -s $asm lib/asm
+
+# create the config
 cat <<EOF > config.mak
 PREFIX=$prefix
 KERNELDIR=$(readlink -f $kerneldir)
diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
new file mode 100644
index 0000000000000..34569c99ae270
--- /dev/null
+++ b/lib/asm-generic/io.h
@@ -0,0 +1,154 @@ 
+#ifndef _ASM_GENERIC_IO_H_
+#define _ASM_GENERIC_IO_H_
+/*
+ * asm-generic/io.h
+ *  adapted from the Linux kernel's include/asm-generic/io.h
+ *  and arch/arm/include/asm/io.h
+ *
+ * Copyright (C) 2014, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include "libcflat.h"
+
+#ifndef __raw_readb
+static inline u8 __raw_readb(const volatile void *addr)
+{
+	return *(const volatile u8 *)addr;
+}
+#endif
+
+#ifndef __raw_readw
+static inline u16 __raw_readw(const volatile void *addr)
+{
+	return *(const volatile u16 *)addr;
+}
+#endif
+
+#ifndef __raw_readl
+static inline u32 __raw_readl(const volatile void *addr)
+{
+	return *(const volatile u32 *)addr;
+}
+#endif
+
+#ifndef __raw_readq
+static inline u64 __raw_readq(const volatile void *addr)
+{
+	assert(sizeof(unsigned long) == sizeof(u64));
+	return *(const volatile u64 *)addr;
+}
+#endif
+
+#ifndef __raw_writeb
+static inline void __raw_writeb(u8 b, volatile void *addr)
+{
+	*(volatile u8 *)addr = b;
+}
+#endif
+
+#ifndef __raw_writew
+static inline void __raw_writew(u16 b, volatile void *addr)
+{
+	*(volatile u16 *)addr = b;
+}
+#endif
+
+#ifndef __raw_writel
+static inline void __raw_writel(u32 b, volatile void *addr)
+{
+	*(volatile u32 *)addr = b;
+}
+#endif
+
+#ifndef __raw_writeq
+static inline void __raw_writeq(u64 b, volatile void *addr)
+{
+	assert(sizeof(unsigned long) == sizeof(u64));
+	*(volatile u64 *)addr = b;
+}
+#endif
+
+#ifndef __bswap16
+static inline u16 __bswap16(u16 x)
+{
+	return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
+}
+#endif
+
+#ifndef __bswap32
+static inline u32 __bswap32(u32 x)
+{
+	return ((x & 0xff000000) >> 24) | ((x & 0x00ff0000) >>  8) |
+	       ((x & 0x0000ff00) <<  8) | ((x & 0x000000ff) << 24);
+}
+#endif
+
+#ifndef __bswap64
+static inline u64 __bswap64(u64 x)
+{
+	return ((x & 0x00000000000000ffULL) << 56) |
+	       ((x & 0x000000000000ff00ULL) << 40) |
+	       ((x & 0x0000000000ff0000ULL) << 24) |
+	       ((x & 0x00000000ff000000ULL) <<  8) |
+	       ((x & 0x000000ff00000000ULL) >>  8) |
+	       ((x & 0x0000ff0000000000ULL) >> 24) |
+	       ((x & 0x00ff000000000000ULL) >> 40) |
+	       ((x & 0xff00000000000000ULL) >> 56);
+}
+#endif
+
+#ifndef __cpu_is_be
+#define __cpu_is_be() (0)
+#endif
+
+#define le16_to_cpu(x) \
+	({ u16 __r = __cpu_is_be() ? __bswap16(x) : (x); __r; })
+#define cpu_to_le16 le16_to_cpu
+
+#define le32_to_cpu(x) \
+	({ u32 __r = __cpu_is_be() ? __bswap32(x) : (x); __r; })
+#define cpu_to_le32 le32_to_cpu
+
+#define le64_to_cpu(x) \
+	({ u64 __r = __cpu_is_be() ? __bswap64(x) : (x); __r; })
+#define cpu_to_le64 le64_to_cpu
+
+#define be16_to_cpu(x) \
+	({ u16 __r = !__cpu_is_be() ? __bswap16(x) : (x); __r; })
+#define cpu_to_be16 be16_to_cpu
+
+#define be32_to_cpu(x) \
+	({ u32 __r = !__cpu_is_be() ? __bswap32(x) : (x); __r; })
+#define cpu_to_be32 be32_to_cpu
+
+#define be64_to_cpu(x) \
+	({ u64 __r = !__cpu_is_be() ? __bswap64(x) : (x); __r; })
+#define cpu_to_be64 be64_to_cpu
+
+#ifndef rmb
+#define rmb() do { } while (0)
+#endif
+#ifndef wmb
+#define wmb() do { } while (0)
+#endif
+
+#define readb(addr) \
+	({ u8 __r = __raw_readb(addr); rmb(); __r; })
+#define readw(addr) \
+	({ u16 __r = le16_to_cpu(__raw_readw(addr)); rmb(); __r; })
+#define readl(addr) \
+	({ u32 __r = le32_to_cpu(__raw_readl(addr)); rmb(); __r; })
+#define readq(addr) \
+	({ u64 __r = le64_to_cpu(__raw_readq(addr)); rmb(); __r; })
+
+#define writeb(b, addr) \
+	({ wmb(); __raw_writeb(b, addr); })
+#define writew(b, addr) \
+	({ wmb(); __raw_writew(cpu_to_le16(b), addr); })
+#define writel(b, addr) \
+	({ wmb(); __raw_writel(cpu_to_le32(b), addr); })
+#define writeq(b, addr) \
+	({ wmb(); __raw_writeq(cpu_to_le64(b), addr); })
+
+#endif /* _ASM_GENERIC_IO_H_ */
diff --git a/lib/asm-generic/spinlock.h b/lib/asm-generic/spinlock.h
new file mode 100644
index 0000000000000..31417442e3330
--- /dev/null
+++ b/lib/asm-generic/spinlock.h
@@ -0,0 +1,4 @@ 
+#ifndef _ASM_GENERIC_SPINLOCK_H_
+#define _ASM_GENERIC_SPINLOCK_H_
+#error need architecture specific asm/spinlock.h
+#endif