MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_floppy_read

Function rt_floppy_read

bsp/x86/drivers/floppy.c:268–298  ·  view source on GitHub ↗

position: block page address, not bytes address * buffer: * size : how many blocks */

Source from the content-addressed store, hash-verified

266 * size : how many blocks
267 */
268static 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:

Callers

nothing calls this directly

Calls 8

rt_mutex_takeFunction · 0.85
floppy_read_cmdFunction · 0.85
rt_sem_takeFunction · 0.85
floppy_resultFunction · 0.85
panicFunction · 0.85
rt_memcpyFunction · 0.85
floppy_motorOffFunction · 0.85
rt_mutex_releaseFunction · 0.85

Tested by

no test coverage detected