FDD cache

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
HanzZ

FDD cache

Post by HanzZ »

Hi :),
I am writing floppy driver and he goes right. But i have one problem.
If I read some sectors from floopy => change diskette => and read sectors again, I will get the same sectors (sectors from first diskette..not from second diskette)...
I think, that problem is with cache of floppy... How can I delete data from cache... If problem is otherwhere, tell me ;)

thanks ;)

(I am OS novice ;) )
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:FDD cache

Post by Pype.Clicker »

well, you may want to force your user to tell the system when they remove the floppy ... or check if the "disk changed" status is somehow reliable ...
Xardfir

Re:FDD cache

Post by Xardfir »

Do it the DOS way. It's slow but reliable.

On any non-sequential operation read track 0.
Compare the volume number ID with the previous request, if it doesn't match then put up a box demanding the previous disk.
If the user hits cancel, try to exit gracefully. Apple 2, Commodore and CP/M all suffered problems because they didn't check the disk.

I would also reccommend not using the floppy controllers 'disk change' feature. A lot of mass produced floppy drives don't implement it correctly. The only way to make sure (if you want to use it) is have the user change disks during installation of your OS and then decide. Microsoft Backup for MSDOS did this, and only 1 of 3 computers I used Backup on supported the disk change notification correctly.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:FDD cache

Post by Pype.Clicker »

The alternative being to be unix-like: user mounts floppy before she can access it and knows (because she read the f*** manual) that if she changes the floppy without unmounting first, Bad Things (tm) are going to occur ...

Now of course, if your average user looks more like Mr. Anykey, your system will be unusable for him ... all depend. Do you expect Mr. Anykey to know how to insert a floppy in 2005, anyway ?

(writing this post makes me feels the urge to start a USB support for clicker :)
HanzZ

Re:FDD cache

Post by HanzZ »

thanks ;D
now I can detect floppy disk change, but I don't know, what I have to do, when i detect disk change... how can i clear cache memory in floppy controller? I haven't any idea...
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:FDD cache

Post by Solar »

Xardfir wrote: On any non-sequential operation read track 0.
Compare the volume number ID with the previous request, if it doesn't match then put up a box demanding the previous disk.
If the user hits cancel, try to exit gracefully. Apple 2, Commodore and CP/M all suffered problems because they didn't check the disk.
Ahem... I assume you refer to Commodore PC.

Commodore Amiga checked the volume ID of the disk every three seconds or so. That allowed to sense disk changes automatically, and if there were unwritten buffers, it popped a requester asking you to insert the previous disk or lose data.
Every good solution is obvious once you've found it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:FDD cache

Post by Pype.Clicker »

Well, that all depends on how you built your cache. I assume you don't simply grab 1.44 MB of physical ram for floppy caching, right ? you have something like

Code: Select all

struct FloppyCache {
    FloppyTrack *cache[TRACKS_ON_DISK];
    // initialize this with NULLs
};

void fillCache(struct FloppyCache* fc, trackno)
{
    if (fc->cache[trackno]) return; // in cache already;
    fc->cache[trackno]=alloc(MEM_DMA_CAPABLE,sizeof(FloppyTrack));
    floppy_load_track(fc->cache[trackno],trackno);
    return;
}

void clearCache(struct FloppyCache *fc)
{
    for (int i=0;i<TRACK_ON_DISK;i++) {
        if (fc->cache[i]) free(fc->cache[i]);
        fc->cache[i]=NULL;
    }
}
Xardfir

Re:FDD cache

Post by Xardfir »

Hiya,
@ Solar:
My apologies for my Commodore ambiguity (I have adopted 3 Amiga 500's myself). My reference was to the less capable 1541/2 and 1570 series of Commodore disk drives running their own version of Commodore Dos.
The only redeeming feature of the 1570 was that it could write CP/M disks which could be read on a PC (using CP/M 86).

@ HanzZ:
As for caching, might I suggest looking at the DMA page in the OSFAQ, as it provides a way of using the DMA to supply a track cache for the floppy disk in hardware. Less code for you to write, let the hardware do the work.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:FDD cache

Post by Brendan »

Hi,
Xardfir wrote:The only redeeming feature of the 1570 was that it could write CP/M disks which could be read on a PC (using CP/M 86).
These disk drives aren't disk drives - they're more like mini file servers (you could connect several computers to one of them, and the computer/s send commands rather than messing about with low level sector addressing stuff).

They also made better use of the media (more sectors on outer tracks) and allowed custom code to be uploaded.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply