12 #include "irx_imports.h"
14 #define MODNAME "XESDRV"
17 #define DPRINTF(x...) printf(MODNAME ": " x)
22 static int module_start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
23 static int module_stop(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
27 static 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);
30 esdrv_df_ioctl2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
32 esioctl2_func_1(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
34 esioctl2_func_10(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
36 esioctl2_func_2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
38 esioctl2_func_3(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
40 esioctl2_func_4(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
42 esioctl2_func_5(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
44 esioctl2_func_6(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
46 esioctl2_func_7(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
48 esioctl2_func_8(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
50 esioctl2_func_9(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
52 esioctl2_func_a(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
54 esioctl2_func_b(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
56 esioctl2_func_c(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
58 esioctl2_func_d(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
60 esioctl2_func_e(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
62 esioctl2_func_f(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
196 static es_regs_t *
const es_regs = (
void *)0xBF415000;
201 int (*fn)(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
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},
221 IOMANX_RETURN_VALUE_IMPL(
ENOTSUP);
246 IOMANX_RETURN_VALUE_S64(
ENOTSUP),
254 .desc =
"PSX ES DRIVER",
261 IRX_ID(MODNAME, 1, 1);
263 int _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);
271 static 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;
288 static 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 )
338 static 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);
361 esdrv_df_ioctl2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
375 static void EsAcsSetAaryptorIoMode(
void)
381 static u8 EsAcsGetAaryptorIoMode(
void)
383 return es_regs->r_es0C;
387 static void EsAcsAaryptorIoEnable(
void)
389 es_regs->r_es0C |= 1;
393 static void EsAcsAaryptorIoDisable(
void)
395 es_regs->r_es0C &= ~1;
400 static u8 EsAcsIsAaryptorIoEnable(
void)
402 return es_regs->r_es0C & 1;
406 static void EsAcsSetBbryptorIoMode(
void)
408 es_regs->r_es0E = 0x58;
412 static u8 EsAcsGetBbryptorIoMode(
void)
414 return es_regs->r_es0E;
418 static void EsAcsBbryptorIoEnable(
void)
420 es_regs->r_es0E |= 1;
424 static u8 EsAcsIsBbryptorIoEnable(
void)
426 return es_regs->r_es0E & 1;
431 static void EsAcsBbryptorIoDisable(
void)
433 es_regs->r_es0E &= ~1;
438 static u8 EsAcsGetProcessCall(
void)
440 return es_regs->r_es28;
444 static void EsAcsAaStreamOn(
void)
450 static u8 EsAcsIsAaStreamOn(
void)
452 return es_regs->r_es28 & 2;
456 static void EsAcsAaTreminate(
void)
462 static u8 EsAcsIsAaEmpty(
void)
464 return es_regs->r_es1C & 2;
468 static u8 EsAcsGetStatusAaEmpty(
void)
470 return es_regs->r_es1C & 2;
473 static u8 EsAcsIsAaComplete(
void)
475 return es_regs->r_es1A & 2;
478 static void EsAcsSetAaCompleteIntrClear(
void)
480 es_regs->r_es1A &= 2;
483 static u8 EsAcsIsAaPckError(
void)
485 return es_regs->r_es18 & 2;
488 static void EsAcsSetAaPckErrorIntrClear(
void)
490 es_regs->r_es18 &= 2;
493 static void EsAcsBbStreamOn(
void)
499 static u8 EsAcsIsBbStreamOn(
void)
501 return es_regs->r_es28 & 1;
505 static void EsAcsBbTreminate(
void)
510 static u8 EsAcsIsBbComplete(
void)
512 return es_regs->r_es1A & 1;
515 static void EsAcsSetBbCompleteIntrClear(
void)
517 es_regs->r_es1A &= 1;
520 static u8 EsAcsIsBbPckError(
void)
522 return es_regs->r_es18 & 1;
525 static void EsAcsSetBbPckErrorIntrClear(
void)
527 es_regs->r_es18 &= 1;
531 static u8 EsAcsIsBbEmpty(
void)
533 return es_regs->r_es1C & 1;
538 static void EsAcsBbThroughEnable(
void)
540 es_regs->r_es08 |= 8;
544 static void EsAcsBbThroughDisable(
void)
546 es_regs->r_es08 &= ~8;
549 static u8 EsAcsIsBbBlockThrough(
void)
551 return es_regs->r_es08 & 8;
555 static 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;
565 static u8 EsAcsGetStatusBbEmpty(
void)
567 return es_regs->r_es1C & 1;
571 static int EsAcsGetSerialNumber(
void)
573 return es_regs->r_es3E | (es_regs->r_es38 << 24) | (es_regs->r_es3A << 16) | (es_regs->r_es3C << 8);
578 static 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;
587 static void EsAcsSetSerialNumberReg1(u8 a1)
589 es_regs->r_es38 = a1;
592 static void EsAcsSetSerialNumberReg2(u8 a1)
594 es_regs->r_es3A = a1;
597 static void EsAcsSetSerialNumberReg3(u8 a1)
599 es_regs->r_es3C = a1;
602 static void EsAcsSetSerialNumberReg4(u8 a1)
604 es_regs->r_es3E = a1;
608 static u8 EsAcsGetStatusA(
void)
610 return es_regs->r_es20;
615 static u8 EsAcsIsBbStatusInit(
void)
617 return (es_regs->r_es20 & 0xF) == 0;
621 static u8 EsAcsIsBbStatusIdle(
void)
623 return (es_regs->r_es20 & 0xF) == 1;
627 static u8 EsAcsIsBbStatusNn(
void)
629 return (es_regs->r_es20 & 0xF) == 2;
633 static u8 EsAcsIsBbStatusUUTT(
void)
635 return (es_regs->r_es20 & 0xF) == 3;
639 static u8 EsAcsIsBbStatusDec(
void)
641 return (es_regs->r_es20 & 0xF) == 4;
646 static u8 EsAcsIsBbStatusRandom(
void)
648 return (es_regs->r_es20 & 0xF) == 6;
652 static void EsAcsSetSdeData(u8 a1)
654 es_regs->r_es34 = a1;
657 static void EsAcsAllIntDisableA(
void)
662 static void EsAcsAllIntDisableB(
void)
667 static void EsAcsAllIntDisableC(
void)
672 static void EsAcsAllIntDisable(
void)
674 EsAcsAllIntDisableA();
675 EsAcsAllIntDisableB();
676 EsAcsAllIntDisableC();
679 static void EsAcsAllIntStatClearA(
void)
681 es_regs->r_es18 = 0x9F;
684 static void EsAcsAllIntStatClearB(
void)
686 es_regs->r_es1A = 0xDF;
689 static void EsAcsAllIntStatClearC(
void)
691 es_regs->r_es1C = 0x83;
694 static void EsAcsAllIntStatClear(
void)
696 EsAcsAllIntStatClearA();
697 EsAcsAllIntStatClearB();
698 EsAcsAllIntStatClearC();
702 static void EsAcsIntEnableInitComplete(
void)
704 es_regs->r_es12 |= 0x40;
709 static void EsAcsIntDisableInitComplete(
void)
711 es_regs->r_es12 &= ~0x40;
716 static void EsAcsIntEnableProcessRandom(
void)
718 es_regs->r_es14 |= 0x80;
723 static void EsAcsIntDisableProcessRandom(
void)
725 es_regs->r_es14 &= ~0x80;
730 static void EsAcsIntEnableNnInvalid(
void)
732 es_regs->r_es10 |= 0x10;
737 static void EsAcsIntDisableNnInvalid(
void)
739 es_regs->r_es10 &= ~0x10;
744 static void EsAcsIntEnableNnRevoked(
void)
746 es_regs->r_es10 |= 8;
751 static void EsAcsIntDisableNnRevoked(
void)
753 es_regs->r_es10 &= ~8;
758 static void EsAcsIntEnableNnReplaced(
void)
760 es_regs->r_es10 |= 4;
765 static void EsAcsIntDisableNnReplaced(
void)
767 es_regs->r_es10 &= ~4;
772 static void EsAcsIntEnableNnComplete(
void)
774 es_regs->r_es12 |= 0x10;
779 static void EsAcsIntDisableNnComplete(
void)
781 es_regs->r_es12 &= ~0x10;
786 static void EsAcsIntEnableProcessNn(
void)
788 EsAcsIntEnableNnInvalid();
789 EsAcsIntEnableNnRevoked();
790 EsAcsIntEnableNnReplaced();
791 EsAcsIntEnableNnComplete();
796 static void EsAcsIntDisableProcessNn(
void)
798 EsAcsIntDisableNnInvalid();
799 EsAcsIntDisableNnRevoked();
800 EsAcsIntDisableNnReplaced();
801 EsAcsIntDisableNnComplete();
806 static void EsAcsIntEnableUUComplete(
void)
808 es_regs->r_es12 |= 8;
813 static void EsAcsIntDisableUUComplete(
void)
815 es_regs->r_es12 &= ~8;
820 static void EsAcsIntEnableProcessUU(
void)
822 EsAcsIntEnableUUComplete();
827 static void EsAcsIntDisableProcessUU(
void)
829 EsAcsIntDisableUUComplete();
834 static void EsAcsIntEnableTTComplete(
void)
836 es_regs->r_es12 |= 4;
841 static void EsAcsIntDisableTTComplete(
void)
843 es_regs->r_es12 &= ~4;
848 static void EsAcsIntEnableProcessTT(
void)
850 EsAcsIntEnableTTComplete();
855 static void EsAcsIntDisableProcessTT(
void)
857 EsAcsIntDisableTTComplete();
862 static void EsAcsIntEnableBbEmpty(
void)
864 es_regs->r_es14 |= 1;
869 static void EsAcsIntDisableBbEmpty(
void)
871 es_regs->r_es14 &= ~1;
876 static void EsAcsIntEnableBbPackErr(
void)
878 es_regs->r_es10 |= 1;
883 static void EsAcsIntDisableBbPackErr(
void)
885 es_regs->r_es10 &= ~1;
890 static void EsAcsIntEnableAaPackErr(
void)
892 es_regs->r_es10 |= 2;
897 static void EsAcsIntDisableAaPackErr(
void)
899 es_regs->r_es10 &= ~2;
903 static void EsAcsSoftReset(
void)
905 es_regs->r_es00 = 0x80;
908 static void EsAcsInitTerminate(
void)
910 es_regs->r_es2C = 0x40;
913 static void EsAcsSetInitComplete(
void)
915 es_regs->r_es1A &= 0x40;
918 static void EsAcsRandSeedSn(
void)
920 es_regs->r_es08 |= 0x10;
923 static u8 EsAcsIsAccessProhibit(
void)
925 return es_regs->r_es22 & 0x80;
928 static u8 EsAcsIsInidecError(
void)
930 return es_regs->r_es18 & 0x80;
933 static void EsAcsSetInidecErrorIntrClear(
void)
935 es_regs->r_es18 &= 0x80;
938 static u8 EsAcsIsLrsComplete(
void)
940 return es_regs->r_es1A & 0x80;
943 static void EsAcsSetLrsComplete(
void)
945 es_regs->r_es1A &= 0x80;
948 static u8 EsAcsIsInitComplete(
void)
950 return es_regs->r_es1A & 0x40;
953 static void EsAcsStartRandom(
void)
955 es_regs->r_es2A = 0x80;
958 static u8 EsAcsIsRandomComplete(
void)
960 return es_regs->r_es1C & 0x80;
963 static void EsAcsSetRandomComplete(
void)
965 es_regs->r_es1C &= 0x80;
968 static void EsAcsStartNn(
void)
970 es_regs->r_es28 = 0x10;
973 static void EsAcsTerminateNn(
void)
975 es_regs->r_es2C = 0x10;
978 static u8 EsAcsIsNnInvalid(
void)
980 return es_regs->r_es18 & 0x10;
983 static u8 EsAcsIsNnRevoked(
void)
985 return es_regs->r_es18 & 8;
988 static u8 EsAcsIsNnReplaced(
void)
990 return es_regs->r_es18 & 4;
993 static u8 EsAcsIsNnComplete(
void)
995 return es_regs->r_es1A & 0x10;
998 static void EsAcsSetNnInvalid(
void)
1000 es_regs->r_es18 &= 0x10;
1003 static void EsAcsSetNnRevoked(
void)
1005 es_regs->r_es18 &= 8;
1008 static void EsAcsSetNnReplaced(
void)
1010 es_regs->r_es18 &= 4;
1013 static void EsAcsSetNnComplete(
void)
1015 es_regs->r_es1A &= 0x10;
1018 static void EsAcsSetNnIntrAllClear(
void)
1020 EsAcsSetNnInvalid();
1021 EsAcsSetNnRevoked();
1022 EsAcsSetNnReplaced();
1023 EsAcsSetNnComplete();
1026 static void EsAcsSetNnPacksUsed(u8 a1)
1028 es_regs->r_es36 = a1;
1031 static 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];
1043 static void EsAcsStartUU(
void)
1045 es_regs->r_es28 = 8;
1048 static void EsAcsStartTT(
void)
1050 es_regs->r_es28 = 4;
1053 static u8 EsAcsIsUUComplete(
void)
1055 return es_regs->r_es1A & 8;
1058 static u8 EsAcsIsTTComplete(
void)
1060 return es_regs->r_es1A & 4;
1063 static void EsAcsSetUUComplete(
void)
1065 es_regs->r_es1A = 8;
1068 static void EsAcsSetTTComplete(
void)
1070 es_regs->r_es1A = 4;
1073 static void EsAcsSetBbryptedTitleKey(
void)
1075 es_regs->r_es08 |= 4;
1078 static void EsAcsSetRandomTitleKey(
void)
1080 es_regs->r_es08 &= ~4;
1083 static 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];
1095 static 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];
1107 static 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);
1120 static u8 EsAcsGetIntrSrcA(
void)
1122 return es_regs->r_es18;
1127 static u8 EsAcsGetIntrSrcB(
void)
1129 return es_regs->r_es1A;
1134 static u8 EsAcsGetIntrSrcC(
void)
1136 return es_regs->r_es1C;
1140 static u8 EsAcsGetChipVersion(
void)
1142 return es_regs->r_es02;
1145 static u8 EsAcsGetRevision1(
void)
1147 return es_regs->r_es04;
1150 static u8 EsAcsGetRevision2(
void)
1152 return es_regs->r_es06;
1156 static u16 EsAcsGetReg(
int a1)
1158 return *(u16 *)(&es_regs->r_es00 + a1);
1163 static void EsAcsSetReg(u8 a1, u8 a2)
1165 *(u16 *)(&es_regs->r_es00 + a1) = a2;
1169 static u8 EsDrvNnResultCheck(
void)
1171 if ( EsAcsIsNnInvalid() != 0 )
1175 if ( EsAcsIsNnRevoked() != 0 )
1179 if ( EsAcsIsNnReplaced() != 0 )
1183 if ( EsAcsIsNnComplete() != 0 )
1190 static void EsDrvSoftReset(
void)
1196 static void EsDrvSetSerialNumber(u8 *a1)
1198 EsAcsSetSerialNumberReg1(a1[0]);
1199 EsAcsSetSerialNumberReg2(a1[1]);
1200 EsAcsSetSerialNumberReg3(a1[2]);
1201 EsAcsSetSerialNumberReg4(a1[3]);
1204 static u8 EsDrvSetSde(u8 *a1)
1208 EsAcsSetInidecErrorIntrClear();
1209 EsAcsSetLrsComplete();
1210 for ( i = 0; i < 0x1be; i += 1 )
1212 EsAcsSetSdeData(a1[i]);
1215 if ( EsAcsIsAccessProhibit() != 0 )
1222 static u8 EsDrvCheckSdeProcess(
int a1)
1224 if ( EsAcsIsInidecError() )
1226 EsAcsSetInidecErrorIntrClear();
1229 if ( EsAcsIsLrsComplete() == 0 )
1233 EsAcsSetLrsComplete();
1238 static u8 EsDrvTrmntInitProcess(
void)
1242 EsAcsSetInitComplete();
1243 EsAcsInitTerminate();
1244 for ( i = 0; i < 0x65; i += 1 )
1246 if ( EsAcsIsInitComplete() )
1248 EsAcsSetInitComplete();
1251 DelayThread(100000);
1256 static void EsDrvCmpltInitProcess(
void)
1259 EsAcsSetAaryptorIoMode();
1260 EsAcsSetBbryptorIoMode();
1261 EsAcsAllIntDisable();
1262 EsAcsAllIntStatClear();
1263 EsAcsAaryptorIoEnable();
1264 EsAcsBbryptorIoEnable();
1267 static u8 EsDrvRndNnCheck(
void)
1269 if ( EsAcsIsBbStatusIdle() == 0 )
1274 static u8 EsDrvRandom(
void)
1278 for ( i = 0; i < 15; ++i )
1283 EsAcsSetRandomComplete();
1285 for ( j = 0; j < 6; j += 1 )
1287 if ( EsAcsIsRandomComplete() )
1298 static void EsDrvSetNnParam(u8 a1,
const u8 *a2)
1300 EsAcsSetNnPacksUsed(a1);
1301 EsAcsSetNnValidationData(a2);
1304 static void EsDrvSetNnStart(
void)
1306 EsAcsSetNnIntrAllClear();
1307 EsAcsBbThroughDisable();
1311 static int EsDrvStartNnCheckStat(
void)
1313 return EsDrvNnResultCheck();
1316 static void EsDrvSetNnStop(
void)
1321 static int EsDrvStopNnCheckStat(
void)
1325 retval = EsDrvNnResultCheck();
1331 for ( i = 0; i < 10; i += 1 )
1333 retval = EsDrvNnResultCheck();
1339 EsAcsSetNnIntrAllClear();
1343 static u8 EsDrvSetUUStart(
const u8 *a1)
1345 if ( EsAcsIsBbStatusUUTT() == 0 )
1349 EsAcsBbThroughDisable();
1350 EsAcsSetMediaId(a1);
1351 EsAcsSetUUComplete();
1356 static u8 EsDrvCmpltUUProcess(
void)
1360 for ( i = 0; i < 0x65; i += 1 )
1362 if ( EsAcsIsUUComplete() )
1364 EsAcsSetUUComplete();
1372 static u8 EsDrvSetTTStart(u8 a1,
const u8 *a2)
1376 EsAcsSetBbryptedTitleKey();
1381 EsAcsSetRandomTitleKey();
1383 EsAcsSetTTComplete();
1388 static u8 EsDrvCmpltTTProcess(u8 a1, u8 *a2)
1392 for ( i = 0; i < 0x65; i += 1 )
1394 if ( EsAcsIsTTComplete() )
1396 EsAcsSetTTComplete();
1408 static u8 EsDrvBbStart(
void)
1410 if ( EsAcsIsBbBlockThrough() != 0 )
1414 EsAcsSetBbPckErrorIntrClear();
1415 EsAcsSetBbCompleteIntrClear();
1420 static int EsDrvBbBsCheck(
void)
1422 if ( EsAcsIsBbPckError() != 0 )
1424 EsAcsSetBbPckErrorIntrClear();
1430 static u8 EsDrvBbStop(
void)
1435 for ( i = 0; i < 0x65; i += 1 )
1437 if ( EsAcsIsBbComplete() )
1439 EsAcsSetBbCompleteIntrClear();
1442 DelayThread(100000);
1447 static void EsDrvAaStart(
void)
1449 EsAcsSetAaPckErrorIntrClear();
1450 EsAcsSetAaCompleteIntrClear();
1454 static int EsDrvAaBsCheck(
void)
1456 if ( EsAcsIsAaPckError() != 0 )
1458 EsAcsSetAaPckErrorIntrClear();
1464 static u8 EsDrvAaStop(
void)
1469 for ( i = 0; i < 0x65; i += 1 )
1471 if ( EsAcsIsAaComplete() )
1473 EsAcsSetAaCompleteIntrClear();
1476 DelayThread(100000);
1482 static void EsDrvBbFifoClear(
void)
1484 if ( !EsAcsIsBbBlockThrough() )
1486 EsAcsIntDisableBbPackErr();
1493 static void EsDrvAaFifoClear(
void)
1500 static int EsDrvGetBbPesScrambleControl(
void)
1502 return EsAcsGetStatusBbPesScrambleControl();
1506 static int EsDrvAaEmptyCheck(
void)
1508 return EsAcsGetStatusAaEmpty() == 0;
1511 static int EsDrvBbEmptyCheck(
void)
1513 return EsAcsGetStatusBbEmpty() == 0;
1516 static int EsDrvGetChipVersion(
void)
1518 return EsAcsGetChipVersion();
1521 static int EsDrvGetRevision1(
void)
1523 return EsAcsGetRevision1();
1526 static int EsDrvGetRevision2(
void)
1528 return EsAcsGetRevision2();
1532 static int EsDrvGetReg(
int a1)
1534 return EsAcsGetReg(a1);
1539 static void EsDrvSetReg(u8 a1, u8 a2)
1541 EsAcsSetReg(a1, a2);
1546 esioctl2_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();
1561 esioctl2_func_10(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1569 *(u32 *)buf = 0x4071200;
1574 esioctl2_func_2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1587 esioctl2_func_3(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1600 esioctl2_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();
1629 esioctl2_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 )
1646 esioctl2_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);
1668 esioctl2_func_7(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1676 *(u8 *)buf = EsDrvStartNnCheckStat();
1681 esioctl2_func_8(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1690 *(u8 *)buf = EsDrvStopNnCheckStat();
1695 esioctl2_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];
1730 esioctl2_func_a(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1744 esioctl2_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();
1758 esioctl2_func_c(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1767 if ( EsDrvAaStop() != 0 )
1773 esioctl2_func_d(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1787 esioctl2_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();
1801 esioctl2_func_f(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
1810 if ( EsDrvBbStop() != 0 )