Drop obsoleted patch.
[linux-flexiantxendom0-3.2.10.git] / include / asm-ia64 / kdb.h
1 #ifndef _ASM_KDB_H
2 #define _ASM_KDB_H
3
4 /*
5  * Kernel Debugger Architecture Dependent Global Headers
6  *
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
9  * for more details.
10  *
11  * Copyright (c) 1999-2004 Silicon Graphics, Inc.  All Rights Reserved.
12  */
13
14 /*
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.
19  */
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)
24
25         /*
26          * Needed for exported symbols.
27          */
28 typedef unsigned long kdb_machreg_t;
29
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"
36
37 /*
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.
43  */
44
45 /*
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
50  * addresses,
51  */
52
53 #include <asm/uaccess.h>
54
55 static inline int
56 __kdba_putarea_size(unsigned long to_xxx, void *from, size_t size)
57 {
58         mm_segment_t oldfs = get_fs();
59         int r;
60         char c;
61         c = *((volatile char *)from);
62         c = *((volatile char *)from + size - 1);
63
64         if (to_xxx >> 61 <= 4) {
65                 return kdb_putuserarea_size(to_xxx, from, size);
66         }
67
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);
71         }
72 #endif
73         set_fs(KERNEL_DS);
74         r = __copy_to_user((void *)to_xxx, from, size);
75         set_fs(oldfs);
76         return r;
77 }
78
79 static inline int
80 __kdba_getarea_size(void *to, unsigned long from_xxx, size_t size)
81 {
82         mm_segment_t oldfs = get_fs();
83         int r;
84         *((volatile char *)to) = '\0';
85         *((volatile char *)to + size - 1) = '\0';
86
87         if (from_xxx >> 61 <= 4) {
88                 return kdb_getuserarea_size(to, from_xxx, size);
89         }
90
91         set_fs(KERNEL_DS);
92         switch (size) {
93         case 1:
94                 r = __copy_to_user(to, (void *)from_xxx, 1);
95                 break;
96         case 2:
97                 r = __copy_to_user(to, (void *)from_xxx, 2);
98                 break;
99         case 4:
100                 r = __copy_to_user(to, (void *)from_xxx, 4);
101                 break;
102         case 8:
103                 r = __copy_to_user(to, (void *)from_xxx, 8);
104                 break;
105         default:
106                 r = __copy_to_user(to, (void *)from_xxx, size);
107                 break;
108         }
109         set_fs(oldfs);
110         return r;
111 }
112
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.
116  */
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);
120 #else
121 #define kdba_putarea_size __kdba_putarea_size
122 #define kdba_getarea_size __kdba_getarea_size
123 #endif
124
125 static inline int
126 kdba_verify_rw(unsigned long addr, size_t size)
127 {
128         unsigned char data[size];
129         return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, data, size));
130 }
131
132 static inline unsigned long
133 kdba_funcptr_value(void *fp)
134 {
135         /* ia64 function descriptor, first word is address of code */
136         return *(unsigned long *)fp;
137 }
138
139 #endif  /* !_ASM_KDB_H */