Kaynağa Gözat

Add DBGLVL_IO to trace all memory-mapped I/O.

tags/v0.9.4
Michael Brown 17 yıl önce
ebeveyn
işleme
604c934981
2 değiştirilmiş dosya ile 51 ekleme ve 7 silme
  1. 40
    7
      src/arch/i386/include/io.h
  2. 11
    0
      src/include/compiler.h

+ 40
- 7
src/arch/i386/include/io.h Dosyayı Görüntüle

@@ -72,13 +72,46 @@ static inline void iounmap(void *virt_addr __unused)
72 72
  * differently. On the x86 architecture, we just read/write the
73 73
  * memory location directly.
74 74
  */
75
-#define readb(addr) (*(volatile uint8_t *) (addr))
76
-#define readw(addr) (*(volatile uint16_t *) (addr))
77
-#define readl(addr) (*(volatile uint32_t *) (addr))
78
-
79
-#define writeb(b,addr) ((*(volatile uint8_t *) (addr)) = (b))
80
-#define writew(b,addr) ((*(volatile uint16_t *) (addr)) = (b))
81
-#define writel(b,addr) ((*(volatile uint32_t *) (addr)) = (b))
75
+static inline __attribute__ (( always_inline )) unsigned long
76
+_readb ( volatile uint8_t *addr ) {
77
+	unsigned long data = *addr;
78
+	DBGIO ( "[%08lx] => %02lx\n", virt_to_phys ( addr ), data );
79
+	return data;
80
+}
81
+static inline __attribute__ (( always_inline )) unsigned long
82
+_readw ( volatile uint16_t *addr ) {
83
+	unsigned long data = *addr;
84
+	DBGIO ( "[%08lx] => %04lx\n", virt_to_phys ( addr ), data );
85
+	return data;
86
+}
87
+static inline __attribute__ (( always_inline )) unsigned long
88
+_readl ( volatile uint32_t *addr ) {
89
+	unsigned long data = *addr;
90
+	DBGIO ( "[%08lx] => %08lx\n", virt_to_phys ( addr ), data );
91
+	return data;
92
+}
93
+#define readb( addr ) _readb ( ( volatile uint8_t * ) (addr) )
94
+#define readw( addr ) _readw ( ( volatile uint16_t * ) (addr) )
95
+#define readl( addr ) _readl ( ( volatile uint32_t * ) (addr) )
96
+
97
+static inline __attribute__ (( always_inline )) void
98
+_writeb ( unsigned long data, volatile uint8_t *addr ) {
99
+	DBGIO ( "[%08lx] <= %02lx\n", virt_to_phys ( addr ), data );
100
+	*addr = data;
101
+}
102
+static inline __attribute__ (( always_inline )) void
103
+_writew ( unsigned long data, volatile uint16_t *addr ) {
104
+	DBGIO ( "[%08lx] <= %04lx\n", virt_to_phys ( addr ), data );
105
+	*addr = data;
106
+}
107
+static inline __attribute__ (( always_inline )) void
108
+_writel ( unsigned long data, volatile uint32_t *addr ) {
109
+	DBGIO ( "[%08lx] <= %08lx\n", virt_to_phys ( addr ), data );
110
+	*addr = data;
111
+}
112
+#define writeb( b, addr ) _writeb ( (b), ( volatile uint8_t * ) (addr) )
113
+#define writew( b, addr ) _writew ( (b), ( volatile uint16_t * ) (addr) )
114
+#define writel( b, addr ) _writel ( (b), ( volatile uint32_t * ) (addr) )
82 115
 
83 116
 #define memcpy_fromio(a,b,c)	memcpy((a),(void *)(b),(c))
84 117
 #define memcpy_toio(a,b,c)	memcpy((void *)(a),(b),(c))

+ 11
- 0
src/include/compiler.h Dosyayı Görüntüle

@@ -144,6 +144,8 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr,
144 144
 #define DBG_EXTRA	( DBGLVL & DBGLVL_EXTRA )
145 145
 #define DBGLVL_PROFILE	4
146 146
 #define DBG_PROFILE	( DBGLVL & DBGLVL_PROFILE )
147
+#define DBGLVL_IO	8
148
+#define DBG_IO		( DBGLVL & DBGLVL_IO )
147 149
 
148 150
 /**
149 151
  * Print debugging message if we are at a certain debug level
@@ -262,6 +264,15 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr,
262 264
 #define DBGCP_HDA( ... )	DBGC_HDA_IF	( PROFILE, __VA_ARGS__ )
263 265
 #define DBGCP_HD( ... )		DBGC_HD_IF	( PROFILE, __VA_ARGS__ )
264 266
 
267
+/* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( IO, ... )*/
268
+
269
+#define DBGIO( ... )		DBG_IF		( IO, __VA_ARGS__ )
270
+#define DBGIO_HDA( ... )	DBG_HDA_IF	( IO, __VA_ARGS__ )
271
+#define DBGIO_HD( ... )		DBG_HD_IF	( IO, __VA_ARGS__ )
272
+#define DBGCIO( ... )		DBGC_IF		( IO, __VA_ARGS__ )
273
+#define DBGCIO_HDA( ... )	DBGC_HDA_IF	( IO, __VA_ARGS__ )
274
+#define DBGCIO_HD( ... )	DBGC_HD_IF	( IO, __VA_ARGS__ )
275
+
265 276
 
266 277
 #if DEBUG_SYMBOL == 0
267 278
 #define NDEBUG

Loading…
İptal
Kaydet