Author: ian
Date: Tue Jan 20 22:56:59 2015
New Revision: 277454
URL: https://svnweb.freebsd.org/changeset/base/277454

Log:
  Add inline implementations of arm bus_space_read/write_N().
  
  Reviewed by:  cognet

Modified:
  head/sys/arm/arm/bus_space-v6.c
  head/sys/arm/include/bus.h

Modified: head/sys/arm/arm/bus_space-v6.c
==============================================================================
--- head/sys/arm/arm/bus_space-v6.c     Tue Jan 20 22:51:29 2015        
(r277453)
+++ head/sys/arm/arm/bus_space-v6.c     Tue Jan 20 22:56:59 2015        
(r277454)
@@ -65,10 +65,10 @@ static struct bus_space _base_tag = {
        generic_bs_barrier,
 
        /* read (single) */
-       generic_bs_r_1,
-       generic_armv4_bs_r_2,
-       generic_bs_r_4,
-       NULL,
+       NULL,   /* bs_r_1, Use inline code in bus.h */
+       NULL,   /* bs_r_2, Use inline code in bus.h */
+       NULL,   /* bs_r_4, Use inline code in bus.h */
+       NULL,   /* bs_r_8, Use inline code in bus.h */
 
        /* read multiple */
        generic_bs_rm_1,
@@ -83,10 +83,10 @@ static struct bus_space _base_tag = {
        NULL,
 
        /* write (single) */
-       generic_bs_w_1,
-       generic_armv4_bs_w_2,
-       generic_bs_w_4,
-       NULL,
+       NULL,   /* bs_w_1, Use inline code in bus.h */
+       NULL,   /* bs_w_2, Use inline code in bus.h */
+       NULL,   /* bs_w_4, Use inline code in bus.h */
+       NULL,   /* bs_w_8, Use inline code in bus.h */
 
        /* write multiple */
        generic_bs_wm_1,
@@ -119,10 +119,10 @@ static struct bus_space _base_tag = {
        NULL,
 
        /* read stream (single) */
-       NULL,
-       NULL,
-       NULL,
-       NULL,
+       NULL,   /* bs_r_1_s, Use inline code in bus.h */ 
+       NULL,   /* bs_r_2_s, Use inline code in bus.h */ 
+       NULL,   /* bs_r_4_s, Use inline code in bus.h */ 
+       NULL,   /* bs_r_8_s, Use inline code in bus.h */ 
 
        /* read multiple stream */
        NULL,
@@ -137,10 +137,10 @@ static struct bus_space _base_tag = {
        NULL,
 
        /* write stream (single) */
-       NULL,
-       NULL,
-       NULL,
-       NULL,
+       NULL,   /* bs_w_1_s, Use inline code in bus.h */ 
+       NULL,   /* bs_w_2_s, Use inline code in bus.h */ 
+       NULL,   /* bs_w_4_s, Use inline code in bus.h */ 
+       NULL,   /* bs_w_8_s, Use inline code in bus.h */ 
 
        /* write multiple stream */
        NULL,

Modified: head/sys/arm/include/bus.h
==============================================================================
--- head/sys/arm/include/bus.h  Tue Jan 20 22:51:29 2015        (r277453)
+++ head/sys/arm/include/bus.h  Tue Jan 20 22:56:59 2015        (r277454)
@@ -252,10 +252,6 @@ struct bus_space {
 #define        __bs_c(a,b)             __CONCAT(a,b)
 #define        __bs_opname(op,size)    __bs_c(__bs_c(__bs_c(bs_,op),_),size)
 
-#define        __bs_rs(sz, t, h, o)                                            
\
-       (*(t)->__bs_opname(r,sz))((t)->bs_cookie, h, o)
-#define        __bs_ws(sz, t, h, o, v)                                         
\
-       (*(t)->__bs_opname(w,sz))((t)->bs_cookie, h, o, v)
 #define        __bs_nonsingle(type, sz, t, h, o, a, c)                         
\
        (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, a, c)
 #define        __bs_set(type, sz, t, h, o, v, c)                               
\
@@ -272,6 +268,28 @@ struct bus_space {
        (*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, a, c)
 
 
+#define __generate_inline_bs_rs(IFN, MBR, TYP)                                 
\
+       static inline TYP                                               \
+       IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)      \
+       {                                                               \
+                                                                       \
+               if (__predict_true(t->MBR == NULL))                     \
+                       return (*(volatile TYP *)(h + o));              \
+               else                                                    \
+                       return (t->MBR(t->bs_cookie, h, o));            \
+       }
+
+#define __generate_inline_bs_ws(IFN, MBR, TYP)                                 
\
+       static inline void                                              \
+       IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, TYP v)\
+       {                                                               \
+                                                                       \
+               if (__predict_true(t->MBR == NULL))                     \
+                       *(volatile TYP *)(h + o) = v;                   \
+               else                                                    \
+                       t->MBR(t->bs_cookie, h, o, v);                  \
+       }
+
 /*
  * Mapping and unmapping operations.
  */
@@ -304,15 +322,15 @@ struct bus_space {
 /*
  * Bus read (single) operations.
  */
-#define        bus_space_read_1(t, h, o)       __bs_rs(1,(t),(h),(o))
-#define        bus_space_read_2(t, h, o)       __bs_rs(2,(t),(h),(o))
-#define        bus_space_read_4(t, h, o)       __bs_rs(4,(t),(h),(o))
-#define        bus_space_read_8(t, h, o)       __bs_rs(8,(t),(h),(o))
-
-#define bus_space_read_stream_1(t, h, o)        __bs_rs_s(1,(t), (h), (o))
-#define bus_space_read_stream_2(t, h, o)        __bs_rs_s(2,(t), (h), (o))
-#define bus_space_read_stream_4(t, h, o)        __bs_rs_s(4,(t), (h), (o))
-#define        bus_space_read_stream_8(t, h, o)        
__bs_rs_s(8,8,(t),(h),(o))
+__generate_inline_bs_rs(bus_space_read_1, bs_r_1, uint8_t);
+__generate_inline_bs_rs(bus_space_read_2, bs_r_2, uint16_t);
+__generate_inline_bs_rs(bus_space_read_4, bs_r_4, uint32_t);
+__generate_inline_bs_rs(bus_space_read_8, bs_r_8, uint64_t);
+
+__generate_inline_bs_rs(bus_space_read_stream_1, bs_r_1_s, uint8_t);           
+__generate_inline_bs_rs(bus_space_read_stream_2, bs_r_2_s, uint16_t);          
+__generate_inline_bs_rs(bus_space_read_stream_4, bs_r_4_s, uint32_t);          
+__generate_inline_bs_rs(bus_space_read_stream_8, bs_r_8_s, uint64_t);          
 
 /*
  * Bus read multiple operations.
@@ -361,15 +379,15 @@ struct bus_space {
 /*
  * Bus write (single) operations.
  */
-#define        bus_space_write_1(t, h, o, v)   __bs_ws(1,(t),(h),(o),(v))
-#define        bus_space_write_2(t, h, o, v)   __bs_ws(2,(t),(h),(o),(v))
-#define        bus_space_write_4(t, h, o, v)   __bs_ws(4,(t),(h),(o),(v))
-#define        bus_space_write_8(t, h, o, v)   __bs_ws(8,(t),(h),(o),(v))
-
-#define        bus_space_write_stream_1(t, h, o, v)    
__bs_ws_s(1,(t),(h),(o),(v))
-#define        bus_space_write_stream_2(t, h, o, v)    
__bs_ws_s(2,(t),(h),(o),(v))
-#define        bus_space_write_stream_4(t, h, o, v)    
__bs_ws_s(4,(t),(h),(o),(v))
-#define        bus_space_write_stream_8(t, h, o, v)    
__bs_ws_s(8,(t),(h),(o),(v))
+__generate_inline_bs_ws(bus_space_write_1, bs_w_1, uint8_t);
+__generate_inline_bs_ws(bus_space_write_2, bs_w_2, uint16_t);
+__generate_inline_bs_ws(bus_space_write_4, bs_w_4, uint32_t);
+__generate_inline_bs_ws(bus_space_write_8, bs_w_8, uint64_t);
+
+__generate_inline_bs_ws(bus_space_write_stream_1, bs_w_1_s, uint8_t);          
 
+__generate_inline_bs_ws(bus_space_write_stream_2, bs_w_2_s, uint16_t);         
 
+__generate_inline_bs_ws(bus_space_write_stream_4, bs_w_4_s, uint32_t);         
 
+__generate_inline_bs_ws(bus_space_write_stream_8, bs_w_8_s, uint64_t);         
 
 
 
 /*
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to