~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c,v 1.16 2002/12/11 17:23:33 dawes Exp $ */
 
2
/*
 
3
 * includes
 
4
 */
 
5
 
 
6
#include "rendition.h"
 
7
#include "v1krisc.h"
 
8
#include "vboard.h"
 
9
#include "vloaduc.h"
 
10
#include "vos.h"
 
11
 
 
12
#if defined(SCO) || defined(SCO325)
 
13
#define PATH_MAX 1024
 
14
#endif
 
15
 
 
16
/* 
 
17
 * global data
 
18
 */
 
19
 
 
20
#include "cscode.h"
 
21
 
 
22
/* Global imported during compile-time */
 
23
static char MICROCODE_DIR [PATH_MAX] = MODULEDIR;
 
24
 
 
25
/*
 
26
 * local function prototypes
 
27
 */
 
28
 
 
29
 
 
30
/*
 
31
 * functions
 
32
 */
 
33
int
 
34
verite_initboard(ScrnInfoPtr pScreenInfo)
 
35
{
 
36
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
37
 
 
38
    IOADDRESS iob=pRendition->board.io_base;
 
39
    vu8 *vmb;
 
40
    vu32 offset;
 
41
    vu8 memendian;
 
42
    int c,pc;
 
43
 
 
44
    /* write "monitor" program to memory */
 
45
    v1k_stop(pScreenInfo);
 
46
    pRendition->board.csucode_base=0x800;
 
47
    memendian=verite_in8(iob+MEMENDIAN);
 
48
    verite_out8(iob+MEMENDIAN, MEMENDIAN_NO);
 
49
 
 
50
    /* Note that CS ucode must wait on address in csucode_base
 
51
     * when initialized for later context switch code to work. */
 
52
 
 
53
    ErrorF("Loading csucode @ 0x%x + 0x800\n", pRendition->board.vmem_base);
 
54
    vmb=pRendition->board.vmem_base;
 
55
    offset=pRendition->board.csucode_base;
 
56
    for (c=0; c<sizeof(csrisc)/sizeof(vu32); c++, offset+=sizeof(vu32))
 
57
        verite_write_memory32(vmb, offset, csrisc[c]);
 
58
 
 
59
    /* Initialize the CS flip semaphore */
 
60
    verite_write_memory32(vmb, 0x7f8, 0);
 
61
    verite_write_memory32(vmb, 0x7fc, 0);
 
62
 
 
63
    /* Run the code we just transfered to the boards memory */
 
64
    /* ... and start accelerator */
 
65
    v1k_flushicache(pScreenInfo);
 
66
 
 
67
    verite_out8(iob + STATEINDEX, STATEINDEX_PC);
 
68
    pc = verite_in32(iob + STATEDATA);
 
69
    v1k_start(pScreenInfo, pRendition->board.csucode_base);
 
70
 
 
71
    /* Get on loading the ucode */
 
72
    verite_out8(iob + STATEINDEX, STATEINDEX_PC);
 
73
 
 
74
    for (c = 0; c < 0xffffffL; c++){
 
75
        v1k_stop(pScreenInfo);
 
76
        pc = verite_in32(iob + STATEDATA);
 
77
        v1k_continue(pScreenInfo);
 
78
        if (pc == pRendition->board.csucode_base)
 
79
            break;
 
80
    }
 
81
    if (pc != pRendition->board.csucode_base){
 
82
        xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
 
83
                   ("VERITE_INITBOARD -- PC != CSUCODEBASE\n"));
 
84
        ErrorF ("RENDITION: PC == 0x%x   --  CSU == 0x%x\n",
 
85
                pc,pRendition->board.csucode_base);
 
86
    }
 
87
 
 
88
    /* reset memory endian */
 
89
    verite_out8(iob+MEMENDIAN, memendian);
 
90
 
 
91
    if (V1000_DEVICE == pRendition->board.chip){
 
92
        c=verite_load_ucfile(pScreenInfo, strcat ((char *)MICROCODE_DIR,"v10002d.uc"));
 
93
    }
 
94
    else {
 
95
        /* V2x00 chip */
 
96
        c=verite_load_ucfile(pScreenInfo, strcat ((char *)MICROCODE_DIR,"v20002d.uc"));
 
97
    }
 
98
 
 
99
    if (c == -1) {
 
100
        xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
 
101
                   ("Microcode loading failed !!!\n"));
 
102
        return 1;
 
103
    }
 
104
 
 
105
    pRendition->board.ucode_entry=c;
 
106
 
 
107
#ifdef DEBUG
 
108
    ErrorF("UCode_Entry == 0x%x\n",pRendition->board.ucode_entry); */
 
109
#endif
 
110
 
 
111
    /* Everything's OK */
 
112
    return 0;
 
113
}
 
114
 
 
115
 
 
116
int
 
117
verite_resetboard(ScrnInfoPtr pScreenInfo)
 
118
{
 
119
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
120
    vu16 iob=pRendition->board.io_base; 
 
121
    vu8 memendian=verite_in8(iob+MEMENDIAN);
 
122
    vu32 crtcctl = verite_in32(iob+CRTCCTL);
 
123
 
 
124
    v1k_softreset(pScreenInfo);
 
125
    verite_out8(iob+MEMENDIAN, memendian);
 
126
    verite_out32(iob+CRTCCTL, crtcctl);
 
127
 
 
128
    return 0;
 
129
}
 
130
 
 
131
int
 
132
verite_getmemorysize(ScrnInfoPtr pScreenInfo)
 
133
{
 
134
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
135
 
 
136
#define PATTERN  0xf5faaf5f
 
137
#define START    0x12345678
 
138
#define ONEMEG   (1024L*1024L)
 
139
    vu32 offset;
 
140
    vu32 pattern;
 
141
    vu32 start;
 
142
    vu8 memendian;
 
143
#ifdef XSERVER
 
144
    vu8 modereg;
 
145
 
 
146
    modereg=verite_in8(pRendition->board.io_base+MODEREG);
 
147
    verite_out8(pRendition->board.io_base+MODEREG, NATIVE_MODE);
 
148
#endif
 
149
 
 
150
    /* no byte swapping */
 
151
    memendian=verite_in8(pRendition->board.io_base+MEMENDIAN);
 
152
    verite_out8(pRendition->board.io_base+MEMENDIAN, MEMENDIAN_NO);
 
153
 
 
154
    /* it looks like the v1000 wraps the memory; but for I'm not sure,
 
155
     * let's test also for non-writable offsets */
 
156
    start=verite_read_memory32(pRendition->board.vmem_base, 0);
 
157
    verite_write_memory32(pRendition->board.vmem_base, 0, START);
 
158
    for (offset=ONEMEG; offset<16*ONEMEG; offset+=ONEMEG) {
 
159
#ifdef DEBUG
 
160
        ErrorF( "Testing %d MB: ", offset/ONEMEG);
 
161
#endif
 
162
        pattern=verite_read_memory32(pRendition->board.vmem_base, offset);
 
163
        if (START == pattern) {
 
164
#ifdef DEBUG
 
165
            ErrorF( "Back at the beginning\n");
 
166
#endif
 
167
            break;    
 
168
        }
 
169
        
 
170
        pattern^=PATTERN;
 
171
        verite_write_memory32(pRendition->board.vmem_base, offset, pattern);
 
172
        
 
173
#ifdef DEBUG
 
174
        ErrorF( "%x <-> %x\n", (int)pattern, 
 
175
                    (int)verite_read_memory32(pRendition->board.vmem_base, offset));
 
176
#endif
 
177
 
 
178
        if (pattern != verite_read_memory32(pRendition->board.vmem_base, offset)) {
 
179
            offset-=ONEMEG;
 
180
            break;    
 
181
        }
 
182
        verite_write_memory32(pRendition->board.vmem_base, offset, pattern^PATTERN);
 
183
    }
 
184
    verite_write_memory32(pRendition->board.vmem_base, 0, start);
 
185
 
 
186
    if (16*ONEMEG <= offset)
 
187
        pRendition->board.mem_size=4*ONEMEG;
 
188
    else 
 
189
            pRendition->board.mem_size=offset;
 
190
 
 
191
    /* restore default byte swapping */
 
192
    verite_out8(pRendition->board.io_base+MEMENDIAN, memendian);
 
193
 
 
194
#ifdef XSERVER
 
195
    verite_out8(pRendition->board.io_base+MODEREG, modereg);
 
196
#endif
 
197
 
 
198
    return pRendition->board.mem_size;
 
199
#undef PATTERN
 
200
#undef ONEMEG
 
201
}
 
202
 
 
203
void
 
204
verite_check_csucode(ScrnInfoPtr pScreenInfo)
 
205
{
 
206
  renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
207
  IOADDRESS iob=pRendition->board.io_base;
 
208
  vu8 *vmb;
 
209
  vu32 offset;
 
210
  int c;
 
211
  int memend;
 
212
  int mismatches=0;
 
213
 
 
214
  memend=verite_in8(iob+MEMENDIAN);
 
215
  verite_out8(iob+MEMENDIAN, MEMENDIAN_NO);
 
216
 
 
217
#ifdef DEBUG
 
218
  ErrorF("Checking presence of csucode @ 0x%x + 0x800\n",
 
219
         pRendition->board.vmem_base);
 
220
 
 
221
  if (0x800 != pRendition->board.csucode_base)
 
222
    ErrorF("pRendition->board.csucode_base == 0x%x\n",
 
223
           pRendition->board.csucode_base);
 
224
#endif
 
225
 
 
226
  /* compare word by word */
 
227
  vmb=pRendition->board.vmem_base;
 
228
  offset=pRendition->board.csucode_base;
 
229
  for (c=0; c<sizeof(csrisc)/sizeof(vu32); c++, offset+=sizeof(vu32))
 
230
    if (csrisc[c] != verite_read_memory32(vmb, offset)) {
 
231
      ErrorF("csucode mismatch in word %02d: 0x%08x should be 0x%08x\n",
 
232
             c,
 
233
             verite_read_memory32(vmb, offset),
 
234
             csrisc[c]);
 
235
      mismatches++;
 
236
    }
 
237
#ifdef DEBUG
 
238
  ErrorF("Encountered %d out of %d possible mismatches\n",
 
239
         mismatches,
 
240
         sizeof(csrisc)/sizeof(vu32));
 
241
#endif
 
242
 
 
243
  verite_out8(iob+MEMENDIAN, memend);
 
244
}
 
245
 
 
246
/*
 
247
 * end of file vboard.c
 
248
 */