Download Manual

Transcript
ERTFS User Guide
Section 12: Porting: mutex semaphore support
Note: ERTFS does not require mutex semaphore in non-multitasking environments. If you are porting to a non-multitasking
environment, or if you can guarantee that only one task at a time will use ERTFS, then please skip this section.
ERTFS requires several mutex (binary) semaphores. One mutex semaphore is required per drive to be used and one system
wide critical section mutex semaphore is required. There are a maximum of 26 possible drives but the actual number to support is user configurable as described in Section 3.
In addition some device drivers may require their own mutex semaphores to function properly. The only stock driver that requires a mutex is the ATA/IDE driver. If you are using ATA/IDE please plan for one extra mutex.
The Mutex code is abstracted into three functions that must be modified by the user to support the target RTOS. The required
functions are:
1. rtfs_port_alloc_mutex()
2. rtfs_port_claim_mutex()
3. rtfs_port_release_mutex()
The requirements for each of these functions is provided here.
unsigned long rtfs_port_alloc_mutex(void) This routine takes no arguments and returns an unsigned long. The routine must allocate and initialize a Mutex, setting it to the “not
owned” state. It must return an unsigned long value that will be used as a handle. ERTFS will not interpret the value of the return
value. The handle will only be used as an argument to the rtfs_port_claim_mutex() and rtfs_port_release_mutex() calls. The
handle may be used as an index into a table or it may be cast internally to an RTOS specific pointer. If the mutex allocation
function fails, this routine must return 0 and the ERTFS calling function will return failure.
void rtfs_port_claim_mutex(unsigned long handle) This routine takes as an argument a mutex handle that was returned by rtfs_port_alloc_mutex(). If the mutex is already
claimed, it must wait for it to be released and then claim the mutex and return.
void rtfs_port_release_mutex(unsigned long handle) This routine takes as an argument a mutex handle that was returned by rtfs_port_alloc_mutex() that was previously claimed
by a call to rtfs_port_claim_mutex(). It must release the handle and cause a caller blocked in rtfs_port_claim_mutex() for
that same handle to unblock.
Section 12: Porting: Mutex Semaphore Support
27