PS2SDK
PS2 Homebrew Libraries
siftoo.c
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
11 /*
12  * @file
13  * SIFToo low-level driver.
14  *
15  * The SBUS Interface (SIF) has 3 DMA channels, with the first 2 reserved
16  * for SCEI's SIF RPC interface. As far as I know, the last channel is
17  * only used for debugging within the EE's kernel (I haven't seen it in use
18  * on the IOP yet, I guess they decided to leave those modules out of the
19  * BIOS). So on consumer units SIF DMA channel 2 (SIF2) is unused.
20  *
21  * SIF2 is a bidirectional channel, which means data can be transferred in
22  * either direction on the SBUS. The SIFToo driver provides an interface
23  * for IOP drivers to communicate via the EE using this channel.
24  */
25 
26 #include "types.h"
27 #include "defs.h"
28 #include "irx.h"
29 
30 #include "loadcore.h"
31 #include "intrman.h"
32 #include "sifman.h"
33 #include "sbusintr.h"
34 #include "siftoo.h"
35 #include "stdio.h"
36 
37 IRX_ID("SIFToo_driver", 1, 1);
38 
39 #define SIF2_SBUS_IRQ 0
40 
41 int sif2_control(u32 intr, void *unused);
42 
43 extern struct irx_export_table _exp_siftoo;
44 
45 int _start(int argc, char *argv[])
46 {
47  u32 state;
48 
49  (void)argc;
50  (void)argv;
51 
52  if (RegisterLibraryEntries(&_exp_siftoo) != 0)
53  return MODULE_NO_RESIDENT_END;
54 
55  /* Add our SBUS interrupt handler. */
56  if (sbus_intr_init() < 0) {
57  printf("Unable to initialize SBUS interrupt driver, exiting.\n");
58  return MODULE_NO_RESIDENT_END;
59  }
60 
61  if (sbus_intr_handler_add(SIF2_SBUS_IRQ, sif2_control, NULL) < 0) {
62  printf("Unable to register SIFToo Control handler, exiting.\n");
63  return MODULE_NO_RESIDENT_END;
64  }
65 
66  CpuSuspendIntr((int *)&state);
67  sceSifDma2Init();
68  CpuResumeIntr(state);
69 
70  return MODULE_RESIDENT_END;
71 }
72 
73 int shutdown()
74 {
75  return 0;
76 }
77 
78 int sif2_init()
79 {
80  /* Perform the EE handshake:
81  * - Check if the EE was already initialized, and if so send a control
82  * message with our recieve buffer address.
83  * - If it hasn't been initialized yet, set SIF SM flag 0x80000 and
84  * wait for an event signaling that the EE is ready.
85  */
86 
87  return 0;
88 }
89 
90 int sif2_exit()
91 {
92  return 0;
93 }
94 
95 int sif2_control(u32 intr, void *unused)
96 {
97  (void)intr;
98  (void)unused;
99 
100  return 0;
101 }
102 
103 int sif2_mem_read(u32 addr, void *buf, u32 size)
104 {
105  (void)addr;
106  (void)buf;
107  (void)size;
108 
109  return 0;
110 }
111 
112 int sif2_mem_write(u32 addr, void *buf, u32 size)
113 {
114  (void)addr;
115  (void)buf;
116  (void)size;
117 
118  return 0;
119 }
sifman.h
shutdown
int shutdown()
Definition: siftoo.c:73
CpuSuspendIntr
int CpuSuspendIntr(int *state)
Definition: intrman.c:195
loadcore.h
irx.h
irx_export_table
Definition: irx.h:90
stdio.h
CpuResumeIntr
int CpuResumeIntr(int state)
Definition: intrman.c:217
siftoo.h
defs.h
intrman.h
sbusintr.h