Subversion Repositories shark

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1063 tullio 1
 
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
2 pj 19
#include <ll/i386/hw-data.h>
20
#include <ll/i386/mem.h>
21
#include <ll/i386/cons.h>
22
/*
23
#include <ll/i386/x-dos.h>
24
#include <ll/i386/x-dosmem.h>
25
*/
26
#include <ll/sys/ll/ll-func.h>
27
 
28
#include "trident.h"
29
#include "chips.h"
30
 
31
enum {TRIDENT_8800, TRIDENT_8900, TRIDENT_9000, TRIDENT_9200, TRIDENT_9420,
32
    TRIDENT_9680,
33
    TRIDENT_UNKNOWN
34
};
35
 
36
static const char *trident_chipname[] =
37
{"8800", "8900", "9000", "9200", "9420", "9680",
38
 "Unknown Trident chip"};
39
 
40
int trident_chiptype;
41
int trident_flags;
42
int trident_memory;
43
 
44
static int trident_init(int par1, int par2)
45
{
46
    BYTE value;
47
 
48
    outp(0x3D4, 0x1f);
49
        /* this should detect up to 2M memory now */
50
    trident_memory = (inp(0x3D5) & 0x07) * 256 + 256;
51
 
52
    outp(0x3C4, 0x0B);
53
    outp(0x3C5, 0);
54
 
55
    value = inp(0x3C5);
56
 
57
    switch(value) {
58
        case 0x03:
59
        case 0x04:
60
            trident_chiptype = TRIDENT_8900;
61
            break;
62
        case 0x13:
63
        case 0x23:
64
        case 0x93:
65
            trident_chiptype = TRIDENT_9000;
66
            break;
67
        case 0x53:
68
        case 0x83:
69
            trident_chiptype = TRIDENT_9200;
70
            break;
71
        case 0x73:
72
            trident_chiptype = TRIDENT_9420;
73
            break;
74
        case 0xD3:
75
            trident_chiptype = TRIDENT_9680;
76
        default:
77
            trident_chiptype = TRIDENT_UNKNOWN;
78
/*          trident_chiptype = TRIDENT_8800;  */
79
/*          trident_chiptype = TRIDENT_9440;  */
80
            break;
81
    }
82
    return 1;
83
}
84
 
85
 
86
int trident_test(void)
87
{
88
    BYTE old_value, old_misc_value, value, misc_value, power_up_value;
89
    int res;
90
 
91
    res = CHIP_NOT_FOUND;
92
 
93
    outp(0x3CE, 0x06);
94
    old_misc_value = inp(0x3CF);
95
    misc_value = old_misc_value & 0x03;
96
    misc_value |= 0x04;
97
    outp(0x3CF, misc_value);
98
 
99
    outp(0x3C4, 0x0E);
100
    old_value = inp(0x3C5);
101
 
102
    outp(0x3C5, 0x00);
103
 
104
    value = inp(0x3C5) & 0x0F;
105
 
106
    outp(0x3C5, old_value);
107
 
108
    outp(0x3CE, 0x06);
109
    outp(0x3CF, old_misc_value);
110
 
111
    if (value >= 0x02) {
112
        res = CHIP_FOUND;
113
    }else {
114
        outp(0x3C4, 0x0F);
115
        outp(0x3C5, 0x00);
116
 
117
        power_up_value = inp(0x3C5);
118
 
119
        if (power_up_value != 0) {
120
            res = CHIP_FOUND;
121
        }
122
    }
123
    if (res == CHIP_FOUND) {
124
                        trident_init(0,0);
125
                        if (trident_chiptype != TRIDENT_UNKNOWN) {
126
                                        return 1;
127
                        } else {
128
                                        return -1;
129
                        }
130
    }
131
    return res;
132
}
133
 
134
void trident_showinfo()
135
{
136
    cprintf("\t Using Trident driver (%s, %dK).\n",
137
        trident_chipname[trident_chiptype], trident_memory);
138
}
139
 
140
void trident_setpage(int page)
141
{
142
    WORD app;
143
    BYTE bb;
144
 
145
    bb = page;
146
    if ((bb & 0x02) == 0x02) {
147
        bb = (bb & 0xFD);
148
    } else {
149
        bb = (bb | 0x02);
150
    }
151
 
152
/*    outp(0x03C4, 0x0b);
153
    outp(0x03C5, inp(0x03C5));
154
    inp(0x3C5); */
155
 
156
/*    bb = page ^ 0x02;*/
157
 
158
    app = 0x0E || (bb << 8);
159
 
160
outp(0x3C4, 0x0E);
161
outp(0x3C5, bb);
162
/*    outw(0x3C4, app);*/
163
 
164
/*
165
    outp(0x03C4, 0x0b);
166
    outp(0x03C5, inp(0x03C5));
167
    inp(0x3C5);
168
 
169
    outp(0x03C4, 0x0e);
170
    outp(0x03C5, page ^ 0x02);
171
*/
172
}
173
 
174
DWORD trident_getmem(void)
175
{
176
    return trident_memory * 1024;
177
}