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.
20 #include <asm/kdb_break.h> /* break numbers are separated for CONFIG_KDB_LOCK */
21 #define KDB_ENTER2(b) asm("\tbreak "#b"\n")
22 #define KDB_ENTER1(b) KDB_ENTER2(b)
23 #define KDB_ENTER() do {if (kdb_on && !KDB_IS_RUNNING()) { KDB_ENTER1(KDB_BREAK_ENTER); }} while(0)
26 * Needed for exported symbols.
28 typedef unsigned long kdb_machreg_t;
30 #define kdb_machreg_fmt "0x%lx"
31 #define kdb_machreg_fmt0 "0x%016lx"
32 #define kdb_bfd_vma_fmt "0x%lx"
33 #define kdb_bfd_vma_fmt0 "0x%016lx"
34 #define kdb_elfw_addr_fmt "0x%lx"
35 #define kdb_elfw_addr_fmt0 "0x%016lx"
38 * Functions to safely read and write kernel areas. The {to,from}_xxx
39 * addresses are not necessarily valid, these functions must check for
40 * validity. If the arch already supports get and put routines with
41 * suitable validation and/or recovery on invalid addresses then use
42 * those routines, otherwise check it yourself.
46 * asm-ia64 uaccess.h supplies __copy_to_user which relies on MMU to
47 * trap invalid addresses in the _xxx fields. Verify the other address
48 * of the pair is valid by accessing the first and last byte ourselves,
49 * then any access violations should only be caused by the _xxx
53 #include <asm/uaccess.h>
56 __kdba_putarea_size(unsigned long to_xxx, void *from, size_t size)
58 mm_segment_t oldfs = get_fs();
61 c = *((volatile char *)from);
62 c = *((volatile char *)from + size - 1);
64 if (to_xxx >> 61 <= 4) {
65 return kdb_putuserarea_size(to_xxx, from, size);
68 #ifdef VPERNODE_BASE /* if present, the new CONFIG_NUMA code */
69 if (to_xxx >= VPERNODE_BASE && to_xxx < VGLOBAL_BASE) {
70 to_xxx = ia64_imva(to_xxx);
74 r = __copy_to_user((void *)to_xxx, from, size);
80 __kdba_getarea_size(void *to, unsigned long from_xxx, size_t size)
82 mm_segment_t oldfs = get_fs();
84 *((volatile char *)to) = '\0';
85 *((volatile char *)to + size - 1) = '\0';
87 if (from_xxx >> 61 <= 4) {
88 return kdb_getuserarea_size(to, from_xxx, size);
94 r = __copy_to_user(to, (void *)from_xxx, 1);
97 r = __copy_to_user(to, (void *)from_xxx, 2);
100 r = __copy_to_user(to, (void *)from_xxx, 4);
103 r = __copy_to_user(to, (void *)from_xxx, 8);
106 r = __copy_to_user(to, (void *)from_xxx, size);
113 /* For numa with replicated code/data, the platform must supply its own
114 * kdba_putarea_size and kdba_getarea_size routines. Without replication kdb
115 * uses the standard architecture routines.
117 #ifdef CONFIG_NUMA_REPLICATE
118 extern int kdba_putarea_size(unsigned long to_xxx, void *from, size_t size);
119 extern int kdba_getarea_size(void *to, unsigned long from_xxx, size_t size);
121 #define kdba_putarea_size __kdba_putarea_size
122 #define kdba_getarea_size __kdba_getarea_size
126 kdba_verify_rw(unsigned long addr, size_t size)
128 unsigned char data[size];
129 return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, data, size));
132 static inline unsigned long
133 kdba_funcptr_value(void *fp)
135 /* ia64 function descriptor, first word is address of code */
136 return *(unsigned long *)fp;
139 #endif /* !_ASM_KDB_H */