Home | History | Annotate | Line # | Download | only in lib
      1 /*	$NetBSD: lock.c,v 1.1.1.1 2014/04/01 16:16:06 jakllsch Exp $	*/
      2 
      3 /*++
      4 
      5 Copyright (c) 1998  Intel Corporation
      6 
      7 Module Name:
      8 
      9     lock.c
     10 
     11 Abstract:
     12 
     13     Implements FLOCK
     14 
     15 
     16 
     17 Revision History
     18 
     19 --*/
     20 
     21 
     22 #include "lib.h"
     23 
     24 
     25 VOID
     26 InitializeLock (
     27     IN OUT FLOCK    *Lock,
     28     IN EFI_TPL      Priority
     29     )
     30 /*++
     31 
     32 Routine Description:
     33 
     34     Initialize a basic mutual exclusion lock.   Each lock
     35     provides mutual exclusion access at it's task priority
     36     level.  Since there is no-premption (at any TPL) or
     37     multiprocessor support, acquiring the lock only consists
     38     of raising to the locks TPL.
     39 
     40     Note on a debug build the lock is acquired and released
     41     to help ensure proper usage.
     42 
     43 Arguments:
     44 
     45     Lock        - The FLOCK structure to initialize
     46 
     47     Priority    - The task priority level of the lock
     48 
     49 
     50 Returns:
     51 
     52     An initialized F Lock structure.
     53 
     54 --*/
     55 {
     56     Lock->Tpl = Priority;
     57     Lock->OwnerTpl = 0;
     58     Lock->Lock = 0;
     59 }
     60 
     61 
     62 VOID
     63 AcquireLock (
     64     IN FLOCK    *Lock
     65     )
     66 /*++
     67 
     68 Routine Description:
     69 
     70     Raising to the task priority level of the mutual exclusion
     71     lock, and then acquires ownership of the lock.
     72 
     73 Arguments:
     74 
     75     Lock        - The lock to acquire
     76 
     77 Returns:
     78 
     79     Lock owned
     80 
     81 --*/
     82 {
     83     RtAcquireLock (Lock);
     84 }
     85 
     86 
     87 VOID
     88 ReleaseLock (
     89     IN FLOCK    *Lock
     90     )
     91 /*++
     92 
     93 Routine Description:
     94 
     95     Releases ownership of the mutual exclusion lock, and
     96     restores the previous task priority level.
     97 
     98 Arguments:
     99 
    100     Lock        - The lock to release
    101 
    102 Returns:
    103 
    104     Lock unowned
    105 
    106 --*/
    107 {
    108     RtReleaseLock (Lock);
    109 }
    110