ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ia64 / sn / fakeprom / make_textsym
1 #!/bin/sh
2 #
3 # Build a textsym file for use in the Arium ITP probe.
4 #
5 #
6 # This file is subject to the terms and conditions of the GNU General Public
7 # License.  See the file "COPYING" in the main directory of this archive
8 # for more details.
9 #
10 # Copyright (c) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
11 #
12
13 help() {
14 cat <<END
15 Build a WinDD "symtxt" file for use with the Arium ECM-30 probe.
16
17         Usage: $0 [<vmlinux file> [<output file>]]
18                 If no input file is specified, it defaults to vmlinux.
19                 If no output file name is specified, it defaults to "textsym".
20 END
21 exit 1
22 }
23
24 err () {
25         echo "ERROR - $*" >&2
26         exit 1
27 }
28
29
30 OPTS="H"
31 while getopts "$OPTS" c ; do
32         case $c in
33                 H)  help;;
34                 \?) help;;
35         esac
36
37 done
38 shift `expr $OPTIND - 1`
39
40 #OBJDUMP=/usr/bin/ia64-linux-objdump
41 LINUX=${1:-vmlinux}
42 TEXTSYM=${2:-${LINUX}.sym}
43 TMPSYM=${2:-${LINUX}.sym.tmp}
44 trap "/bin/rm -f $TMPSYM" 0
45
46 [ -f $VMLINUX ] || help
47
48 $OBJDUMP -t $LINUX | egrep -v '__ks' | sort > $TMPSYM
49 SN1=`egrep "dig_setup|Synergy_da_indr" $TMPSYM|wc -l`
50
51 # Dataprefix and textprefix correspond to the VGLOBAL_BASE and VPERNODE_BASE.
52 # Eventually, these values should be:
53 #       dataprefix      ffffffff
54 #       textprefix      fffffffe
55 # but right now they're still changing, so make them dynamic.
56 dataprefix=`awk ' / \.data      / { print substr($1, 0, 8) ; exit ; }' $TMPSYM`
57 textprefix=`awk ' / \.text      / { print substr($1, 0, 8) ; exit ; }' $TMPSYM`
58
59 # pipe everything thru sort
60 echo "TEXTSYM V1.0"
61 (cat <<END 
62 GLOBAL | ${textprefix}00000000 | CODE | VEC_VHPT_Translation_0000
63 GLOBAL | ${textprefix}00000400 | CODE | VEC_ITLB_0400
64 GLOBAL | ${textprefix}00000800 | CODE | VEC_DTLB_0800
65 GLOBAL | ${textprefix}00000c00 | CODE | VEC_Alt_ITLB_0c00
66 GLOBAL | ${textprefix}00001000 | CODE | VEC_Alt_DTLB_1000
67 GLOBAL | ${textprefix}00001400 | CODE | VEC_Data_nested_TLB_1400
68 GLOBAL | ${textprefix}00001800 | CODE | VEC_Instruction_Key_Miss_1800
69 GLOBAL | ${textprefix}00001c00 | CODE | VEC_Data_Key_Miss_1c00
70 GLOBAL | ${textprefix}00002000 | CODE | VEC_Dirty-bit_2000
71 GLOBAL | ${textprefix}00002400 | CODE | VEC_Instruction_Access-bit_2400
72 GLOBAL | ${textprefix}00002800 | CODE | VEC_Data_Access-bit_2800
73 GLOBAL | ${textprefix}00002c00 | CODE | VEC_Break_instruction_2c00
74 GLOBAL | ${textprefix}00003000 | CODE | VEC_External_Interrupt_3000
75 GLOBAL | ${textprefix}00003400 | CODE | VEC_Reserved_3400
76 GLOBAL | ${textprefix}00003800 | CODE | VEC_Reserved_3800
77 GLOBAL | ${textprefix}00003c00 | CODE | VEC_Reserved_3c00
78 GLOBAL | ${textprefix}00004000 | CODE | VEC_Reserved_4000
79 GLOBAL | ${textprefix}00004400 | CODE | VEC_Reserved_4400
80 GLOBAL | ${textprefix}00004800 | CODE | VEC_Reserved_4800
81 GLOBAL | ${textprefix}00004c00 | CODE | VEC_Reserved_4c00
82 GLOBAL | ${textprefix}00005000 | CODE | VEC_Page_Not_Present_5000
83 GLOBAL | ${textprefix}00005100 | CODE | VEC_Key_Permission_5100
84 GLOBAL | ${textprefix}00005200 | CODE | VEC_Instruction_Access_Rights_5200
85 GLOBAL | ${textprefix}00005300 | CODE | VEC_Data_Access_Rights_5300
86 GLOBAL | ${textprefix}00005400 | CODE | VEC_General_Exception_5400
87 GLOBAL | ${textprefix}00005500 | CODE | VEC_Disabled_FP-Register_5500
88 GLOBAL | ${textprefix}00005600 | CODE | VEC_Nat_Consumption_5600
89 GLOBAL | ${textprefix}00005700 | CODE | VEC_Speculation_5700
90 GLOBAL | ${textprefix}00005800 | CODE | VEC_Reserved_5800
91 GLOBAL | ${textprefix}00005900 | CODE | VEC_Debug_5900
92 GLOBAL | ${textprefix}00005a00 | CODE | VEC_Unaligned_Reference_5a00
93 GLOBAL | ${textprefix}00005b00 | CODE | VEC_Unsupported_Data_Reference_5b00
94 GLOBAL | ${textprefix}00005c00 | CODE | VEC_Floating-Point_Fault_5c00
95 GLOBAL | ${textprefix}00005d00 | CODE | VEC_Floating_Point_Trap_5d00
96 GLOBAL | ${textprefix}00005e00 | CODE | VEC_Lower_Privilege_Tranfer_Trap_5e00
97 GLOBAL | ${textprefix}00005f00 | CODE | VEC_Taken_Branch_Trap_5f00
98 GLOBAL | ${textprefix}00006000 | CODE | VEC_Single_Step_Trap_6000
99 GLOBAL | ${textprefix}00006100 | CODE | VEC_Reserved_6100
100 GLOBAL | ${textprefix}00006200 | CODE | VEC_Reserved_6200
101 GLOBAL | ${textprefix}00006300 | CODE | VEC_Reserved_6300
102 GLOBAL | ${textprefix}00006400 | CODE | VEC_Reserved_6400
103 GLOBAL | ${textprefix}00006500 | CODE | VEC_Reserved_6500
104 GLOBAL | ${textprefix}00006600 | CODE | VEC_Reserved_6600
105 GLOBAL | ${textprefix}00006700 | CODE | VEC_Reserved_6700
106 GLOBAL | ${textprefix}00006800 | CODE | VEC_Reserved_6800
107 GLOBAL | ${textprefix}00006900 | CODE | VEC_IA-32_Exeception_6900
108 GLOBAL | ${textprefix}00006a00 | CODE | VEC_IA-32_Intercept_6a00
109 GLOBAL | ${textprefix}00006b00 | CODE | VEC_IA-32_Interrupt_6b00
110 GLOBAL | ${textprefix}00006c00 | CODE | VEC_Reserved_6c00
111 GLOBAL | ${textprefix}00006d00 | CODE | VEC_Reserved_6d00
112 GLOBAL | ${textprefix}00006e00 | CODE | VEC_Reserved_6e00
113 GLOBAL | ${textprefix}00006f00 | CODE | VEC_Reserved_6f00
114 GLOBAL | ${textprefix}00007000 | CODE | VEC_Reserved_7000
115 GLOBAL | ${textprefix}00007100 | CODE | VEC_Reserved_7100
116 GLOBAL | ${textprefix}00007200 | CODE | VEC_Reserved_7200
117 GLOBAL | ${textprefix}00007300 | CODE | VEC_Reserved_7300
118 GLOBAL | ${textprefix}00007400 | CODE | VEC_Reserved_7400
119 GLOBAL | ${textprefix}00007500 | CODE | VEC_Reserved_7500
120 GLOBAL | ${textprefix}00007600 | CODE | VEC_Reserved_7600
121 GLOBAL | ${textprefix}00007700 | CODE | VEC_Reserved_7700
122 GLOBAL | ${textprefix}00007800 | CODE | VEC_Reserved_7800
123 GLOBAL | ${textprefix}00007900 | CODE | VEC_Reserved_7900
124 GLOBAL | ${textprefix}00007a00 | CODE | VEC_Reserved_7a00
125 GLOBAL | ${textprefix}00007b00 | CODE | VEC_Reserved_7b00
126 GLOBAL | ${textprefix}00007c00 | CODE | VEC_Reserved_7c00
127 GLOBAL | ${textprefix}00007d00 | CODE | VEC_Reserved_7d00
128 GLOBAL | ${textprefix}00007e00 | CODE | VEC_Reserved_7e00
129 GLOBAL | ${textprefix}00007f00 | CODE | VEC_Reserved_7f00
130 END
131
132
133 awk '
134 / _start$/ {start=1}
135 / start_ap$/ {start=1}
136 /__start_gate_section/ {start=1}
137 /^'${dataprefix}\|${textprefix}'/ {
138         if ($4 == ".kdb")
139                 next
140         if (start && substr($NF,1,1) != "0") {
141                 type = substr($0,26,5)
142                 if (type == ".text")
143                         printf "GLOBAL | %s | CODE | %s\n", $1, $NF
144                 else {
145                         n = 0
146                         s = $(NF-1)
147                         while (length(s) > 0) {
148                                 n = n*16 + (index("0123456789abcdef", substr(s,1,1)) - 1)
149                                 s = substr(s,2)
150                         }
151                         printf "GLOBAL | %s | DATA | %s | %d\n", $1, $NF, n
152                 }
153         }
154         if($NF == "_end") 
155                 exit
156
157 }
158 ' $TMPSYM ) | egrep -v " __device| __vendor" | awk -v sn1="$SN1" '
159 /GLOBAL/ {
160         print $0
161         if (sn1 != 0) {
162                 /* 32 bits of sn1 physical addrs, */
163                 print substr($0,1,9) "04" substr($0,20,16) "Phy_" substr($0,36)
164         } else {
165                 /* 38 bits of sn2 physical addrs, need addr space bits */
166                 print substr($0,1,9) "3004" substr($0,20,16) "Phy_" substr($0,36)
167         }
168
169 } ' | sort -k3
170
171 N=`wc -l $TEXTSYM|awk '{print $1}'`
172 echo "Generated TEXTSYM file" >&2
173 echo "  $LINUX --> $TEXTSYM" >&2
174 echo "  Found $N symbols" >&2