MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / command_cd_read

Function command_cd_read

src/scsiemul.cpp:477–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477static int command_cd_read(TrapContext *ctx, struct devstruct *dev, uaecptr data, uae_u64 offset, uae_u32 length, uae_u32 *io_actual)
478{
479 uae_u32 len, sector, startoffset;
480 int blocksize;
481
482 blocksize = dev->configblocksize;
483 *io_actual = 0;
484 startoffset = offset % blocksize;
485 offset -= startoffset;
486 sector = (uae_u32)(offset / blocksize);
487 while (length > 0) {
488 uae_u8 temp[4096];
489 if (blocksize != 2048) {
490 if (!sys_command_cd_rawread (dev->unitnum, temp, sector, 1, blocksize))
491 return 20;
492 } else {
493 if (!sys_command_cd_read (dev->unitnum, temp, sector, 1))
494 return 20;
495 }
496 if (startoffset > 0) {
497 len = blocksize - startoffset;
498 if (len > length)
499 len = length;
500 trap_memcpyha_safe(ctx, data, temp + startoffset, len);
501 length -= len;
502 data += len;
503 startoffset = 0;
504 *io_actual += len;
505 } else if (length >= blocksize) {
506 len = blocksize;
507 trap_memcpyha_safe(ctx, data, temp, len);
508 length -= len;
509 data += len;
510 *io_actual += len;
511 } else {
512 trap_memcpyha_safe(ctx, data, temp, length);
513 *io_actual += length;
514 length = 0;
515 }
516 sector++;
517 }
518 return 0;
519}
520
521static int dev_do_io_other(TrapContext *ctx, struct devstruct *dev, uae_u8 *iobuf, uaecptr request)
522{

Callers 1

dev_do_io_cdFunction · 0.85

Calls 3

sys_command_cd_rawreadFunction · 0.85
sys_command_cd_readFunction · 0.85
trap_memcpyha_safeFunction · 0.85

Tested by

no test coverage detected