Chop out more dead code.
[mesa.git] / src / mesa / drivers / dri / sis / sis_debug.c
1 /**************************************************************************
2
3 Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
4 All Rights Reserved.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sub license, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
13
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial portions
16 of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 IN NO EVENT SHALL SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR
22 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **************************************************************************/
27 /* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_debug.c,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
28
29 /*
30 * Authors:
31 * Sung-Ching Lin <sclin@sis.com.tw>
32 *
33 */
34
35 /*
36 * dump HW states, set environment variable SIS_DEBUG
37 * to enable these functions
38 */
39
40 #include <fcntl.h>
41 #include <assert.h>
42
43 #include "sis_context.h"
44
45 /* for SiS 300/630/540 */
46 #define MMIOLength (0x8FFF-0x8800+1)
47 #define MMIO3DOffset (0x8800)
48 #define FILE_NAME "300.dump"
49
50 char *IOBase4Debug = 0;
51
52 char *prevLockFile = NULL;
53 int prevLockLine = 0;
54
55 GLint _empty[0x10000];
56
57 void
58 dump_agp (void *addr, int dword_count)
59 {
60 if (!getenv ("SIS_DEBUG"))
61 return;
62
63 {
64 int i;
65 FILE *file = fopen ("300agp.dump", "w");
66
67 if (file)
68 {
69 for (i = 0; i < dword_count; i++)
70 {
71 fprintf (file, "%f\n", *(float *) addr);
72 ((unsigned char *) addr) += 4;
73 }
74 fclose (file);
75 }
76 }
77 }
78
79 void
80 d2f_once (GLcontext * ctx)
81 {
82 XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
83 sisContextPtr smesa = SIS_CONTEXT(ctx);
84
85 static int serialNumber = -1;
86
87 if (serialNumber == smesa->serialNumber)
88 return;
89 else
90 serialNumber = smesa->serialNumber;
91
92 d2f();
93 }
94
95 void
96 d2f (void)
97 {
98 if (!getenv ("SIS_DEBUG"))
99 return;
100
101 /* dump 0x8800 - 0x8AFF */
102 {
103 int fh;
104 int rval;
105 void *addr = IOBase4Debug + MMIO3DOffset;
106
107 assert (IOBase4Debug);
108
109 if ((fh = open (FILE_NAME, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
110 {
111 rval = write (fh, addr, MMIOLength);
112 assert (rval != -1);
113 close (fh);
114 }
115 }
116 }
117
118 /* dump to HW */
119 void
120 d2h (char *file_name)
121 {
122 int fh;
123 int rval;
124 void *addr[MMIOLength];
125
126 if (!getenv ("SIS_DEBUG"))
127 return;
128
129 if ((fh = open (file_name, O_CREAT, S_IREAD | S_IWRITE)) != -1)
130 {
131 rval = read (fh, addr, MMIOLength);
132 assert (rval != -1);
133 close (fh);
134 }
135 memcpy (IOBase4Debug + MMIO3DOffset, addr, MMIOLength);
136
137 }
138
139 /* dump video memory to file */
140 void
141 dvidmem (unsigned char *addr, int size)
142 {
143 int fh;
144 int rval;
145 static char *file_name = "vidmem.dump";
146
147 if (!getenv ("SIS_DEBUG"))
148 return;
149
150 if ((fh = open (file_name, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
151 {
152 rval = write (fh, addr, size);
153 assert (rval != -1);
154 close (fh);
155 }
156 }