di.h File Reference

#include <types.h>
#include <broadway.h>

Go to the source code of this file.

Enumerations

enum  di_cmd_t {
  DI_CMD_INQUIRY = 0x12, DI_CMD_DMAREAD = 0xA8, DI_CMD_SEEK = 0xAB, DI_CMD_GETERROR = 0xE0,
  DI_CMD_PLAYAUDIO = 0xE1, DI_CMD_AUDIOSTATUS = 0xE2, DI_CMD_STOPMOTOR = 0xE3, DI_CMD_DVDAUDIO = 0xE4,
  DI_CMD_DEBUG = 0xFE, DI_CMD_UNLOCK = 0xFF
}
enum  di_dmaread_cmd_t { DI_DMAREAD_SECTOR = 0x00, DI_DMAREAD_DISCID = 0x40 }
enum  di_debug_cmd_t { DI_DEBUG_MEMORY = 0x01, DI_DEBUG_DRVCONTROL = 0x11, DI_DEBUG_JUMP = 0x12 }
enum  di_drvctrl_cmd2_t { DI_MOTOR_DOWN = 0x0000, DI_MOTOR_UP = 0x0100, DI_DRIVE_ACCEPT = 0x0400, DI_DRIVE_CHECKDISK = 0x0800 }
enum  di_error1_t {
  DI_ERROR1_OK = 0x00, DI_ERROR1_LIDOPEN = 0x01, DI_ERROR1_DISKCHANGED = 0x02, DI_ERROR1_NODISC = 0x03,
  DI_ERROR1_MOTOROFF = 0x04, DI_ERROR1_BADDISC = 0x05
}
enum  di_error2_t {
  DI_ERROR2_OK = 0x000000, DI_ERROR2_MOTORSTOP = 0x020400, DI_ERROR2_DISCID = 0x020401, DI_ERROR2_COVEROPEN = 0x023A00,
  DI_ERROR2_NOSEEK = 0x030200, DI_ERROR2_READERROR = 0x031100, DI_ERROR2_TRANSFER = 0x040800, DI_ERROR2_COMMAND = 0x052000,
  DI_ERROR2_AUDIOBUF = 0x052001, DI_ERROR2_LBARANGE = 0x052100, DI_ERROR2_INVALIDFIELD = 0x052400, DI_ERROR2_AUDIOCMD = 0x052401,
  DI_ERROR2_CONFIG = 0x052402, DI_ERROR2_ENDOFUSER = 0x056300, DI_ERROR2_MEDIUMCHANGE = 0x062800, DI_ERROR2_OPREMOVAL = 0x0B5A01
}

Functions

int di_initialize (void)
 Initialize the DI subsystem.
int di_shutdown (void)
 Shut down the DI subsystem.
void di_reset (BOOL hard)
 Resets the drive.
BOOL di_cover_open (void)
 Detects if the drive cover is open.
void di_set_command (di_cmd_t cmd, u8 subcmd1, u16 subcmd2, u32 off, u32 len)
 Set the command to be sent for a transfer.
void di_set_dma (u32 addr, u32 len)
 Set DMA address and length.
u32 di_immediate_recv (void)
 Read the immediate data buffer.
void di_immediate_send (u32 data)
 Write the immediate data buffer.
void di_transfer (BOOL write, BOOL dma)
 Starts a transfer from the DI.
BOOL di_transfer_ended (void)
 Check if the DI transfer is complete.
void irq_di_enable (u32 irq)
 Enables a specific DI IRQ.
void irq_di_disable (u32 irq)
 Disables a specific DI IRQ.
int irq_di_register_handler (u32 irqn, int(*exec)(u32 irq, void *data), void *data)
 Register a DI IRQ handler.
irq_handler_t irq_di_get_handler (u32 irqn)
 Gets a DI IRQ handler.

Detailed Description

An abstraction of the Drive Interface (DI). Low level access is abstracted; a higher level abstraction should be available soon.


Enumeration Type Documentation

enum di_cmd_t

The known command numbers for di_send_command()

Enumerator:
DI_CMD_INQUIRY 

DMA, read, gets drive info

DI_CMD_DMAREAD 

DMA, read, subcmd2 is di_dmaread_cmd_t

DI_CMD_SEEK 

Imm, read, seeks the drive

DI_CMD_GETERROR 

Imm, read, request error status

DI_CMD_PLAYAUDIO 

Imm, read, play audio stream (?)

DI_CMD_AUDIOSTATUS 

Imm, read, request audio status

DI_CMD_STOPMOTOR 

Imm, read, stop drive motor

DI_CMD_DVDAUDIO 

Imm, read, subcmd1 is on/off

DI_CMD_DEBUG 

Imm, subcmd1 is di_debug_cmd_t

DI_CMD_UNLOCK 

Imm, read, unlock the drive

The known DI_CMD_DEBUG subcommands

Enumerator:
DI_DEBUG_MEMORY 

Imm, read/write memory/cache

DI_DEBUG_DRVCONTROL 

Imm, read, various drive controls

DI_DEBUG_JUMP 

Imm, read, JSR to off

The known DI_CMD_DMAREAD subcommands

Enumerator:
DI_DMAREAD_SECTOR 

DMA, read, reads a sector

DI_DMAREAD_DISCID 

DMA, read, reads Disc ID/Init Disc

DI_DEBUG_DRVCONTROL subcommands

Enumerator:
DI_MOTOR_DOWN 

Spin down the motor

DI_MOTOR_UP 

Spin up the motor

DI_DRIVE_ACCEPT 

Force the drive to accept the disc

DI_DRIVE_CHECKDISK 

Force the drive to check the disc

Error codes (top byte)

Enumerator:
DI_ERROR1_OK 

No error

DI_ERROR1_LIDOPEN 

Lid open

DI_ERROR1_DISKCHANGED 

Disc changed

DI_ERROR1_NODISC 

No disc

DI_ERROR1_MOTOROFF 

Motor off

DI_ERROR1_BADDISC 

Disc not initialized/disc ID not read

Error codes (bottom 3 bytes)

Enumerator:
DI_ERROR2_OK 

No error

DI_ERROR2_MOTORSTOP 

Motor stopped

DI_ERROR2_DISCID 

Disc ID not read

DI_ERROR2_COVEROPEN 

Medium not preset/Cover opened

DI_ERROR2_NOSEEK 

No seek complete

DI_ERROR2_READERROR 

Unrecovered read error

DI_ERROR2_TRANSFER 

Transfer protocol error

DI_ERROR2_COMMAND 

Invalid command operation code

DI_ERROR2_AUDIOBUF 

Audio buffer not set

DI_ERROR2_LBARANGE 

LBA out of range

DI_ERROR2_INVALIDFIELD 

Invalid field in command packet

DI_ERROR2_AUDIOCMD 

Invalid audio command

DI_ERROR2_CONFIG 

Configuration out of permitted period

DI_ERROR2_ENDOFUSER 

End of user area encountered on this track

DI_ERROR2_MEDIUMCHANGE 

Medium may have changed

DI_ERROR2_OPREMOVAL 

Operator medium removal request


Function Documentation

BOOL di_cover_open ( void   ) 

Detects if the drive cover is open.

Returns:
TRUE if the cover is open, FALSE if it's closed.
u32 di_immediate_recv ( void   ) 

Read the immediate data buffer.

Returns:
The immediate data buffer.
void di_immediate_send ( u32  data  ) 

Write the immediate data buffer.

Parameters:
data data to write to immediate data buffer.
int di_initialize ( void   ) 

Initialize the DI subsystem.

Initializes the DI subsystem, registers the handler for the DI interrupt and performs all other required initialization tasks.

Returns:
If initialization was successful, returns 1. Otherwise 0.
See also:
di_shutdown()
void di_reset ( BOOL  hard  ) 

Resets the drive.

Parameters:
hard if TRUE, perform a hard drive reset. If FALSE, just soft reset.
void di_set_command ( di_cmd_t  cmd,
u8  subcmd1,
u16  subcmd2,
u32  off,
u32  len 
)

Set the command to be sent for a transfer.

Parameters:
cmd the command to use.
subcmd1 a parameter to cmd.
subcmd2 a parameter to cmd.
off offset to data to use. (in 32bit words)
len length of the data to use.
void di_set_dma ( u32  addr,
u32  len 
)

Set DMA address and length.

Parameters:
addr address of the buffer in main memory. (32byte aligned)
len length of the buffer. (32byte aligned)
int di_shutdown ( void   ) 

Shut down the DI subsystem.

Shuts down the DI subsystem, unregisters the handler for the DI interrupt and performs all other required shut down tasks.

Returns:
If shut down was successful, returns 1. Otherwise 0.
See also:
di_initialize()
void di_transfer ( BOOL  write,
BOOL  dma 
)

Starts a transfer from the DI.

Parameters:
write if TRUE, this transfer is a write. If FALSE, it's a read.
dma if TRUE, this transfer is a DMA. If FALSE, it's an immediate transfer.
See also:
di_transfer_ended()
BOOL di_transfer_ended ( void   ) 

Check if the DI transfer is complete.

Returns:
TRUE if transfer is complete, FALSE if transfer is still in progress.
See also:
di_transfer()
void irq_di_disable ( u32  irq  ) 

Disables a specific DI IRQ.

Parameters:
irq the IRQ to disable
See also:
irq_di_enable()
void irq_di_enable ( u32  irq  ) 

Enables a specific DI IRQ.

Parameters:
irq the IRQ to enable
See also:
irq_di_disable()
irq_handler_t irq_di_get_handler ( u32  irqn  ) 

Gets a DI IRQ handler.

Gets the IRQ handler information for a DI IRQ.

Parameters:
irqn the IRQ whose handler is to be returned.
Returns:
The irq_handler_t structure containing information about the handler.
See also:
irq_di_register_handler()
int irq_di_register_handler ( u32  irqn,
int(*)(u32 irq, void *data)  exec,
void *  data 
)

Register a DI IRQ handler.

Parameters:
irqn the IRQ whose handle is to be registered.
exec the callback to be called when the IRQ fires. Pass NULL to unregister the IRQ.
data the data to be passed to the IRQ when it fires.
Returns:
Returns 1 on success, 0 on failure.
See also:
irq_di_get_handler()
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated by  doxygen 1.6.3