| // Copyright 2018 The Fuchsia Authors. All rights reserved. | 
 | // Use of this source code is governed by a BSD-style license that can be | 
 | // found in the LICENSE file. | 
 | library fuchsia.nand; | 
 | using fuchsia.hardware.nand; | 
 | using zx; | 
 |  | 
 | // Defines a Read/Write/Erase request to be sent to the nand driver. | 
 | @for_deprecated_c_bindings | 
 | type BrokerRequestData = resource struct { | 
 |     vmo zx.handle:<VMO, optional>; // Only used for read and write. | 
 |     length uint32; // In pages (read / write) or blocks (erase). | 
 |     offset_nand uint32; // In pages (read / write) or blocks (erase). | 
 |     offset_data_vmo uint64; // In pages. | 
 |     offset_oob_vmo uint64; // In pages. | 
 |     data_vmo bool; // True to read or write data. | 
 |     oob_vmo bool; // True to read or write OOB data. | 
 | }; | 
 |  | 
 | @for_deprecated_c_bindings | 
 | type BrokerRequestDataBytes = resource struct { | 
 |     vmo zx.handle:<VMO>; // Only used for read and write. | 
 |     length uint64; // In bytes. | 
 |     offset_nand uint64; // In bytes. | 
 |     offset_data_vmo uint64; // In bytes. | 
 | }; | 
 |  | 
 | /// The Broker allows for serialized entry to the raw nand, which ensures only a single client is | 
 | /// ever talking to the nand device, and all higher level clients have disconnected. In addition, | 
 | /// access to raw nand is restricted from the system during production where nand-broker is not | 
 | /// present. | 
 | @for_deprecated_c_bindings | 
 | protocol Broker { | 
 |     // Retrieves the nand info from the underlying device. | 
 |     GetInfo() -> (struct { | 
 |         status zx.status; | 
 |         info box<fuchsia.hardware.nand.Info>; | 
 |     }); | 
 |  | 
 |     // Reads from the nand device. | 
 |     Read(resource struct { | 
 |         request BrokerRequestData; | 
 |     }) -> (struct { | 
 |         status zx.status; | 
 |         corrected_bit_flips uint32; | 
 |     }); | 
 |  | 
 |     // Writes to the nand device. | 
 |     Write(resource struct { | 
 |         request BrokerRequestData; | 
 |     }) -> (struct { | 
 |         status zx.status; | 
 |     }); | 
 |  | 
 |     // Reads from the nand device. | 
 |     ReadBytes(resource struct { | 
 |         request BrokerRequestDataBytes; | 
 |     }) -> (struct { | 
 |         status zx.status; | 
 |     }); | 
 |  | 
 |     // Writes to the nand device. | 
 |     WriteBytes(resource struct { | 
 |         request BrokerRequestDataBytes; | 
 |     }) -> (struct { | 
 |         status zx.status; | 
 |     }); | 
 |  | 
 |     // Erases part of the nand device. | 
 |     Erase(resource struct { | 
 |         request BrokerRequestData; | 
 |     }) -> (struct { | 
 |         status zx.status; | 
 |     }); | 
 | }; |