Cryptography Reference
In-Depth Information
The structure registers involves the variable registers.created , which
is used for counting the number of requested registers to be created. A call to
the function free_reg_l() described below results in the set of registers being
released only if registers.created has the value 1 . Otherwise, registers.created
is simply reduced by 1 . With the use of this mechanism, called a semaphore ,we
manage to prevent a set of registers allocated by one function being inadvertently
released by another function. On the other hand, every function that requests the
set of registers by calling create_reg_l() is responsible for releasing it again with
free_reg_l() . Moreover, in general, one cannot assume that the registers contain
specific values after a function has been called.
The variable NoofRegs , which determines the number of registers created by
create_reg_l() , can be changed by the function set_noofregs_l() . This change,
however, remains in effect only until the currently allocated set of registers is
released and a new set is created with create_reg_l() .
Function:
set number of registers
void set_noofregs_l (unsigned int nregs);
Syntax:
nregs (number of registers in the register bank)
Input:
void
set_noofregs_l (unsigned int nregs)
{
NoofRegs = (USHORT)nregs;
}
Now that a set of registers can be allocated, one may ask how individual
registers can be accessed. For this it is necessary to select the address field
reg_l , dynamically allocated by create_reg_l() , of the above-defined structure
clint_reg . This will be accomplished with the help of the function get_reg_l() ,
introduced below, which returns a pointer to an individual register of the set
of registers, provided that the specified ordinal number denotes an allocated
register.
 
Search WWH ::




Custom Search