Jump to content

APT Hard Disk Preparation and Utilities

Recommended Posts

Slow progress, but I think this is more user-friendly than before:




Won't let you make more than one FAT partition at the moment, but you can leave space for more and create them using a partition editor on the PC. FDISK will then pick up these pre-existing multiple FAT partitions and allow you to attach them as "external" APT partitions.


Quite fun doing the dialogue boxes (as a pre-cursor to the GUI). If you de-select "MBR" and "FAT" is on, FAT turns off... likewise if you turn on "FAT" and "MBR" is off, MBR turns on (since you can't have a FAT without an MBR container).


Of course, if "FAT" is off, the FAT size box should be inaccessible - which comes next. :)

Edited by flashjazzcat
  • Like 1
Link to comment
Share on other sites

Looks awesome.


Is that kind of UI abstraction in textmode somehow reusable for the graphical GUI?


Thanks! Yeah - it should be very re-usable, and it's given me a good insight into how to handle dialogues. The text mode version uses callbacks for "events", but I'll probably confine things to message-passing in the GUI, since the callback mechanism can get a bit hairy, despite the fact this dialogue manager's completely re-entrant. With a little alteration, though, the text mode version could be used with a mouse. The GUI's dialogue manager will require completely different rendering routines, of course, but I'd say the text-mode version constitutes about 50 per cent of the basic work.


Here's a little something else as well:




This is FDISK's device selector running on the 1200XL, which has an internal IDEa interface (with custom APT BIOS) as well as SIDE/U1MB PBI. I've changed the device IDs to accurately reflect KMK's "hierarchical" scheme as described in the DEVINFO / DISKINFO docs (pertaining to IDE Plus), as well as in the APT tech docs on my website. Those numbers which almost look like IP addresses represent the device ID hierarchy. In this case, the first one is the master device on PBI controller 0 (IDEa), while the second one is the master device on PBI controller 6 (U1MB PBI - although the U1MB BIOS numbers the PBI IDs 1-8 instead of 0-7).


The format is BUS_ID . Controller_ID . Device_ID:


The Bus ID is an arbitrary number identifying the I/O bus the device is physically attached to.

$00 represents the Serial Bus (SIO), $01 the parallel bus, and $02 the SpartaDOS X internal

LSIO interface. SIDE returns $02 here.


The Controller ID is a number identifying the controller attached to the bus. SIO devices

should return $00 here. For PBI devices the PBI device ID is returned here; in fact this is the

number of the bit in the PBI enable register that activates the device. The value for PBI

devices is thus ranged from 0 to 7.


The Device ID is a number identifying the physical device itself. For IDE/ATA this will be $01

for the master drive and $02 for the slave drive. Floppies return unit number, and if a disk

drive contains more than one physical drive, the same DEVICE ID should be returned for all

of them.

Edited by flashjazzcat
Link to comment
Share on other sites

Getting closer now:




This shows an "external" partition (the first entry) which points to the FAT area on the CF card. The sector numbers look a bit out of context (since they're by definition outside of the APT partition space), and there'll be no "free space" gaps around them, but you can set the drive number and access flags. Position, size and density are obviously pre-populated for FAT partitions and cannot be changed. You'll be able to use these partitions with Drac030's beta FAT drivers for SDX.

  • Like 1
Link to comment
Share on other sites

FAT16 doesn't keep a running free sector count in the boot record, so the driver needs to scan the FAT every time there's been a change to the filesystem. FAT32 does keep a record, however, so naturally we look forward to that driver very much. Not sure how (or if) the current FATFS driver will sense that the free sector count needs recalculation following a hot-swap - haven't tested that yet. It should be obvious how handy this will all be, though, especially when the drivers are write-capable. ;)

Edited by flashjazzcat
Link to comment
Share on other sites

Well - everything you need is already available, apart from the FDISK program which inserts "external" partitions into the APT. And that'll be released in beta shortly.


Yes - you currently need to create a separate FAT32 partition (AFAIK). This is just one reason I'm anxious to see a FAT32 filesystem driver for SDX.

Link to comment
Share on other sites

Speaking of RTFM, I reformatted the FAT16 partition with the largest possible cluster size (4096 bytes or 8 sectors is the best Windows would manage), and - as Drac030 points out in the WHATSNEW.TXT accompanying the FAT drivers - this speeds up the initial free sector scan significantly. He recommends 8KB clusters.

Edited by flashjazzcat
Link to comment
Share on other sites

  • 1 month later...

Decided to ditch the free/used space model previously employed in the editor:



A few obvious bugs, but it'll be ready soon. Previously, when creating lots of (i.e. more than sixteen) partitions, the additional sectors required for the chain-linked extended partition table records would tend to get bunched up together in the first available free space: typically at the very end of the disk. This was hardly in keeping with the original APT design ethos. So this editor shuffles the partitions around every time an edit occurs, and slots those partition table records in, right ahead of the group of partitions they actually describe. This "floating partition" approach is completely in keeping with similar editors on the ST (ICD Pro, HDDriver, CBHD, etc). More often than not, the only edits you want to perform on the partition table involve adding extra partitions to the end of the table, and this remains a non-destructive operation. The editor code (and consequently the application) is smaller and easier to debug, and I've been able to add useful stuff like split/divide, so you can ask the program to split the available space into a number of equal-sized partitions, or set up n partitions of a specified size.


While researching ST partition editors, I found use of the Pasti ACSI emulator for Steem extremely useful.

Edited by flashjazzcat
  • Like 4
Link to comment
Share on other sites

That new split/divide function is a great help in creating many partitions fast!.. One question though, from the video, I noticed the function creates 8 equal sized partitions when you enter the common partition size (65535) but leave the Partitions number blank. Why did you decide to make it 8? Also, would it be too much to ask to pre-fill the drive id's (optionally). This would make it even faster to create the partitions.


In any case, great effort, FDISK is getting more useful and user friendly by the day :thumbsup:


P.S: I also love the integration of the APT and FAT...

Link to comment
Share on other sites

Added toggle to show partition size by sectors or MB:




The 32MB partitions are actually 65,535 sectors long, hence 31.99MB. It was quite interesting converting 32-bit integers to pseudo-FP representation without using the OS FP library. It'll work the other way, too, so you can type in the partition sizes in MB in this view.


Partition count fixed. Note that there are eight partitions here because only seven 32MB partitions will fit into the available space. Partition 1 is actually an external FAT32 partition (255MB long), so isn't counted towards the total space usage. The auto-fill allows either even division of the available space into a specified number of partitions, or filling the space with as many partitions of a specified size which will fit.

Edited by flashjazzcat
  • Like 1
Link to comment
Share on other sites

Here's a reasonably functional build of the new partition editor:




Don't use this to experiment on partitioned disks with anything valuable on them. I expect there to be a fair number of bugs, so anyone who wants to test would be better off doing so with empty CF cards or by using imaged CF cards in Altirra.


Changes since FDISK3:


  • The partition editor has been completely redesigned. Partitions now "float" to the beginning of the available space. Although there are many excellent reasons for doing things this way, if you edit a disk prepared with FDISK3 which had empty space between partitions, this editor will close up that empty space. You have been warned! :)
  • Y/N responses have been replaced with OK/Cancel dialogue boxes. In fact, the entire UI has been revamped. Dialogues operate much as you'd expect: you can navigate between fields using Tab/Shift-Tab, or the left and right arrow keys. Return generally fires the "OK" button, unless the Cancel button has the highlight on it.
  • The Device selector now lists every PBI device on the system which responds to APT requests. I tested this with an IDEa interface and U1MB/SIDE2 (PBI) connected at the same time, but I'd appreciate it if someone could test this with different hardware set-ups. SDX soft-driver devices should also be picked up and added to the list. The three-digit number before each listed device is: [PBI Device].[bUS ID].[Device ID]. PBI device is just the PBI ID (0-7), BUS ID is the generic ID for PBI devices ($01; the SDX SIDE driver will show up as $02), and Device ID is 1 for Master, 2 for Slave. These values are documented in the APT API manual, found on my website.
  • For partition tables with more than sixteen entries, the partition table chain now threads itself properly between the partition data, at the appropriate points (i.e. before every subsequent block of 31 partitions). This should reduce seek time on spinning disks by a slight but probably unnoticeable amount. :)
  • Partition sizes can now be viewed as sectors or MB values. When you're in MB mode, you also specify the partition size in MB. Watch out for changes to partition sizes when editing in MB view. Although a 65,535 sector partition will show up as 31.99MB, a 31.99 typed into the size field will not yield a 65,535 sector partition, but a 65,515 sector one. Likewise, specifying a 32MB partition will (logically) result in one 65,536 sectors long: one more sector than SpartaDOS X requires.
  • You can insert (finally) "external" FAT partition references with Partition->Make External (or the "X" key). FDISK will pick up any (primary) FAT partitions on the disk and present them in a list. Just select the one you want, give it a drive number, and make sure the partition is formatted (via the PC) with the appropriate file system.
  • Initial media set-up has been redesigned. You can still only specify one FAT, but gone is the succession of pop-up windows and "Y/N" prompts. It's all done from one dialogue box.


Known Issues:


  • Validation checking is fairly loose at the moment. You might be able to screw things up (and I'm sure some will be trying hard) by typing in nonsense values. I'll be tightening this stuff up, though, since although this should be a set-it-and-forget it application, it's pretty mission-critical stuff so I want it as robust as possible.
  • You can't type in fractional MB values in the Disk Initialisation dialogue (where you set up the APT and FAT) yet. I'll fix this soon.
  • Free sector count might seem misleading: this is because there's a one sector overhead for meta-data ahead of each partition. That's not to mention the sectors consumed by extended partition table entries, so it's difficult to come up with an accurate free sector reporting scheme without confounding the user with unwanted information.
  • I want to add a properties panel to the top-level menu, which will report the partition geometry of the chosen device (i.e. report the sizes of all the primary FAT partitions, as well as the APT).


On the advice of Candle, I used the information provided in the Microsoft EFI FAT32 Specification to write the code which detects whether a file system is FAT12, FAT16 or FAT32. FDISK does it EXACTLY the way Microsoft tells us to do it (using the same algorithm), and detection is based purely on the number of data clusters. Trouble is, this isn't reliable if you format a small partition with FAT32... the Microsoft method then doesn't work, unless you add a few lines of code to discern FAT32 on the basis of certain unambiguous fields which are empty when the file system is FAT32. Seems to work (the program can distinguish between FAT16 and FAT32 when the partitions are the same size), but this is something which will need stress-testing, even if it is only a cosmetic concern at the end of the day.

Speaking of FAT: I'm only checking for partition type $0C at the moment, so I'll add the other IDs later for completeness. Also note that extended MBR partitions (i.e. EPRs) of any kind aren't supported at the moment. I don't think this is an issue, since I can't see us needing more than three FATs plus an APT on a Compact Flash card.


Anyway: don't be surprised if stuff's broken. If it's anything not covered above, I'd be interested to hear about it. Also suggestions on extra features (such as augmentation to the split / divide function).


PS: You can use this program with S_VBXE and RC_GR8 (under SpartaDOS X), but you'll have to start it with "X" if using RC_GR8.SYS (otherwise there's not enough RAM for the GR.8 display). Note also that FDISK should run under any DOS.

Edited by flashjazzcat
  • Like 3
Link to comment
Share on other sites

Everything went well but not able to create partitions with Altirra [EMU]. No key presses registered during sizing phase. Emulated CF card did not show proper size of CF image.


EDIT: This was with the IDE+20.ROM. I also did a 256 MB CF card on real hardware and it is working with Ultimate and Incognito.

Edited by rdea6
Link to comment
Share on other sites

Right - thanks for spotting that Roy: it was a bug. IDE Plus evidently (and quite properly) checks the first byte of the partition table, which contains the number of drive mapping slots, less fifteen. If it finds a nonsense value, it obviously rejects the partition table. There was a bug which caused the APT signature to overwrite the mapping entry count, making the partition table invalid to the IDE Plus BIOS.




Fixed that, and just tested it in Altirra and it seems fine. Wasn't able to reproduce any issues with partition size reporting yet. I also changed the initialization routine so that if you select a FAT16 partition, partition type $06 gets created, instead of type $0C.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...