5 * Kernel Debugger Architecture Dependent Global Headers
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
15 * KDB_ENTER() is a macro which causes entry into the kernel
16 * debugger from any point in the kernel code stream. If it
17 * is intended to be used from interrupt level, it must use
18 * a non-maskable entry method. The vector is KDB_VECTOR,
21 #define KDB_ENTER() do {if (kdb_on && !KDB_IS_RUNNING()) { asm("\tint $249\n"); }} while(0)
24 * Needed for exported symbols.
26 typedef unsigned long kdb_machreg_t;
28 #define kdb_machreg_fmt "0x%lx"
29 #define kdb_machreg_fmt0 "0x%016lx"
30 #define kdb_bfd_vma_fmt "0x%lx"
31 #define kdb_bfd_vma_fmt0 "0x%016lx"
32 #define kdb_elfw_addr_fmt "0x%x"
33 #define kdb_elfw_addr_fmt0 "0x%016x"
36 * Per cpu arch specific kdb state. Must be in range 0xff000000.
38 #define KDB_STATE_A_IF 0x01000000 /* Saved IF flag */
41 * Functions to safely read and write kernel areas. The {to,from}_xxx
42 * addresses are not necessarily valid, these functions must check for
43 * validity. If the arch already supports get and put routines with
44 * suitable validation and/or recovery on invalid addresses then use
45 * those routines, otherwise check it yourself.
49 * asm-i386 uaccess.h supplies __copy_to_user which relies on MMU to
50 * trap invalid addresses in the _xxx fields. Verify the other address
51 * of the pair is valid by accessing the first and last byte ourselves,
52 * then any access violations should only be caused by the _xxx
56 #include <asm/uaccess.h>
59 __kdba_putarea_size(unsigned long to_xxx, void *from, size_t size)
61 mm_segment_t oldfs = get_fs();
64 c = *((volatile char *)from);
65 c = *((volatile char *)from + size - 1);
67 if (to_xxx < PAGE_OFFSET) {
68 return kdb_putuserarea_size(to_xxx, from, size);
72 r = __copy_to_user((void *)to_xxx, from, size);
78 __kdba_getarea_size(void *to, unsigned long from_xxx, size_t size)
80 mm_segment_t oldfs = get_fs();
82 *((volatile char *)to) = '\0';
83 *((volatile char *)to + size - 1) = '\0';
85 if (from_xxx < PAGE_OFFSET) {
86 return kdb_getuserarea_size(to, from_xxx, size);
90 r = __copy_to_user(to, (void *)from_xxx, size);
95 /* For numa with replicated code/data, the platform must supply its own
96 * kdba_putarea_size and kdba_getarea_size routines. Without replication kdb
97 * uses the standard architecture routines.
99 #ifdef CONFIG_NUMA_REPLICATE
100 extern int kdba_putarea_size(unsigned long to_xxx, void *from, size_t size);
101 extern int kdba_getarea_size(void *to, unsigned long from_xxx, size_t size);
103 #define kdba_putarea_size __kdba_putarea_size
104 #define kdba_getarea_size __kdba_getarea_size
108 kdba_verify_rw(unsigned long addr, size_t size)
110 unsigned char data[size];
111 return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, data, size));
114 static inline unsigned long
115 kdba_funcptr_value(void *fp)
117 return (unsigned long)fp;
120 #endif /* !_ASM_KDB_H */