23#define CMD_PACKET_MAX 128
24#define CMD_PACKET_DATA_MAX 112
25#define SYS_CMD_HANDLER_MAX 32
28#define DMAC_COMM_STAT 0x1000e010
29#define DMAC_SIF0_CHCR 0x1000c000
53extern int _iop_reboot_count;
55int _SifCmdIntHandler(
int channel);
58static unsigned int _SifSendCmd(
int cid,
int mode,
void *pkt,
int pktsize,
void *src,
67 if (pktsize > CMD_PACKET_DATA_MAX)
72 header->
psize = pktsize;
80 SifWriteBackDCache(src, size);
82 dmat[
count].src = src;
83 dmat[
count].dest = dest;
84 dmat[
count].size = size;
89 dmat[
count].src = pkt;
91 dmat[
count].size = pktsize;
92 dmat[
count].attr = SIF_DMA_ERT | SIF_DMA_INT_O;
95 SifWriteBackDCache(pkt, pktsize);
98 return iSifSetDma(dmat,
count);
100 return SifSetDma(dmat,
count);
104SifSendCmd(
int command,
void *send_data,
int send_len,
105 void *extra_from,
void *extra_dest,
int extra_len)
107 return _SifSendCmd(command, 0, send_data, send_len,
108 extra_from, extra_dest, extra_len);
112iSifSendCmd(
int command,
void *send_data,
int send_len,
113 void *extra_from,
void *extra_dest,
int extra_len)
116 extra_from, extra_dest, extra_len);
120#ifdef F__sif_cmd_int_handler
121int _SifCmdIntHandler(
int channel)
128 int size, pktquads, id, i = 0;
136 if (!(size = header->
psize))
139 pktquads = (size + 30) >> 4;
154 id = header->
cid & ~SIF_CMD_ID_SYSTEM;
157 if ((u32)
id <
cmd_data->nr_sys_handlers)
158 cmd_handlers =
cmd_data->sys_cmd_handlers;
162 if ((u32)id < cmd_data->nr_usr_handlers)
163 cmd_handlers =
cmd_data->usr_cmd_handlers;
168 if (cmd_handlers[
id].handler)
169 cmd_handlers[id].handler(packet, cmd_handlers[
id].harg);
188static int sif0_id = -1;
196static void change_addr(
void *packet,
void *harg)
199 struct ca_pkt *pkt = (
struct ca_pkt *)packet;
211static void set_sreg(
void *packet,
void *harg)
214 struct sr_pkt *pkt = (
struct sr_pkt *)packet;
216 cmd_data->sregs[pkt->sreg] = pkt->val;
221 static struct ca_pkt packet __attribute((
aligned(64)));
223 static int _rb_count = 0;
224 if (_rb_count != _iop_reboot_count) {
225 _rb_count = _iop_reboot_count;
227 DisableDmac(DMAC_SIF0);
228 RemoveDmacHandler(DMAC_SIF0, sif0_id);
238 _sif_cmd_data.
pktbuf = UNCACHED_SEG(pktbuf);
239 _sif_cmd_data.unused = UNCACHED_SEG(sif_unused);
240 _sif_cmd_data.sys_cmd_handlers = sys_cmd_handlers;
241 _sif_cmd_data.nr_sys_handlers = SYS_CMD_HANDLER_MAX;
242 _sif_cmd_data.usr_cmd_handlers = NULL;
243 _sif_cmd_data.nr_usr_handlers = 0;
244 _sif_cmd_data.sregs = sregs;
246 for (i = 0; i < SYS_CMD_HANDLER_MAX; i++) {
247 _sif_cmd_data.sys_cmd_handlers[i].handler = NULL;
248 _sif_cmd_data.sys_cmd_handlers[i].harg = NULL;
251 for (i = 0; i < 32; i++)
252 _sif_cmd_data.sregs[i] = 0;
254 _sif_cmd_data.sys_cmd_handlers[0].handler = change_addr;
255 _sif_cmd_data.sys_cmd_handlers[0].harg = &_sif_cmd_data;
256 _sif_cmd_data.sys_cmd_handlers[1].handler = set_sreg;
257 _sif_cmd_data.sys_cmd_handlers[1].harg = &_sif_cmd_data;
262 if (_lw(DMAC_COMM_STAT) & STAT_SIF0)
263 _sw(STAT_SIF0, DMAC_COMM_STAT);
266 if (!(_lw(DMAC_SIF0_CHCR) & CHCR_STR))
269 sif0_id = AddDmacHandler(DMAC_SIF0, &_SifCmdIntHandler, 0);
270 EnableDmac(DMAC_SIF0);
274 _sif_cmd_data.
iopbuf = (
void *)SifGetReg(SIF_SYSREG_SUBADDR);
275 if (_sif_cmd_data.
iopbuf) {
278 packet.buf = _sif_cmd_data.
pktbuf;
279 SifSendCmd(SIF_CMD_CHANGE_SADDR, &packet,
sizeof packet, NULL, NULL, 0);
286 SifSetReg(SIF_SYSREG_SUBADDR, (u32)_sif_cmd_data.
iopbuf);
289 SifSetReg(SIF_SYSREG_MAINADDR, (u32)&_sif_cmd_data);
290 packet.header.opt = 0;
291 packet.buf = _sif_cmd_data.
pktbuf;
292 SifSendCmd(SIF_CMD_INIT_CMD, &packet,
sizeof packet, NULL, NULL, 0);
298 DisableDmac(DMAC_SIF0);
299 RemoveDmacHandler(DMAC_SIF0, sif0_id);
304#ifdef F_sif_cmd_client
309 old = _sif_cmd_data.usr_cmd_handlers;
310 _sif_cmd_data.usr_cmd_handlers = db;
311 _sif_cmd_data.nr_usr_handlers = size;
316void SifAddCmdHandler(
int pos, SifCmdHandler_t handler,
void *harg)
319 u32
id = pos & ~SIF_CMD_ID_SYSTEM;
321 cmd_handlers = (pos &
SIF_CMD_ID_SYSTEM) ? _sif_cmd_data.sys_cmd_handlers : _sif_cmd_data.usr_cmd_handlers;
323 cmd_handlers[id].handler = handler;
324 cmd_handlers[id].harg = harg;
328#ifdef F_sif_cmd_remove_cmdhandler
329void SifRemoveCmdHandler(
int pos)
331 u32
id = pos & ~SIF_CMD_ID_SYSTEM;
334 _sif_cmd_data.sys_cmd_handlers[id].handler = NULL;
336 _sif_cmd_data.usr_cmd_handlers[id].handler = NULL;
341int SifGetSreg(
int sreg)
343 return _sif_cmd_data.sregs[sreg];
#define SIF_CMD_ID_SYSTEM
u32 count
start sector of fragmented bd/file