11#include "irx_imports.h"
16IRX_ID(
"rmreset", 1, 1);
20static void sio2_ctrl_set(u32 val)
22 USE_IOP_MMIO_HWPORT();
24 iop_mmio_hwport->sio2.ctrl = val;
27static u32 sio2_ctrl_get(
void)
29 USE_IOP_MMIO_HWPORT();
31 return iop_mmio_hwport->sio2.ctrl;
34static u32 sio2_stat6c_get(
void)
36 USE_IOP_MMIO_HWPORT();
38 return iop_mmio_hwport->sio2.recv1;
41static void sio2_portN_ctrl1_set(
int N, u32 val)
43 USE_IOP_MMIO_HWPORT();
45 iop_mmio_hwport->sio2.send1_2_buf[N * 2] = val;
50static void sio2_portN_ctrl2_set(
int N, u32 val)
52 USE_IOP_MMIO_HWPORT();
54 iop_mmio_hwport->sio2.send1_2_buf[(N * 2) + 1] = val;
61static void sio2_regN_set(
int N, u32 val)
63 USE_IOP_MMIO_HWPORT();
65 iop_mmio_hwport->sio2.send3_buf[N] = val;
80static void sio2_data_out(u8 val)
82 USE_IOP_MMIO_HWPORT();
84 iop_mmio_hwport->sio2.out_fifo = val;
87static u8 sio2_data_in(
void)
89 USE_IOP_MMIO_HWPORT();
91 return iop_mmio_hwport->sio2.in_fifo;
98int _start(
int ac,
char **av)
108 printf(
"rmreset start\n");
109 ctrl_save = sio2_ctrl_get();
111 for ( i = 0; i < 4; i += 1 )
113 sio2_portN_ctrl1_set(i, 0xC0C0050F);
114 sio2_portN_ctrl2_set(i, 0x1060014u);
116 sio2_regN_set(0, 0x1C0740u);
121 for ( i = 3; i < (int)(
sizeof(inoutbuf)); i += 1 )
123 for ( i = 0; i < (int)(
sizeof(inoutbuf)); i += 1 )
124 sio2_data_out(inoutbuf[i]);
125 sio2_ctrl_set(0xB1u);
126 while ( !((sio2_stat6c_get() >> 12) & 1) )
128 for ( i = 0; i < 7; i += 1 )
131 for ( i = 0; i < 4; i += 1 )
133 sio2_portN_ctrl1_set(i, 0xC0C0050F);
134 sio2_portN_ctrl2_set(i, 0x1060014u);
136 sio2_regN_set(0, 0x1C0741u);
141 for ( i = 3; i < (int)(
sizeof(inoutbuf)); i += 1 )
143 for ( i = 0; i < (int)(
sizeof(inoutbuf)); i += 1 )
144 sio2_data_out(inoutbuf[i]);
145 sio2_ctrl_set(0xB1u);
146 while ( !((sio2_stat6c_get() >> 12) & 1) )
148 for ( i = 0; i < 7; i += 1 )
151 sio2_ctrl_set(ctrl_save & ~1);
152 printf(
"rmreset end\n");
153 return MODULE_NO_RESIDENT_END;