Add Hoth interface

Create a new google namespace and add the Hoth interface to this
namespace.

Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: I001dc34ef081885b6094d3d1aab578b0d882b53a
diff --git a/gen/com/google/gbmc/Hoth/meson.build b/gen/com/google/gbmc/Hoth/meson.build
new file mode 100644
index 0000000..4acfe71
--- /dev/null
+++ b/gen/com/google/gbmc/Hoth/meson.build
@@ -0,0 +1,14 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+    'com/google/gbmc/Hoth__cpp'.underscorify(),
+    input: [ '../../../../../yaml/com/google/gbmc/Hoth.interface.yaml',  ],
+    output: [ 'error.cpp', 'error.hpp', 'server.cpp', 'server.hpp', 'client.hpp',  ],
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'cpp',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../yaml',
+        'com/google/gbmc/Hoth',
+    ],
+)
+
diff --git a/gen/com/google/gbmc/meson.build b/gen/com/google/gbmc/meson.build
new file mode 100644
index 0000000..8cce8a2
--- /dev/null
+++ b/gen/com/google/gbmc/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+subdir('Hoth')
+generated_others += custom_target(
+    'com/google/gbmc/Hoth__markdown'.underscorify(),
+    input: [ '../../../../yaml/com/google/gbmc/Hoth.interface.yaml',  ],
+    output: [ 'Hoth.md' ],
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'markdown',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../yaml',
+        'com/google/gbmc/Hoth',
+    ],
+)
+
diff --git a/gen/com/google/meson.build b/gen/com/google/meson.build
new file mode 100644
index 0000000..194bca6
--- /dev/null
+++ b/gen/com/google/meson.build
@@ -0,0 +1,2 @@
+# Generated file; do not modify.
+subdir('gbmc')
diff --git a/gen/com/meson.build b/gen/com/meson.build
index b06016e..9a2e068 100644
--- a/gen/com/meson.build
+++ b/gen/com/meson.build
@@ -1,3 +1,4 @@
 # Generated file; do not modify.
+subdir('google')
 subdir('ibm')
 subdir('intel')
diff --git a/meson.build b/meson.build
index 856123b..63f4120 100644
--- a/meson.build
+++ b/meson.build
@@ -32,6 +32,9 @@
 if get_option('data_com_intel')
     selected_subdirs += 'com/intel'
 endif
+if get_option('data_com_google')
+    selected_subdirs += 'com/google'
+endif
 if get_option('data_org_freedesktop')
     selected_subdirs += 'org/freedesktop'
 endif
diff --git a/meson_options.txt b/meson_options.txt
index 56a1679..7d4a23b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,7 @@
 option('libphosphor_dbus', type: 'boolean', value: true)
 option('data_com_ibm', type: 'boolean', value: false)
 option('data_com_intel', type: 'boolean', value: false)
+option('data_com_google', type: 'boolean', value: false)
 option('data_org_freedesktop', type: 'boolean', value: true)
 option('data_org_open_power', type: 'boolean', value: false)
 option('data_xyz_openbmc_project', type: 'boolean', value: true)
diff --git a/yaml/com/google/gbmc/Hoth.errors.yaml b/yaml/com/google/gbmc/Hoth.errors.yaml
new file mode 100644
index 0000000..c697f93
--- /dev/null
+++ b/yaml/com/google/gbmc/Hoth.errors.yaml
@@ -0,0 +1,13 @@
+- name: CommandFailure
+  description: Failed to send the command to Hoth.
+- name: ResponseFailure
+  description: Failed to retrieve response from Hoth.
+- name: FirmwareFailure
+  description: Failed to send firmware update to Hoth.
+- name: ResponseNotFound
+  description: Could not find a response. The command may not have completed yet.
+- name: InterfaceError
+  description: A system error occured with the Hoth interface.
+- name: ExpectedInfoNotFound
+  description: Could not find the expected information in the response.
+
diff --git a/yaml/com/google/gbmc/Hoth.interface.yaml b/yaml/com/google/gbmc/Hoth.interface.yaml
new file mode 100644
index 0000000..c15daf5
--- /dev/null
+++ b/yaml/com/google/gbmc/Hoth.interface.yaml
@@ -0,0 +1,294 @@
+description: >
+  Implement the Hoth command control interface.
+
+methods:
+  - name: SendHostCommand
+    description: >
+      Send a host command to Hoth and return the response.
+      This will block on Hoth completing its internal operations.
+      Critical host commands like LoadTokens are banned.
+      This method should be called from the IPMI HostCommand passthrough.
+    parameters:
+      - name: Command
+        type: array[byte]
+        description: >
+          Data to write to Hoth SPI host command offset.
+    returns:
+      - name: Response
+        type: array[byte]
+        description: >
+          Data read from Hoth SPI host command offset.
+    errors:
+      - self.Error.CommandFailure
+      - self.Error.ResponseFailure
+      - self.Error.InterfaceError
+      - xyz.openbmc_project.Common.Error.Timeout
+
+  - name: SendTrustedHostCommand
+    description: >
+      Send a host command to Hoth and return the response.
+      This will block on Hoth completing its internal operations.
+      Critical host commands like LoadTokens are allowed.
+      This method should be called from the BMC.
+    parameters:
+      - name: Command
+        type: array[byte]
+        description: >
+          Data to write to Hoth SPI host command offset.
+    returns:
+      - name: Response
+        type: array[byte]
+        description: >
+          Data read from Hoth SPI host command offset.
+    errors:
+      - self.Error.CommandFailure
+      - self.Error.ResponseFailure
+      - self.Error.InterfaceError
+      - xyz.openbmc_project.Common.Error.Timeout
+
+  - name: SendHostCommandAsync
+    description: >
+      Send a host command to Hoth and immediately return without waiting for
+      response. Caller can either poll with calls to GetHostCommandResponse
+      until retrieving the response, or wait for a ResponseReady signal.
+    parameters:
+      - name: Command
+        type: array[byte]
+        description: >
+          Data to write to Hoth SPI host command offset.
+    returns:
+      - name: CallToken
+        type: uint64
+        description: >
+          The representation for the call made
+    errors:
+      - self.Error.CommandFailure
+
+  - name: GetHostCommandResponse
+    description: >
+      Read the response from Hoth mailbox.
+    parameters:
+      - name: CallToken
+        type: uint64
+        description: >
+          The token returned from SendHostCommandAsync()
+    returns:
+      - name: Response
+        type: array[byte]
+        description: >
+          Data read from Hoth SPI host command offset
+    errors:
+      - self.Error.ResponseFailure
+      - self.Error.ResponseNotFound
+      - self.Error.InterfaceError
+
+  - name: UpdateFirmware
+    description: >
+      Write given firmware data to the Hoth firmware partition in EEPROM.
+    parameters:
+      - name: FirmwareData
+        type: array[byte]
+        description: >
+          Hoth firmware image
+    errors:
+      - self.Error.FirmwareFailure
+
+  - name: GetFirmwareUpdateStatus
+    description: >
+      Get the status of the firmware update process.
+    returns:
+      - name: Status
+        type: enum[self.FirmwareUpdateStatus]
+        description: >
+          Status of the firmware update
+
+  - name: InitiatePayload
+    description: >
+      Initiates erasure of the EEPROM staging area. Note that this will lock up
+      access to Hoth for an extended time and may go over the kernel's SPI
+      write timeout. Calling multiple small ErasePayload is recommended.
+    errors:
+      - self.Error.CommandFailure
+      - self.Error.ResponseFailure
+      - self.Error.InterfaceError
+
+  - name: GetInitiatePayloadStatus
+    description: >
+      Get the status of the payload initiation process.
+    returns:
+      - name: Status
+        type: enum[self.FirmwareUpdateStatus]
+        description: >
+          Status of the payload initiation
+
+  - name: ErasePayload
+    description: >
+      Erases the given size starting at the specified offset of the staging
+      partition.
+    parameters:
+      - name: Offset
+        type: uint32
+        description: >
+          Offset of the staging partition to start erasing from.
+      - name: Size
+        type: uint32
+        description: >
+          Size of the staging partition to erase.
+    errors:
+      - self.Error.CommandFailure
+      - self.Error.ResponseFailure
+      - self.Error.InterfaceError
+
+  - name: SendPayload
+    description: >
+      Chunk and send the binary specified in the image path
+    parameters:
+      - name: ImagePath
+        type: string
+        description: >
+          Firmware image path
+    errors:
+      - self.Error.FirmwareFailure
+      - self.Error.InterfaceError
+
+  - name: GetSendPayloadStatus
+    description: >
+      Get the status of the send payload process.
+    returns:
+      - name: Status
+        type: enum[self.FirmwareUpdateStatus]
+        description: >
+          Status of the send payload process.
+
+  - name: VerifyPayload
+    description: >
+      Initiates the verification process without activating the staging area
+    errors:
+      - self.Error.InterfaceError
+
+  - name: GetVerifyPayloadStatus
+    description: >
+      Get the status of the payload verification process.
+    returns:
+      - name: Status
+        type: enum[self.FirmwareUpdateStatus]
+        description: >
+          Status of the payload verification
+
+  - name: ActivatePayload
+    description: >
+      Activates the staging area as persistent or non-persistent for next boot
+      if verification was successful.
+    parameters:
+      - name: MakePersistent
+        type: boolean
+        description: >
+          Flag to determine whether to activate the staged image as persistent
+          or non-persistent for next boot.
+    errors:
+      - self.Error.CommandFailure
+      - self.Error.ResponseFailure
+      - self.Error.InterfaceError
+
+  - name: GetPayloadSize
+    description: >
+      Determines the max size of the payload region.
+    returns:
+      - name: Size
+        type: uint32
+        description: >
+          The size of the payload region
+    errors:
+      - self.Error.CommandFailure
+      - self.Error.ResponseFailure
+      - self.Error.InterfaceError
+
+  - name: Confirm
+    description: >
+      Prevents hoth from rolling back and using the previous image.
+      When an image can be comfirmed to be working well, this command is given,
+      which disarms the hoth watchdog.
+    errors:
+      - self.Error.CommandFailure
+      - self.Error.ResponseFailure
+      - self.Error.InterfaceError
+
+  - name: GetTotalBootTime
+    description: >
+      Get total time spending from reset to HVNGOOD.
+    returns:
+      - name: Time
+        type: uint32
+        description: >
+          Time in microseconds.
+    errors:
+      - self.Error.ResponseFailure
+      - self.Error.ExpectedInfoNotFound
+
+  - name: GetFirmwareUpdateTime
+    description: >
+      Get time spending in the self update routine. Since a proper self update
+      involves a reset, this time is always expected to be low.
+    returns:
+      - name: Time
+        type: uint32
+        description: >
+          Time in microseconds.
+    errors:
+      - self.Error.ResponseFailure
+      - self.Error.ExpectedInfoNotFound
+
+  - name: GetFirmwareMirroringTime
+    description: >
+      Get time spending in mirroing the self-update. This time is a reasonable
+      proxy for the total self update time.
+    returns:
+      - name: Time
+        type: uint32
+        description: >
+          Time in microseconds.
+    errors:
+      - self.Error.ResponseFailure
+      - self.Error.ExpectedInfoNotFound
+
+  - name: GetPayloadValidationTime
+    description: >
+      Get time spending in validating the payload, copying mutable regions and/or
+      dealing with failsafe fallback.
+    returns:
+      - name: Time
+        type: uint32
+        description: >
+          Time in microseconds.
+    errors:
+      - self.Error.ResponseFailure
+      - self.Error.ExpectedInfoNotFound
+
+signals:
+  - name: HostCommandResponseReady
+    description: >
+      This signal is broadcast when a response is ready for the call that
+      returned CallToken.
+    properties:
+      - name: CallToken
+        type: uint64
+        description: >
+          The token returned from SendHostCommandAsync()
+
+enumerations:
+   - name: FirmwareUpdateStatus
+     description: >
+       The status of a firmware update through hothd
+     values:
+       - name: 'None'
+         description: >
+           No update initiated
+       - name: 'InProgress'
+         description: >
+           Update still in progress
+       - name: 'Error'
+         description: >
+           Update has failed
+       - name: 'Done'
+         description: >
+           Update has completed successfully