Subversion Repositories HelenOS

Rev

Rev 4204 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4204 Rev 4221
Line 12... Line 12...
12
#include <ddi.h>
12
#include <ddi.h>
13
#include <libarch/ddi.h>
13
#include <libarch/ddi.h>
14
 
14
 
15
#include "internal.h"
15
#include "internal.h"
16
 
16
 
-
 
17
#define PCI_CONF1   0xcf8
-
 
18
#define PCI_CONF1_SIZE  8
-
 
19
 
17
 
20
 
18
static void conf12_init(struct pci_access *a)
21
static void conf12_init(struct pci_access *a)
19
{
22
{  
20
}
23
}
21
 
24
 
22
static void conf12_cleanup(struct pci_access *a UNUSED)
25
static void conf12_cleanup(struct pci_access *a UNUSED)
23
{
26
{
24
}
27
}
Line 68... Line 71...
68
 
71
 
69
static int conf1_detect(struct pci_access *a)
72
static int conf1_detect(struct pci_access *a)
70
{
73
{
71
    unsigned int tmp;
74
    unsigned int tmp;
72
    int res = 0;
75
    int res = 0;
-
 
76
   
-
 
77
    /*
-
 
78
     * Gain control over PCI configuration ports.
-
 
79
     */
-
 
80
    void * addr;
-
 
81
    if (pio_enable((void *)PCI_CONF1, PCI_CONF1_SIZE, &addr)) {
-
 
82
        return 0;
-
 
83
    }
73
 
84
 
74
    pio_write_8(0xCFB, 0x01);
85
    pio_write_8(0xCFB, 0x01);
75
    tmp = pio_read_32(0xCF8);
86
    tmp = pio_read_32(0xCF8);
76
    pio_write_32(0xCF8, 0x80000000);
87
    pio_write_32(0xCF8, 0x80000000);
77
    if (pio_read_32(0xCF8) == 0x80000000) {
88
    if (pio_read_32(0xCF8) == 0x80000000) {
Line 140... Line 151...
140
 *  Configuration type 2. Obsolete and brain-damaged, but existing.
151
 *  Configuration type 2. Obsolete and brain-damaged, but existing.
141
 */
152
 */
142
 
153
 
143
static int conf2_detect(struct pci_access *a)
154
static int conf2_detect(struct pci_access *a)
144
{
155
{
-
 
156
    /*
-
 
157
     * Gain control over PCI configuration ports.
-
 
158
     */
-
 
159
    void * addr;
-
 
160
    if (pio_enable((void *)PCI_CONF1, PCI_CONF1_SIZE, &addr)) {
-
 
161
        return 0;
-
 
162
    }
-
 
163
    if (pio_enable((void *)0xC000, 0x1000, &addr)) {
-
 
164
        return 0;
-
 
165
    }  
-
 
166
   
145
    /* This is ugly and tends to produce false positives. Beware. */
167
    /* This is ugly and tends to produce false positives. Beware. */
146
    pio_write_8(0xCFB, 0x00);
168
    pio_write_8(0xCFB, 0x00);
147
    pio_write_8(0xCF8, 0x00);
169
    pio_write_8(0xCF8, 0x00);
148
    pio_write_8(0xCFA, 0x00);
170
    pio_write_8(0xCFA, 0x00);
149
    if (pio_read_8(0xCF8) == 0x00 && pio_read_8(0xCFA) == 0x00)
171
    if (pio_read_8(0xCF8) == 0x00 && pio_read_8(0xCFA) == 0x00)
Line 176... Line 198...
176
        break;
198
        break;
177
    default:
199
    default:
178
        pio_write_8(0xcf8, 0);
200
        pio_write_8(0xcf8, 0);
179
        return pci_generic_block_read(d, pos, buf, len);
201
        return pci_generic_block_read(d, pos, buf, len);
180
    }
202
    }
181
    pio_write_8((void *)0xcf8, 0);
203
    pio_write_8(0xcf8, 0);
182
    return 1;
204
    return 1;
183
}
205
}
184
 
206
 
185
static int conf2_write(struct pci_dev *d, int pos, byte * buf, int len)
207
static int conf2_write(struct pci_dev *d, int pos, byte * buf, int len)
186
{
208
{