Subversion Repositories shark

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
#include <ll/i386/hw-data.h>
2
#include <ll/i386/mem.h>
3
#include <ll/i386/cons.h>
4
/*
5
#include <ll/i386/x-dos.h>
6
#include <ll/i386/x-dosmem.h>
7
*/
8
#include <ll/sys/ll/ll-func.h>
9
 
10
#include "trident.h"
11
#include "chips.h"
12
 
13
enum {TRIDENT_8800, TRIDENT_8900, TRIDENT_9000, TRIDENT_9200, TRIDENT_9420,
14
    TRIDENT_9680,
15
    TRIDENT_UNKNOWN
16
};
17
 
18
static const char *trident_chipname[] =
19
{"8800", "8900", "9000", "9200", "9420", "9680",
20
 "Unknown Trident chip"};
21
 
22
int trident_chiptype;
23
int trident_flags;
24
int trident_memory;
25
 
26
static int trident_init(int par1, int par2)
27
{
28
    BYTE value;
29
 
30
    outp(0x3D4, 0x1f);
31
        /* this should detect up to 2M memory now */
32
    trident_memory = (inp(0x3D5) & 0x07) * 256 + 256;
33
 
34
    outp(0x3C4, 0x0B);
35
    outp(0x3C5, 0);
36
 
37
    value = inp(0x3C5);
38
 
39
    switch(value) {
40
        case 0x03:
41
        case 0x04:
42
            trident_chiptype = TRIDENT_8900;
43
            break;
44
        case 0x13:
45
        case 0x23:
46
        case 0x93:
47
            trident_chiptype = TRIDENT_9000;
48
            break;
49
        case 0x53:
50
        case 0x83:
51
            trident_chiptype = TRIDENT_9200;
52
            break;
53
        case 0x73:
54
            trident_chiptype = TRIDENT_9420;
55
            break;
56
        case 0xD3:
57
            trident_chiptype = TRIDENT_9680;
58
        default:
59
            trident_chiptype = TRIDENT_UNKNOWN;
60
/*          trident_chiptype = TRIDENT_8800;  */
61
/*          trident_chiptype = TRIDENT_9440;  */
62
            break;
63
    }
64
    return 1;
65
}
66
 
67
 
68
int trident_test(void)
69
{
70
    BYTE old_value, old_misc_value, value, misc_value, power_up_value;
71
    int res;
72
 
73
    res = CHIP_NOT_FOUND;
74
 
75
    outp(0x3CE, 0x06);
76
    old_misc_value = inp(0x3CF);
77
    misc_value = old_misc_value & 0x03;
78
    misc_value |= 0x04;
79
    outp(0x3CF, misc_value);
80
 
81
    outp(0x3C4, 0x0E);
82
    old_value = inp(0x3C5);
83
 
84
    outp(0x3C5, 0x00);
85
 
86
    value = inp(0x3C5) & 0x0F;
87
 
88
    outp(0x3C5, old_value);
89
 
90
    outp(0x3CE, 0x06);
91
    outp(0x3CF, old_misc_value);
92
 
93
    if (value >= 0x02) {
94
        res = CHIP_FOUND;
95
    }else {
96
        outp(0x3C4, 0x0F);
97
        outp(0x3C5, 0x00);
98
 
99
        power_up_value = inp(0x3C5);
100
 
101
        if (power_up_value != 0) {
102
            res = CHIP_FOUND;
103
        }
104
    }
105
    if (res == CHIP_FOUND) {
106
                        trident_init(0,0);
107
                        if (trident_chiptype != TRIDENT_UNKNOWN) {
108
                                        return 1;
109
                        } else {
110
                                        return -1;
111
                        }
112
    }
113
    return res;
114
}
115
 
116
void trident_showinfo()
117
{
118
    cprintf("\t Using Trident driver (%s, %dK).\n",
119
        trident_chipname[trident_chiptype], trident_memory);
120
}
121
 
122
void trident_setpage(int page)
123
{
124
    WORD app;
125
    BYTE bb;
126
 
127
    bb = page;
128
    if ((bb & 0x02) == 0x02) {
129
        bb = (bb & 0xFD);
130
    } else {
131
        bb = (bb | 0x02);
132
    }
133
 
134
/*    outp(0x03C4, 0x0b);
135
    outp(0x03C5, inp(0x03C5));
136
    inp(0x3C5); */
137
 
138
/*    bb = page ^ 0x02;*/
139
 
140
    app = 0x0E || (bb << 8);
141
 
142
outp(0x3C4, 0x0E);
143
outp(0x3C5, bb);
144
/*    outw(0x3C4, app);*/
145
 
146
/*
147
    outp(0x03C4, 0x0b);
148
    outp(0x03C5, inp(0x03C5));
149
    inp(0x3C5);
150
 
151
    outp(0x03C4, 0x0e);
152
    outp(0x03C5, page ^ 0x02);
153
*/
154
}
155
 
156
DWORD trident_getmem(void)
157
{
158
    return trident_memory * 1024;
159
}