From WiiBrew
< /dev
Jump to navigation Jump to search

Through /dev/di you can control the DVD.

The inbuf size of all /dev/di IOS cmds must be 0x20

The first entry of the inbuf should(!) be the DI cmd, Starlet fixes it if it doesn't match.

Fleshed out into a simple API called "WDVD": http://emergent.unpy.net/01212889187

ios_ioctl( di_fd, 0x88, inbuf, 0x20, outbuf, 0x20);
((u32*)inbuf)[0x00] = 0xE0000000;
ios_ioctl( di_fd, 0xE0, inbuf, 0x20, outbuf, 0x20);
(Actual DVD error code is returned in (u32*)outbuf)[0x00])
Identical to the error codes found in yagcd section (so far).
DVDLowRead (Only works after DVDOpenPartition)
((u32*)inbuf)[0x00] = 0x71000000;
((u32*)inbuf)[0x01] = size;
((u32*)inbuf)[0x02] = byte_offset >> 2;
ios_ioctl( di_fd, 0x71, inbuf, 0x20, dst, size);
// Only works up to 0x0050000; in newer IOS versions (IOS30+) the whole 
// data block (i.e. offset and offset + len) has to been within one of the following three
// areas (bytes >> 2):
// * 0x00000000 - 0x00014000 (limit of older IOS versions)
// * 0x460a0000 - 0x460a0008
// * 0x7ed40000 - 0x7ed40008
((u32*)inbuf)[0x00] = 0x8D000000;
((u32*)inbuf)[0x01] = size;
((u32*)inbuf)[0x02] = byte_Offset >> 2;
ios_ioctl( di_fd, 0x8D, inbuf, 0x20, dst, size);
((u32*)inbuf)[0x00] = 0xE3000000;
((u32*)inbuf)[0x01] = 0;	// optional, unknown
((u32*)inbuf)[0x02] = 0;	// optional, unknown
ios_ioctl( di_fd, 0xE3, inbuf, 0x20, outbuf, 0x20);
((u32*)inbuf)[0x00] = 0x8A000000;
((u32*)inbuf)[0x01] = 1;
ios_ioctl( di_fd, 0x8A, inbuf, 0x20, outbuf, 0x20);
DVDLowReadDiskID, read to 0x80000000
((u32*)inbuf)[0x00] = 0x70000000;
ios_ioctl( di_fd, 0x70, inbuf, 0x20, dst, 0x20);
((u32*)inbuf)[0x00] = 0x8C000000;
IOS_Ioctl( di_fd, 0x8C, inbuf, 0x20, 0, 0);
((u32*)buffer)[(0x40>>2)]	=  0x8B000000;
((u32*)buffer)[(0x40>>2)+1]	=  game_partition_byte_offset>>2;

((u32*)buffer)[0x00] = PHYSADDR(buffer+0x40);	//0x00
((u32*)buffer)[0x01] = 0x20;			//0x04
((u32*)buffer)[0x02] = 0;			//0x08; optional tik
((u32*)buffer)[0x03] = 0x2A4;			//0x0C 
((u32*)buffer)[0x04] = 0;			//0x10; optional cert chain
((u32*)buffer)[0x05] = 0;			//0x14

((u32*)buffer)[0x06] = PHYSADDR(buffer+0x380);	//0x18; dvd cert chain
((u32*)buffer)[0x07] = 0x49E4;			//0x1C
((u32*)buffer)[0x08] = PHYSADDR(buffer+0x360);	//0x20; some kind of error buffer
((u32*)buffer)[0x09] = 0x20;			//0x24

IOS_Ioctlv( di_fd, 0x8B, 3, 2, buffer);