1Copyright 2018 IBM 2 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9Unless required by applicable law or agreed to in writing, software 10distributed under the License is distributed on an "AS IS" BASIS, 11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12See the License for the specific language governing permissions and 13limitations under the License. 14 15# Introduction 16 17This document defines a protocol and several transports for flash access 18mediation between the host and the Baseboard Management Controller (BMC). 19 20The driving motivation for the protocol is to expose flash devices owned by the 21BMC to the host. Usually, the flash device of interest is the host's firmware 22flash device - in some platform designs this is owned by the BMC to enable 23lights-out updates of the host firmware. 24 25As the flash is owned by the BMC, access by the host to its firmware must be 26abstracted and mediated. Abstraction and mediation alleviates several problems: 27 281. Proliferation of flash controller driver implementations throughout firmware 292. Conflict of access between the host and the BMC to the flash controller 303. In some circumstances, mitigates security concerns. 31 32The protocol introduced in this document addresses each of these issues. 33Specifically, the document addresses defining a control mechanism for exposing 34flash data in the LPC firmware space, communicated via functions in the LPC IO 35space. 36 37# Scope 38 39The scope of the document is limited to defining the protocol and its 40transports, and does not cover the content or structure of the data read or 41written to the flash by the host firmware. 42 43The definition of transport-specific parameters, for example selection of IPMI 44`(NetFn, Command)` pairs, is also beyond the scope of the document. 45 46# Background, Design and Constraints 47 48The protocol was developed to meet requirements on OpenPOWER systems based 49around the ASPEED BMC System-on-Chips such as the AST2400 and AST2500. 50The ASPEED BMCs have properties and features that need to be taken into account: 51 521. A read-only mapping of the SPI flash devices onto the ARM core's AHB 532. Remapping of LPC Firmware cycles onto the AHB (LPC2AHB bridge) 543. A reasonable but not significant amount of attached DRAM 55 56Prior to the development of the protocol described below flash reads were 57serviced by pointing the LPC2AHB bridge at the read-only flash mapping, and 58writes were serviced by a separate bridge that suffers significant performance 59and security issues. 60 61Point 3 serves to justify some of the design decisions embodied in the 62protocol, mainly the complexity required by the flexibility to absorb as much 63or as little reserved memory as desired via the concept of BMC-controlled 64windowing. 65 66The core concept of the protocol moves access away from the naive routing of 67LPC firmware cycles onto the host firmware SPI flash AHB mapping, and 68concentrates on servicing the LPC firmware cycles from reserved system memory. 69As the memory backing the LPC2AHB mapping is now writable the protocol meets 70the host's write requirements by defining commands to open, dirty and flush an 71in-memory window representing the state of the flash. The mechanism to read the 72flash becomes same as write, just that the dirty and flush commands are not 73legal on such windows. 74 75## Historic and Future Naming 76 77The original transport for the protocol was the ASPEED BMC LPC mailbox 78interface, and previous revisions of the protocol documentation referred to the 79protocol as the "mailbox" or "mbox" protocol. This naming is now deprecated, as 80the protocol has grown further transports and naming the protocol by its 81transport rather than its intent was, on reflection, misguided. 82 83The protocol has been tentatively renamed to the "Host I/O Mapping Protocol" or 84"hiomap". This is a reflection of its true purpose - to control the host's view 85of data exposed from the BMC. 86 87# Protocol Overview 88 89The primary flow of the protocol is for the host to send requests to the BMC, 90which adjusts the mapping of the LPC firmware space as requested and returns a 91status response to the host. These interactions are labelled "commands". 92However, as there is now an active software component on the BMC consuming 93access requests, the BMC must occasionally indicate state changes to the host. 94Such interactions are labelled "events". For example, if a user or other system 95software on the BMC suspends the host's access to its flash device, the 96BMC-side daemon implementing the protocol must notify the host that its 97requests will be denied until further notice. 98 99## Protocol Versioning 100 101To enable evolution of the command and event interfaces, incremental changes to 102the behaviour are defined in new versions of the protocol. The descriptions 103and tables that follow all identify the versions to which they are applicable. 104 105The highest currently specified protocol version is version 3. 106 107## Table of Commands 108 109| ID | Name | v1 | v2 | v3 | Description | 110|----|------|----|----|----|-------------| 111| 1 | [`RESET`](#reset-command) | ✓ | ✓ | ✓ | Reset the state of the LPC firmware space, closing any active window | 112| 2 | [`GET_INFO`](#get_info-command) | ✓ | ✓ | ✓ | Perform protocol version negotiation and retrieve fundamental parameters | 113| 3 | [`GET_FLASH_INFO`](#get_flash_info-command) | ✓ | ✓ | ✓ | Retrieve flash-specific parameters | 114| 4 | [`CREATE_READ_WINDOW`](#create_read_window-command) | ✓ | ✓ | ✓ | Request mapping of a flash region for read | 115| 5 | [`CLOSE`](#close-command) | ✓ | ✓ | ✓ | Close the current window, flushing any dirty regions | 116| 6 | [`CREATE_WRITE_WINDOW`](#create_write_window-command) | ✓ | ✓ | ✓ | Request mapping of a flash region for write | 117| 7 | [`MARK_DIRTY`](#mark_dirty-command) | ✓ | ✓ | ✓ | Mark a region of a write window as modified | 118| 8 | [`FLUSH`](#flush-command) | ✓ | ✓ | ✓ | Flush dirty regions of the write window to flash | 119| 9 | [`ACK`](#ack-command) | ✓ | ✓ | ✓ | Acknowledge the receipt of an event from the BMC | 120| 10 | [`ERASE`](#erase-command) | | ✓ | ✓ | Mark a region of a write window as erased | 121| 11 | [`GET_FLASH_NAME`](#get_flash_name-command) | | | ✓ | Retrieve the name of an indexed flash device | 122| 12 | [`LOCK`](#lock-command) | | | ✓ | Mark a region of the current flash window as immutable | 123 124## Table of Events 125 126| ID | Name | v1 | v2 | v3 | Description | 127|----|------|----|----|----|-------------| 128| 0 | [`PROTOCOL_RESET`](#protocol_reset-event) | ✓ | ✓ | ✓ | The host is required to perform version negotiation and re-establish its window of interest | 129| 1 | [`WINDOW_RESET`](#window_reset-event) | | ✓ | ✓ | The host must re-establish its window of interest | 130| 6 | [`FLASH_CONTROL_LOST`](#flash_control_lost-event) | | ✓ | ✓ | The host should suspend access requests | 131| 7 | [`DAEMON_READY`](#daemon_ready-event) | | ✓ | ✓ | The daemon is active and can accept commands | 132 133## List of Transports 134 135An essential feature of the protocol is that its behaviour is independent of 136the host-BMC transport. The command and event interfaces of each transport 137necessarily reflect the version of the protocol they are implementing, but the 138transport has no influence otherwise. 139 140There are three documented transports for the protocol: 141 1421. The [ASPEED BMC LPC Mailbox transport](#mailbox-transport) 1432. The [IPMI transport](#ipmi-transport) 1443. The [DBus transport](#dbus-transport) 145 146The command layout, routing and event mechanism for each transport all have 147different features and are detailed below. An important note is that command 148design is limited by the most constrained transport - the LPC mailbox 149transport - where only 11 bytes are available for encoding of command 150parameters. 151 152Implementations must choose to support one or more of the transports outlined 153in this document. 154 155Note that the DBus transport is intended for BMC-internal communications, and 156can be used to separate a host-interface transport from the protocol 157implementation. 158 159## Protocol Flow 160 161The high-level protocol flow is that the host first issues a `GET_INFO` command 162to negotiate the protocol version and acquire parameters fundamental to 163constructing arguments to and interpreting responses from the commands that 164follow. 165 166Once `GET_INFO` has successfully completed, the host should request the flash 167parameters with `GET_FLASH_INFO`. The response provides information on the 168flash capacity and the size of its erase granule. 169 170Following `GET_FLASH_INFO`, the next act is to establish an active flash window 171with either one of the `CREATE_READ_WINDOW` or `CREATE_WRITE_WINDOW` commands. 172 173In the event of creating a write window the host must inform the BMC of the 174regions to which it has written with `MARK_DIRTY`- the BMC receives no 175notification of accesses from the host, they are simply mapped by the LPC2AHB 176bridge as necessary. As the accesses are to system memory and not the flash 177the changes identified by the `MARK_DIRTY` commands are not permanent until a 178`FLUSH` command is received (implicit flushes are discussed below), at which 179point the dirty regions of the active window will be written to the flash 180device. 181 182As an optimisation the host may choose to use the `ERASE` command to indicate 183that large regions should be set to the erased state. This optimisation saves 184the associated LPC firmware cycles to write the regions into the erased state. 185 186## Version Negotiation 187 188When invoking `GET_INFO` the host must provide the BMC its highest 189supported version of the protocol. The BMC must respond with a protocol version 190less than or equal to that requested by the host, or in the event that there is 191no such value, an error code. In the event that an error is returned the host 192must not continue to communicate with the BMC. Otherwise, the protocol version 193returned by the BMC is the agreed protocol version for all further 194communication. The host may at a future point request a change in protocol 195version by issuing a subsequent `GET_INFO` command. 196 197### Unversioned Commands 198 199In some circumstances it is necessary for bootstrap or optimisation purposes to 200support unversioned commands. The protocol supports three unversioned commands: 201 2021. `RESET` 2032. `GET_INFO` 2043. `ACK` 205 206All remaining commands have their presence and behaviour specified with respect 207to the negotiated version of the protocol. 208 209The arguments to the `GET_INFO` command are considered unversioned and as a 210result are static in nature - the protocol implementation has no means to 211decode version-specific arguments as the version has not yet been 212negotiated. With respect to the response, the version field is unversioned, but 213all subsequent fields _may_ be versioned. 214 215`RESET` remaining unversioned is an optimisation catering to deeply embedded 216components on the host side that may need access to the command. Keeping 217`RESET` unversioned removes the complexity of implementing `GET_INFO` with its 218version negotiation and minimises the overhead required to get into the 219pre-boot state. 220 221Defining `ACK` as unversioned ensures host firmware that has minimal protocol 222support can silence interrupts from the BMC as required. 223 224## Sequence Numbers 225 226Sequence numbers are included in messages for correlation of commands and 227responses. v1, v2 and v3 of the protocol permit either zero or one commands to 228be in progress (yet to receive a response). 229 230For generality, the host must generate a sequence number that is unique with 231respect to the previous command (one that has received a response) and any 232in-progress commands. Sequence numbers meeting this requirement are considered 233valid. The BMC's response to a command must contain the same sequence number 234issued by the host as found in the relevant command. 235 236Sequence numbers may be reused in accordance with the constraints outlined 237above. However, it is not an error if the BMC receives a unversioned command 238(`RESET`, `GET_INFO` or `ACK`) with an invalid sequence number. For all other 239cases, the BMC must respond with an error if the constraints are violated. If 240the host receives a sequence-related error response it must consider any 241in-progress commands to have failed. The host may retry the affected command(s) 242after generating a suitable sequence number. 243 244## Window Management 245 246There is only ever one active window which is the window created by the most 247recent `CREATE_READ_WINDOW` or `CREATE_WRITE_WINDOW` call which succeeded. Even 248though there are two types of windows there can still only be one active window 249irrespective of type. The host must not write to a read window. The host may 250read from a write window and the BMC must guarantee that the window reflects 251what the host has written there. 252 253A window can be closed by issuing the `CLOSE` command, in which case there is 254no active window and the host must not access the LPC firmware space until a 255window is subsequently opened. If the host closes an active write window then 256the BMC must perform an implicit flush. If the host tries to open a new window 257with an already active window then the active window is closed (and implicitly 258flushed if it was a write window). If the new window is successfully opened 259then it is the new active window; if the command fails then there is no active 260window and the previously active window must no longer be accessed. 261 262The host must not access an LPC address other than that which is contained by 263the active window. The host must not use write management functions (see below) 264if the active window is a read window or if there is no active window. 265 266## Command Parameter Types 267 268It is common in the protocol definition for command parameters to be 269represented in terms of a block size. This block size may refer to e.g. the 270size of the erase granule of the flash, or it may be another value entirely. 271Regardless of what it represents, the argument values are scaled by the block 272size determined by version negotiation. Specifying arguments in terms of a 273block size allows transports to keep a compact representation in constrained 274implementations such as the LPC mailbox transport. 275 276Note that for simplicity block size must always be a power-of-2. The block size 277must also be greater than or equal to 4K regardless of the negotiated protocol 278version. 279 280Finally, conversion between blocks and bytes is achieved by respectively 281dividing or multiplying the quantity by the negotiated block-size. 282 283# Transport Overview 284 285Several transports are defined for the protocol and are outlined below. The key 286features of transport support are the wire-format, delivery mechanisms of 287commands and events, and the definition and delivery of response codes. 288 289The DBus transport is the most foreign of the three as it does not encode the 290command index or a sequence number; these two elements are handled by the 291properties of DBus itself. 292 293## Mailbox Transport 294 295* Multi-byte quantity endianness: Little-endian 296* Command length encoding: Assumed from negotiated protocol version 297* Parameter alignment: Packed (no padding) 298* Command status response: ABI-defined Response byte 299* Event Delivery: ABI-defined BMC Status byte 300 301The mailbox transport defines the ABI used over the mailbox registers. There 302are 16 data registers and several status and control registers for managing 303interrupts between the host and the BMC. For the purpose of defining the 304transport ABI the status and control registers can mostly be disregarded, save 305for the necessity of issuing and responding to interrupts on each side. 306 307Assuming the registers are in a contiguous layout (this is not reflected in the 308hardware, but may be the abstraction presented by the associated kernel 309driver), the ABI is defined as follows, where the bytes in the range [2, 12] 310are available for command parameters and are defined on a per-command basis. 311 312``` 313 0 7 15 31 314 +----------+----------+---------------------+ 315 0 | Command | Sequence | | 316 +----------+----------+---------------------+ 317 4 | | 318 +-------------------------------------------+ 319 8 | | 320 +----------+----------+----------+----------+ 32112 | | Response | BMC Sts | Host Sts | 322 +----------+----------+----------+----------+ 323 0 7 15 23 31 324``` 325 326Command status response codes are as follows: 327 328### Status Codes 329 330| ID | Name | v1 | v2 | v3 | Description | 331|----|----------------|----|----|----|------------------------------------------------------| 332| 1 | `SUCCESS` | ✓ | ✓ | ✓ | Command completed successfully | 333| 2 | `PARAM_ERROR` | ✓ | ✓ | ✓ | Error with parameters supplied or command invalid | 334| 3 | `WRITE_ERROR` | ✓ | ✓ | ✓ | Error writing to the backing file system | 335| 4 | `SYSTEM_ERROR` | ✓ | ✓ | ✓ | Error in BMC performing system action | 336| 5 | `TIMEOUT` | ✓ | ✓ | ✓ | Timeout in performing action | 337| 6 | `BUSY` | | ✓ | ✓ | Flash access suspended, retry later | 338| 7 | `WINDOW_ERROR` | | ✓ | ✓ | Invalid window state or command invalid for window | 339| 8 | `SEQ_ERROR` | | ✓ | ✓ | Invalid sequence number supplied with command | 340| 9 | `LOCKED_ERROR` | | | ✓ | Erased or dirtied region intersected a locked region | 341 342## IPMI Transport 343 344* Multi-byte quantity endianness: Little-endian 345* Command length encoding: Assumed from negotiated protocol version 346* Parameter alignment: Packed (no padding) 347* Command status response: Mapped to IPMI completion codes 348* Event Delivery: Status byte in SEL via `SMS_ATN` 349 350The IPMI transport must reserve one `(NetFn, Command)` pair for host-to-BMC 351communications and one SEL `(NetFn, Command)` pair for BMC-to-host 352communication, signaled by `SMS_ATN`. 353 354The wire command framing is as follows: 355 3561. The command identifier is the first value and is encoded in one byte 3572. The sequence number is the second value and is encoded in one byte 3583. Parameters required by the (version, command) pair follow 359 360``` 361 0 7 15 N 362 +----------+----------+--------- -------+ 363 0 | Command | Sequence | ... | 364 +----------+----------+--------- -------+ 365``` 366 367## DBus Transport 368 369* Multi-byte quantity endianness: Transport encoded 370* Command length encoding: Transport encoded 371* Parameter alignment: Transport encoded 372* Command status response: Mapped to Unix system error codes 373* Event Delivery: DBus signals and properties per event type 374 375DBus defines its own wire-format for messages, and so support for this 376transport concentrates on mapping commands and events onto DBus concepts. 377Specifically, commands are represented by DBus methods and events are 378represented by properties. DBus will automatically generate a 379`PropertiesChanged` signal for changes to properties allowing consumers to 380learn of updates as they happen. 381 382As the commands are represented by DBus methods there is no need to encode the 383command index in the request - this is represented by the appropriate method on 384the implementation object's interface. 385 386Similarly, there's no need to encode sequence numbers as DBus handles the 387correlation of messages over the bus. As there is no encoding of sequence 388numbers, there is no need to describe a command status response like 389`SEQ_ERROR`, which allows a clean mapping to Unix error codes. 390 391Finally, commands mapped to methods have the number of parameters and types 392described by the method's type signature, though these descriptions concern the 393basic wire types and not the semantic types relevant to the protocol. The method 394type signature and parameter ordering are described in the relevant command 395definition. 396 397# Command Definitions 398 399The command identifier values and command-response parameter formats are 400described in tables under headers for each command. The order of the parameters 401in the parameter tables reflects the order of the parameters in the commands 402and responses. The M, I, and D columns represent the Mailbox, IPMI and DBus 403transports respectively. For the command identifier table the value in these 404columns' cells represent the command index, or for DBus, its method name. For 405the parameter tables the value represent the parameter's offset in the message 406(disregarding the command and sequence bytes), or in the case of DBus the 407appropriate [type 408signature](https://dbus.freedesktop.org/doc/dbus-specification.html#basic-types). 409 410## `RESET` Command 411 412| v1 | v2 | v3 | M | I | D | 413|----|----|----|---|---|-------| 414| ✓ | ✓ | ✓ | 1 | 1 | Reset | 415 416### v1 Parameters 417 418<table> 419<tr> 420<th>Command</th><th>Response</th> 421</tr> 422<tr> 423<td valign="top"> 424 425| Parameter | Unit | Size | M | I | D | 426|-------------------|---------|------|---|---|---| 427 428</td> 429<td valign="top"> 430 431| Parameter | Unit | Size | M | I | D | 432|-------------------|---------|------|---|---|---| 433 434</td> 435</tr> 436</table> 437 438 439### v2 Parameters 440 441<table> 442<tr> 443<th>Command</th><th>Response</th> 444</tr> 445<tr> 446<td valign="top"> 447 448| Parameter | Unit | Size | M | I | D | 449|-------------------|---------|------|---|---|---| 450 451</td> 452<td valign="top"> 453 454| Parameter | Unit | Size | M | I | D | 455|-------------------|---------|------|---|---|---| 456 457</td> 458</tr> 459</table> 460 461### v3 Parameters 462 463<table> 464<tr> 465<th>Command</th><th>Response</th> 466</tr> 467<tr> 468<td valign="top"> 469 470| Parameter | Unit | Size | M | I | D | 471|-------------------|---------|------|---|---|---| 472 473</td> 474<td valign="top"> 475 476| Parameter | Unit | Size | M | I | D | 477|-------------------|---------|------|---|---|---| 478 479</td> 480</tr> 481</table> 482 483### Description 484 485Requests the BMC return the LPC firmware space to a state ready for host 486firmware bootstrap. 487 488## `GET_INFO` Command 489 490| v1 | v2 | v3 | M | I | D | 491|----|----|----|---|---|---------| 492| ✓ | ✓ | ✓ | 2 | 2 | GetInfo | 493 494### v1 Parameters 495 496<table> 497<tr> 498<th>Command</th><th>Response</th> 499</tr> 500<tr> 501<td valign="top"> 502 503| Parameter | Unit | Size | M | I | D | 504|-------------------|---------|------|---|---|---| 505| Version | Version | 1 | 0 | 0 | y | 506 507</td> 508<td valign="top"> 509 510| Parameter | Unit | Size | M | I | D | 511|-------------------|---------|------|---|---|---| 512| Version | Version | 1 | 0 | 0 | y | 513| Read Window Size | Blocks | 2 | 1 | 1 | q | 514| Write Window Size | Blocks | 2 | 3 | 3 | q | 515 516</td> 517</tr> 518</table> 519 520 521### v2 Parameters 522 523<table> 524<tr> 525<th>Command</th><th>Response</th> 526</tr> 527<tr> 528<td valign="top"> 529 530| Parameter | Unit | Size | M | I | D | 531|-------------------|---------|------|---|---|---| 532| Version | Version | 1 | 0 | 0 | y | 533 534</td> 535<td valign="top"> 536 537| Parameter | Unit | Size | M | I | D | 538|-------------------|---------|------|---|---|---| 539| Version | Version | 1 | 0 | 0 | y | 540| Block Size Shift | Count | 1 | 5 | 1 | y | 541| Timeout | Seconds | 2 | 6 | 2 | q | 542 543</td> 544</tr> 545</table> 546 547### v3 Parameters 548 549<table> 550<tr> 551<th>Command</th><th>Response</th> 552</tr> 553<tr> 554<td valign="top"> 555 556| Parameter | Unit | Size | M | I | D | 557|-------------------|---------|------|---|---|---| 558| Version | Version | 1 | 0 | 0 | y | 559| Block Size Shift | Count | 1 | 1 | 1 | y | 560 561</td> 562<td valign="top"> 563 564| Parameter | Unit | Size | M | I | D | 565|-------------------|---------|------|---|---|---| 566| Version | Version | 1 | 0 | 0 | y | 567| Block Size Shift | Count | 1 | 5 | 1 | y | 568| Timeout | Seconds | 2 | 6 | 2 | q | 569| Devices | Count | 1 | 8 | 4 | y | 570 571</td> 572</tr> 573</table> 574 575### Description 576 577The suggested timeout is a hint to the host as to how long it should wait after 578issuing a command to the BMC before it times out waiting for a response. This 579is the maximum time which the BMC thinks it could take to service any command 580which the host could issue. This may be set to zero to indicate that the BMC 581does not wish to provide a hint in which case the host must choose some 582reasonable value. 583 584From v3 the host may desire a specific block size and thus can request this by 585giving a hint to the daemon (may be zero). The daemon may use this to select 586the block size which it will use however is free to ignore it. The value in the 587response is the block size which must be used for all further requests until a 588new size is negotiated by another call to `GET_INFO`. 589 590## `GET_FLASH_INFO` Command 591 592| v1 | v2 | v3 | M | I | D | 593|----|----|----|---|---|--------------| 594| ✓ | ✓ | ✓ | 3 | 3 | GetFlashInfo | 595 596### v1 Parameters 597 598<table> 599<tr> 600<th>Command</th><th>Response</th> 601</tr> 602<tr> 603<td valign="top"> 604 605| Parameter | Unit | Size | M | I | D | 606|-------------------|---------|------|---|---|---| 607 608</td> 609<td valign="top"> 610 611| Parameter | Unit | Size | M | I | D | 612|-------------------|---------|------|---|---|---| 613| Flash Size | Bytes | 4 | 0 | 0 | u | 614| Erase Granule | Bytes | 4 | 4 | 4 | u | 615 616</td> 617</tr> 618</table> 619 620 621### v2 Parameters 622 623<table> 624<tr> 625<th>Command</th><th>Response</th> 626</tr> 627<tr> 628<td valign="top"> 629 630| Parameter | Unit | Size | M | I | D | 631|-------------------|---------|------|---|---|---| 632 633</td> 634<td valign="top"> 635 636| Parameter | Unit | Size | M | I | D | 637|-------------------|---------|------|---|---|---| 638| Flash Size | Blocks | 2 | 0 | 0 | q | 639| Erase Granule | Blocks | 2 | 2 | 2 | q | 640 641</td> 642</tr> 643</table> 644 645### v3 Parameters 646 647<table> 648<tr> 649<th>Command</th><th>Response</th> 650</tr> 651<tr> 652<td valign="top"> 653 654| Parameter | Unit | Size | M | I | D | 655|-------------------|---------|------|---|---|---| 656| Device ID | Index | 1 | 0 | 0 | y | 657 658</td> 659<td valign="top"> 660 661| Parameter | Unit | Size | M | I | D | 662|-------------------|---------|------|---|---|---| 663| Flash Size | Blocks | 2 | 0 | 0 | q | 664| Erase Granule | Blocks | 2 | 2 | 2 | q | 665 666</td> 667</tr> 668</table> 669 670## `CREATE_READ_WINDOW` Command 671 672| v1 | v2 | v3 | M | I | D | 673|----|----|----|---|---|------------------| 674| ✓ | ✓ | ✓ | 4 | 4 | CreateReadWindow | 675 676### v1 Parameters 677 678<table> 679<tr> 680<th>Command</th><th>Response</th> 681</tr> 682<tr> 683<td valign="top"> 684 685| Parameter | Unit | Size | M | I | D | 686|-------------------|---------|------|---|---|---| 687| Flash Offset | Blocks | 2 | 0 | 0 | q | 688 689</td> 690<td valign="top"> 691 692| Parameter | Unit | Size | M | I | D | 693|-------------------|---------|------|---|---|---| 694| LPC FW Offset | Blocks | 2 | 0 | 0 | q | 695 696</td> 697</tr> 698</table> 699 700 701### v2 Parameters 702 703<table> 704<tr> 705<th>Command</th><th>Response</th> 706</tr> 707<tr> 708<td valign="top"> 709 710| Parameter | Unit | Size | M | I | D | 711|-------------------|---------|------|---|---|---| 712| Flash Address | Blocks | 2 | 0 | 0 | q | 713| Length | Blocks | 2 | 2 | 2 | q | 714 715</td> 716<td valign="top"> 717 718| Parameter | Unit | Size | M | I | D | 719|-------------------|---------|------|---|---|---| 720| LPC FW Address | Blocks | 2 | 0 | 0 | q | 721| Length | Blocks | 2 | 2 | 2 | q | 722| Flash Address | blocks | 2 | 4 | 4 | q | 723 724</td> 725</tr> 726</table> 727 728### v3 Parameters 729 730<table> 731<tr> 732<th>Command</th><th>Response</th> 733</tr> 734<tr> 735<td valign="top"> 736 737| Parameter | Unit | Size | M | I | D | 738|-------------------|---------|------|---|---|---| 739| Flash Address | Blocks | 2 | 0 | 0 | q | 740| Length | Blocks | 2 | 2 | 2 | q | 741| Device ID | Index | 1 | 4 | 4 | y | 742 743</td> 744<td valign="top"> 745 746| Parameter | Unit | Size | M | I | D | 747|-------------------|---------|------|---|---|---| 748| LPC FW Address | Blocks | 2 | 0 | 0 | q | 749| Length | Blocks | 2 | 2 | 2 | q | 750| Flash Address | blocks | 2 | 4 | 4 | q | 751 752</td> 753</tr> 754</table> 755 756### Description 757 758The flash offset which the host requests access to is always taken from the 759start of flash - that is it is an absolute offset into flash. 760 761LPC bus address is always given from the start of the LPC address space - that 762is it is an absolute address. 763 764The requested access size is only a hint. The response indicates the actual 765size of the window. The BMC may want to use the requested size to pre-load the 766remainder of the request. The host must not access past the end of the active 767window. 768 769The flash offset mapped by the window is an absolute flash offset and must be 770less than or equal to the flash offset requested by the host. It is the 771responsibility of the host to use this information to access any offset which 772is required. 773 774The requested window size may be zero. In this case the BMC is free to create 775any sized window but it must contain at least the first block of data requested 776by the host. A large window is of course preferred and should correspond to the 777default size returned in the `GET_INFO` command. 778 779If this command returns successfully then the created window is the active 780window. If it fails then there is no active window. 781 782## `CLOSE` Command 783 784| v1 | v2 | v3 | M | I | D | 785|----|----|----|---|---|-------| 786| ✓ | ✓ | ✓ | 5 | 5 | Close | 787 788### v1 Parameters 789 790<table> 791<tr> 792<th>Command</th><th>Response</th> 793</tr> 794<tr> 795<td valign="top"> 796 797| Parameter | Unit | Size | M | I | D | 798|-------------------|---------|------|---|---|---| 799 800</td> 801<td valign="top"> 802 803| Parameter | Unit | Size | M | I | D | 804|-------------------|---------|------|---|---|---| 805 806</td> 807</tr> 808</table> 809 810 811### v2 Parameters 812 813<table> 814<tr> 815<th>Command</th><th>Response</th> 816</tr> 817<tr> 818<td valign="top"> 819 820| Parameter | Unit | Size | M | I | D | 821|-------------------|---------|------|---|---|---| 822| Flags | Field | 1 | 0 | 0 | y | 823 824</td> 825<td valign="top"> 826 827| Parameter | Unit | Size | M | I | D | 828|-------------------|---------|------|---|---|---| 829 830</td> 831</tr> 832</table> 833 834### v3 Parameters 835 836<table> 837<tr> 838<th>Command</th><th>Response</th> 839</tr> 840<tr> 841<td valign="top"> 842 843| Parameter | Unit | Size | M | I | D | 844|-------------------|---------|------|---|---|---| 845| Flags | Field | 1 | 0 | 0 | y | 846 847</td> 848<td valign="top"> 849 850| Parameter | Unit | Size | M | I | D | 851|-------------------|---------|------|---|---|---| 852 853</td> 854</tr> 855</table> 856 857### Description 858 859Closes the active window. Any further access to the LPC bus address specified 860to address the previously active window will have undefined effects. If the 861active window is a write window then the BMC must perform an implicit flush. 862 863The Flags argument allows the host to provide some hints to the BMC. Defined 864values are: 865 866``` 8670x01 - Short Lifetime: 868 The window is unlikely to be accessed anytime again in the near future. 869 The effect of this will depend on BMC implementation. In the event that 870 the BMC performs some caching the BMC daemon could mark data contained 871 in a window closed with this flag as first to be evicted from the cache. 872``` 873 874## `CREATE_WRITE_WINDOW` Command 875 876| v1 | v2 | v3 | M | I | D | 877|----|----|----|---|---|-------------------| 878| ✓ | ✓ | ✓ | 6 | 6 | CreateWriteWindow | 879 880### v1 Parameters 881 882<table> 883<tr> 884<th>Command</th><th>Response</th> 885</tr> 886<tr> 887<td valign="top"> 888 889| Parameter | Unit | Size | M | I | D | 890|-------------------|---------|------|---|---|---| 891| Flash Offset | Blocks | 2 | 0 | 0 | q | 892 893</td> 894<td valign="top"> 895 896| Parameter | Unit | Size | M | I | D | 897|-------------------|---------|------|---|---|---| 898| LPC FW Offset | Blocks | 2 | 0 | 0 | q | 899 900</td> 901</tr> 902</table> 903 904 905### v2 Parameters 906 907<table> 908<tr> 909<th>Command</th><th>Response</th> 910</tr> 911<tr> 912<td valign="top"> 913 914| Parameter | Unit | Size | M | I | D | 915|-------------------|---------|------|---|---|---| 916| Flash Address | Blocks | 2 | 0 | 0 | q | 917| Length | Blocks | 2 | 2 | 2 | q | 918 919</td> 920<td valign="top"> 921 922| Parameter | Unit | Size | M | I | D | 923|-------------------|---------|------|---|---|---| 924| LPC FW Address | Blocks | 2 | 0 | 0 | q | 925| Length | Blocks | 2 | 2 | 2 | q | 926| Flash Address | blocks | 2 | 4 | 4 | q | 927 928</td> 929</tr> 930</table> 931 932### v3 Parameters 933 934<table> 935<tr> 936<th>Command</th><th>Response</th> 937</tr> 938<tr> 939<td valign="top"> 940 941| Parameter | Unit | Size | M | I | D | 942|-------------------|---------|------|---|---|---| 943| Flash Address | Blocks | 2 | 0 | 0 | q | 944| Length | Blocks | 2 | 2 | 2 | q | 945| Device ID | Index | 1 | 4 | 4 | y | 946 947</td> 948<td valign="top"> 949 950| Parameter | Unit | Size | M | I | D | 951|-------------------|---------|------|---|---|---| 952| LPC FW Address | Blocks | 2 | 0 | 0 | q | 953| Length | Blocks | 2 | 2 | 2 | q | 954| Flash Address | blocks | 2 | 4 | 4 | q | 955 956</td> 957</tr> 958</table> 959 960### Description 961 962The flash offset which the host requests access to is always taken from the 963start of flash - that is it is an absolute offset into flash. 964 965LPC bus address is always given from the start of the LPC address space - that 966is it is an absolute address. 967 968The requested access size is only a hint. The response indicates the actual 969size of the window. The BMC may want to use the requested size to pre-load the 970remainder of the request. The host must not access past the end of the active 971window. 972 973The flash offset mapped by the window is an absolute flash offset and must be 974less than or equal to the flash offset requested by the host. It is the 975responsibility of the host to use this information to access any offset which 976is required. 977 978The requested window size may be zero. In this case the BMC is free to create 979any sized window but it must contain at least the first block of data requested 980by the host. A large window is of course preferred and should correspond to the 981default size returned in the `GET_INFO` command. 982 983If this command returns successfully then the created window is the active 984window. If it fails then there is no active window. 985 986## `MARK_DIRTY` Command 987 988| v1 | v2 | v3 | M | I | D | 989|----|----|----|---|---|-----------| 990| ✓ | ✓ | ✓ | 7 | 7 | MarkDirty | 991 992### v1 Parameters 993 994<table> 995<tr> 996<th>Command</th><th>Response</th> 997</tr> 998<tr> 999<td valign="top"> 1000 1001| Parameter | Unit | Size | M | I | D | 1002|-------------------|---------|------|---|---|---| 1003| Flash Offset | Blocks | 2 | 0 | 0 | q | 1004| Length | Bytes | 4 | 2 | 2 | u | 1005 1006</td> 1007<td valign="top"> 1008 1009| Parameter | Unit | Size | M | I | D | 1010|-------------------|---------|------|---|---|---| 1011 1012</td> 1013</tr> 1014</table> 1015 1016 1017### v2 Parameters 1018 1019<table> 1020<tr> 1021<th>Command</th><th>Response</th> 1022</tr> 1023<tr> 1024<td valign="top"> 1025 1026| Parameter | Unit | Size | M | I | D | 1027|-------------------|---------|------|---|---|---| 1028| Window Offset | Blocks | 2 | 0 | 0 | q | 1029| Length | Blocks | 2 | 2 | 2 | q | 1030 1031</td> 1032<td valign="top"> 1033 1034| Parameter | Unit | Size | M | I | D | 1035|-------------------|---------|------|---|---|---| 1036 1037</td> 1038</tr> 1039</table> 1040 1041### v3 Parameters 1042 1043<table> 1044<tr> 1045<th>Command</th><th>Response</th> 1046</tr> 1047<tr> 1048<td valign="top"> 1049 1050| Parameter | Unit | Size | M | I | D | 1051|-------------------|---------|------|---|---|---| 1052| Window Offset | Blocks | 2 | 0 | 0 | q | 1053| Length | Blocks | 2 | 2 | 2 | q | 1054| Flags | Field | 1 | 4 | 4 | y | 1055 1056</td> 1057<td valign="top"> 1058 1059| Parameter | Unit | Size | M | I | D | 1060|-------------------|---------|------|---|---|---| 1061 1062</td> 1063</tr> 1064</table> 1065 1066### Description 1067 1068 1069The BMC has no method for intercepting writes that 1070occur over the LPC bus. The host must explicitly notify 1071the daemon of where and when a write has occurred so it 1072can be flushed to backing storage. 1073 1074Offsets are given as an absolute (either into flash (V1) or the 1075active window (V2)) and a zero offset refers to the first 1076block. If the offset + number exceeds the size of the active 1077window then the command must not succeed. 1078 1079The host can give a hint to the daemon that is doesn't have to erase a flash 1080area before writing to it by setting bit zero of the Flags parameter. This 1081means that the daemon will blindly perform a write to that area and will not 1082try to erase it before hand. This can be used if the host knows that a large 1083area has already been erased for example but then wants to perform many small 1084writes. 1085 1086## `FLUSH` Command 1087 1088| v1 | v2 | v3 | M | I | D | 1089|----|----|----|---|---|-------| 1090| ✓ | ✓ | ✓ | 8 | 8 | Flush | 1091 1092### v1 Parameters 1093 1094<table> 1095<tr> 1096<th>Command</th><th>Response</th> 1097</tr> 1098<tr> 1099<td valign="top"> 1100 1101| Parameter | Unit | Size | M | I | D | 1102|-------------------|---------|------|---|---|---| 1103| Flash Offset | Blocks | 2 | 0 | 0 | q | 1104| Length | Bytes | 4 | 2 | 2 | u | 1105 1106</td> 1107<td valign="top"> 1108 1109| Parameter | Unit | Size | M | I | D | 1110|-------------------|---------|------|---|---|---| 1111 1112</td> 1113</tr> 1114</table> 1115 1116 1117### v2 Parameters 1118 1119<table> 1120<tr> 1121<th>Command</th><th>Response</th> 1122</tr> 1123<tr> 1124<td valign="top"> 1125 1126| Parameter | Unit | Size | M | I | D | 1127|-------------------|---------|------|---|---|---| 1128 1129</td> 1130<td valign="top"> 1131 1132| Parameter | Unit | Size | M | I | D | 1133|-------------------|---------|------|---|---|---| 1134 1135</td> 1136</tr> 1137</table> 1138 1139### v3 Parameters 1140 1141<table> 1142<tr> 1143<th>Command</th><th>Response</th> 1144</tr> 1145<tr> 1146<td valign="top"> 1147 1148| Parameter | Unit | Size | M | I | D | 1149|-------------------|---------|------|---|---|---| 1150 1151</td> 1152<td valign="top"> 1153 1154| Parameter | Unit | Size | M | I | D | 1155|-------------------|---------|------|---|---|---| 1156 1157</td> 1158</tr> 1159</table> 1160 1161### Description 1162 1163Flushes any dirty/erased blocks in the active window to the backing storage. 1164 1165In V1 this can also be used to mark parts of the flash dirty and flush in a 1166single command. In V2 the explicit mark dirty command must be used before a 1167call to flush since there are no longer any arguments. If the offset + length 1168exceeds the size of the active window then the command must not succeed. 1169 1170## `ACK` Command 1171 1172| v1 | v2 | v3 | M | I | D | 1173|----|----|----|---|---|-----| 1174| ✓ | ✓ | ✓ | 9 | 9 | Ack | 1175 1176### v1 Parameters 1177 1178<table> 1179<tr> 1180<th>Command</th><th>Response</th> 1181</tr> 1182<tr> 1183<td valign="top"> 1184 1185| Parameter | Unit | Size | M | I | D | 1186|-------------------|---------|------|---|---|---| 1187| Ack Mask | Field | 1 | 0 | 0 | y | 1188 1189</td> 1190<td valign="top"> 1191 1192| Parameter | Unit | Size | M | I | D | 1193|-------------------|---------|------|---|---|---| 1194 1195</td> 1196</tr> 1197</table> 1198 1199 1200### v2 Parameters 1201 1202<table> 1203<tr> 1204<th>Command</th><th>Response</th> 1205</tr> 1206<tr> 1207<td valign="top"> 1208 1209| Parameter | Unit | Size | M | I | D | 1210|-------------------|---------|------|---|---|---| 1211| Ack Mask | Field | 1 | 0 | 0 | y | 1212 1213</td> 1214<td valign="top"> 1215 1216| Parameter | Unit | Size | M | I | D | 1217|-------------------|---------|------|---|---|---| 1218 1219</td> 1220</tr> 1221</table> 1222 1223### v3 Parameters 1224 1225<table> 1226<tr> 1227<th>Command</th><th>Response</th> 1228</tr> 1229<tr> 1230<td valign="top"> 1231 1232| Parameter | Unit | Size | M | I | D | 1233|-------------------|---------|------|---|---|---| 1234| Ack Mask | Field | 1 | 0 | 0 | y | 1235 1236</td> 1237<td valign="top"> 1238 1239| Parameter | Unit | Size | M | I | D | 1240|-------------------|---------|------|---|---|---| 1241 1242</td> 1243</tr> 1244</table> 1245 1246### Description 1247 1248The host should use this command to acknowledge BMC events propagated to the 1249host. 1250 1251## `ERASE` Command 1252 1253| v1 | v2 | v3 | M | I | D | 1254|----|----|----|----|----|-------| 1255| | ✓ | ✓ | 10 | 10 | Erase | 1256 1257### v2 Parameters 1258 1259<table> 1260<tr> 1261<th>Command</th><th>Response</th> 1262</tr> 1263<tr> 1264<td valign="top"> 1265 1266| Parameter | Unit | Size | M | I | D | 1267|-------------------|---------|------|---|---|---| 1268| Window Offset | Blocks | 2 | 0 | 0 | q | 1269| Length | Blocks | 2 | 2 | 2 | q | 1270 1271</td> 1272<td valign="top"> 1273 1274| Parameter | Unit | Size | M | I | D | 1275|-------------------|---------|------|---|---|---| 1276 1277</td> 1278</tr> 1279</table> 1280 1281### v3 Parameters 1282 1283<table> 1284<tr> 1285<th>Command</th><th>Response</th> 1286</tr> 1287<tr> 1288<td valign="top"> 1289 1290| Parameter | Unit | Size | M | I | D | 1291|-------------------|---------|------|---|---|---| 1292| Window Offset | Blocks | 2 | 0 | 0 | q | 1293| Length | Blocks | 2 | 2 | 2 | q | 1294 1295</td> 1296<td valign="top"> 1297 1298| Parameter | Unit | Size | M | I | D | 1299|-------------------|---------|------|---|---|---| 1300 1301</td> 1302</tr> 1303</table> 1304 1305### Description 1306 1307This command allows the host to erase a large area without the need to 1308individually write 0xFF repetitively. 1309 1310Offset is the offset within the active window to start erasing from (zero 1311refers to the first block of the active window) and number is the number of 1312blocks of the active window to erase starting at offset. If the offset + number 1313exceeds the size of the active window then the command must not succeed. 1314 1315## `GET_FLASH_NAME` Command 1316 1317| v1 | v2 | v3 | M | I | D | 1318|----|----|----|----|----|--------------| 1319| | | ✓ | 11 | 11 | GetFlashName | 1320 1321 1322### v3 Parameters 1323 1324<table> 1325<tr> 1326<th>Command</th><th>Response</th> 1327</tr> 1328<tr> 1329<td valign="top"> 1330 1331| Parameter | Unit | Size | M | I | D | 1332|-------------------|---------|------|---|---|---| 1333| Device ID | Index | 1 | 0 | 0 | y | 1334 1335</td> 1336<td valign="top"> 1337 1338| Parameter | Unit | Size | M | I | D | 1339|-------------------|---------|------|---|---|---| 1340| Name length | Bytes | 1 | 0 | 0 | - | 1341| Name | String | 10 | 1 | 1 | s | 1342 1343</td> 1344</tr> 1345</table> 1346 1347### Description 1348 1349Describes a flash with some kind of identifier useful to the host system. 1350 1351The length in the response is the number of response arguments as part of the 1352flash name field which the host should expect to have been populated. 1353 1354Note that DBus encodes the string length in its string type, so the explicit 1355length is omitted from the DBus message. 1356 1357## `LOCK` Command 1358 1359| v1 | v2 | v3 | M | I | D | 1360|----|----|----|----|----|------| 1361| | | ✓ | 12 | 12 | Lock | 1362 1363### v3 Parameters 1364 1365<table> 1366<tr> 1367<th>Command</th><th>Response</th> 1368</tr> 1369<tr> 1370<td valign="top"> 1371 1372| Parameter | Unit | Size | M | I | D | 1373|-------------------|---------|------|---|---|---| 1374| Flash Offset | Blocks | 2 | 0 | 0 | q | 1375| Length | Blocks | 2 | 2 | 2 | q | 1376| Device ID | Index | 1 | 4 | 4 | y | 1377 1378</td> 1379<td valign="top"> 1380 1381| Parameter | Unit | Size | M | I | D | 1382|-------------------|---------|------|---|---|---| 1383 1384</td> 1385</tr> 1386</table> 1387 1388### Description 1389 1390Lock an area of flash so that the host can't mark it dirty or erased. If the 1391requested area is within the current window and that area is currently marked 1392dirty or erased then this command must fail. 1393 1394# Event Definitions 1395 1396The M, I, and D columns represent the Mailbox, IPMI and DBus transports 1397respectively. The values in the M, I or D columns represent the events' bit 1398index in the status byte, or in the case of the DBus transport the name of the 1399relevant property. 1400 1401For the DBus interface, properties are used for all event types regardless of 1402whether they should be acknowledged or not as part of the protocol. This 1403ensures that state changes can be published atomically. 1404 1405## `PROTOCOL_RESET` Event 1406 1407| v1 | v2 | v3 | M | I | D | 1408|----|----|----|---|---|---------------| 1409| ✓ | ✓ | ✓ | 0 | 0 | ProtocolReset | 1410 1411### Description 1412 1413Used to inform the host that a protocol reset has occurred, likely due to 1414restarting the daemon. The host must perform protocol version negotiation again 1415and must assume it has no active window. The host must also assume that any 1416in-flight commands have failed. 1417 1418## `WINDOW_RESET` Event 1419 1420| v1 | v2 | v3 | M | I | D | 1421|----|----|----|---|---|-------------| 1422| | ✓ | ✓ | 1 | 1 | WindowReset | 1423 1424### Description 1425 1426The host must assume that its active window has been closed and that it no 1427longer has an active window. The host is not required to perform protocol 1428version negotiation again. The host must assume that any in-flight commands 1429have failed. 1430 1431## `FLASH_CONTROL_LOST` Event 1432 1433| v1 | v2 | v3 | M | I | D | 1434|----|----|----|---|---|------------------| 1435| | ✓ | ✓ | 6 | 6 | FlashControlLost | 1436 1437### Description 1438 1439The BMC daemon has been suspended and thus no longer controls access to the 1440flash (most likely because some other process on the BMC required direct access 1441to the flash and has suspended the BMC daemon to preclude concurrent access). 1442 1443The BMC daemon must clear this bit itself when it regains control of the flash 1444(the host isn't able to clear it through an acknowledge command). 1445 1446The host must not assume that the contents of the active window correctly 1447reflect the contents of flash while this bit is set. 1448 1449## `DAEMON_READY` Event 1450 1451| v1 | v2 | v3 | M | I | D | 1452|----|----|----|---|---|-------------| 1453| | ✓ | ✓ | 7 | 7 | DaemonReady | 1454 1455### Description 1456 1457Used to inform the host that the BMC daemon is ready to accept command 1458requests. The host isn't able to clear this bit through an acknowledge command, 1459the BMC daemon must clear it before it terminates (assuming it didn't terminate 1460unexpectedly). 1461 1462The host should not expect a response while this bit is not set. 1463 1464Note that this bit being set is not a guarantee that the BMC daemon will 1465respond as it or the BMC may have crashed without clearing it. 1466