12#include "irx_imports.h"
14#define MODNAME "XESDRV"
17#define DPRINTF(x...) printf(MODNAME ": " x)
22static int module_start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
23static int module_stop(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
27static int esdrv_df_devctl(
28 iomanX_iop_file_t *f,
const char *name,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
30esdrv_df_ioctl2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
32esioctl2_func_1(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
34esioctl2_func_10(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
36esioctl2_func_2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
38esioctl2_func_3(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
40esioctl2_func_4(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
42esioctl2_func_5(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
44esioctl2_func_6(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
46esioctl2_func_7(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
48esioctl2_func_8(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
50esioctl2_func_9(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
52esioctl2_func_a(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
54esioctl2_func_b(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
56esioctl2_func_c(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
58esioctl2_func_d(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
60esioctl2_func_e(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
62esioctl2_func_f(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
196static es_regs_t *
const es_regs = (
void *)0xBF415000;
202} DevctlCmdTbl[16] = {
203 {0x5464, &esioctl2_func_1},
204 {0x5465, &esioctl2_func_2},
205 {0x5466, &esioctl2_func_3},
206 {0x5467, &esioctl2_func_4},
207 {0x5468, &esioctl2_func_5},
208 {0x5469, &esioctl2_func_6},
209 {0x546A, &esioctl2_func_7},
210 {0x546B, &esioctl2_func_8},
211 {0x546C, &esioctl2_func_9},
212 {0x546D, &esioctl2_func_a},
213 {0x546E, &esioctl2_func_b},
214 {0x546F, &esioctl2_func_c},
215 {0x5470, &esioctl2_func_d},
216 {0x5471, &esioctl2_func_e},
217 {0x5472, &esioctl2_func_f},
218 {0x5473, &esioctl2_func_10},
221IOMANX_RETURN_VALUE_IMPL(
ENOTSUP);
246 IOMANX_RETURN_VALUE_S64(
ENOTSUP),
254 .desc =
"PSX ES DRIVER",
261IRX_ID(MODNAME, 1, 1);
263int _start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
266 return module_start(argc, argv, startaddr, mi);
268 return module_stop(argc, argv, startaddr, mi);
271static int module_start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
277 if ( iomanX_AddDrv(&ESDRV) != 0 )
278 return MODULE_NO_RESIDENT_END;
280 return MODULE_REMOVABLE_END;
282 if ( mi && ((mi->
newflags & 2) != 0) )
284 return MODULE_RESIDENT_END;
288static int module_stop(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
295 if ( iomanX_DelDrv(ESDRV.name) != 0 )
296 return MODULE_REMOVABLE_END;
297 return MODULE_NO_RESIDENT_END;
308 semaparam.initial = 1;
310 semaparam.option = 0;
311 sema_id_tmp = CreateSema(&semaparam);
312 if ( sema_id_tmp < 0 )
314 sema_id = sema_id_tmp;
322 if ( DeleteSema(sema_id) != 0 )
338static int esdrv_df_devctl(
339 iomanX_iop_file_t *f,
const char *name,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
348 for ( i = 0; i < (
sizeof(DevctlCmdTbl) /
sizeof(DevctlCmdTbl[0])); i += 1 )
350 if ( DevctlCmdTbl[i].cmd == cmd )
352 retres = DevctlCmdTbl[i].fn(f, cmd, arg, arglen, buf, buflen);
361esdrv_df_ioctl2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
375static void EsAcsSetAaryptorIoMode(
void)
381static u8 EsAcsGetAaryptorIoMode(
void)
383 return es_regs->r_es0C;
387static void EsAcsAaryptorIoEnable(
void)
389 es_regs->r_es0C |= 1;
393static void EsAcsAaryptorIoDisable(
void)
395 es_regs->r_es0C &= ~1;
400static u8 EsAcsIsAaryptorIoEnable(
void)
402 return es_regs->r_es0C & 1;
406static void EsAcsSetBbryptorIoMode(
void)
408 es_regs->r_es0E = 0x58;
412static u8 EsAcsGetBbryptorIoMode(
void)
414 return es_regs->r_es0E;
418static void EsAcsBbryptorIoEnable(
void)
420 es_regs->r_es0E |= 1;
424static u8 EsAcsIsBbryptorIoEnable(
void)
426 return es_regs->r_es0E & 1;
431static void EsAcsBbryptorIoDisable(
void)
433 es_regs->r_es0E &= ~1;
438static u8 EsAcsGetProcessCall(
void)
440 return es_regs->r_es28;
444static void EsAcsAaStreamOn(
void)
450static u8 EsAcsIsAaStreamOn(
void)
452 return es_regs->r_es28 & 2;
456static void EsAcsAaTreminate(
void)
462static u8 EsAcsIsAaEmpty(
void)
464 return es_regs->r_es1C & 2;
468static u8 EsAcsGetStatusAaEmpty(
void)
470 return es_regs->r_es1C & 2;
473static u8 EsAcsIsAaComplete(
void)
475 return es_regs->r_es1A & 2;
478static void EsAcsSetAaCompleteIntrClear(
void)
480 es_regs->r_es1A &= 2;
483static u8 EsAcsIsAaPckError(
void)
485 return es_regs->r_es18 & 2;
488static void EsAcsSetAaPckErrorIntrClear(
void)
490 es_regs->r_es18 &= 2;
493static void EsAcsBbStreamOn(
void)
499static u8 EsAcsIsBbStreamOn(
void)
501 return es_regs->r_es28 & 1;
505static void EsAcsBbTreminate(
void)
510static u8 EsAcsIsBbComplete(
void)
512 return es_regs->r_es1A & 1;
515static void EsAcsSetBbCompleteIntrClear(
void)
517 es_regs->r_es1A &= 1;
520static u8 EsAcsIsBbPckError(
void)
522 return es_regs->r_es18 & 1;
525static void EsAcsSetBbPckErrorIntrClear(
void)
527 es_regs->r_es18 &= 1;
531static u8 EsAcsIsBbEmpty(
void)
533 return es_regs->r_es1C & 1;
538static void EsAcsBbThroughEnable(
void)
540 es_regs->r_es08 |= 8;
544static void EsAcsBbThroughDisable(
void)
546 es_regs->r_es08 &= ~8;
549static u8 EsAcsIsBbBlockThrough(
void)
551 return es_regs->r_es08 & 8;
555static u8 EsAcsGetStatusBbPesScrambleControl(
void)
559 r_es22 = es_regs->r_es22;
560 es_regs->r_es22 = r_es22 & 0xC;
561 return (u8)(r_es22 & 0xC) >> 2;
565static u8 EsAcsGetStatusBbEmpty(
void)
567 return es_regs->r_es1C & 1;
571static int EsAcsGetSerialNumber(
void)
573 return es_regs->r_es3E | (es_regs->r_es38 << 24) | (es_regs->r_es3A << 16) | (es_regs->r_es3C << 8);
578static void EsAcsSetSerialNumber(
unsigned int a1)
580 es_regs->r_es38 = (a1 >> 24) & 0xFF;
581 es_regs->r_es3A = (a1 >> 16) & 0xFF;
582 es_regs->r_es3C = (a1 >> 8) & 0xFF;
583 es_regs->r_es3E = a1 & 0xFF;
587static void EsAcsSetSerialNumberReg1(u8 a1)
589 es_regs->r_es38 = a1;
592static void EsAcsSetSerialNumberReg2(u8 a1)
594 es_regs->r_es3A = a1;
597static void EsAcsSetSerialNumberReg3(u8 a1)
599 es_regs->r_es3C = a1;
602static void EsAcsSetSerialNumberReg4(u8 a1)
604 es_regs->r_es3E = a1;
608static u8 EsAcsGetStatusA(
void)
610 return es_regs->r_es20;
615static u8 EsAcsIsBbStatusInit(
void)
617 return (es_regs->r_es20 & 0xF) == 0;
621static u8 EsAcsIsBbStatusIdle(
void)
623 return (es_regs->r_es20 & 0xF) == 1;
627static u8 EsAcsIsBbStatusNn(
void)
629 return (es_regs->r_es20 & 0xF) == 2;
633static u8 EsAcsIsBbStatusUUTT(
void)
635 return (es_regs->r_es20 & 0xF) == 3;
639static u8 EsAcsIsBbStatusDec(
void)
641 return (es_regs->r_es20 & 0xF) == 4;
646static u8 EsAcsIsBbStatusRandom(
void)
648 return (es_regs->r_es20 & 0xF) == 6;
652static void EsAcsSetSdeData(u8 a1)
654 es_regs->r_es34 = a1;
657static void EsAcsAllIntDisableA(
void)
662static void EsAcsAllIntDisableB(
void)
667static void EsAcsAllIntDisableC(
void)
672static void EsAcsAllIntDisable(
void)
674 EsAcsAllIntDisableA();
675 EsAcsAllIntDisableB();
676 EsAcsAllIntDisableC();
679static void EsAcsAllIntStatClearA(
void)
681 es_regs->r_es18 = 0x9F;
684static void EsAcsAllIntStatClearB(
void)
686 es_regs->r_es1A = 0xDF;
689static void EsAcsAllIntStatClearC(
void)
691 es_regs->r_es1C = 0x83;
694static void EsAcsAllIntStatClear(
void)
696 EsAcsAllIntStatClearA();
697 EsAcsAllIntStatClearB();
698 EsAcsAllIntStatClearC();
702static void EsAcsIntEnableInitComplete(
void)
704 es_regs->r_es12 |= 0x40;
709static void EsAcsIntDisableInitComplete(
void)
711 es_regs->r_es12 &= ~0x40;
716static void EsAcsIntEnableProcessRandom(
void)
718 es_regs->r_es14 |= 0x80;
723static void EsAcsIntDisableProcessRandom(
void)
725 es_regs->r_es14 &= ~0x80;
730static void EsAcsIntEnableNnInvalid(
void)
732 es_regs->r_es10 |= 0x10;
737static void EsAcsIntDisableNnInvalid(
void)
739 es_regs->r_es10 &= ~0x10;
744static void EsAcsIntEnableNnRevoked(
void)
746 es_regs->r_es10 |= 8;
751static void EsAcsIntDisableNnRevoked(
void)
753 es_regs->r_es10 &= ~8;
758static void EsAcsIntEnableNnReplaced(
void)
760 es_regs->r_es10 |= 4;
765static void EsAcsIntDisableNnReplaced(
void)
767 es_regs->r_es10 &= ~4;
772static void EsAcsIntEnableNnComplete(
void)
774 es_regs->r_es12 |= 0x10;
779static void EsAcsIntDisableNnComplete(
void)
781 es_regs->r_es12 &= ~0x10;
786static void EsAcsIntEnableProcessNn(
void)
788 EsAcsIntEnableNnInvalid();
789 EsAcsIntEnableNnRevoked();
790 EsAcsIntEnableNnReplaced();
791 EsAcsIntEnableNnComplete();
796static void EsAcsIntDisableProcessNn(
void)
798 EsAcsIntDisableNnInvalid();
799 EsAcsIntDisableNnRevoked();
800 EsAcsIntDisableNnReplaced();
801 EsAcsIntDisableNnComplete();
806static void EsAcsIntEnableUUComplete(
void)
808 es_regs->r_es12 |= 8;
813static void EsAcsIntDisableUUComplete(
void)
815 es_regs->r_es12 &= ~8;
820static void EsAcsIntEnableProcessUU(
void)
822 EsAcsIntEnableUUComplete();
827static void EsAcsIntDisableProcessUU(
void)
829 EsAcsIntDisableUUComplete();
834static void EsAcsIntEnableTTComplete(
void)
836 es_regs->r_es12 |= 4;
841static void EsAcsIntDisableTTComplete(
void)
843 es_regs->r_es12 &= ~4;
848static void EsAcsIntEnableProcessTT(
void)
850 EsAcsIntEnableTTComplete();
855static void EsAcsIntDisableProcessTT(
void)
857 EsAcsIntDisableTTComplete();
862static void EsAcsIntEnableBbEmpty(
void)
864 es_regs->r_es14 |= 1;
869static void EsAcsIntDisableBbEmpty(
void)
871 es_regs->r_es14 &= ~1;
876static void EsAcsIntEnableBbPackErr(
void)
878 es_regs->r_es10 |= 1;
883static void EsAcsIntDisableBbPackErr(
void)
885 es_regs->r_es10 &= ~1;
890static void EsAcsIntEnableAaPackErr(
void)
892 es_regs->r_es10 |= 2;
897static void EsAcsIntDisableAaPackErr(
void)
899 es_regs->r_es10 &= ~2;
903static void EsAcsSoftReset(
void)
905 es_regs->r_es00 = 0x80;
908static void EsAcsInitTerminate(
void)
910 es_regs->r_es2C = 0x40;
913static void EsAcsSetInitComplete(
void)
915 es_regs->r_es1A &= 0x40;
918static void EsAcsRandSeedSn(
void)
920 es_regs->r_es08 |= 0x10;
923static u8 EsAcsIsAccessProhibit(
void)
925 return es_regs->r_es22 & 0x80;
928static u8 EsAcsIsInidecError(
void)
930 return es_regs->r_es18 & 0x80;
933static void EsAcsSetInidecErrorIntrClear(
void)
935 es_regs->r_es18 &= 0x80;
938static u8 EsAcsIsLrsComplete(
void)
940 return es_regs->r_es1A & 0x80;
943static void EsAcsSetLrsComplete(
void)
945 es_regs->r_es1A &= 0x80;
948static u8 EsAcsIsInitComplete(
void)
950 return es_regs->r_es1A & 0x40;
953static void EsAcsStartRandom(
void)
955 es_regs->r_es2A = 0x80;
958static u8 EsAcsIsRandomComplete(
void)
960 return es_regs->r_es1C & 0x80;
963static void EsAcsSetRandomComplete(
void)
965 es_regs->r_es1C &= 0x80;
968static void EsAcsStartNn(
void)
970 es_regs->r_es28 = 0x10;
973static void EsAcsTerminateNn(
void)
975 es_regs->r_es2C = 0x10;
978static u8 EsAcsIsNnInvalid(
void)
980 return es_regs->r_es18 & 0x10;
983static u8 EsAcsIsNnRevoked(
void)
985 return es_regs->r_es18 & 8;
988static u8 EsAcsIsNnReplaced(
void)
990 return es_regs->r_es18 & 4;
993static u8 EsAcsIsNnComplete(
void)
995 return es_regs->r_es1A & 0x10;
998static void EsAcsSetNnInvalid(
void)
1000 es_regs->r_es18 &= 0x10;
1003static void EsAcsSetNnRevoked(
void)
1005 es_regs->r_es18 &= 8;
1008static void EsAcsSetNnReplaced(
void)
1010 es_regs->r_es18 &= 4;
1013static void EsAcsSetNnComplete(
void)
1015 es_regs->r_es1A &= 0x10;
1018static void EsAcsSetNnIntrAllClear(
void)
1020 EsAcsSetNnInvalid();
1021 EsAcsSetNnRevoked();
1022 EsAcsSetNnReplaced();
1023 EsAcsSetNnComplete();
1026static void EsAcsSetNnPacksUsed(u8 a1)
1028 es_regs->r_es36 = a1;
1031static void EsAcsSetNnValidationData(
const u8 *a1)
1033 es_regs->r_es40 = *a1;
1034 es_regs->r_es42 = a1[1];
1035 es_regs->r_es44 = a1[2];
1036 es_regs->r_es46 = a1[3];
1037 es_regs->r_es48 = a1[4];
1038 es_regs->r_es4A = a1[5];
1039 es_regs->r_es4C = a1[6];
1040 es_regs->r_es4E = a1[7];
1043static void EsAcsStartUU(
void)
1045 es_regs->r_es28 = 8;
1048static void EsAcsStartTT(
void)
1050 es_regs->r_es28 = 4;
1053static u8 EsAcsIsUUComplete(
void)
1055 return es_regs->r_es1A & 8;
1058static u8 EsAcsIsTTComplete(
void)
1060 return es_regs->r_es1A & 4;
1063static void EsAcsSetUUComplete(
void)
1065 es_regs->r_es1A = 8;
1068static void EsAcsSetTTComplete(
void)
1070 es_regs->r_es1A = 4;
1073static void EsAcsSetBbryptedTitleKey(
void)
1075 es_regs->r_es08 |= 4;
1078static void EsAcsSetRandomTitleKey(
void)
1080 es_regs->r_es08 &= ~4;
1083static void EsAcsSetMediaId(
const u8 *a1)
1085 es_regs->r_es50 = a1[0];
1086 es_regs->r_es52 = a1[1];
1087 es_regs->r_es54 = a1[2];
1088 es_regs->r_es56 = a1[3];
1089 es_regs->r_es58 = a1[4];
1090 es_regs->r_es5A = a1[5];
1091 es_regs->r_es5C = a1[6];
1092 es_regs->r_es5E = a1[7];
1095static void EsAcsSetTTe(
const u8 *a1)
1097 es_regs->r_es60 = a1[0];
1098 es_regs->r_es62 = a1[1];
1099 es_regs->r_es64 = a1[2];
1100 es_regs->r_es66 = a1[3];
1101 es_regs->r_es68 = a1[4];
1102 es_regs->r_es6A = a1[5];
1103 es_regs->r_es6C = a1[6];
1104 es_regs->r_es6E = a1[7];
1107static void EsAcsGetTTe(u8 *a1)
1109 a1[0] = (u8)(es_regs->r_es70);
1110 a1[1] = (u8)(es_regs->r_es72);
1111 a1[2] = (u8)(es_regs->r_es74);
1112 a1[3] = (u8)(es_regs->r_es76);
1113 a1[4] = (u8)(es_regs->r_es78);
1114 a1[5] = (u8)(es_regs->r_es7A);
1115 a1[6] = (u8)(es_regs->r_es7C);
1116 a1[7] = (u8)(es_regs->r_es7E);
1120static u8 EsAcsGetIntrSrcA(
void)
1122 return es_regs->r_es18;
1127static u8 EsAcsGetIntrSrcB(
void)
1129 return es_regs->r_es1A;
1134static u8 EsAcsGetIntrSrcC(
void)
1136 return es_regs->r_es1C;
1140static u8 EsAcsGetChipVersion(
void)
1142 return es_regs->r_es02;
1145static u8 EsAcsGetRevision1(
void)
1147 return es_regs->r_es04;
1150static u8 EsAcsGetRevision2(
void)
1152 return es_regs->r_es06;
1156static u16 EsAcsGetReg(
int a1)
1158 return *(u16 *)(&es_regs->r_es00 + a1);
1163static void EsAcsSetReg(u8 a1, u8 a2)
1165 *(u16 *)(&es_regs->r_es00 + a1) = a2;
1169static u8 EsDrvNnResultCheck(
void)
1171 if ( EsAcsIsNnInvalid() != 0 )
1175 if ( EsAcsIsNnRevoked() != 0 )
1179 if ( EsAcsIsNnReplaced() != 0 )
1183 if ( EsAcsIsNnComplete() != 0 )
1190static void EsDrvSoftReset(
void)
1196static void EsDrvSetSerialNumber(u8 *a1)
1198 EsAcsSetSerialNumberReg1(a1[0]);
1199 EsAcsSetSerialNumberReg2(a1[1]);
1200 EsAcsSetSerialNumberReg3(a1[2]);
1201 EsAcsSetSerialNumberReg4(a1[3]);
1204static u8 EsDrvSetSde(u8 *a1)
1208 EsAcsSetInidecErrorIntrClear();
1209 EsAcsSetLrsComplete();
1210 for ( i = 0; i < 0x1be; i += 1 )
1212 EsAcsSetSdeData(a1[i]);
1215 if ( EsAcsIsAccessProhibit() != 0 )
1222static u8 EsDrvCheckSdeProcess(
int a1)
1224 if ( EsAcsIsInidecError() )
1226 EsAcsSetInidecErrorIntrClear();
1229 if ( EsAcsIsLrsComplete() == 0 )
1233 EsAcsSetLrsComplete();
1238static u8 EsDrvTrmntInitProcess(
void)
1242 EsAcsSetInitComplete();
1243 EsAcsInitTerminate();
1244 for ( i = 0; i < 0x65; i += 1 )
1246 if ( EsAcsIsInitComplete() )
1248 EsAcsSetInitComplete();
1251 DelayThread(100000);
1256static void EsDrvCmpltInitProcess(
void)
1259 EsAcsSetAaryptorIoMode();
1260 EsAcsSetBbryptorIoMode();
1261 EsAcsAllIntDisable();
1262 EsAcsAllIntStatClear();
1263 EsAcsAaryptorIoEnable();
1264 EsAcsBbryptorIoEnable();
1267static u8 EsDrvRndNnCheck(
void)
1269 if ( EsAcsIsBbStatusIdle() == 0 )
1274static u8 EsDrvRandom(
void)
1278 for ( i = 0; i < 15; ++i )
1283 EsAcsSetRandomComplete();
1285 for ( j = 0; j < 6; j += 1 )
1287 if ( EsAcsIsRandomComplete() )
1298static void EsDrvSetNnParam(u8 a1,
const u8 *a2)
1300 EsAcsSetNnPacksUsed(a1);
1301 EsAcsSetNnValidationData(a2);
1304static void EsDrvSetNnStart(
void)
1306 EsAcsSetNnIntrAllClear();
1307 EsAcsBbThroughDisable();
1311static int EsDrvStartNnCheckStat(
void)
1313 return EsDrvNnResultCheck();
1316static void EsDrvSetNnStop(
void)
1321static int EsDrvStopNnCheckStat(
void)
1325 retval = EsDrvNnResultCheck();
1331 for ( i = 0; i < 10; i += 1 )
1333 retval = EsDrvNnResultCheck();
1339 EsAcsSetNnIntrAllClear();
1343static u8 EsDrvSetUUStart(
const u8 *a1)
1345 if ( EsAcsIsBbStatusUUTT() == 0 )
1349 EsAcsBbThroughDisable();
1350 EsAcsSetMediaId(a1);
1351 EsAcsSetUUComplete();
1356static u8 EsDrvCmpltUUProcess(
void)
1360 for ( i = 0; i < 0x65; i += 1 )
1362 if ( EsAcsIsUUComplete() )
1364 EsAcsSetUUComplete();
1372static u8 EsDrvSetTTStart(u8 a1,
const u8 *a2)
1376 EsAcsSetBbryptedTitleKey();
1381 EsAcsSetRandomTitleKey();
1383 EsAcsSetTTComplete();
1388static u8 EsDrvCmpltTTProcess(u8 a1, u8 *a2)
1392 for ( i = 0; i < 0x65; i += 1 )
1394 if ( EsAcsIsTTComplete() )
1396 EsAcsSetTTComplete();
1408static u8 EsDrvBbStart(
void)
1410 if ( EsAcsIsBbBlockThrough() != 0 )
1414 EsAcsSetBbPckErrorIntrClear();
1415 EsAcsSetBbCompleteIntrClear();
1420static int EsDrvBbBsCheck(
void)
1422 if ( EsAcsIsBbPckError() != 0 )
1424 EsAcsSetBbPckErrorIntrClear();
1430static u8 EsDrvBbStop(
void)
1435 for ( i = 0; i < 0x65; i += 1 )
1437 if ( EsAcsIsBbComplete() )
1439 EsAcsSetBbCompleteIntrClear();
1442 DelayThread(100000);
1447static void EsDrvAaStart(
void)
1449 EsAcsSetAaPckErrorIntrClear();
1450 EsAcsSetAaCompleteIntrClear();
1454static int EsDrvAaBsCheck(
void)
1456 if ( EsAcsIsAaPckError() != 0 )
1458 EsAcsSetAaPckErrorIntrClear();
1464static u8 EsDrvAaStop(
void)
1469 for ( i = 0; i < 0x65; i += 1 )
1471 if ( EsAcsIsAaComplete() )
1473 EsAcsSetAaCompleteIntrClear();
1476 DelayThread(100000);
1482static void EsDrvBbFifoClear(
void)
1484 if ( !EsAcsIsBbBlockThrough() )
1486 EsAcsIntDisableBbPackErr();
1493static void EsDrvAaFifoClear(
void)
1500static int EsDrvGetBbPesScrambleControl(
void)
1502 return EsAcsGetStatusBbPesScrambleControl();
1506static int EsDrvAaEmptyCheck(
void)
1508 return EsAcsGetStatusAaEmpty() == 0;
1511static int EsDrvBbEmptyCheck(
void)
1513 return EsAcsGetStatusBbEmpty() == 0;
1516static int EsDrvGetChipVersion(
void)
1518 return EsAcsGetChipVersion();
1521static int EsDrvGetRevision1(
void)
1523 return EsAcsGetRevision1();
1526static int EsDrvGetRevision2(
void)
1528 return EsAcsGetRevision2();
1532static int EsDrvGetReg(
int a1)
1534 return EsAcsGetReg(a1);
1539static void EsDrvSetReg(u8 a1, u8 a2)
1541 EsAcsSetReg(a1, a2);
1546esioctl2_func_1(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1554 *(u8 *)buf = EsDrvGetChipVersion();
1555 *((u8 *)buf + 1) = EsDrvGetRevision1();
1556 *((u8 *)buf + 2) = EsDrvGetRevision2();
1561esioctl2_func_10(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1569 *(u32 *)buf = 0x4071200;
1574esioctl2_func_2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1587esioctl2_func_3(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1600esioctl2_func_4(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1609 EsDrvSetSerialNumber((u8 *)arg);
1610 if ( EsDrvSetSde((u8 *)arg + 4) != 0 )
1615 EsDrvCheckSdeProcess(((*((u8 *)arg + 452) << 16) & 0x1FFFF) | (u16)(*((u8 *)arg + 451) << 8) | *((u8 *)arg + 450))
1620 if ( EsDrvTrmntInitProcess() != 0 )
1624 EsDrvCmpltInitProcess();
1629esioctl2_func_5(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1638 if ( EsDrvRndNnCheck() )
1640 if ( EsDrvRandom() != 0 )
1646esioctl2_func_6(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1654 if ( EsDrvRndNnCheck() != 0 )
1658 if ( (
unsigned int)*(u8 *)arg - 1 >= 0x10 )
1662 EsDrvSetNnParam(*(u8 *)arg, (u8 *)arg + 1);
1668esioctl2_func_7(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1676 *(u8 *)buf = EsDrvStartNnCheckStat();
1681esioctl2_func_8(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1690 *(u8 *)buf = EsDrvStopNnCheckStat();
1695esioctl2_func_9(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1704 if ( EsDrvSetUUStart((u8 *)arg) != 0 )
1708 if ( EsDrvCmpltUUProcess() != 0 )
1713 if ( EsDrvSetTTStart(*((u8 *)arg + 8), (u8 *)arg + 9) != 0 )
1717 if ( EsDrvCmpltTTProcess(*((u8 *)arg + 8), (u8 *)arg + 9) != 0 )
1722 for ( i = 0; i < 8; i += 1 )
1724 ((u8 *)buf)[i] = ((u8 *)arg)[i + 9];
1730esioctl2_func_a(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1744esioctl2_func_b(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1752 *(u8 *)buf = EsDrvAaBsCheck();
1753 *((u8 *)buf + 1) = EsDrvAaEmptyCheck();
1758esioctl2_func_c(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1767 if ( EsDrvAaStop() != 0 )
1773esioctl2_func_d(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1787esioctl2_func_e(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1795 *(u8 *)buf = EsDrvBbBsCheck();
1796 *((u8 *)buf + 1) = EsDrvBbEmptyCheck();
1801esioctl2_func_f(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1810 if ( EsDrvBbStop() != 0 )