Subversion Repositories HelenOS

Rev

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

Rev 4428 Rev 4440
Line 70... Line 70...
70
    uint32_t control;
70
    uint32_t control;
71
    uint32_t pad3[3];
71
    uint32_t pad3[3];
72
 
72
 
73
    uint32_t status;
73
    uint32_t status;
74
 
74
 
75
/*  FIXME: Need to fix pio_enable() to support >= page_size areas.
-
 
76
 
-
 
77
    uint32_t pad4[3];
75
    uint32_t pad4[3];
78
    uint32_t pad5[0x3fc0];
76
    uint8_t pad5[0x3fc0];
79
 
77
 
80
    uint8_t buffer[512];*/
78
    uint8_t buffer[512];
81
} gxe_bd_t;
79
} gxe_bd_t;
82
 
80
 
83
typedef struct {
-
 
84
    uint8_t buffer[512];
-
 
85
} gxe_buf_t;
-
 
86
 
81
 
87
static const size_t block_size = 512;
82
static const size_t block_size = 512;
88
static size_t comm_size;
83
static size_t comm_size;
89
 
84
 
90
static uintptr_t dev_physical = 0x13000000;
85
static uintptr_t dev_physical = 0x13000000;
91
static gxe_bd_t *dev;
86
static gxe_bd_t *dev;
92
static gxe_buf_t *devbuf;
-
 
93
 
87
 
94
static uint32_t disk_id = 0;
88
static uint32_t disk_id = 0;
95
 
89
 
96
static atomic_t dev_futex = FUTEX_INITIALIZER;
90
static atomic_t dev_futex = FUTEX_INITIALIZER;
97
 
91
 
Line 133... Line 127...
133
        return rc;
127
        return rc;
134
    }
128
    }
135
 
129
 
136
    dev = vaddr;
130
    dev = vaddr;
137
 
131
 
138
    rc = pio_enable((void *) dev_physical + 0x4000, sizeof(gxe_buf_t), &vaddr);
-
 
139
    if (rc != EOK) {
-
 
140
        printf(NAME ": Could not initialize device I/O space.\n");
-
 
141
        return rc;
-
 
142
    }
-
 
143
 
-
 
144
    devbuf = vaddr;
-
 
145
 
-
 
146
    rc = devmap_device_register("disk0", &dev_handle);
132
    rc = devmap_device_register("disk0", &dev_handle);
147
    if (rc != EOK) {
133
    if (rc != EOK) {
148
        devmap_hangup_phone(DEVMAP_DRIVER);
134
        devmap_hangup_phone(DEVMAP_DRIVER);
149
        printf(NAME ": Unable to register device.\n");
135
        printf(NAME ": Unable to register device.\n");
150
        return rc;
136
        return rc;
Line 250... Line 236...
250
    if (status == STATUS_FAILURE) {
236
    if (status == STATUS_FAILURE) {
251
        return EIO;
237
        return EIO;
252
    }
238
    }
253
 
239
 
254
    for (i = 0; i < size; i++) {
240
    for (i = 0; i < size; i++) {
255
        ((uint8_t *) buf)[i] = w =
-
 
256
            pio_read_8(&devbuf->buffer[i]);
241
        ((uint8_t *) buf)[i] = w = pio_read_8(&dev->buffer[i]);
257
    }
242
    }
258
 
243
 
259
    futex_up(&dev_futex);
244
    futex_up(&dev_futex);
260
    return EOK;
245
    return EOK;
261
}
246
}
Line 265... Line 250...
265
    uint32_t status;
250
    uint32_t status;
266
    size_t i;
251
    size_t i;
267
    uint32_t w;
252
    uint32_t w;
268
 
253
 
269
    for (i = 0; i < size; i++) {
254
    for (i = 0; i < size; i++) {
270
        pio_write_8(&devbuf->buffer[i], ((const uint8_t *) buf)[i]);
255
        pio_write_8(&dev->buffer[i], ((const uint8_t *) buf)[i]);
271
    }
256
    }
272
 
257
 
273
    futex_down(&dev_futex);
258
    futex_down(&dev_futex);
274
    pio_write_32(&dev->offset_lo, (uint32_t) offset);
259
    pio_write_32(&dev->offset_lo, (uint32_t) offset);
275
    pio_write_32(&dev->offset_hi, offset >> 32);
260
    pio_write_32(&dev->offset_hi, offset >> 32);