maintenance

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6866 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2011-01-16 20:14:16 +00:00
parent bc3565341d
commit 1b5c614d0e
3 changed files with 234 additions and 233 deletions

View File

@ -39,6 +39,7 @@ set(SRCS Src/ActionReplay.cpp
Src/HW/EXI_DeviceAD16.cpp Src/HW/EXI_DeviceAD16.cpp
Src/HW/EXI_DeviceAMBaseboard.cpp Src/HW/EXI_DeviceAMBaseboard.cpp
Src/HW/EXI_DeviceEthernet.cpp Src/HW/EXI_DeviceEthernet.cpp
Src/HW/EXI_DeviceGecko.cpp
Src/HW/EXI_DeviceIPL.cpp Src/HW/EXI_DeviceIPL.cpp
Src/HW/EXI_DeviceMemoryCard.cpp Src/HW/EXI_DeviceMemoryCard.cpp
Src/HW/EXI_DeviceMic.cpp Src/HW/EXI_DeviceMic.cpp

View File

@ -1,170 +1,170 @@
// Copyright (C) 2003 Dolphin Project. // Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0. // the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details. // GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program. // A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/ // If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "EXI_Device.h" #include "EXI_Device.h"
#include "EXI_DeviceGecko.h" #include "EXI_DeviceGecko.h"
#include "SFML/Network.hpp" #include "SFML/Network.hpp"
#include "Thread.h" #include "Thread.h"
#include <queue> #include <queue>
static Common::Thread *connectionThread = NULL; static Common::Thread *connectionThread = NULL;
static std::queue<sf::SocketTCP> waiting_socks; static std::queue<sf::SocketTCP> waiting_socks;
static Common::CriticalSection cs_gecko; static Common::CriticalSection cs_gecko;
namespace { volatile bool server_running; } namespace { volatile bool server_running; }
static THREAD_RETURN GeckoConnectionWaiter(void*) static THREAD_RETURN GeckoConnectionWaiter(void*)
{ {
server_running = true; server_running = true;
Common::SetCurrentThreadName("Gecko Connection Waiter"); Common::SetCurrentThreadName("Gecko Connection Waiter");
sf::SocketTCP server; sf::SocketTCP server;
// "dolphin gecko" // "dolphin gecko"
if (!server.Listen(0xd6ec)) if (!server.Listen(0xd6ec))
return 0; return 0;
server.SetBlocking(false); server.SetBlocking(false);
sf::SocketTCP new_client; sf::SocketTCP new_client;
while (server_running) while (server_running)
{ {
if (server.Accept(new_client) == sf::Socket::Done) if (server.Accept(new_client) == sf::Socket::Done)
{ {
cs_gecko.Enter(); cs_gecko.Enter();
waiting_socks.push(new_client); waiting_socks.push(new_client);
cs_gecko.Leave(); cs_gecko.Leave();
} }
SLEEP(1); SLEEP(1);
} }
server.Close(); server.Close();
return 0; return 0;
} }
void GeckoConnectionWaiter_Shutdown() void GeckoConnectionWaiter_Shutdown()
{ {
server_running = false; server_running = false;
if (connectionThread) if (connectionThread)
{ {
connectionThread->WaitForDeath(); connectionThread->WaitForDeath();
delete connectionThread; delete connectionThread;
connectionThread = NULL; connectionThread = NULL;
} }
} }
static bool GetAvailableSock(sf::SocketTCP& sock_to_fill) static bool GetAvailableSock(sf::SocketTCP& sock_to_fill)
{ {
bool sock_filled = false; bool sock_filled = false;
cs_gecko.Enter(); cs_gecko.Enter();
if (waiting_socks.size()) if (waiting_socks.size())
{ {
sock_to_fill = waiting_socks.front(); sock_to_fill = waiting_socks.front();
waiting_socks.pop(); waiting_socks.pop();
sock_filled = true; sock_filled = true;
} }
cs_gecko.Leave(); cs_gecko.Leave();
return sock_filled; return sock_filled;
} }
GeckoSockServer::GeckoSockServer() GeckoSockServer::GeckoSockServer()
{ {
if (!connectionThread) if (!connectionThread)
connectionThread = new Common::Thread(GeckoConnectionWaiter, (void*)0); connectionThread = new Common::Thread(GeckoConnectionWaiter, (void*)0);
} }
GeckoSockServer::~GeckoSockServer() GeckoSockServer::~GeckoSockServer()
{ {
client.Close(); client.Close();
} }
CEXIGecko::CEXIGecko() CEXIGecko::CEXIGecko()
: m_uPosition(0) : m_uPosition(0)
, recv_fifo(false) , recv_fifo(false)
{ {
} }
void CEXIGecko::SetCS(int cs) void CEXIGecko::SetCS(int cs)
{ {
if (cs) if (cs)
m_uPosition = 0; m_uPosition = 0;
} }
bool CEXIGecko::IsPresent() bool CEXIGecko::IsPresent()
{ {
return true; return true;
} }
void CEXIGecko::ImmReadWrite(u32 &_uData, u32 _uSize) void CEXIGecko::ImmReadWrite(u32 &_uData, u32 _uSize)
{ {
if (!client.IsValid()) if (!client.IsValid())
if (!GetAvailableSock(client)) if (!GetAvailableSock(client))
;// TODO nothing for now ;// TODO nothing for now
// for debug // for debug
u32 oldval = _uData; u32 oldval = _uData;
// TODO do we really care about _uSize? // TODO do we really care about _uSize?
u8 data = 0; u8 data = 0;
std::size_t got; std::size_t got;
switch (_uData >> 28) switch (_uData >> 28)
{ {
// maybe do something fun later // maybe do something fun later
case CMD_LED_OFF: case CMD_LED_OFF:
break; break;
case CMD_LED_ON: case CMD_LED_ON:
break; break;
// maybe should only | 2bytes? // maybe should only | 2bytes?
case CMD_INIT: case CMD_INIT:
_uData = ident; _uData = ident;
break; break;
// PC -> Gecko // PC -> Gecko
case CMD_RECV: case CMD_RECV:
// TODO recv // TODO recv
client.Receive((char*)&data, sizeof(data), got); client.Receive((char*)&data, sizeof(data), got);
recv_fifo = !!got; recv_fifo = !!got;
if (recv_fifo) if (recv_fifo)
_uData = 0x08000000 | (data << 16); _uData = 0x08000000 | (data << 16);
break; break;
// Gecko -> PC // Gecko -> PC
case CMD_SEND: case CMD_SEND:
data = (_uData >> 20) & 0xff; data = (_uData >> 20) & 0xff;
// TODO send // TODO send
client.Send((char*)&data, sizeof(data)); client.Send((char*)&data, sizeof(data));
// If successful // If successful
_uData |= 0x04000000; _uData |= 0x04000000;
break; break;
// Check if ok for Gecko -> PC, or FIFO full // Check if ok for Gecko -> PC, or FIFO full
// |= 0x04000000 if FIFO is not full // |= 0x04000000 if FIFO is not full
case CMD_CHK_TX: case CMD_CHK_TX:
_uData = 0x04000000; _uData = 0x04000000;
break; break;
// Check if data in FIFO for PC -> Gecko, or FIFO empty // Check if data in FIFO for PC -> Gecko, or FIFO empty
// |= 0x04000000 if data in recv FIFO // |= 0x04000000 if data in recv FIFO
case CMD_CHK_RX: case CMD_CHK_RX:
//_uData = recv_fifo ? 0x04000000 : 0; //_uData = recv_fifo ? 0x04000000 : 0;
_uData = 0x04000000; _uData = 0x04000000;
break; break;
default: default:
ERROR_LOG(EXPANSIONINTERFACE, "Uknown USBGecko command %x", _uData); ERROR_LOG(EXPANSIONINTERFACE, "Uknown USBGecko command %x", _uData);
break; break;
} }
if (_uData) { ERROR_LOG(EXPANSIONINTERFACE, "rw %x %08x %08x", oldval, _uData, _uSize); } if (_uData) { ERROR_LOG(EXPANSIONINTERFACE, "rw %x %08x %08x", oldval, _uData, _uSize); }
} }

View File

@ -1,63 +1,63 @@
// Copyright (C) 2003 Dolphin Project. // Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0. // the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details. // GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program. // A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/ // If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifndef _EXIDEVICE_GECKO_H #ifndef _EXIDEVICE_GECKO_H
#define _EXIDEVICE_GECKO_H #define _EXIDEVICE_GECKO_H
#include "SFML/Network.hpp" #include "SFML/Network.hpp"
class GeckoSockServer class GeckoSockServer
: public sf::SocketTCP : public sf::SocketTCP
{ {
public: public:
GeckoSockServer(); GeckoSockServer();
~GeckoSockServer(); ~GeckoSockServer();
//private: //private:
sf::SocketTCP client; sf::SocketTCP client;
}; };
class CEXIGecko class CEXIGecko
: public IEXIDevice : public IEXIDevice
, private GeckoSockServer , private GeckoSockServer
{ {
public: public:
CEXIGecko(); CEXIGecko();
void SetCS(int _iCS); void SetCS(int _iCS);
bool IsPresent(); bool IsPresent();
void ImmReadWrite(u32 &_uData, u32 _uSize); void ImmReadWrite(u32 &_uData, u32 _uSize);
private: private:
enum enum
{ {
CMD_LED_OFF = 0x7, CMD_LED_OFF = 0x7,
CMD_LED_ON = 0x8, CMD_LED_ON = 0x8,
CMD_INIT = 0x9, CMD_INIT = 0x9,
CMD_RECV = 0xa, CMD_RECV = 0xa,
CMD_SEND = 0xb, CMD_SEND = 0xb,
CMD_CHK_TX = 0xc, CMD_CHK_TX = 0xc,
CMD_CHK_RX = 0xd, CMD_CHK_RX = 0xd,
}; };
u32 m_uPosition; u32 m_uPosition;
bool recv_fifo; bool recv_fifo;
static const u32 ident = 0x04700000; static const u32 ident = 0x04700000;
}; };
#endif #endif