ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
internal.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int checkModelVersion (void)
 
void GsDmaInit (void)
 
void GsDmaSend (const void *addr, u32 qwords)
 
void GsDmaSend_tag (const void *addr, u32 qwords, const GS_GIF_DMACHAIN_TAG *tag)
 
void GsDmaWait (void)
 

Function Documentation

◆ checkModelVersion()

int checkModelVersion ( void  )

Definition at line 52 of file draw.c.

53 {
54  int fd, result, i;
55  char data[256], *pData;
56 
57  if((fd=open("rom0:ROMVER", O_RDONLY))>=0)
58  {
59  for(pData=data,i=0; i<sizeof(data); i++)
60  {
61  read(fd, pData, 1);
62  if(*pData++=='\0') break;
63  }
64  close(fd);
65 
66  //ROMVER string format: VVVVRTYYYYMMDD\n
67  result=(20010608<atoi(data+i-9));
68  }
69  else result=-1;
70 
71  return result;
72 }
u32 data
Definition: libmouse.c:36
s32 result
Definition: rpc_client.c:23

References data, and result.

Referenced by GsSetDefaultDisplayEnv().

◆ GsDmaInit()

void GsDmaInit ( void  )

Definition at line 58 of file dma.c.

59 {
60  /* This appears to have been based on code from Sony that initializes DMA channels 0-9, in bulk.
61  Reset/init DMA CH 2 (GIF) only. */
62  __asm__(
63  "li $2,0x1000A000 \n"
64  "sw $0,0x80($2) \n" // D2_SADR = 0. Documented to not exist, but is done.
65  "sw $0,0($2) \n" // D2_CHCR = 0
66  "sw $0,0x30($2) \n" // D2_TADR = 0
67  "sw $0,0x10($2) \n" // D2_MADR = 0
68  "sw $0,0x50($2) \n" // D2_ASR1 = 0
69  "sw $0,0x40($2) \n" // D2_ASR0 = 0
70  "li $2,0xFF1F \n" // Clear all interrupt status under D_STAT, other than SIF0, SIF1 & SIF2.
71  "sw $2,0x1000E010 \n"
72  "lw $2,0x1000E010 \n"
73  "lui $3,0xFF1F \n" // Clear all interrupt masks under D_STAT, other SIF0, SIF1 & SIF2. Writing a 1 reverses the bit.
74  "and $2,$3 \n"
75  "sw $2,0x1000E010 \n"
76  "sw $0,0x1000E000 \n" // D_CTRL = 0
77  "sw $0,0x1000E020 \n" // D_PCR = 0
78  "sw $0,0x1000E030 \n" // D_SQWC = 0
79  "sw $0,0x1000E050 \n" // D_RBOR = 0
80  "sw $0,0x1000E040 \n" // D_RBSR = 0
81  "li $3,1 \n"
82  "lw $2,0x1000E000 \n"
83  "ori $3,$2,1 \n" // D_CTRL (DMAE 1)
84  "sw $3,0x1000E000 \n"
85  );
86 }

Referenced by GsResetGraph().

◆ GsDmaSend()

void GsDmaSend ( const void *  addr,
u32  qwords 
)

Definition at line 88 of file dma.c.

89 {
90  DMA_CHCR chcr;
91  static char spr;
92 
93  if((u32)addr >= 0x70000000 && (u32)addr <= 0x70003fff)
94  {
95  spr = 1;
96  }
97  else
98  {
99  spr = 0;
100  }
101 
102  *((vu32 *)(gif_madr)) = ( u32 )((( u32 )addr) & 0x7FFFFFFF) << 0 | (u32)((spr) & 0x00000001) << 31;;
103 
104  *((vu32 *)(gif_qwc)) = qwords;
105 
106  chcr.direction =1;
107  chcr.mode =0;
108  chcr.asp =0;
109  chcr.tte =0;
110  chcr.tie =0;
111  chcr.start_flag =1;
112  chcr.tag =0;
113  chcr.pad1 =0;
114  chcr.pad2 =0;
115  *((volatile DMA_CHCR *)(gif_chcr)) = chcr;
116 }
#define gif_madr
Definition: dma.c:23
#define gif_chcr
Definition: dma.c:21
#define gif_qwc
Definition: dma.c:25
Definition: dma.c:37
unsigned direction
Definition: dma.c:39
unsigned tag
Definition: dma.c:55
unsigned tte
Definition: dma.c:47
unsigned pad1
Definition: dma.c:41
unsigned tie
Definition: dma.c:49
unsigned start_flag
Definition: dma.c:51
unsigned mode
Definition: dma.c:43
unsigned pad2
Definition: dma.c:53
unsigned asp
Definition: dma.c:45
unsigned int u32
Definition: tamtypes.h:30
volatile u32 vu32
Definition: tamtypes.h:38

References DMA_CHCR::asp, DMA_CHCR::direction, gif_chcr, gif_madr, gif_qwc, DMA_CHCR::mode, DMA_CHCR::pad1, DMA_CHCR::pad2, DMA_CHCR::start_flag, DMA_CHCR::tag, DMA_CHCR::tie, and DMA_CHCR::tte.

Referenced by GsClearDrawEnv1(), GsClearDrawEnv2(), GsEnableAlphaBlending1(), GsEnableAlphaBlending2(), GsEnableAlphaTransparency1(), GsEnableAlphaTransparency2(), GsEnableColorClamp(), GsEnableDithering(), GsLoadImage(), GsOverridePrimAttributes(), GsPutZBufferEnv1(), GsPutZBufferEnv2(), GsSelectTexure1(), GsSelectTexure2(), GsSetFogColor(), GsSetFrame1(), GsSetFrame2(), GsSetPixelTest1(), GsSetPixelTest2(), GsSetScissor1(), GsSetScissor2(), GsSetXYOffset1(), GsSetXYOffset2(), and GsTextureFlush().

◆ GsDmaSend_tag()

void GsDmaSend_tag ( const void *  addr,
u32  qwords,
const GS_GIF_DMACHAIN_TAG tag 
)

Definition at line 118 of file dma.c.

119 {
120  DMA_CHCR chcr;
121  static char spr;
122 
123  if((u32)addr >= 0x70000000 && (u32)addr <= 0x70003fff)
124  {
125  spr = 1;
126  }
127  else
128  {
129  spr = 0;
130  }
131 
132  *((vu32 *)(gif_madr)) = ( u32 )((( u32 )addr) & 0x7FFFFFFF) << 0 | (u32)((spr) & 0x00000001) << 31;
133  *((vu32 *)(gif_qwc)) = qwords;
134  *((vu32 *)(gif_tadr)) = ( u32 )((( u32 )tag) & 0x7FFFFFFF) << 0 | (u32)((0) & 0x00000001) << 31;
135 
136  chcr.direction =1;
137  chcr.mode =1; //chain
138  chcr.asp =0;
139  chcr.tte =0;
140  chcr.tie =0;
141  chcr.start_flag =1;
142  chcr.tag =0;
143  chcr.pad1 =0;
144  chcr.pad2 =0;
145  *((volatile DMA_CHCR *)(gif_chcr)) = chcr;
146 }
#define gif_tadr
Definition: dma.c:26

References DMA_CHCR::asp, DMA_CHCR::direction, gif_chcr, gif_madr, gif_qwc, gif_tadr, DMA_CHCR::mode, DMA_CHCR::pad1, DMA_CHCR::pad2, DMA_CHCR::start_flag, DMA_CHCR::tag, DMA_CHCR::tie, and DMA_CHCR::tte.

Referenced by GsGifPacketsExecute().

◆ GsDmaWait()