position: block page address, not bytes address * buffer: * size : how many blocks */
| 266 | * size : how many blocks |
| 267 | */ |
| 268 | static rt_ssize_t rt_floppy_read(rt_device_t device, rt_off_t position, void *buffer, rt_size_t size) |
| 269 | { |
| 270 | rt_size_t doSize = size; |
| 271 | |
| 272 | rt_mutex_take(&lock, RT_WAITING_FOREVER); |
| 273 | while(size>0) |
| 274 | { |
| 275 | floppy_read_cmd(position); |
| 276 | |
| 277 | rt_sem_take(&sem, RT_WAITING_FOREVER); /* waiting isr sem forever */ |
| 278 | |
| 279 | floppy_result(); |
| 280 | io_delay(); |
| 281 | |
| 282 | if(ST1 != 0 || ST2 != 0) |
| 283 | { |
| 284 | panic("ST0 %d ST1 %d ST2 %d\n",ST0,ST1,ST2); |
| 285 | } |
| 286 | |
| 287 | rt_memcpy(buffer, floppy_buffer, 512); |
| 288 | |
| 289 | floppy_motorOff(); |
| 290 | io_delay(); |
| 291 | |
| 292 | position += 1; |
| 293 | size -= 1; |
| 294 | } |
| 295 | rt_mutex_release(&lock); |
| 296 | |
| 297 | return doSize; |
| 298 | } |
| 299 | |
| 300 | /* position: block page address, not bytes address |
| 301 | * buffer: |
nothing calls this directly
no test coverage detected