Intel AMT Features > Storage Administration and Operations > Use Cases > Storage: Block Operations (Read/Write/Lock/Unlock)
CollapseAll image

Storage: Block Operations (Read/Write/Lock/Unlock)

The fundamental operations on a block all have the same flow. These operations may be performed on blocks owned by the registered application or on blocks belonging to other applications for which the registered application has the requisite permission (either read-only or read-write).

1.  Register the application, as described in the Storage: Register Application, Perform Task, Unregister Application flow. You should have the session handle and application handle available.

2.  Retrieve the block handle for the block of interest, as described in the Storage: Get the Block Handles for an Application flow.

3.  Perform one or more of the following operations:

a.   Lock the block by invoking AMT_ThirdPartyDataStorageService.LockBlock with the session handle and the block handle as input parameters. Locking the block is an optional operation, but is recommended.

 Note:

When a block is locked, no other application may either read or write the block. Block locks have a timeout associated with them.

Click here for a snippet demonstrating this step

You can execute this snippet by inserting it into the execution template found here.

  

$thirdPartyDataStorageServiceRef =$wsmanConnectionObject.NewReference("SELECT * FROM AMT_ThirdPartyDataStorageService WHERE Name='Intel(r) AMT Third Party Data Storage Service'")

$inputObject =$thirdPartyDataStorageServiceRef.CreateMethodInput("LockBlock")

# $sessionHandle is the session handle returned by 'RegisterApplication' method.

$inputObject.SetProperty("SessionHandle",$sessionHandle.ToString())

# $blockHandle is the block handle returned by 'Create a block for the registered application' use case.

$inputObject.SetProperty("BlockHandle",$blockHandle.ToString())

$outputObject =$thirdPartyDataStorageServiceRef.InvokeMethod($inputObject)

$returnValue =$outputObject.GetProperty("ReturnValue")

 

 

b.   Read data from the block by invoking AMT_ThirdPartyDataStorageService.ReadBlock with the following input parameters:

Parameter

Description/Value

SessionHandle

The session handle.

BlockHandle

The handle of the block.

ByteOffset

The offset within the block from which reading is to start.

ByteCount

The number of bytes that should be read.

 

The data is returned as an array of bytes as an output parameter.

Click here for a snippet demonstrating this step

You can execute this snippet by inserting it into the execution template found here.

  

$thirdPartyDataStorageServiceRef =$wsmanConnectionObject.NewReference("SELECT * FROM AMT_ThirdPartyDataStorageService WHERE Name='Intel(r) AMT Third Party Data Storage Service'")

$inputObject =$thirdPartyDataStorageServiceRef.CreateMethodInput("ReadBlock")

# $sessionHandle is the session handle returned by 'RegisterApplication' method.

$inputObject.SetProperty("SessionHandle",$sessionHandle.ToString())

# $blockHandle is the block handle returned by 'Create a block for the registered application' use case.

$inputObject.SetProperty("BlockHandle",$blockHandle.ToString())

$inputObject.SetProperty("ByteOffset","0")

$inputObject.SetProperty("ByteCount","11")

$outputObject =$thirdPartyDataStorageServiceRef.InvokeMethod($inputObject)

$returnValue =$outputObject.GetProperty("ReturnValue")

if($returnValue -like "0")

{

    $data =$outputObject.GetProperty("Data")

}

 

 

c.    Write data to the block by invoking AMT_ThirdPartyDataStorageService.WriteBlock with the following input parameters:

Parameter

Description/Value

SessionHandle

The session handle.

BlockHandle

The handle of the block.

ByteOffset

The offset within the block at which writing is to start.

Data

A byte array with the data to be written.

 

The number of bytes actually written is returned as an output parameter.

Click here for a snippet demonstrating this step

You can execute this snippet by inserting it into the execution template found here.

  

$thirdPartyDataStorageServiceRef =$wsmanConnectionObject.NewReference("SELECT * FROM AMT_ThirdPartyDataStorageService WHERE Name='Intel(r) AMT Third Party Data Storage Service'")

$inputObject =$thirdPartyDataStorageServiceRef.CreateMethodInput("WriteBlock")

# $sessionHandle is the session handle returned by 'RegisterApplication' method.

$inputObject.SetProperty("SessionHandle",$sessionHandle.ToString())

# $blockHandle is the block handle returned by 'Create a block for the registered application' use case.

$inputObject.SetProperty("BlockHandle",$blockHandle.ToString())

$inputObject.SetProperty("ByteOffset","0")

$inputObject.SetProperty("Data","100011101010010")

$outputObject =$thirdPartyDataStorageServiceRef.InvokeMethod($inputObject)

$returnValue =$outputObject.GetProperty("ReturnValue")

 

 

4.  If the block was previously locked, unlock the block by invoking AMT_ThirdPartyDataStorageService.UnlockBlock with the session handle and the block handle as input parameters.

Click here for a snippet demonstrating this step

You can execute this snippet by inserting it into the execution template found here.

  

$thirdPartyDataStorageServiceRef =$wsmanConnectionObject.NewReference("SELECT * FROM AMT_ThirdPartyDataStorageService WHERE Name='Intel(r) AMT Third Party Data Storage Service'")

$inputObject =$thirdPartyDataStorageServiceRef.CreateMethodInput("UnlockBlock")

# $sessionHandle is the session handle returned by 'RegisterApplication' method.

$inputObject.SetProperty("SessionHandle",$sessionHandle.ToString())

# $blockHandle is the block handle returned by 'Create a block for the registered application' use case.

$inputObject.SetProperty("BlockHandle",$blockHandle.ToString())

$outputObject =$thirdPartyDataStorageServiceRef.InvokeMethod($inputObject)

$returnValue =$outputObject.GetProperty("ReturnValue")

 

 

5.  Unregister the application when done. See Storage: Register Application, Perform Task, Unregister Application.

Instance Diagram

Not applicable

Classes Used in This Flow

SDK Sample

If there is a sample demonstrating this flow, it is included in the SDK installation file. See SDK Installation Layout for details.

 

See Also:

   Storage Concepts and Objects

   Application Development Guidelines

   Examples of Using the Storage Feature

Copyright © 2006-2022, Intel Corporation. All rights reserved.