English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 11 July 2019, 00:40   #1
hjalfi
Registered User
 
Join Date: Feb 2019
Location: Zurich
Posts: 38
What are the 16 bytes of metadata in disk sector headers for?

I'm reading Amiga floppy disks (context: http://cowlark.com/fluxengine).

An ADF file has 2x80x11 512-byte sectors.

However, an Amiga floppy disk has an extra 16 bytes of data in each sector header, which the documentation I've been able to find just says 'reserved for filesystem use'. So, an Amiga sector really stores 528 bytes of data.

But ADF files don't store this, and given that I can boot uae off an ADF system disk just fine, this suggests that the Amiga filesystem does not, in fact, use this data.

So what's it for? Can I get away with ignoring it completely? If I can't, how am I supposed to represent it in a disk image, given that ADF doesn't store it?
hjalfi is offline  
Old 11 July 2019, 00:55   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by hjalfi View Post
I'm reading Amiga floppy disks (context: http://cowlark.com/fluxengine).

An ADF file has 2x80x11 512-byte sectors.

However, an Amiga floppy disk has an extra 16 bytes of data in each sector header, which the documentation I've been able to find just says 'reserved for filesystem use'. So, an Amiga sector really stores 528 bytes of data.

But ADF files don't store this, and given that I can boot uae off an ADF system disk just fine, this suggests that the Amiga filesystem does not, in fact, use this data.

So what's it for? Can I get away with ignoring it completely? If I can't, how am I supposed to represent it in a disk image, given that ADF doesn't store it?
Yes, not used in any (standard) filesystem, you can safely ignore it.
If you want to store this data in a file you need to resort to extended ADF.

PS: welcome on board
ross is offline  
Old 11 July 2019, 15:49   #3
hjalfi
Registered User
 
Join Date: Feb 2019
Location: Zurich
Posts: 38
Is there a standard extended ADF format for storing this sort of thing? Or do I need to come up with a custom format (which no emulator would understand, of couse)?
hjalfi is offline  
Old 11 July 2019, 17:28   #4
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by hjalfi View Post
Is there a standard extended ADF format for storing this sort of thing? Or do I need to come up with a custom format (which no emulator would understand, of couse)?
Custom MFM format.

Perfectly usable by WinUAE.
ross is offline  
Old 11 July 2019, 18:53   #5
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
There is no "cooked" (not based on raw MFM) format that is able to store both data and sector headers. Ext adf is quite simple, short format description is in UAE disk.c.

I think there was one or two programs that used sector headers for some purposes but I don't remember any names.
Toni Wilen is offline  
Old 11 July 2019, 20:44   #6
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
PackDev supposedly supports storing and writing back sector header data. WinUAE supports PackDev (.pkd) files.

I say supposedly, because I seem to remember playing with it and not being able to write or read anything other than all-zero sector header data. I took a .pkd file, hex-edited something non-zero in the part corresponding to sector header data, then wrote the .pkd to a floppy (extended ADF). On creating a .pkd from that floppy, I think the sector header data in the .pkd file was all-zero. That was a while ago though, maybe I mis-remembered???
mark_k is offline  
Old 11 July 2019, 21:21   #7
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
Ugh, I checked the PackDev source code. Back in the day I archived my original Amiga disks using PackDev because it was supposed to archive/handle sector label data...

(Some comments etc. deleted from the source extract for brevity.)
Code:
/*
Read sectors

Inputs:  DiskExtIO    Pointer to IOExtTD
         SectorBuffer Buffer for sector data
         LabelBuffer  Buffer for LabelBuffer data
         Offset       Number of first block to read
         NumBlocks    Number of blocks
         Block size   Size of a block in bytes
         Diskchanges  Number of disk changes having to stay constant,
                      -1 to ignore it

Return:  None

Comment: Note that an ETD command is not used because some HDs don't support
         them (e.g. oktagon.device). To avoid the disk change problem, the
         number of disk changes is checked by hand.
         It is a good idea to use buffer pointers divisable by 4 because HD
         devices may be much faster with this

*/

VOID ReadSectors(struct IOExtTD *DiskExtIO,APTR SectorBuffer,APTR LabelBuffer,
  ULONG Offset,ULONG NumBlocks,ULONG BlockSize,LONG Diskchanges,LONG Errblk)
{
	DiskExtIO->iotd_Req.io_Command=(UWORD) CMD_READ;
	DiskExtIO->iotd_Req.io_Offset=Offset*BlockSize;
	DiskExtIO->iotd_Req.io_Data=SectorBuffer;
	DiskExtIO->iotd_Req.io_Length=NumBlocks*BlockSize;
	DiskExtIO->iotd_SecLabel=(ULONG)LabelBuffer;
	Do(DiskExtIO,Errblk,_SpcVerify ? IGNOREERROR:ASKRETRY);
}
ReadSectors() uses CMD_READ. But in order to actually read sector label data ETD_READ must be used instead. WriteSectors() has a similar problem (CMD_WRITE not ETD_WRITE). However it looks like FormatTrack(), used when writing to floppy disk with ETDFORMAT argument, might actually use ETD_FORMAT.

So you can probably use the current buggy PackDev to write sector label data to a floppy, but reading it back won't work (you'll get all zero bytes).
mark_k is offline  
Old 12 July 2019, 13:59   #8
hjalfi
Registered User
 
Join Date: Feb 2019
Location: Zurich
Posts: 38
I'd like to tackle nibble disk formats one day --- there are some unpleasant wrinkles with my code, which assumes the data's broken down into sectors --- but that day is not today.

I hadn't realised that Amiga hard drives don't support label data. That explains why the filesystem doesn't use them. PackDev looks promising but I'd need to read the source to determine the file format. I'd have to mandate that you weren't allowed to use a packer, but as the uae code appears to ignore the packer field completely (https://github.com/FrodeSolheim/fs-u...file.cpp#L1059) that's probably not an issue.

TBH, I suspect that what I'm going to do right now is Nothing; my code already produces simple 512-byte sector arrays which means that they're ADF compatible, it looks like genuinely nobody is using the metadata fields, and I've just discovered a nasty sampling problem which manifests when reading the middle tracks of Macintosh 400kB and 800kB disks which means my foreseeable future will be spent slaving over a hot logic analyser, so I don't need to more on my plate right now...

(I'd have thought, though, that using the sector label would be a really cheap and easy way of annoying people who wanted to copy their games to a hard drive.)
hjalfi is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bamiga Sector 1 Compilation disk. redblade request.Old Rare Games 30 12 February 2018 01:02
256 bytes/sector drive & FFS mark_k support.WinUAE 1 30 August 2017 19:17
Disk sector editor DH request.Apps 47 24 August 2012 13:09
Not DOS disk. Sector 21 bad. Over and over and over... XDelusion support.Hardware 2 29 June 2012 23:12
Red Sector Megademo Disk 2 Mark Wright support.Demos 0 11 August 2003 01:53

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:41.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.28471 seconds with 15 queries