EXPORT_C_(s32) DEV9init() { LoadConfig(); setLoggingState(); LogInit(); Dev9Log.WriteLn("dev9null plugin version %d,%d", revision, build); Dev9Log.WriteLn("Initializing dev9null"); // Initialize anything that needs to be initialized. memset(dev9regs, 0, sizeof(dev9regs)); return 0; }
USBwrite32(u32 addr, u32 value) { switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); break; default: //usbRu32(addr) = value; USBLog.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value); } }
EXPORT_C_(void) USBwrite8(u32 addr, u8 value) { switch(addr) { // Handle any appropriate addresses here. case 0x1f801600: USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); break; default: //usbRu8(addr) = value; USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); } }
EXPORT_C_(u16) DEV9read16(u32 addr) { u16 value = 0; switch(addr) { // Addresses you may want to catch here include: // case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) // case 0x10000002: // The Smart Chip revision. Should be 0x11 // case 0x10000004: // More type info: bit 0 - smap; bit 1 - hd; bit 5 - flash // case 0x1000000E: // Similar to the last; bit 1 should be set if a hd is hooked up. // case 0x10000028: // intr_stat // case 0x10000038: // hard drives seem to like reading and writing the max dma size per transfer here. // case 0x1000002A: // intr_mask // case 0x10000040: // pio_data // case 0x10000044: // nsector // case 0x10000046: // sector // case 0x10000048: // lcyl // case 0x1000004A: // hcyl // case 0x1000004C: // select // case 0x1000004E: // status // case 0x1000005C: // status // case 0x10000064: // if_ctrl case 0x10000038: /*value = dev9Ru16(addr);*/ break; default: //value = dev9Ru16(addr); Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr); break; } return value; }
EXPORT_C_(s32) DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) { // See above. Dev9Log.WriteLn("Writing DMA8 Mem."); *bytesProcessed = bytesLeft; return 0; }
EXPORT_C_(s32) USBopen(void *pDsp) { USBLog.WriteLn("Opening USBnull."); // Take care of anything else we need on opening, other then initialization. return 0; }
USBread32(u32 addr) { u32 value = 0; switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); break; default: //value = usbRu32(addr); USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); } return value; }
EXPORT_C_(s32) DEV9open(void *pDsp) { Dev9Log.WriteLn("Opening Dev9null."); // Get anything ready we need to. Opening and creating hard // drive files, for example. return 0; }
EXPORT_C_(s32) FWinit() { LoadConfig(); LogInit(); FWLog.WriteLn("FWnull plugin version %d,%d", revision, build); FWLog.WriteLn("Initializing FWnull"); memset(phyregs, 0, sizeof(phyregs)); // Initializing our registers. fwregs = (s8*)calloc(0x10000,1); if (fwregs == NULL) { FWLog.Message("Error allocating Memory"); return -1; } return 0; }
//#ifdef ENABLE_NEW_IOPDMA_DEV9 EXPORT_C_(s32) DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) { // You'll want to put your own DMA8 reading code here. // Time to interact with your fake (or real) hardware. Dev9Log.WriteLn("Reading DMA8 Mem."); *bytesProcessed = bytesLeft; return 0; }
EXPORT_C_(u16) USBread16(u32 addr) { u16 value = 0; switch(addr) { // Handle any appropriate addresses here. case 0x1f801600: USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); break; default: //value = usbRu16(addr); USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); } return value; }
USBinit() { LoadConfig(); LogInit(); USBLog.WriteLn("USBnull plugin version %d,%d", revision, build); USBLog.WriteLn("Initializing USBnull"); // Initialize memory structures here. usbregs = (s8 *)calloc(0x10000, 1); if (usbregs == NULL) { USBLog.Message("Error allocating memory"); return -1; } return 0; }
void SaveConfig() { string IniPath = s_strIniPath + "/FWnull.ini"; if (!Ini.Open(IniPath, WRITE_FILE)) { FWLog.WriteLn("Failed to open %s\n", IniPath.c_str()); return; } Ini.WriteInt("logging", conf.Log); Ini.Close(); }
EXPORT_C_(void) DEV9write32(u32 addr, u32 value) { switch(addr) { case 0x10000038: /*dev9Ru32(addr) = value;*/ break; default: Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value); //dev9Ru32(addr) = value; break; } }
void LoadConfig() { string IniPath = s_strIniPath + "/FWnull.ini"; if (!Ini.Open(IniPath, READ_FILE)) { FWLog.WriteLn("Failed to open %s", IniPath.c_str()); SaveConfig(); return; } conf.Log = Ini.ReadInt("logging", 0); setLoggingState(); Ini.Close(); }
EXPORT_C_(void) DEV9write16(u32 addr, u16 value) { switch(addr) { // Remember that list on DEV9read16? You'll want to write to a // lot of them, too. case 0x10000038: /*dev9Ru16(addr) = value;*/ break; default: Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value); //dev9Ru16(addr) = value; break; } }
EXPORT_C_(u32 ) DEV9read32(u32 addr) { u32 value = 0; switch(addr) { case 0x10000038: /*value = dev9Ru32(addr);*/ break; default: //value = dev9Ru32(addr); Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr); break; } return value; }
EXPORT_C_(u8) DEV9read8(u32 addr) { u8 value = 0; switch(addr) { // case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) case 0x10000038: /*value = dev9Ru8(addr);*/ break; // We need to have at least one case to avoid warnings. default: //value = dev9Ru8(addr); Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr); break; } return value; }
USBclose() { USBLog.WriteLn("Closing USBnull."); }
EXPORT_C_(void) USBclose() { USBLog.WriteLn("Closing USBnull."); }
EXPORT_C_(void) DEV9writeDMA8Mem(u32* pMem, int size) { // See above. Dev9Log.WriteLn("Writing DMA8 Mem."); }
//#else EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size) { // You'll want to put your own DMA8 reading code here. // Time to interact with your fake (or real) hardware. Dev9Log.WriteLn("Reading DMA8 Mem."); }
EXPORT_C_(void) USBsetRAM(void *mem) { ram = (s8*)mem; USBLog.WriteLn("*Setting ram."); }
EXPORT_C_(s32) FWopen(void *pDsp) { FWLog.WriteLn("Opening FWnull."); return 0; }
EXPORT_C_(void) FWclose() { // Close the plugin. FWLog.WriteLn("Closing FWnull."); }
EXPORT_C_(void) DEV9close() { Dev9Log.WriteLn("Closing Dev9null."); // Close files opened. }
EXPORT_C_(void) DEV9shutdown() { Dev9Log.WriteLn("Shutting down Dev9null."); Dev9Log.Close(); }