Implement READ BUFFER CAPACITY command for CD-ROM

This commit is contained in:
2025-09-24 17:50:05 +01:00
parent a46d1365d9
commit d7e918dabe
4 changed files with 59 additions and 0 deletions

View File

@@ -3455,4 +3455,39 @@ int
cdrom_send_cuesheet(cdrom_t *dev, const uint8_t *buffer, int len)
{
return dev->ops->send_cuesheet(dev->local, buffer, len);
}
int
cdrom_read_buffer_capacity(cdrom_t *dev, uint8_t *buffer, int block)
{
/* Buffer capacity hardcoded to 1MiB */
memset(buffer, 0, 12);
buffer[0] = 0x00; /* Data Length (MSB) */
buffer[1] = 0x0a; /* Data Length (LSB) */
buffer[2] = 0x00; /* Reserved */
buffer[3] = 0x00; /* Reserved */
if (block) { /* 512 blocks */
buffer[4] = 0x00; /* Length of the Buffer (MSB...) */
buffer[5] = 0x00; /* ... */
buffer[6] = 0x02; /* ... */
buffer[7] = 0x00; /* Length of the Buffer (...LSB) */
buffer[8] = 0x00; /* Blank Length of the Buffer (MSB...) */
buffer[9] = 0x00; /* ... */
buffer[10] = 0x00; /* ... */
buffer[11] = 0x00; /* Blank Length of the Buffer (...LSB) */
}
else { /* 1048576 bytes */
buffer[4] = 0x00; /* Length of the Buffer (MSB...) */
buffer[5] = 0x10; /* ... */
buffer[6] = 0x00; /* ... */
buffer[7] = 0x00; /* Length of the Buffer (...LSB) */
buffer[8] = 0x00; /* Blank Length of the Buffer (MSB...) */
buffer[9] = 0x10; /* ... */
buffer[10] = 0x00; /* ... */
buffer[11] = 0x00; /* Blank Length of the Buffer (...LSB) */
}
return 12;
}