Skip to contentSkip to conversation

Make mem access function weak in kgdb.c and kgdb.h

PATCH Superseded sonic zhang 2 participants 2 messages Sep 12, 2008 KGDB / KDB /debug_core

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Make mem access function weak in kgdb.c and kgdb.h

L1 instruction memory and MMR memory on blackfin can not be accessed by common functions probe_kernel_read() and probe_kernel_write(). Blackfin asks for 2/4 byte align access to MMR memory and DMA access to L1 instruction memory. These functions need to be reimplemented in architecture specific kgdb.c. Update documentation and prototypes as well.

---
 include/linux/kgdb.h |   42 ++++++++++++++++++++++++++++++++++++++++--
 kernel/kgdb.c        |    6 +++---
 2 files changed, 43 insertions(+), 5 deletions(-)
include/linux/kgdb.h +40 -2
index 8fdd3cb..cb8a3d6 100644
@@ -267,8 +267,46 @@ extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops);
 extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops);
 
 extern int kgdb_hex2long(char **ptr, unsigned long *long_val);
-extern int kgdb_mem2hex(char *mem, char *buf, int count);
-extern int kgdb_hex2mem(char *buf, char *mem, int count);
+
+/**
+ *      kgdb_mem2hex - (optional arch overide) traslate bin to hex chars
+ *      @mem: source buffer
+ *      @buf: target buffer
+ *      @count: number of bytes in mem
+ *
+ *      Archictures which do not support probe_kernel_(read|write),
+ *      can make an alternate implmentation of this function.
+ *      This function safely reads memory into hex
+ *      characters for use with the kgdb protocol.
+ */
+extern int __weak kgdb_mem2hex(char *mem, char *buf, int count);
+
+/**
+ *      kgdb_hex2mem - (optional arch overide) traslate hex chars to bin
+ *      @buf: source buffer
+ *      @mem: target buffer
+ *      @count: number of bytes in mem
+ *
+ *      Archictures which do not support probe_kernel_(read|write),
+ *      can make an alternate implmentation of this function.
+ *      This function safely writes hex characters into memory
+ *      for use with the kgdb protocol.
+ */
+extern int __weak kgdb_hex2mem(char *buf, char *mem, int count);
+
+/**
+ *      kgdb_ebin2mem - (optional arch overide) Copy the binary array
+ *	pointed to by buf into mem.
+ *      @buf: source buffer
+ *      @mem: target buffer
+ *      @count: number of bytes in mem
+ *
+ *      Archictures which do not support probe_kernel_(read|write),
+ *      can make an alternate implmentation of this function.
+ *      This function safely copys binary array into memory
+ *      for use with the kgdb protocol.
+ */
+extern int __weak kgdb_ebin2mem(char *buf, char *mem, int count);
 
 extern int kgdb_isremovedbreak(unsigned long addr);
 
kernel/kgdb.c +3 -3
index c803730..aae578e 100644
@@ -364,7 +364,7 @@ static void put_packet(char *buffer)
  * Convert the memory pointed to by mem into hex, placing result in buf.
  * Return a pointer to the last char put in buf (null). May return an error.
  */
-int kgdb_mem2hex(char *mem, char *buf, int count)
+int __weak kgdb_mem2hex(char *mem, char *buf, int count)
 {
 	char *tmp;
 	int err;
@@ -394,7 +394,7 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
  * 0x7d escaped with 0x7d.  Return a pointer to the character after
  * the last byte written.
  */
-static int kgdb_ebin2mem(char *buf, char *mem, int count)
+int __weak kgdb_ebin2mem(char *buf, char *mem, int count)
 {
 	int err = 0;
 	char c;
@@ -419,7 +419,7 @@ static int kgdb_ebin2mem(char *buf, char *mem, int count)
  * Return a pointer to the character AFTER the last byte written.
  * May return an error.
  */
-int kgdb_hex2mem(char *buf, char *mem, int count)
+int __weak kgdb_hex2mem(char *buf, char *mem, int count)
 {
 	char *tmp_raw;
 	char *tmp_hex;
Signature · 1 line
1.6.0
#1 lore raw

On Fri, Sep 12, 2008 at 01:39, sonic zhang wrote:

bunch of typos in the comments ...

Quoted 1 line

+ * kgdb_mem2hex - (optional arch overide) traslate bin to hex chars

override / translate

Quoted 1 line

+ * Archictures which do not support probe_kernel_(read|write),

Architectures

Quoted 1 line

+ * can make an alternate implmentation of this function.

implementation

Quoted 1 line

+ * kgdb_hex2mem - (optional arch overide) traslate hex chars to bin

override / translate

Quoted 1 line

+ * Archictures which do not support probe_kernel_(read|write),

Architectures

Quoted 1 line

+ * can make an alternate implmentation of this function.

implementation

Quoted 1 line

+ * kgdb_ebin2mem - (optional arch overide) Copy the binary array

override

Quoted 1 line

+ * Archictures which do not support probe_kernel_(read|write),

Architectures

Quoted 1 line

+ * can make an alternate implmentation of this function.

implementation

Quoted 1 line

+ * This function safely copys binary array into memory

copies
-mike