English Amiga Board


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

 
 
Thread Tools
Old 01 April 2018, 08:51   #1
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
Best way to check active floppy in bootblock

Is there an easy way to check which disk drive just booted my bootblock ?
alpine9000 is offline  
Old 01 April 2018, 10:28   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Trackloader?

When I initialize my trackloader, then I will check all available drives for disks and read block 0 from them (which also contains my trackloader directory). I can find out the drive with the game disk by checking for an identification on it, like for example a 32-bit ID in the Root-Block field of the boot block (offset 8), which is unused for NDOS disks (880 otherwise).
phx is offline  
Old 01 April 2018, 10:31   #3
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
Quote:
Originally Posted by phx View Post
Trackloader?

When I initialize my trackloader, then I will check all available drives for disks and read block 0 from them (which also contains my trackloader directory). I can find out the drive with the game disk by checking for an identification on it, like for example a 32-bit ID in the Root-Block field of the boot block (offset 8), which is unused for NDOS disks (880 otherwise).
Yes I have seen this code (and use it in fact), but in this case I am wondering if there is a shortcut? Surely some pointer into an OS device structure must hold the disk #?
alpine9000 is offline  
Old 02 April 2018, 11:06   #4
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
There is a solution for everything, if you dig deep enough.

As you certainly know, the bootblock receives a trackdisk IoStdReq pointer in A1, which was used to load it. You just have to follow the reference to the drive's Unit structure via IO_UNIT(A1), before it gets difficult...

The public portion of the trackdisk Unit structure (refer to TDU_PUBLICUNIT from devices/trackdisk.i) unfortunately does not include the actual unit number. You have to rely on the internal part of the structure, which follows at offset TDU_PUBLICUNITSIZE:
Code:
*-- Unit Structure
 STRUCTURE TDU,TDU_PUBLICUNITSIZE       ;(000)
        UBYTE   TDU_DRIVETYPE           ;(xxx) the type of the drive
        UBYTE   TDU_RESERVED2           ;(XXX) for alignment
        UWORD   TDU_NUMTRACKS           ;(xxx) number of tracks on this drive
        ULONG   TDU_MAXOFFSET           ;(xxx) max IO_POSITION allowable
                                        ; Note: now variable
        UWORD   TDU_MFM_TRKBUF          ; used to be MFM_TRKBUF equate
        UWORD   TDU_MFM_MAXTRACK        ; used to be MFM_MAXTRACK+2 equate
                                        ; (the +2 is for the $aaa8 on the end!)
        UWORD   TDU_MFM_SLOP            ; used to be MFM_SLOP equate
        UWORD   TDU_NUMSECS             ; used to be 11
        ULONG   TDU_TDT_DISKSYNC        ; used to be TDT_DISKSYNC
        ULONG   TDU_DISKTYPE            ;(xxx) as returned from disk resource
                                        ; Note: now variable
        UBYTE   TDU_FLAGS               ;(xxx) unit flags
        UBYTE   TDU_6522                ;(xxx) word to write to 6522
        UBYTE   TDU_RETRY               ;(xxx) count of retries
        UBYTE   TDU_UNITNUM             ;(xxx) the number of our unit
        (...much more to follow...)
You should find your unit number in TDU_UNITNUM (untested)!
phx is offline  
Old 02 April 2018, 11:10   #5
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
Quote:
Originally Posted by phx View Post
There is a solution for everything, if you dig deep enough.

As you certainly know, the bootblock receives a trackdisk IoStdReq pointer in A1, which was used to load it. You just have to follow the reference to the drive's Unit structure via IO_UNIT(A1), before it gets difficult...

The public portion of the trackdisk Unit structure (refer to TDU_PUBLICUNIT from devices/trackdisk.i) unfortunately does not include the actual unit number. You have to rely on the internal part of the structure, which follows at offset TDU_PUBLICUNITSIZE:
Code:
*-- Unit Structure
 STRUCTURE TDU,TDU_PUBLICUNITSIZE       ;(000)
        UBYTE   TDU_DRIVETYPE           ;(xxx) the type of the drive
        UBYTE   TDU_RESERVED2           ;(XXX) for alignment
        UWORD   TDU_NUMTRACKS           ;(xxx) number of tracks on this drive
        ULONG   TDU_MAXOFFSET           ;(xxx) max IO_POSITION allowable
                                        ; Note: now variable
        UWORD   TDU_MFM_TRKBUF          ; used to be MFM_TRKBUF equate
        UWORD   TDU_MFM_MAXTRACK        ; used to be MFM_MAXTRACK+2 equate
                                        ; (the +2 is for the $aaa8 on the end!)
        UWORD   TDU_MFM_SLOP            ; used to be MFM_SLOP equate
        UWORD   TDU_NUMSECS             ; used to be 11
        ULONG   TDU_TDT_DISKSYNC        ; used to be TDT_DISKSYNC
        ULONG   TDU_DISKTYPE            ;(xxx) as returned from disk resource
                                        ; Note: now variable
        UBYTE   TDU_FLAGS               ;(xxx) unit flags
        UBYTE   TDU_6522                ;(xxx) word to write to 6522
        UBYTE   TDU_RETRY               ;(xxx) count of retries
        UBYTE   TDU_UNITNUM             ;(xxx) the number of our unit
        (...much more to follow...)
You should find your unit number in TDU_UNITNUM (untested)!
Yes! That’s exactly what I was looking for. Thanks so much! I’ll report back when I get a chance to test it.
alpine9000 is offline  
Old 02 April 2018, 11:24   #6
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,541
Yes, please tell us if it worked. The internal TDU is from 3.1. I don't know if it changed since 1.x.
phx is offline  
Old 02 April 2018, 11:27   #7
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
Quote:
Originally Posted by phx View Post
Yes, please tell us if it worked. The internal TDU is from 3.1. I don't know if it changed since 1.x.
Does 1.x even allow booting from a drive other than DF0 ?
alpine9000 is offline  
Old 02 April 2018, 11:34   #8
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
Why do you need to know boot drive? AFAIK disk private part has changed in all KS versions.
Toni Wilen is online now  
Old 02 April 2018, 11:36   #9
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
Quote:
Originally Posted by Toni Wilen View Post
Why do you need to know boot drive? AFAIK disk private part has changed in all KS versions.
Just trying to remove the hard coded drive # from a trackloader so I can boot from an external gotek cable I have on order ;-)
alpine9000 is offline  
Old 02 April 2018, 12:05   #10
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
Can't selx bits in $bfd100 give that kind of info ?
meynaf is offline  
Old 02 April 2018, 12:18   #11
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
Quote:
Originally Posted by alpine9000 View Post
Just trying to remove the hard coded drive # from a trackloader so I can boot from an external gotek cable I have on order ;-)
If you already have working trackloader, it should be very easy to add extra drive check. Just find first drive that has disk inserted if you want minimal solution and don't want to check if disk contains expected data.
Toni Wilen is online now  
Old 02 April 2018, 12:28   #12
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
Quote:
Originally Posted by Toni Wilen View Post
If you already have working trackloader, it should be very easy to add extra drive check. Just find first drive that has disk inserted if you want minimal solution and don't want to check if disk contains expected data.
I guess that's the fallback, I was just double checking there isn't a one liner I can do (like what meynaf suggested above, except I don't think it works).

I just figured that number must be in RAM or the hardware somewhere if the OS has just used the drive to load my bootblock.
alpine9000 is offline  
Old 02 April 2018, 12:43   #13
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
Unfortunately simple unit number is not available in any public data structures (or even in static private).

It should be easy after dos exists but boot block executes before dos initializes.
Toni Wilen is online now  
Old 02 April 2018, 12:58   #14
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
Quote:
Originally Posted by Toni Wilen View Post
Unfortunately simple unit number is not available in any public data structures (or even in static private).

It should be easy after dos exists but boot block executes before dos initializes.
Well I guess that’s it then, time for plan B
alpine9000 is offline  
Old 02 April 2018, 13:43   #15
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
I faced this problem for a multifloppy dynamic loader but not solved in a clean/simple way..
So i've fall back to this steps:
- derive which floppies are connected in the chain (this can be from A1 in every KS, see my addchip bootblock, http://eab.abime.net/showpost.php?p=...3&postcount=25)
- scan and map with a simple ID in sector 0 what drive contain what floppy
- if /CHNG detected, repeat scan and remap
ross is offline  
Old 02 April 2018, 13:46   #16
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
Quote:
Originally Posted by meynaf View Post
Can't selx bits in $bfd100 give that kind of info ?
Hi meynaf, I also tried this way but unfortunately is not reliable
ross is offline  
Old 02 April 2018, 13:55   #17
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
Quote:
Originally Posted by ross View Post
Hi meynaf, I also tried this way but unfortunately is not reliable
For a very simple check yes, but what happens if you start some i/o with the iorequest and then examine the hardware ?
meynaf is offline  
Old 02 April 2018, 14:04   #18
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
Quote:
Originally Posted by meynaf View Post
For a very simple check yes, but what happens if you start some i/o with the iorequest and then examine the hardware ?
This actually deserves a try.
But it's probably the same thing as when the bootblock code is starting (and in that case it does not work).
ross is offline  
Old 02 April 2018, 14:21   #19
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,571
This is most likely too timing sensitive and it probably also depends on disk rotational position.
Toni Wilen is online now  
Old 07 April 2018, 08:27   #20
alpine9000
Registered User
 
Join Date: Mar 2016
Location: Australia
Posts: 881
What happens if you try and turn the motor on in an empty drive ?

I ask as I think that it probably what happens with a lot of trackloaders if you stick them in df1:. They will load the boot block from df1, then the trackloader will try and load the demo/game data from the hard coded df0:
alpine9000 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
A600 and display distortion when floppy is active mr.spiv support.Hardware 6 03 January 2016 10:55
Active adapter for PC HD floppy drive to be used as Amiga HD demolition support.Hardware 4 23 September 2014 21:14
boot floppy w/o bootblock emufan request.UAE Wishlist 0 12 March 2014 16:57
screen flickers when floppy is active dalton support.Hardware 9 28 December 2010 22:48
BootBlock Virus check on Zany Golf NfernalNfluence support.WinUAE 9 17 June 2009 09:47

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 17:07.

Top

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