Rev 4530 | Rev 4532 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4530 | Rev 4531 | ||
---|---|---|---|
Line 66... | Line 66... | ||
66 | 66 | ||
67 | static dev_handle_t dev_handle[MAX_DISKS]; |
67 | static dev_handle_t dev_handle[MAX_DISKS]; |
68 | 68 | ||
69 | static atomic_t dev_futex = FUTEX_INITIALIZER; |
69 | static atomic_t dev_futex = FUTEX_INITIALIZER; |
70 | 70 | ||
71 | static disk_t disk[2]; |
71 | static disk_t disk[MAX_DISKS]; |
72 | 72 | ||
73 | static int ata_bd_init(void); |
73 | static int ata_bd_init(void); |
74 | static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall); |
74 | static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall); |
75 | static int ata_bd_rdwr(int disk_id, ipcarg_t method, off_t offset, off_t size, |
75 | static int ata_bd_rdwr(int disk_id, ipcarg_t method, off_t offset, off_t size, |
76 | void *buf); |
76 | void *buf); |
Line 94... | Line 94... | ||
94 | return -1; |
94 | return -1; |
95 | 95 | ||
96 | /* Put drives to reset, disable interrupts. */ |
96 | /* Put drives to reset, disable interrupts. */ |
97 | printf("Reset drives...\n"); |
97 | printf("Reset drives...\n"); |
98 | pio_write_8(&ctl->device_control, DCR_SRST); |
98 | pio_write_8(&ctl->device_control, DCR_SRST); |
99 | /* printf("wait for busy\n"); |
- | |
100 | do { |
- | |
101 | status = pio_read_8(&cmd->status); |
- | |
102 | } while ((status & SR_BSY) == 0); |
99 | /* FIXME: Find out how to do this properly. */ |
103 | */ |
- | |
104 | async_usleep(100); |
100 | async_usleep(100); |
105 | pio_write_8(&ctl->device_control, 0); |
101 | pio_write_8(&ctl->device_control, 0); |
106 | 102 | ||
107 | do { |
103 | do { |
108 | status = pio_read_8(&cmd->status); |
104 | status = pio_read_8(&cmd->status); |
Line 151... | Line 147... | ||
151 | int i; |
147 | int i; |
152 | 148 | ||
153 | printf("Identify drive %d\n", disk_id); |
149 | printf("Identify drive %d\n", disk_id); |
154 | pio_write_8(&cmd->drive_head, ((disk_id != 0) ? DHR_DRV : 0)); |
150 | pio_write_8(&cmd->drive_head, ((disk_id != 0) ? DHR_DRV : 0)); |
155 | async_usleep(100); |
151 | async_usleep(100); |
156 | pio_write_8(&cmd->command, 0xEC); |
152 | pio_write_8(&cmd->command, CMD_IDENTIFY_DRIVE); |
157 | 153 | ||
158 | status = pio_read_8(&cmd->status); |
154 | status = pio_read_8(&cmd->status); |
159 | printf("Status = 0x%x\n", status); |
155 | printf("Status = 0x%x\n", status); |
160 | 156 | ||
161 | d->present = false; |
157 | d->present = false; |
Line 167... | Line 163... | ||
167 | if ((status & SR_DRDY) == 0) { |
163 | if ((status & SR_DRDY) == 0) { |
168 | printf("None attached.\n"); |
164 | printf("None attached.\n"); |
169 | return ENOENT; |
165 | return ENOENT; |
170 | } |
166 | } |
171 | 167 | ||
172 | for (i = 0; i < 256; i++) { |
168 | for (i = 0; i < block_size / 2; i++) { |
173 | do { |
169 | do { |
174 | status = pio_read_8(&cmd->status); |
170 | status = pio_read_8(&cmd->status); |
175 | } while ((status & SR_DRDY) == 0); |
171 | } while ((status & SR_DRDY) == 0); |
176 | 172 | ||
177 | data = pio_read_16(&cmd->data_port); |
173 | data = pio_read_16(&cmd->data_port); |
Line 364... | Line 360... | ||
364 | pio_write_8(&cmd->drive_head, drv_head); |
360 | pio_write_8(&cmd->drive_head, drv_head); |
365 | pio_write_8(&cmd->sector_count, 1); |
361 | pio_write_8(&cmd->sector_count, 1); |
366 | pio_write_8(&cmd->sector_number, s); |
362 | pio_write_8(&cmd->sector_number, s); |
367 | pio_write_8(&cmd->cylinder_low, c & 0xff); |
363 | pio_write_8(&cmd->cylinder_low, c & 0xff); |
368 | pio_write_8(&cmd->cylinder_high, c >> 16); |
364 | pio_write_8(&cmd->cylinder_high, c >> 16); |
369 | pio_write_8(&cmd->command, 0x20); |
365 | pio_write_8(&cmd->command, CMD_READ_SECTORS); |
370 | 366 | ||
371 | /* Read data from the disk buffer. */ |
367 | /* Read data from the disk buffer. */ |
372 | 368 | ||
373 | for (i = 0; i < 256; i++) { |
369 | for (i = 0; i < block_size / 2; i++) { |
374 | do { |
370 | do { |
375 | status = pio_read_8(&cmd->status); |
371 | status = pio_read_8(&cmd->status); |
376 | } while ((status & SR_DRDY) == 0); |
372 | } while ((status & SR_DRDY) == 0); |
377 | 373 | ||
378 | data = pio_read_16(&cmd->data_port); |
374 | data = pio_read_16(&cmd->data_port); |