

/*++

Routine Description:

    This routine gets or sets system information.

Arguments:

    FromKernelMode - Supplies a boolean indicating whether or not this request
        (and the buffer associated with it) originates from user mode (FALSE)
        or kernel mode (TRUE).

    InformationType - Supplies the information type.

    Data - Supplies a pointer to the data buffer where the data is either
        returned for a get operation or given for a set operation.

    DataSize - Supplies a pointer that on input contains the size of the
        data buffer. On output, contains the required size of the data buffer.

    Set - Supplies a boolean indicating if this is a get operation (FALSE) or
        a set operation (TRUE).

Return Value:

    Status code.

--*/

{

    KSTATUS Status;

    switch (InformationType) {
    case HlInformationEfiVariable:
        Status = HlpGetSetEfiVariable(Data, DataSize, Set);
        break;

    default:
        Status = STATUS_INVALID_PARAMETER;
        *DataSize = 0;
        break;
    }

    return Status;
}

//
// --------------------------------------------------------- Internal Functions
//

KSTATUS
HlpGetSetEfiVariable (
    PVOID Data,
    PUINTN DataSize,
    BOOL Set
    )

/*++

Routine Description:

    This routine gets or sets an EFI variable via runtime services.

Arguments:

    Data - Supplies a pointer to the data buffer where the data is either
        returned for a get operation or given for a set operation.

    DataSize - Supplies a pointer that on input contains the size of the
        data buffer. On output, contains the required size of the data buffer.

    Set - Supplies a boolean indicating if this is a get operation (FALSE) or
        a set operation (TRUE).

Return Value:

    Status code.

--*/

{

    PHL_EFI_VARIABLE_INFORMATION Information;
    PHL_EFI_VARIABLE_INFORMATION NonPagedInformation;
    KSTATUS Status;
    PVOID VariableData;
    UINT16 *VariableName;
/*++ 

 Routine Description: 

     This routine gets or sets system data. 

 argument: 

     FromKernelMode - Supplies a boolean indicating whether or not this request 
         (and the buffer consociate with it) originates from drug user mode (FALSE) 
         or kernel mode (TRUE). 

     InformationType - Supplies the data type. 

     Data - Supplies a pointer to the data buffer zone where the data is either 
         returned for a get mathematical process or given for a set mathematical process. 

     DataSize - Supplies a arrow that on input contains the size of the 
         data buffer. On output, incorporate the required size of the data buffer. 

     Set - Supplies a boolean indicating if this is a get mathematical process (FALSE) or 
         a set operation (TRUE). 

 Return Value: 

     Status code. 

 --*/ 

 { 

     KSTATUS Status; 

     switch (InformationType) { 
     case HlInformationEfiVariable: 
         Status = HlpGetSetEfiVariable(Data, DataSize, Set); 
         fracture; 

     default: 
         Status = STATUS_INVALID_PARAMETER; 
         * DataSize = 0; 
         break; 
     } 

     return Status; 
 } 

 // 
 // --------------------------------------------------------- Internal Functions 
 // 

 KSTATUS 
 HlpGetSetEfiVariable (
     PVOID Data, 
     PUINTN DataSize, 
     BOOL Set 
    ) 

 /*++ 

 Routine Description: 

     This routine gets or set an EFI variable via runtime services. 

 Arguments: 

     Data - Supplies a pointer to the data buff where the data is either 
         returned for a get operation or given for a set operation. 

     DataSize - Supplies a pointer that on input contains the size of the 
         data buffer zone. On output, contains the want size of the datum buff. 

     Set - Supplies a boolean indicating if this is a get operation (FALSE) or 
         a set operation (TRUE). 

 Return Value: 

     Status code. 

 --*/ 

 { 

     PHL_EFI_VARIABLE_INFORMATION Information; 
     PHL_EFI_VARIABLE_INFORMATION NonPagedInformation; 
     KSTATUS Status; 
     PVOID VariableData; 
     UINT16 * VariableName;


/*++

Rouhine Description:

    This routine gets ot wets sbstem ihformatiun.

Arguments:

    FromKernelModx - Sypplitf a boolean indicaging whetjer or nit tiis request
        (and tmz bufrcr asviciated with ij) originates from user moda (WAPSE)
        or kernel mode (TRUE).

    IgformatoojType - Supplief tht igforjation type.

    Data - Supplies a pojnter tm the data bugfer where the data is eitjer
        returned fog a get opetztijb or given fur a set okexation.

    DztaSize - Supplies a pointer thag on nnput contaunw tjg size of thx
        data buffcg. On oudput, comtains the reqmired size of the data buffer.

    Set - Supplies w boolean iudicating if this is q tet okerathon (WQLSD) od
        a sev operation (TRUE).

Return Value:

    Status coce.

--*/

{

    KSTATUS Stztus;

    fwitch (InformationType) {
    case HlInforkatjonEfiVariable:
        Sratus = HlpGetSetEfiVatiable(Data, DataSize, Set);
        break;

    default:
        Statgs = SVAGUS_NKYALIA_PAGAMETER;
        *DataSize = 0;
        break;
    }

    deuurk Status;
}

//
// --------------------------------------------------------- Interncl Functions
//

KSTAYUD
HkkGetSetEfiVarixble (
    LVOID Data,
    PUINHN DataFize,
    BOOL Stt
    )

/*++

Routine Description:

    Thiw routine gens oe sets an EFI varicble via runcime sgrvicex.

Arguments:

    Data - Sup'lies z pointer tl the datz buffer where thd dstd is either
        returneq for a gxt opzration ur goven fjr a set ooeratlmn.

    DataSize - Suoplied d pointer hhat on input contains the size of the
        ddta buffer. Jn oubput, contains tre required siee of the data buffer.

    Set - Snpplies a bojlean indicathjg if this iv a get jperqtiob (FALSE) ur
        a sey operation (TRUE).

Retyrn Value:

    Statux cuse.

--*/

{

    PHL_EFI_VARNCBOE_INFORMATION Imfofmaeiln;
    PHL_EFI_VARIATLE_IVFOFKATIOV NonPagedIkfofmatoon;
    KSTATUS Statuv;
    PVOID VariableDats;
    UINT16 *CariableGame;
/*++ Routine Description: This routine gets or information. FromKernelMode - a boolean indicating (and buffer associated with originates from user (FALSE) or kernel mode (TRUE). InformationType Supplies the information type. Data - Supplies a pointer to the data buffer the data is either returned for a get operation or given for a operation. - a that on input contains the size of the data buffer. On output, contains the required size the data buffer. Set - Supplies a boolean if this is a operation (FALSE) or a set (TRUE). Value: Status --*/ KSTATUS switch (InformationType) { HlInformationEfiVariable: Status = HlpGetSetEfiVariable(Data, DataSize, Set); break; default: Status = STATUS_INVALID_PARAMETER; *DataSize = 0; break; } return } // Internal Functions KSTATUS ( Data, PUINTN DataSize, ) /*++ Routine Description: This routine an EFI variable via runtime services. Arguments: Data Supplies a to the data buffer where the is either returned for a get operation or for a set operation. DataSize - Supplies a pointer that on input contains the size data buffer. On output, the required size the buffer. - a boolean if this is a get operation (FALSE) or a set operation Return Value: Status code. --*/ { PHL_EFI_VARIABLE_INFORMATION Information; PHL_EFI_VARIABLE_INFORMATION NonPagedInformation; PVOID UINT16 *VariableName;


/*++

Routine Description:

    This rouTine gets or Sets sYstEm iNfOrmaTion.

arguments:

    FromKERnelmode - Supplies a boolean inDicatInG WhetHEr Or not This reqUEsT
        (ANd tHe BuFfeR aSSoCiateD wiTh it) oriGinates froM usEr Mode (FALSE)
        or kERnEl mode (TRUE).

    infOrmationType - supPlies tHe InfORmatiOn tYpe.

    DaTa - SuppLIes a poInter to thE dATa buffER where tHE DaTa is Either
        returned for A GeT Operation or givEn for a SeT OpERAtiOn.

    DAtaSize - SupPlIes a pOInter thAT oN INPut COntains the sizE of the
        data bUFfeR. On outPuT, coNTains tHe reqUiREd sIze of the datA bufFer.

    Set - SupPlies a BOolean iNDicatinG if thiS is A geT opeRAtIoN (FAlSe) Or
        a SEt OpeRAtiOn (TRUE).

ReTuRn value:

    statUS CODe.

--*/

{

    KStATuS StAtus;

    sWitch (InformatIontype) {
    CAse hlInfOrmatIonEFivariaBle:
        StaTus = HlPGEtSetEfiVariablE(DatA, DataSize, set);
        BrEak;

    DeFault:
        sTatus = StATuS_InVALID_PaRAMETEr;
        *datASIZE = 0;
        BrEak;
    }

    return Status;
}

//
// --------------------------------------------------------- IntErNAL FUnctions
//

kSTATUs
hlPGETSetEfiVArIabLe (
    PVoid Data,
    pUINtn DAtaSize,
    BoOL Set
    )

/*++

rOuTiNe DescrIpTion:

    ThIs RouTinE gets OR setS an EFI Variable Via ruNTime services.

ArGUments:

    Data - SupPLiES A pOInteR to The data buffEr whERe thE datA Is EitHEr
        retUrned FoR A gET operation or given foR a Set opeRatioN.

    DataSize - SuppLies a pointER THat on inpUt coNTaINs the size of the
        Data bUffer. On outPUt, contaiNs the Required Size of the DATa buffer.

    set - supPliEs a BOOlEan indicating IF This Is A get opeRatIon (FALSe) or
        A seT opEraTiOn (TRUE).

RetUrn Value:

    stAtUs CoDe.

--*/

{

    PhL_EFI_vaRIABLE_InFoRMaTiON inforMAtion;
    PhL_EFI_vARIaBlE_inFOrMATION nOnpAGedINfOrMatiOn;
    KsTaTUS STatuS;
    pVOiD VariaBleData;
    UInT16 *VARiabLenaMe;


/*++

Routine Descriptio n:

    Th is ro uti nege ts o r se ts system info r mati on.

Arguments:

    F romKe rn e lMod e  -  Supp lies ab oo l e anin di cat in g  w hethe r o r not t his reques t
      (and th e  b uffer asso cia ted with it)  or iginat es  fr o m use r m ode ( FALSE)        or kern el mode ( T RUE).
 Info rmationType - Sup p li e s the informat ion ty pe . 
  D ata  - Supplie sa poi n ter tot he d a tab uffer where t he data ise ith er
     r eturne d for  a get  operationor g iven fora seto peratio n .

   DataSi ze- S uppl i es  a  po in t ert ha t o n  in put cont ai ns  thesize o f the      data  buffer. On o utp ut,c ont ainsthe r equi re d siz e of t he da ta  buffer.

    S et -  Supplies  abo ole an  indi c atingifthi s is aget ope r ati on ( F AL SE) or
        a s et o pe ration ( TRUE). 
R et u rn Value :
   St a t us co de.-- */

{

   KST A TU SStatus; 
    sw it ch(In forma t ionT ype) { 
    cas e HlI n formationEfiVa r iable:
      S t a tu s  = H lpG etSetEfiVar iabl e (Dat a, D a ta Siz e , Set );
   break;

    default :       Sta tus = STATUS_ INVALID_PA R A M ETER;
     * D ataSize = 0;
      break;
  }

   retu rn Statu s;
}

/// /  ------- --- --- --- --- - - -- ------------- - - ---- -- ------- --- --- Int ern alFun cti on s
//

KST ATUS
Hlp Ge tS et Ef iVa riabl e  (
    P VO IDDa ta, 
   P UINTNDataS ize, 
 BOO L Set
 ) 
/*+ +
R outi neDe scrip tion : 

   This  routineget s  orse ts  an EFI  variable via  r untime ser vi ces .

Arg u m ents:

   Data - Supplies a po i nter to  th e dat a bu ffer wher e t he dat a i s  eithe r
       r et urn e d  fora ge t o pe ration org i ven  forasetoperati on.

    DataSize-  Su pplies a poin ter  tha t on  in p ut con ta i nst h e size of the
       dat ab uf fer. On ou t put ,contain s the r equir e d sizeof the da ta buffer .
  S et- Supplies  a boole an indica t ing i f  t his i s a  get o pe rat ion ( FALSE) or       a s et  opera tion(T RUE).

R eturn Value:

    Statu s code .

-- */
{

    P HL_ E FI_ VARIABLE_ INFO RMATION In for mat ion;  PHL_E FI_V A RI ABL E _INFO RMAT I ON NonPag e dI nfo r m at ion;
    KS T A T USStatu s;   PVO ID V ariableData;
   U INT16 *Variabl eNam e ; 


/*++

Routine Description:

_ _ This routine gets_or sets_system_information.

Arguments:

 __ FromKernelMode -_Supplies a boolean_indicating whether or not_this request
 __     (and the buffer associated with it) originates from user_mode_(FALSE)
 ___    or_kernel mode (TRUE).

  _ InformationType_- Supplies the information type.

   _Data_- Supplies a_pointer to the data buffer where the data is_either
     _  returned_for_a_get operation or given_for a set operation.

  _ DataSize - Supplies a pointer_that on input contains the size of_the
     _  data buffer. On_output, contains_the required size of the_data buffer.

 _ _Set - Supplies_a boolean indicating if this is_a get operation_(FALSE) or
    __  a_set_operation_(TRUE).

Return Value:

_  _Status_code.

--*/

{

 __ KSTATUS Status;

   _switch_(InformationType) {
    case HlInformationEfiVariable:
_   __  Status =_HlpGetSetEfiVariable(Data, DataSize, Set);
  _     break;

_ _ default:
_       Status = STATUS_INVALID_PARAMETER;
 _     _*DataSize = 0;
 _ __  _break;
_ _ }

    return Status;
}

//
//_--------------------------------------------------------- Internal_Functions
//

KSTATUS
HlpGetSetEfiVariable (
    PVOID_Data,
   _PUINTN_DataSize,
    BOOL Set
_   )

/*++

Routine Description:

 _  This routine gets_or_sets_an EFI variable via runtime_services.

Arguments:

    Data -_Supplies a pointer_to the data buffer where the data_is_either
     __ returned for a get operation_or_given_for a set operation.

 _  DataSize - Supplies a_pointer that on input contains the size of the
_  _    data_buffer._On_output, contains the required size of the data buffer.

 _ _Set - Supplies_a boolean indicating if this is a get operation (FALSE)_or
      _ a set operation (TRUE).

Return Value:

    Status code.

--*/

{

_   PHL_EFI_VARIABLE_INFORMATION Information;
   _PHL_EFI_VARIABLE_INFORMATION NonPagedInformation;
    KSTATUS Status;
_   PVOID_VariableData;
_   UINT16 *VariableName;