Konamiman / Nextor

A disk operating system for MSX computers, forked from MSX-DOS 2.31
Other
183 stars 33 forks source link

DEV_STATUS should be called to detect removable disk changes #4

Closed sdsnatcher closed 5 years ago

sdsnatcher commented 5 years ago

Currently, Nextor tries to find out if a removable media has changed by checking the FAT header itself.

But this results in unnecessary reads of the media. There are interfaces that provide a hardware disk-change function that can considerably speed up this. Some examples are the Panasonic MSX2+/TR and Sanyo MSX2+ floppy disk interfaces, and the FB-Labs SDHC interface.

The best approach would be for Nextor to call DEV_STATUS, before accessing a removable media, and only if DEV_STATUS returned A=3 (*1) it would try to figure itself by checking the FAT header.

*1: Means that the media is present, but this device can't determine whether it has been changed

sdsnatcher commented 5 years ago

Calling DEV_STATUS before accessing a media also allows the driver to take its necessary measures when a media is changed, and allows cleaner and leaner drivers.

For example, FBLabs' SDHC interface has to load the new card info to its WorkArea, because SD and SDHC cards have protocol differences.

Since DEV_STATUS isn't called by Nextor before accessing a media, the card change check function has to be replicated for many other driver functions, like DEV_RW.

sdsnatcher commented 5 years ago

The DEV_STATUS is being called correctly buy Nextor for removable media. (sometimes maybe too often).

The error was in the driver itself.