PS2SDK
PS2 Homebrew Libraries
intrman.h File Reference
#include <types.h>
#include <irx.h>
+ Include dependency graph for intrman.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  intrman_intr_handler_data_
 
struct  intrman_internals_
 

Macros

#define intrman_IMPORTS_start   DECLARE_IMPORT_TABLE(intrman, 1, 2)
 
#define intrman_IMPORTS_end   END_IMPORT_TABLE
 
#define I_GetIntrmanInternalData   DECLARE_IMPORT(3, GetIntrmanInternalData)
 
#define I_RegisterIntrHandler   DECLARE_IMPORT(4, RegisterIntrHandler)
 
#define I_ReleaseIntrHandler   DECLARE_IMPORT(5, ReleaseIntrHandler)
 
#define I_EnableIntr   DECLARE_IMPORT(6, EnableIntr)
 
#define I_DisableIntr   DECLARE_IMPORT(7, DisableIntr)
 
#define I_CpuDisableIntr   DECLARE_IMPORT(8, CpuDisableIntr)
 
#define I_CpuEnableIntr   DECLARE_IMPORT(9, CpuEnableIntr)
 
#define I_CpuInvokeInKmode   DECLARE_IMPORT(14, CpuInvokeInKmode);
 
#define I_DisableDispatchIntr   DECLARE_IMPORT(15, DisableDispatchIntr);
 
#define I_EnableDispatchIntr   DECLARE_IMPORT(16, EnableDispatchIntr);
 
#define I_CpuSuspendIntr   DECLARE_IMPORT(17, CpuSuspendIntr)
 
#define I_CpuResumeIntr   DECLARE_IMPORT(18, CpuResumeIntr)
 
#define I_QueryIntrContext   DECLARE_IMPORT(23, QueryIntrContext)
 
#define I_QueryIntrStack   DECLARE_IMPORT(24, QueryIntrStack)
 
#define I_iCatchMultiIntr   DECLARE_IMPORT(25, iCatchMultiIntr)
 
#define I_SetNewCtxCb   DECLARE_IMPORT(28, SetNewCtxCb)
 
#define I_SetShouldPreemptCb   DECLARE_IMPORT(30, SetShouldPreemptCb)
 
#define INUM_VBLANK   IOP_IRQ_VBLANK
 
#define INUM_GM   IOP_IRQ_SBUS
 
#define INUM_CDROM   IOP_IRQ_CDVD
 
#define INUM_DMA   IOP_IRQ_DMA
 
#define INUM_RTC0   IOP_IRQ_RTC0
 
#define INUM_RTC1   IOP_IRQ_RTC1
 
#define INUM_RTC2   IOP_IRQ_RTC2
 
#define INUM_SIO0   IOP_IRQ_SIO0
 
#define INUM_SIO1   IOP_IRQ_SIO1
 
#define INUM_SPU   IOP_IRQ_SPU
 
#define INUM_PIO   IOP_IRQ_PIO
 
#define INUM_EVBLANK   IOP_IRQ_EVBLANK
 
#define INUM_DVD   IOP_IRQ_DVD
 
#define INUM_PCMCIA   IOP_IRQ_DEV9
 
#define INUM_RTC3   IOP_IRQ_RTC3
 
#define INUM_RTC4   IOP_IRQ_RTC4
 
#define INUM_RTC5   IOP_IRQ_RTC5
 
#define INUM_SIO2   IOP_IRQ_SIO2
 
#define INUM_HTR0   IOP_IRQ_HTR0
 
#define INUM_HTR1   IOP_IRQ_HTR1
 
#define INUM_HTR2   IOP_IRQ_HTR2
 
#define INUM_HTR3   IOP_IRQ_HTR3
 
#define INUM_USB   IOP_IRQ_USB
 
#define INUM_EXTR   IOP_IRQ_EXTR
 
#define INUM_FWRE   IOP_IRQ_ILINK
 
#define INUM_FDMA   IOP_IRQ_FDMA
 
#define INUM_DMA_0   IOP_IRQ_DMA_MDEC_IN
 
#define INUM_DMA_1   IOP_IRQ_DMA_MDEC_OUT
 
#define INUM_DMA_2   IOP_IRQ_DMA_SIF2
 
#define INUM_DMA_3   IOP_IRQ_DMA_CDVD
 
#define INUM_DMA_4   IOP_IRQ_DMA_SPU
 
#define INUM_DMA_5   IOP_IRQ_DMA_PIO
 
#define INUM_DMA_6   IOP_IRQ_DMA_GPU_OTC
 
#define INUM_DMA_BERR   IOP_IRQ_DMA_BERR
 
#define INUM_DMA_7   IOP_IRQ_DMA_SPU2
 
#define INUM_DMA_8   IOP_IRQ_DMA_DEV9
 
#define INUM_DMA_9   IOP_IRQ_DMA_SIF0
 
#define INUM_DMA_10   IOP_IRQ_DMA_SIF1
 
#define INUM_DMA_11   IOP_IRQ_DMA_SIO2_IN
 
#define INUM_DMA_12   IOP_IRQ_DMA_SIO2_OUT
 
#define SetCtxSwitchHandler(...)   SetNewCtxCb(__VA_ARGS__)
 
#define ResetCtxSwitchHandler(...)   ResetNewCtxCb(__VA_ARGS__)
 
#define SetCtxSwitchReqHandler(...)   SetShouldPreemptCb(__VA_ARGS__)
 
#define ResetCtxSwitchReqHandler(...)   ResetShouldPreemptCb(__VA_ARGS__)
 

Typedefs

typedef struct intrman_intr_handler_data_ intrman_intr_handler_data_t
 
typedef struct intrman_internals_ intrman_internals_t
 

Enumerations

enum  iop_irq_list {
  IOP_IRQ_VBLANK = 0, IOP_IRQ_SBUS, IOP_IRQ_CDVD, IOP_IRQ_DMA,
  IOP_IRQ_RTC0, IOP_IRQ_RTC1, IOP_IRQ_RTC2, IOP_IRQ_SIO0,
  IOP_IRQ_SIO1, IOP_IRQ_SPU, IOP_IRQ_PIO, IOP_IRQ_EVBLANK,
  IOP_IRQ_DVD, IOP_IRQ_DEV9, IOP_IRQ_RTC3, IOP_IRQ_RTC4,
  IOP_IRQ_RTC5, IOP_IRQ_SIO2, IOP_IRQ_HTR0, IOP_IRQ_HTR1,
  IOP_IRQ_HTR2, IOP_IRQ_HTR3, IOP_IRQ_USB, IOP_IRQ_EXTR,
  IOP_IRQ_ILINK, IOP_IRQ_FDMA, IOP_IRQ_DMA_MDEC_IN = 0x20, IOP_IRQ_DMA_MDEC_OUT,
  IOP_IRQ_DMA_SIF2, IOP_IRQ_DMA_CDVD, IOP_IRQ_DMA_SPU, IOP_IRQ_DMA_PIO,
  IOP_IRQ_DMA_GPU_OTC, IOP_IRQ_DMA_BERR, IOP_IRQ_DMA_SPU2, IOP_IRQ_DMA_DEV9,
  IOP_IRQ_DMA_SIF0, IOP_IRQ_DMA_SIF1, IOP_IRQ_DMA_SIO2_IN, IOP_IRQ_DMA_SIO2_OUT,
  IOP_IRQ_SW1 = 0x3E, IOP_IRQ_SW2
}
 

Functions

intrman_internals_tGetIntrmanInternalData (void)
 
int RegisterIntrHandler (int irq, int mode, int(*handler)(void *arg), void *arg)
 
int ReleaseIntrHandler (int irq)
 
int EnableIntr (int irq)
 
int DisableIntr (int irq, int *res)
 
int CpuDisableIntr ()
 
int CpuEnableIntr ()
 
int CpuSuspendIntr (int *state)
 
int CpuResumeIntr (int state)
 
int CpuInvokeInKmode (void *function,...)
 
void DisableDispatchIntr (int irq)
 
void EnableDispatchIntr (int irq)
 
int QueryIntrContext (void)
 
int QueryIntrStack (void *sp)
 
int iCatchMultiIntr (void)
 
void SetNewCtxCb (void *cb)
 
void ResetNewCtxCb (void)
 
void SetShouldPreemptCb (void *cb)
 
void ResetShouldPreemptCb (void)
 

Detailed Description

Kernel-based threads.

Definition in file intrman.h.


Data Structure Documentation

◆ intrman_internals_

struct intrman_internals_

Definition at line 86 of file intrman.h.

+ Collaboration diagram for intrman_internals_:
Data Fields
intrman_intr_handler_data_t * interrupt_handler_table
int masked_icr_1
int masked_icr_2
int dmac2_interrupt_handler_mask

Enumeration Type Documentation

◆ iop_irq_list

Enumerator
IOP_IRQ_DMA 

Original DMA controller interrupt (DMA channels 0-6)

IOP_IRQ_DVD 

Not sure what this is, if INUM_CDROM is the interrupt CDVDMAN uses.

IOP_IRQ_EXTR 

Expansion interface on the mainboard. Unused (and unpopulated) on most retail mainboards, but used by DECI2 in the TOOL unit as the MRP interface. In PS mode, INUM_PIO seems to be triggered instead.

IOP_IRQ_FDMA 

Firewire DMA

IOP_IRQ_DMA_BERR 

DMA bus error

IOP_IRQ_SW1 

R3000A Software Interrupt 1 (Used by DECI2).

IOP_IRQ_SW2 

R3000A Software Interrupt 2 (Used by DRVTIF of DECI2)

Definition at line 26 of file intrman.h.

Function Documentation

◆ RegisterIntrHandler()

int RegisterIntrHandler ( int  irq,
int  mode,
int(*)(void *arg)  handler,
void *  arg 
)

Register an interrupt handler for the specified interrupt.

Parameters
irqInterrupt cause to register an interrupt handler for.
modeSpecifies the registers that will be preserved before the interrupt handler is run. The more registers are preserved, the slower the operation. Mode 0: $at, $v0, $v1, $a0, $a1, $a2, $a3 and $ra can be used. Mode 1: All mode 0 registers, as well as $t0-$t9, $gp and $fp can be used. Mode 2: All mode 1 registers, as well as $s0-$s7 can be used.
handlerA pointer to the interrupt handler that will be associated with the interrupt.
argAn optional pointer to data that will be passed to the interrupt handler, whenever it is to be invoked.
Returns
0 on success, non-zero error code on failure.

Definition at line 115 of file intrman.c.

◆ ReleaseIntrHandler()

int ReleaseIntrHandler ( int  irq)

Releases (deregisters) the interrupt handler for the specified interrupt.

Parameters
irqInterrupt cause to release the interrupt handler for.
Returns
0 on success, non-zero error code on failure.

Definition at line 157 of file intrman.c.

◆ EnableIntr()

int EnableIntr ( int  irq)

Enables (unmasks) the specified hardware interrupt cause.

Parameters
irqInterrupt cause to enable.
Returns
Returns 0 on success, non-zero error code on failure.

Definition at line 336 of file intrman.c.

◆ DisableIntr()

int DisableIntr ( int  irq,
int *  res 
)

Disables (masks) the specified hardware interrupt cause.

Parameters
irqInterrupt cause to disable.
resPointer to a variable to receive the interrupt number of the interrupt that was disabled.
Returns
Returns 0 on success, non-zero error code on failure.

Definition at line 385 of file intrman.c.

◆ CpuDisableIntr()

int CpuDisableIntr ( )

Disables interrupts, regardless of the current statue. This is deprecated. The interrupt mask registers for each interrupt cause will not be changed. May be called from an interrupt or thread context.

Returns
Returns 0 on success, non-zero error code on failure.

Definition at line 228 of file intrman.c.

◆ CpuEnableIntr()

int CpuEnableIntr ( )

Enables interrupts, regardless of the current state. This is deprecated. The interrupt mask registers for each interrupt cause will not be changed. May be called from an interrupt or thread context.

Returns
Returns 0 on success, non-zero error code on failure.

Definition at line 240 of file intrman.c.

◆ CpuSuspendIntr()

int CpuSuspendIntr ( int *  state)

Disables interrupts. The interrupt mask registers for each interrupt cause will not be changed. May be called from an interrupt or thread context.

Parameters
stateA pointer to a variable that will store the current interrupt status. Even if KE_CPUDI is returned, state will be set appropriately.
Returns
Returns 0 on success, non-zero error code on failure.
See also
CpuResumeIntr()

Definition at line 195 of file intrman.c.

Referenced by EnterCritical(), and sceCdPOffCallback().

◆ CpuResumeIntr()

int CpuResumeIntr ( int  state)

Enables interrupts. The interrupt mask registers for each interrupt cause will not be changed. May be called from an interrupt or thread context.

Parameters
stateThe previous state of interrupts, as indicated by the preceeding call to CpuSuspendIntr().
Returns
Returns 0 on success, non-zero error code on failure.
See also
CpuSuspendIntr()

Definition at line 217 of file intrman.c.

Referenced by ExitCritical(), and sceCdPOffCallback().

◆ CpuInvokeInKmode()

int CpuInvokeInKmode ( void *  function,
  ... 
)

Invokes a function in kernel mode via a syscall handler. This is usually used for synchronization between interrupt and DECI2 contexts.

Parameters
functionA pointer to the function to call. Specify other arguments for the function, after function.
Returns
The return value of the function.

◆ DisableDispatchIntr()

void DisableDispatchIntr ( int  irq)

Disables dispatching of the interrupt handler, by INTRMAN. Used by DECI2, when DECI2RS is to manage the SIF2 and SBUS interrupts. This does not change the interrupt mask status.

Parameters
irqThe interrupt to mask in software.

Definition at line 484 of file intrman.c.

◆ EnableDispatchIntr()

void EnableDispatchIntr ( int  irq)

Enables dispatching of the interrupt handler, by INTRMAN. This does not change the interrupt mask status.

Parameters
irqThe interrupt to unmask in software.

Definition at line 458 of file intrman.c.

◆ QueryIntrContext()

int QueryIntrContext ( void  )

Indicates whether execution is currently within an interrupt or thread context.

Returns
1 if within the interrupt context, 0 if not.

◆ QueryIntrStack()

int QueryIntrStack ( void *  sp)

Indicates whether the specified stack pointer is within the interrupt stack.

Parameters
spThe stack pointer to check.
Returns
1 if the specified stack pointer is within the interrupt stack, 0 if not.

◆ SetNewCtxCb()

void SetNewCtxCb ( void *  cb)

These set callback functions for thread support Only the thread manager should set these

Definition at line 703 of file intrman.c.