citra-emu
/
citra-canary
Archived
1
0
Fork 0

fixed licensing issue with core_timing being GPL v2+ instead of Dolphin's GPL v2

This commit is contained in:
bunnei 2014-04-08 19:11:21 -04:00
parent ef7cfa0207
commit 3dc3bd5627
2 changed files with 444 additions and 476 deletions

View File

@ -1,20 +1,6 @@
// Copyright (c) 2012- PPSSPP Project / Dolphin Project. // Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// This program is free software: you can redistribute it and/or modify // Refer to the license.txt file included.
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <vector> #include <vector>
#include <cstdio> #include <cstdio>
@ -26,8 +12,6 @@
#include "core.h" #include "core.h"
#include "chunk_file.h" #include "chunk_file.h"
//#include "HLE/sceKernelThread.h"
int g_clock_rate_arm11 = 268123480; int g_clock_rate_arm11 = 268123480;
// is this really necessary? // is this really necessary?
@ -55,7 +39,7 @@ struct BaseEvent
s64 time; s64 time;
u64 userdata; u64 userdata;
int type; int type;
// Event *next; // Event *next;
}; };
typedef LinkedListItem<BaseEvent> Event; typedef LinkedListItem<BaseEvent> Event;
@ -81,7 +65,7 @@ s64 idledCycles;
static std::recursive_mutex externalEventSection; static std::recursive_mutex externalEventSection;
// Warning: not included in save state. // Warning: not included in save state.
void (*advanceCallback)(int cyclesExecuted) = NULL; void(*advanceCallback)(int cyclesExecuted) = NULL;
void SetClockFrequencyMHz(int cpuMhz) void SetClockFrequencyMHz(int cpuMhz)
{ {
@ -97,7 +81,7 @@ int GetClockFrequencyMHz()
Event* GetNewEvent() Event* GetNewEvent()
{ {
if(!eventPool) if (!eventPool)
return new Event; return new Event;
Event* ev = eventPool; Event* ev = eventPool;
@ -109,7 +93,7 @@ Event* GetNewTsEvent()
{ {
allocatedTsEvents++; allocatedTsEvents++;
if(!eventTsPool) if (!eventTsPool)
return new Event; return new Event;
Event* ev = eventTsPool; Event* ev = eventTsPool;
@ -144,7 +128,7 @@ void AntiCrashCallback(u64 userdata, int cyclesLate)
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback) void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback)
{ {
if (event_type >= (int) event_types.size()) if (event_type >= (int)event_types.size())
event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT")); event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT"));
event_types[event_type] = EventType(callback, name); event_types[event_type] = EventType(callback, name);
@ -172,7 +156,7 @@ void Shutdown()
ClearPendingEvents(); ClearPendingEvents();
UnregisterAllEvents(); UnregisterAllEvents();
while(eventPool) while (eventPool)
{ {
Event *ev = eventPool; Event *ev = eventPool;
eventPool = ev->next; eventPool = ev->next;
@ -180,7 +164,7 @@ void Shutdown()
} }
std::lock_guard<std::recursive_mutex> lk(externalEventSection); std::lock_guard<std::recursive_mutex> lk(externalEventSection);
while(eventTsPool) while (eventTsPool)
{ {
Event *ev = eventTsPool; Event *ev = eventTsPool;
eventTsPool = ev->next; eventTsPool = ev->next;
@ -211,9 +195,9 @@ void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata
ne->type = event_type; ne->type = event_type;
ne->next = 0; ne->next = 0;
ne->userdata = userdata; ne->userdata = userdata;
if(!tsFirst) if (!tsFirst)
tsFirst = ne; tsFirst = ne;
if(tsLast) if (tsLast)
tsLast->next = ne; tsLast->next = ne;
tsLast = ne; tsLast = ne;
@ -224,7 +208,7 @@ void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata
// in which case the event will get handled immediately, before returning. // in which case the event will get handled immediately, before returning.
void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata) void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata)
{ {
if(false) //Core::IsCPUThread()) if (false) //Core::IsCPUThread())
{ {
std::lock_guard<std::recursive_mutex> lk(externalEventSection); std::lock_guard<std::recursive_mutex> lk(externalEventSection);
event_types[event_type].callback(userdata, 0); event_types[event_type].callback(userdata, 0);
@ -247,10 +231,10 @@ void AddEventToQueue(Event* ne)
{ {
Event* prev = NULL; Event* prev = NULL;
Event** pNext = &first; Event** pNext = &first;
for(;;) for (;;)
{ {
Event*& next = *pNext; Event*& next = *pNext;
if(!next || ne->time < next->time) if (!next || ne->time < next->time)
{ {
ne->next = next; ne->next = next;
next = ne; next = ne;
@ -279,7 +263,7 @@ s64 UnscheduleEvent(int event_type, u64 userdata)
s64 result = 0; s64 result = 0;
if (!first) if (!first)
return result; return result;
while(first) while (first)
{ {
if (first->type == event_type && first->userdata == userdata) if (first->type == event_type && first->userdata == userdata)
{ {
@ -324,7 +308,7 @@ s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata)
std::lock_guard<std::recursive_mutex> lk(externalEventSection); std::lock_guard<std::recursive_mutex> lk(externalEventSection);
if (!tsFirst) if (!tsFirst)
return result; return result;
while(tsFirst) while (tsFirst)
{ {
if (tsFirst->type == event_type && tsFirst->userdata == userdata) if (tsFirst->type == event_type && tsFirst->userdata == userdata)
{ {
@ -370,7 +354,7 @@ s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata)
} }
// Warning: not included in save state. // Warning: not included in save state.
void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted)) void RegisterAdvanceCallback(void(*callback)(int cyclesExecuted))
{ {
advanceCallback = callback; advanceCallback = callback;
} }
@ -392,7 +376,7 @@ void RemoveEvent(int event_type)
{ {
if (!first) if (!first)
return; return;
while(first) while (first)
{ {
if (first->type == event_type) if (first->type == event_type)
{ {
@ -432,7 +416,7 @@ void RemoveThreadsafeEvent(int event_type)
{ {
return; return;
} }
while(tsFirst) while (tsFirst)
{ {
if (tsFirst->type == event_type) if (tsFirst->type == event_type)
{ {
@ -483,8 +467,8 @@ void ProcessFifoWaitEvents()
{ {
if (first->time <= globalTimer) if (first->time <= globalTimer)
{ {
// LOG(TIMER, "[Scheduler] %s (%lld, %lld) ", // LOG(TIMER, "[Scheduler] %s (%lld, %lld) ",
// first->name ? first->name : "?", (u64)globalTimer, (u64)first->time); // first->name ? first->name : "?", (u64)globalTimer, (u64)first->time);
Event* evt = first; Event* evt = first;
first = first->next; first = first->next;
event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time)); event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time));
@ -512,7 +496,7 @@ void MoveEvents()
tsLast = NULL; tsLast = NULL;
// Move free events to threadsafe pool // Move free events to threadsafe pool
while(allocatedTsEvents > 0 && eventPool) while (allocatedTsEvents > 0 && eventPool)
{ {
Event *ev = eventPool; Event *ev = eventPool;
eventPool = ev->next; eventPool = ev->next;
@ -622,12 +606,12 @@ void DoState(PointerWrap &p)
if (!s) if (!s)
return; return;
int n = (int) event_types.size(); int n = (int)event_types.size();
p.Do(n); p.Do(n);
// These (should) be filled in later by the modules. // These (should) be filled in later by the modules.
event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT")); event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT"));
p.DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(first, (Event **) NULL); p.DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(first, (Event **)NULL);
p.DoLinkedList<BaseEvent, GetNewTsEvent, FreeTsEvent, Event_DoState>(tsFirst, &tsLast); p.DoLinkedList<BaseEvent, GetNewTsEvent, FreeTsEvent, Event_DoState>(tsFirst, &tsLast);
p.Do(g_clock_rate_arm11); p.Do(g_clock_rate_arm11);

View File

@ -1,22 +1,8 @@
// Copyright (c) 2012- PPSSPP Project / Dolphin Project. // Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
// This program is free software: you can redistribute it and/or modify #pragma once
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#ifndef CORE_CORE_TIMING_H_
#define CORE_CORE_TIMING_H_
// This is a system to schedule events into the emulated machine's future. Time is measured // This is a system to schedule events into the emulated machine's future. Time is measured
// in main CPU clock cycles. // in main CPU clock cycles.
@ -69,57 +55,55 @@ inline s64 cyclesToUs(s64 cycles) {
return cycles / (g_clock_rate_arm11 / 1000000); return cycles / (g_clock_rate_arm11 / 1000000);
} }
namespace CoreTiming namespace CoreTiming {
{
void Init();
void Shutdown();
typedef void (*TimedCallback)(u64 userdata, int cyclesLate); void Init();
void Shutdown();
u64 GetTicks(); typedef void(*TimedCallback)(u64 userdata, int cyclesLate);
u64 GetIdleTicks();
// Returns the event_type identifier. u64 GetTicks();
int RegisterEvent(const char *name, TimedCallback callback); u64 GetIdleTicks();
// For save states.
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback);
void UnregisterAllEvents();
// userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk, // Returns the event_type identifier.
// when we implement state saves. int RegisterEvent(const char *name, TimedCallback callback);
void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata=0); // For save states.
void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata=0); void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback);
void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata=0); void UnregisterAllEvents();
s64 UnscheduleEvent(int event_type, u64 userdata);
s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata);
void RemoveEvent(int event_type); // userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk,
void RemoveThreadsafeEvent(int event_type); // when we implement state saves.
void RemoveAllEvents(int event_type); void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata = 0);
bool IsScheduled(int event_type); void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata = 0);
void Advance(); void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata = 0);
void MoveEvents(); s64 UnscheduleEvent(int event_type, u64 userdata);
void ProcessFifoWaitEvents(); s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata);
// Pretend that the main CPU has executed enough cycles to reach the next event. void RemoveEvent(int event_type);
void Idle(int maxIdle = 0); void RemoveThreadsafeEvent(int event_type);
void RemoveAllEvents(int event_type);
bool IsScheduled(int event_type);
void Advance();
void MoveEvents();
void ProcessFifoWaitEvents();
// Clear all pending events. This should ONLY be done on exit or state load. // Pretend that the main CPU has executed enough cycles to reach the next event.
void ClearPendingEvents(); void Idle(int maxIdle = 0);
void LogPendingEvents(); // Clear all pending events. This should ONLY be done on exit or state load.
void ClearPendingEvents();
// Warning: not included in save states. void LogPendingEvents();
void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted));
std::string GetScheduledEventsSummary(); // Warning: not included in save states.
void RegisterAdvanceCallback(void(*callback)(int cyclesExecuted));
void DoState(PointerWrap &p); std::string GetScheduledEventsSummary();
void SetClockFrequencyMHz(int cpuMhz); void DoState(PointerWrap &p);
int GetClockFrequencyMHz();
extern int slicelength; void SetClockFrequencyMHz(int cpuMhz);
int GetClockFrequencyMHz();
extern int slicelength;
}; // namespace }; // namespace
#endif // CORE_CORE_TIMING_H_