Skip to content

Disk Access Process

LuigiBlood edited this page Dec 1, 2021 · 12 revisions

Physical Access Process (Head, Track, Block, Sector)

Read Disk Specification page first.

Seek

  • 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 bit 0x00020000 set then a Mechanic Error has occured.
      • If ASIC_STATUS has bit 0x00040000 set then a Write Protect error has occured (Only happens with Write Seek for Retail Drives.)
    • ASIC_CUR_TK should have the exact head and track info ORed with 0x60000000 (Index Lock).
      • If not, then the seek process has not found a reference position.
    • ASIC_BM_CTL |= 0x01000000 to acknowledge and reset Mechanic Interrupt.

Read

  • 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.

    • ASIC_STATUS will have Buffer Manager Interrupt set (0x04000000).
      • If ASIC_STATUS has bit 0x08000000 set then a Buffer Manager Error has occured.
    • If ASIC_BM_STATUS has both bits 0x00600000 set OR bit 0x02000000 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 bit 0x40000000 set, a user sector has been copied into the buffer.
      • You can DMA one sector from the Data Sector buffer 0xA5000400 to RAM.
    • If ASIC_STATUS has bit 0x10000000 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!
    • 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.
  • 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.

Virtual Access Process (LBA Conversion)