-
Notifications
You must be signed in to change notification settings - Fork 4
Disk Access Process
LuigiBlood edited this page Sep 6, 2022
·
12 revisions
Read Disk Specification page first.
- Use Seek Command
-
ASIC_DATA << 0xHTTT0000
(Replace TTT with Track number [0x000 to 0x497]; H with Head number [0-1]) -
ASIC_CMD << 0x00010001
for READ -
ASIC_CMD << 0x00020001
for WRITE
-
- Cartridge Interrupt will be issued once the seek process is done (or couldn't be done)
-
ASIC_STATUS
will have Mechanic Interrupt set (0x02000000
).- If
ASIC_STATUS
has bit0x00020000
set then a Mechanic Error has occured. - If
ASIC_STATUS
has bit0x00040000
set then a Write Protect error has occured (Only happens with Write Seek for Retail Drives.)
- If
-
ASIC_CUR_TK
should have the exact head and track info ORed with0x60000000
(Index Lock).- If not, then the seek process has not found a reference position.
-
ASIC_BM_CTL |= 0x01000000
to acknowledge and reset Mechanic Interrupt.
-
-
Set Read Micro Sequence to MSEQ RAM (see Micro Sequencer Regular Command)
-
ASIC_SEQ_CTL &= ~0x40000000
to disable Micro Sequencer. - Set byte address 0x12 of the sequence to
Sector Size - 1
. - Upload Sequence to MSEQ RAM (
0xA5000580
) - Set Full Sector Info.
ASIC_SEC_BYTE << 0xBBSS0000
BB = Amount of user sectors and C2 sectors in a block - 1 (always 0x59)
SS = Sector Size - 1 including C1 [+7] - Set Sector Bytes to Read.
ASIC_HOST_SECBYTE << 0x00SS0000
(SS = Sector Size - 1) -
ASIC_SEQ_CTL |= 0x40000000
to enable Micro Sequencer.
-
-
Setup Buffer Manager Control
ASIC_BM_CTL
-
ASIC_BM_CTL |= 0x10000000
to reset Buffer Manager. - Then set the following to
ASIC_BM_CTL
(in one write):-
0x00SS0000
= Sector to start from (0x00 = Block 0 or 0x5A = Block 1). -
0x40000000
= Read Mode Bit -
0x02000000
= Blocks Transfer Bit to read more than one block (if needed)
Wraps from Block 1 to 0 automatically.
-
-
-
Start Reading Data (libultra does some of this!)
- Turn off PI Interrupt.
-
ASIC_BM_CTL |= 0x80000000
to start Buffer Manager.
-
Cartridge Interrupt will be issued for every sector read and put into buffer.
- Read
ASIC_STATUS
to acknowledge Buffer Manager interrupt.-
ASIC_STATUS
will have Buffer Manager Interrupt set (0x04000000
). - If
ASIC_STATUS
has bit0x08000000
set then a Buffer Manager Error has occured.
-
- If
ASIC_BM_STATUS
has both bits0x00600000
set OR bit0x02000000
set then a C1 error has occured.- libleo keeps track of which sectors the error has occured for C2 Correction.
- Above 4 C1 errors, libleo aborts the read.
- If errors are happening in the C2 section of the block, libleo also aborts the read.
- If
ASIC_STATUS
has bit0x40000000
set, a user sector has been copied into the buffer.- You can DMA one sector from the Data Sector buffer
0xA5000400
to RAM.
- You can DMA one sector from the Data Sector buffer
- If
ASIC_STATUS
has bit0x10000000
set, all 4 C2 Sectors has been copied into the buffer.- You can DMA four sectors from the C2 Sector buffer
0xA5000000
to RAM. - Oddity: The hardware actually issues interrupts on every C2 sector read but does not set the C2 Request bit!
- You can DMA four sectors from the C2 Sector buffer
- libleo actually keeps track of the amount of sectors read to ensure everything in done in the right order.
- It also checks if the proper data request or C2 data request information bit has been set.
- Read
-
Once one block has been read:
- If there are C1 errors in the user sectors, then do C2 error correction (done in software by libleo).
- If there are NO C1 errors then it ORs the first 4 32-bit values of C2 together, if it's not 0 then there's an error in the read?
-
Once everything needed in a single track has been read (1 or 2 blocks from it):
- Buffer Manager has automatically stopped.
- You can turn on PI Interrupt.
-
Aborting works like this:
-
ASIC_BM_CTL |= 0x10000000
to reset the Buffer Manager and stop everything. - Then rewrite
ASIC_BM_CTL
without that bit set. - You can turn on PI Interrupt.
-
-
Set Write Micro Sequence to MSEQ RAM (see Micro Sequencer Regular Command)
-
ASIC_SEQ_CTL &= ~0x40000000
to disable Micro Sequencer. - Set byte address 0x12 of the sequence to
Sector Size - 1
. - Upload Sequence to MSEQ RAM (
0xA5000580
) - Set Full Sector Info.
ASIC_SEC_BYTE << 0xBBSS0000
BB = Amount of user sectors and C2 sectors in a block - 1 (always 0x59)
SS = Sector Size - 1 including C1 [+7] - Set Sector Bytes to Read.
ASIC_HOST_SECBYTE << 0x00SS0000
(SS = Sector Size - 1) -
ASIC_SEQ_CTL |= 0x40000000
to enable Micro Sequencer.
-
-
Setup Buffer Manager Control
ASIC_BM_CTL
-
ASIC_BM_CTL |= 0x10000000
to reset Buffer Manager. - Then set the following to
ASIC_BM_CTL
(in one write):-
0x00SS0000
= Sector to start from (0x00 = Block 0 or 0x5A = Block 1). -
0x02000000
= Blocks Transfer Bit to read more than one block (if needed)
Wraps from Block 1 to 0 automatically.
-
-
-
Start Write Data (libultra does some of this!)
- Turn off PI Interrupt.
-
ASIC_BM_CTL |= 0x80000000
to start Buffer Manager.
-
Cartridge Interrupt will be issued for every sector to be written into buffer.
- Read
ASIC_STATUS
to acknowledge Buffer Manager interrupt.-
ASIC_STATUS
will have Buffer Manager Interrupt set (0x04000000
). - If
ASIC_STATUS
has bit0x08000000
set then a Buffer Manager Error has occured.
-
- If
ASIC_STATUS
has bit0x40000000
set, the drive is requesting user sector data.- You can DMA one sector to the Data Sector buffer
0xA5000400
to RAM.
- You can DMA one sector to the Data Sector buffer
- If we're in Blocks Transfer mode then subsequent interrupts should be for the other block in the track.
- libleo actually keeps track of the amount of sectors written to ensure everything in done in the right order.
- It also checks if the proper data request information bit has been set.
- Read
-
Once everything needed in a single track has been written (1 or 2 blocks):
- After writing all user sectors, there is one more Buffer Manager Interrupt (it does NOT request user sector data).
- You do not need to make C2 error correction information, seems to be automatically handled by the drive.
- Then buffer manager has automatically stopped.
- You can turn on PI Interrupt.
- After writing all user sectors, there is one more Buffer Manager Interrupt (it does NOT request user sector data).
-
Aborting works like this:
-
ASIC_BM_CTL |= 0x10000000
to reset the Buffer Manager and stop everything. - Then rewrite
ASIC_BM_CTL
without that bit set. - You can turn on PI Interrupt.
-