Give 5g owner's some immediate relief from playback trouble introduced in r16105 without reverting all the "spinlock" changes. A highly localized version of the patches in FS#8568. More permanent and correct measures are being worked out.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16367 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-02-22 17:29:37 +00:00
parent fcd6cf24a2
commit 766587e3cb

View file

@ -93,6 +93,53 @@ static int multisectors; /* number of supported multisectors */
static unsigned short identify_info[SECTOR_SIZE/2];
#ifdef MAX_PHYS_SECTOR_SIZE
/** This is temporary **/
/* Define the mutex functions to use the special hack object */
#define mutex_init ata_spin_init
#define mutex_lock ata_spin_lock
#define mutex_unlock ata_spin_unlock
void ata_spin_init(struct mutex *m)
{
m->thread = NULL;
m->locked = 0;
m->count = 0;
#if CONFIG_CORELOCK == SW_CORELOCK
corelock_init(&m->cl);
#endif
}
void ata_spin_lock(struct mutex *m)
{
struct thread_entry *current = thread_get_current();
if (current == m->thread)
{
m->count++;
return;
}
while (test_and_set(&m->locked, 1, &m->cl))
yield();
m->thread = current;
}
void ata_spin_unlock(struct mutex *m)
{
if (m->count > 0)
{
m->count--;
return;
}
m->thread = NULL;
test_and_set(&m->locked, 0, &m->cl);
}
/****/
struct sector_cache_entry {
bool inuse;
unsigned long sectornum; /* logical sector */