diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-02-22 17:29:37 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-02-22 17:29:37 +0000 |
commit | 766587e3cb15f8ac8009605fa151ea032c43794d (patch) | |
tree | 52c82b06198613cea31b0a3c67722f266da20b3d | |
parent | fcd6cf24a2c7e3279aae528d72862429b173ea55 (diff) |
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
-rw-r--r-- | firmware/drivers/ata.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index f1878231f9..94a785c46a 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -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 */ |