5 static uint32_t dic
[8] __attribute__((aligned(32)));
7 int _DI_ReadDVD_A8(void* buf
, uint32_t len
, uint32_t lba
);
8 int _DI_ReadDVD_D0(void* buf
, uint32_t len
, uint32_t lba
);
10 int _DI_ReadDVD_A8_Async(void* buf
, uint32_t len
, uint32_t lba
,ipccallback ipc_cb
);
11 int _DI_ReadDVD_D0_Async(void* buf
, uint32_t len
, uint32_t lba
,ipccallback ipc_cb
);
14 Internal function, used when a modchip has been detected.
15 Please refrain from using this function directly.
17 int _DI_ReadDVD_A8_Async(void* buf
, uint32_t len
, uint32_t lba
, ipccallback ipc_cb
){
25 if((uint32_t)buf
& 0x1F){ // This only works with 32 byte aligned addresses!
30 dic
[0] = DVD_READ_UNENCRYPTED
<< 24;
31 dic
[1] = len
<< 11; // 1 LB is 2048 bytes
32 dic
[2] = lba
<< 9; // Nintendo's read function uses byteOffset >> 2, so we only shift 9 left, not 11.
34 ret
= IOS_IoctlAsync(di_fd
, DVD_READ_UNENCRYPTED
, dic
, 0x20, buf
, len
<< 11,ipc_cb
, buf
);
36 if(ret
== 2) errno
= EIO
;
38 return (ret
== 1)? 0 : -ret
;
42 Internal function, used when the drive is DVDVideo compatible.
43 Please refrain from using this function directly.
45 int _DI_ReadDVD_D0_Async(void* buf
, uint32_t len
, uint32_t lba
, ipccallback ipc_cb
){
53 if((uint32_t)buf
& 0x1F){
58 dic
[0] = DVD_READ
<< 24;
59 dic
[1] = 0; // Unknown what this does as of now. (Sets some value to 0x10 in the drive if set).
60 dic
[2] = 0; // USE_DEFAULT_CONFIG flag. Drive will use default config if this bit is set.
64 ret
= IOS_IoctlAsync(di_fd
, DVD_READ
, dic
, 0x20, buf
, len
<< 11,ipc_cb
, buf
);
66 if(ret
== 2) errno
= EIO
;
68 return (ret
== 1)? 0 : -ret
;
75 Internal function, used when a modchip has been detected.
76 Please refrain from using this function directly.
78 int _DI_ReadDVD_A8(void* buf
, uint32_t len
, uint32_t lba
){
79 int ret
, retry_count
= LIBDI_MAX_RETRIES
;
86 if((uint32_t)buf
& 0x1F){ // This only works with 32 byte aligned addresses!
91 dic
[0] = DVD_READ_UNENCRYPTED
<< 24;
92 dic
[1] = len
<< 11; // 1 LB is 2048 bytes
93 dic
[2] = lba
<< 9; // Nintendo's read function uses byteOffset >> 2, so we only shift 9 left, not 11.
96 ret
= IOS_Ioctl(di_fd
, DVD_READ_UNENCRYPTED
, dic
, 0x20, buf
, len
<< 11);
98 }while(ret
!= 1 && retry_count
> 0);
100 if(ret
== 2) errno
= EIO
;
102 return (ret
== 1)? 0 : -ret
;
106 Internal function, used when the drive is DVDVideo compatible.
107 Please refrain from using this function directly.
109 int _DI_ReadDVD_D0(void* buf
, uint32_t len
, uint32_t lba
){
110 int ret
, retry_count
= LIBDI_MAX_RETRIES
;
117 if((uint32_t)buf
& 0x1F){
122 dic
[0] = DVD_READ
<< 24;
123 dic
[1] = 0; // Unknown what this does as of now. (Sets some value to 0x10 in the drive if set).
124 dic
[2] = 0; // USE_DEFAULT_CONFIG flag. Drive will use default config if this bit is set.
131 ret
= IOS_Ioctl(di_fd
, DVD_READ
, dic
, 0x20, buf
, len
<< 11);
133 }while(ret
!= 1 && retry_count
> 0);
135 if(ret
== 2) errno
= EIO
;
137 return (ret
== 1)? 0 : -ret
;