remove some newlines from FileUtil logs.

add ___blank to HLE'd debug logging.
add long long support to HLE_OS::GetStringVA
take care of those annoying sdio 0x40 and 0x41 commands...not that they do much in the first place...
some cleanup on the IPC net devices

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4488 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-10-31 09:17:37 +00:00
parent b7bd9dc5d9
commit 1d666bf109
7 changed files with 188 additions and 187 deletions

View File

@ -100,7 +100,7 @@ bool IsDirectory(const char *filename)
// Doesn't supports deleting a directory
bool Delete(const char *filename)
{
INFO_LOG(COMMON, "Delete: file %s\n", filename);
INFO_LOG(COMMON, "Delete: file %s", filename);
// Return true because we care about the file no
// being there, not the actual delete.
@ -135,7 +135,7 @@ bool Delete(const char *filename)
// Returns true if successful, or path already exists.
bool CreateDir(const char *path)
{
INFO_LOG(COMMON, "CreateDir: directory %s\n", path);
INFO_LOG(COMMON, "CreateDir: directory %s", path);
#ifdef _WIN32
if (::CreateDirectory(path, NULL))
return true;
@ -166,10 +166,10 @@ bool CreateDir(const char *path)
bool CreateFullPath(const char *fullPath)
{
int panicCounter = 100;
INFO_LOG(COMMON, "CreateFullPath: path %s\n", fullPath);
INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath);
if (File::Exists(fullPath)) {
INFO_LOG(COMMON, "CreateFullPath: path exists %s\n", fullPath);
INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath);
return true;
}

View File

@ -63,7 +63,8 @@ static const SPatch OSPatches[] =
{ "vprintf", HLE_OS::HLE_GeneralDebugPrint },
{ "printf", HLE_OS::HLE_GeneralDebugPrint },
{ "puts", HLE_OS::HLE_GeneralDebugPrint }, // gcc-optimized printf?
{ "___blank(char *,...)", HLE_OS::HLE_GeneralDebugPrint }, // dunno, but awesome :D
{ "___blank(char *,...)", HLE_OS::HLE_GeneralDebugPrint }, // used for early init things (normally)
{ "___blank", HLE_OS::HLE_GeneralDebugPrint },
{ "__write_console", HLE_OS::HLE_write_console }, // used by sysmenu (+more?)
// wii only

View File

@ -91,13 +91,19 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
*pArgument++ = *pString;
*pArgument = NULL;
u32 Parameter;
u64 Parameter;
if (ParameterCounter > 10)
{
Parameter = Memory::Read_U32(GPR(1) + 0x8 + ((ParameterCounter - 11) * 4));
}
else
{
if ((*(pString-2) == 'l') && (*(pString-1) == 'l')) // hax, just seen this on sysmenu osreport
{
Parameter = GPR(++ParameterCounter);
Parameter = (Parameter<<32)|GPR(++ParameterCounter);
}
else // normal, 32bit
Parameter = GPR(ParameterCounter);
}
ParameterCounter++;
@ -105,7 +111,7 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
switch(*pString)
{
case 's':
_rOutBuffer += StringFromFormat(ArgumentBuffer, (char*)Memory::GetPointer(Parameter));
_rOutBuffer += StringFromFormat(ArgumentBuffer, (char*)Memory::GetPointer((u32)Parameter));
break;
case 'd':

View File

@ -16,40 +16,30 @@
// http://code.google.com/p/dolphin-emu/
/*
The /dev/net/kd/request requests are part of what is called WiiConnect24,
it's used by for example SSBB, Mario Kart, Metroid Prime 3
// =======================================================
// File description
// -------------
/* Here we handle /dev/net and /dev/net/ncd/manage requests.
// -----------------------
The /dev/net/kd/request requests are part of what is called WiiConnect24,
it's used by for example SSBB, Mario Kart, Metroid Prime 3
0x01 SuspendScheduler (Input: none, Output: 32 bytes)
0x02 ExecTrySuspendScheduler (Input: 32 bytes, Output: 32 bytes) // Sounds like it will
0x01 SuspendScheduler (Input: none, Output: 32 bytes)
0x02 ExecTrySuspendScheduler (Input: 32 bytes, Output: 32 bytes) // Sounds like it will
check if it should suspend the updates scheduler or not. If I returned
(OutBuffer: 0, Ret: -1) to Metroid Prime 3 it got stuck in an endless loops of
requests, probably harmless but I changed it to (OutBuffer: 1, Ret: 0) to stop
the calls. However then it also calls 0x3 and then changes its error message
to a Wii Memory error message from just a general Error message.
0x03 ? (Input: none, Output: 32 bytes) // This is only called if 0x02
0x03 ? (Input: none, Output: 32 bytes) // This is only called if 0x02
does not return -1
0x0f NWC24iRequestGenerateUserId (Input: none, Output: 32 bytes)
0x0f NWC24iRequestGenerateUserId (Input: none, Output: 32 bytes)
Requests are made in this order by these games
Requests are made in this order by these games
Mario Kart: 2, 1, f, 3
SSBB: 2, 3
For Mario Kart I had to return -1 from at least 2, f and 3 to convince it that the network
was unavaliable and prevent if from looking for shared2/wc24 files (and do a PPCHalt when
it failed)
// -------
For Mario Kart I had to return -1 from at least 2, f and 3 to convince it that the network
was unavailable and prevent if from looking for shared2/wc24 files (and do a PPCHalt when
it failed)
*/
// =============
#ifdef _MSC_VER
#pragma warning(disable : 4065) // switch statement contains 'default' but no 'case' labels
@ -72,7 +62,6 @@ extern std::queue<std::pair<u32,std::string> > g_ReplyQueueLater;
// **********************************************************************************
// Handle /dev/net/kd/request requests
CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{
@ -80,7 +69,6 @@ CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(u32 _Devi
CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request()
{
}
bool CWII_IPC_HLE_Device_net_kd_request::Open(u32 _CommandAddress, u32 _Mode)
@ -97,7 +85,6 @@ bool CWII_IPC_HLE_Device_net_kd_request::Close(u32 _CommandAddress)
return true;
}
bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
{
u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC);
@ -107,56 +94,48 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
u32 ReturnValue = 0;
switch(Parameter)
switch (Parameter)
{
case IOCTL_NWC24_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
case IOCTL_NWC24_SUSPEND_SCHEDULAR:
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_UNK_3: // NWC24iResumeForCloseLib
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNK_3 - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_STARTUP_SOCKET:
case IOCTL_NWC24_STARTUP_SOCKET: // NWC24iStartupSocket
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_UNLOCK_SOCKET:
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
PanicAlert("IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
ReturnValue = 0;
break;
case IOCTL_NWC24_GET_SCHEDULAR_STAT:
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_SAVE_MAIL_NOW:
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
ReturnValue = 0;
break;
case IOCTL_NWC24_REQUEST_SHUTDOWN:
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI"); // if ya set the IOS version to a very high value this happens ...
ReturnValue = 0;
// if ya set the IOS version to a very high value this happens ...
INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI");
break;
default:
@ -174,7 +153,6 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
// **********************************************************************************
// Handle /dev/net/ncd/manage requests
CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{}
@ -205,16 +183,16 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
switch (CommandBuffer.Parameter)
{
// WiiMenu
case 0x07: // //NCDGetLinkStatus
case 0x03: // ??? It seems that is related to Write and Read information
case 0x04:
case 0x05:
case IOCTL_NCD_GETLINKSTATUS: // 32 Out. 5th
case IOCTL_NCD_SETIFCONFIG3: // ??? It seems that is related to Write and Read information
case IOCTL_NCD_SETIFCONFIG4: // 7004 In, 32 Out. 4th
case 0x05: // 7004 Out, 32 Out. 2nd, 3rd
case 0x06:
case 0x08:
case 0x08: // 32 Out, 6 Out. 1st
//break;
default:
INFO_LOG(WII_IPC_NET,"NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter);
INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter);
break;
}
Memory::Write_U32(ReturnValue, _CommandAddress+4);
@ -224,7 +202,6 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
// **********************************************************************************
// Handle /dev/net/ip/top requests
CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{}
@ -283,13 +260,14 @@ struct GC_sockaddr_in {
};
u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, u32 BufferInSize, u32 BufferOut, u32 BufferOutSize)
{
// Clean the location of the output buffer to zeroes as a safety precaution */
// Clean the location of the output buffer to zeros as a safety precaution */
Memory::Memset(BufferOut, 0, BufferOutSize);
switch (_Command)
{
case IOCTL_SO_STARTUP:
break;
case IOCTL_SO_SOCKET:
{
u32 AF = Memory::Read_U32(_BufferIn);
@ -300,6 +278,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn,
return Common::swap32(Socket); // So it doesn't get mangled later on
}
break;
case IOCTL_SO_BIND:
{
bind_params *addr = (bind_params*)Memory::GetPointer(_BufferIn);
@ -314,6 +293,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn,
//int bind(int s, struct sockaddr *addr, int addrlen);
}
break;
case IOCTL_SO_LISTEN:
{
u32 S = Memory::Read_U32(_BufferIn);
@ -322,6 +302,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn,
return Return;
}
break;
case IOCTL_SO_ACCEPT:
{
//TODO: (Sonic)Check if this is correct
@ -340,6 +321,7 @@ u32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn,
///dev/net/ip/top::IOCtl request 0x1 (BufferIn: (000318c0, 4), BufferOut: (00058a4c, 8)
}
break;
case IOCTL_SO_GETHOSTID:
return 127 << 24 | 1;
break;
@ -359,14 +341,15 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 _CommandAddress)
u32 ReturnValue = 0;
SIOCtlVBuffer CommandBuffer(_CommandAddress);
switch(CommandBuffer.Parameter)
switch (CommandBuffer.Parameter)
{
case 2:
case 12:
case 15:
case 16:
case 31:
case IOCTL_SO_BIND:
case IOCTLV_SO_RECVFROM:
case IOCTL_SO_SOCKET:
case IOCTL_SO_GETHOSTID:
case IOCTL_SO_STARTUP:
//break;
default:
INFO_LOG(WII_IPC_NET, "NET_IP_TOP IOCtlV: 0x%08X\n", CommandBuffer.Parameter);
break;

View File

@ -20,10 +20,13 @@
#include "WII_IPC_HLE_Device.h"
// **********************************************************************************
// KD is the IOS module responsible for implementing WiiConnect24 functionality. It
// can perform HTTPS downloads, send and receive mail via SMTP, and execute a
// JavaScript-like language while the Wii is in standby mode.
class CWII_IPC_HLE_Device_net_kd_request : public IWII_IPC_HLE_Device
{
public:
CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName);
virtual ~CWII_IPC_HLE_Device_net_kd_request();
@ -33,7 +36,6 @@ public:
virtual bool IOCtl(u32 _CommandAddress);
private:
enum
{
IOCTL_NWC24_SUSPEND_SCHEDULAR = 0x01,
@ -61,12 +63,10 @@ private:
};
};
// **************************************************************************************
// **********************************************************************************
class CWII_IPC_HLE_Device_net_kd_time : public IWII_IPC_HLE_Device
{
public:
CWII_IPC_HLE_Device_net_kd_time(u32 _DeviceID, const std::string& _rDeviceName) :
IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{}
@ -90,7 +90,7 @@ public:
virtual bool IOCtl(u32 _CommandAddress)
{
u32 Parameter = Memory::Read_U32(_CommandAddress +0x0C);
u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C);
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
@ -118,6 +118,7 @@ public:
Memory::Write_U32(0, _CommandAddress + 0x4);
return true;
case IOCTL_NW24_GET_TIME_DIFF: // Input: none, Output: 32
default:
ERROR_LOG(WII_IPC_NET, "%s - IOCtl:\n"
" Parameter: 0x%x (0x17 NWC24iSetRtcCounter) \n"
@ -135,7 +136,6 @@ public:
}
private:
enum
{
IOCTL_NW24_SET_RTC_COUNTER = 0x17,
@ -145,8 +145,7 @@ private:
u8 m_RtcCounter[0x20];
};
// **************************************************************************************
// **********************************************************************************
class CWII_IPC_HLE_Device_net_ip_top : public IWII_IPC_HLE_Device
{
public:
@ -160,50 +159,49 @@ public:
virtual bool IOCtlV(u32 _CommandAddress);
private:
enum {
IOCTL_SO_ACCEPT = 1,
IOCTL_SO_BIND,
IOCTL_SO_CLOSE,
IOCTL_SO_CONNECT,
IOCTL_SO_FCNTL,
IOCTL_SO_GETPEERNAME, // todo
IOCTL_SO_GETSOCKNAME, // todo
IOCTL_SO_GETSOCKOPT, // todo 8
IOCTL_SO_GETPEERNAME,
IOCTL_SO_GETSOCKNAME,
IOCTL_SO_GETSOCKOPT,
IOCTL_SO_SETSOCKOPT,
IOCTL_SO_LISTEN,
IOCTL_SO_POLL, // todo b
IOCTL_SO_POLL,
IOCTLV_SO_RECVFROM,
IOCTLV_SO_SENDTO,
IOCTL_SO_SHUTDOWN, // todo e
IOCTL_SO_SHUTDOWN,
IOCTL_SO_SOCKET,
IOCTL_SO_GETHOSTID,
IOCTL_SO_GETHOSTBYNAME,
IOCTL_SO_GETHOSTBYADDR,// todo
IOCTLV_SO_GETNAMEINFO, // todo 13
IOCTL_SO_UNK14, // todo
IOCTL_SO_INETATON, // todo
IOCTL_SO_INETPTON, // todo
IOCTL_SO_INETNTOP, // todo
IOCTLV_SO_GETADDRINFO, // todo
IOCTL_SO_SOCKATMARK, // todo
IOCTLV_SO_UNK1A, // todo
IOCTLV_SO_UNK1B, // todo
IOCTLV_SO_GETINTERFACEOPT, // todo
IOCTLV_SO_SETINTERFACEOPT, // todo
IOCTL_SO_SETINTERFACE, // todo
IOCTL_SO_STARTUP, // 0x1f
IOCTL_SO_ICMPSOCKET = 0x30, // todo
IOCTLV_SO_ICMPPING, // todo
IOCTL_SO_ICMPCANCEL, // todo
IOCTL_SO_ICMPCLOSE // todo
IOCTL_SO_GETHOSTBYADDR,
IOCTLV_SO_GETNAMEINFO,
IOCTL_SO_UNK14,
IOCTL_SO_INETATON,
IOCTL_SO_INETPTON,
IOCTL_SO_INETNTOP,
IOCTLV_SO_GETADDRINFO,
IOCTL_SO_SOCKATMARK,
IOCTLV_SO_UNK1A,
IOCTLV_SO_UNK1B,
IOCTLV_SO_GETINTERFACEOPT,
IOCTLV_SO_SETINTERFACEOPT,
IOCTL_SO_SETINTERFACE,
IOCTL_SO_STARTUP,
IOCTL_SO_ICMPSOCKET = 0x30,
IOCTLV_SO_ICMPPING,
IOCTL_SO_ICMPCANCEL,
IOCTL_SO_ICMPCLOSE
};
u32 ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize);
};
// **************************************************************************************
// **********************************************************************************
// Seems like just wireless stuff?
class CWII_IPC_HLE_Device_net_ncd_manage : public IWII_IPC_HLE_Device
{
public:
@ -215,6 +213,14 @@ public:
virtual bool Close(u32 _CommandAddress);
virtual bool IOCtlV(u32 _CommandAddress);
private:
enum {
IOCTL_NCD_UNK1 = 1, // NCDLockWirelessDriver
IOCTL_NCD_UNK2 = 2, // NCDUnlockWirelessDriver
IOCTL_NCD_SETIFCONFIG3 = 3,
IOCTL_NCD_SETIFCONFIG4 = 4, // NCDGetWirelessMacAddress
IOCTL_NCD_GETLINKSTATUS = 7 // NCDGetLinkStatus
};
};
#endif

View File

@ -38,7 +38,6 @@ CWII_IPC_HLE_Device_sdio_slot0::CWII_IPC_HLE_Device_sdio_slot0(u32 _DeviceID, co
CWII_IPC_HLE_Device_sdio_slot0::~CWII_IPC_HLE_Device_sdio_slot0()
{
}
bool CWII_IPC_HLE_Device_sdio_slot0::Open(u32 _CommandAddress, u32 _Mode)
@ -101,7 +100,7 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress)
if ((reg == HCR_CLOCKCONTROL) && (val & 1))
{
// Clock is set to oscilliate, enable bit 1 to say it's stable
// Clock is set to oscillate, enable bit 1 to say it's stable
Memory::Write_U32(val | 2, SDIO_BASE + reg);
}
else if ((reg == HCR_SOFTWARERESET) && val)
@ -148,7 +147,10 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress)
break;
case IOCTL_SENDCMD:
if (Memory::Read_U32(BufferIn) != SDHC_CAPABILITIES)
{
INFO_LOG(WII_IPC_SD, "IOCTL_SENDCMD 0x%08x", Memory::Read_U32(BufferIn));
}
ReturnValue = ExecuteCommand(BufferIn, BufferInSize, 0, 0, BufferOut, BufferOutSize);
break;
@ -389,17 +391,20 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS
Memory::Write_U32(0x900, _BufferOut);
break;
case CRAZY_BIGN64:
WARN_LOG(WII_IPC_SD, "CMD64, wtf");
// <svpe> shuffle2_: try returning -4 for cmd x'40.
Memory::Write_U32(-0x04, _BufferOut);
_dbg_assert_msg_(WII_IPC_SD, req.arg == 2, "cmd64 odd arg value 0x%08x", req.arg);
case SDHC_CAPABILITIES:
{
DEBUG_LOG(WII_IPC_SD, "SDHC_CAPABILITIES");
// SDHC 1.0 supports only 10-63 MHz.
// So of course we reply 63MHz :)
u8 mhz_units = 1 << 7;
u16 freq = 63 << 8;
u32 caps = freq | mhz_units;
Memory::Write_U32(caps, _BufferOut);
break;
}
case CRAZY_BIGN65:
ERROR_LOG(WII_IPC_SD, "CMD65, wtf");
// Just means unmount/detach, but we don't care
break;
default:

View File

@ -94,7 +94,7 @@ private:
ACMD_SENDOPCOND = 0x29,
ACMD_SENDSCR = 0x33,
CRAZY_BIGN64 = 0x40,
SDHC_CAPABILITIES = 0x40,
CRAZY_BIGN65 = 0x41,
};