SMC: add events for Satellite Management Controllers

Add events to report issues with attached SMCs, such as
heartbeat failures or inability to communicate.  This is
reported as a generic event (SMCFailed), which is most
likely useful enough for external reporting and fault isolation,
but includes a field for additional debug data of the failure
type.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ic0cc09135d1b8301f98e1df5b6b6e9180929c811
diff --git a/gen/xyz/openbmc_project/State/SMC/meson.build b/gen/xyz/openbmc_project/State/SMC/meson.build
new file mode 100644
index 0000000..9ddddab
--- /dev/null
+++ b/gen/xyz/openbmc_project/State/SMC/meson.build
@@ -0,0 +1,26 @@
+# Generated file; do not modify.
+
+sdbusplus_current_path = 'xyz/openbmc_project/State/SMC'
+
+generated_sources += custom_target(
+    'xyz/openbmc_project/State/SMC__cpp'.underscorify(),
+    input: ['../../../../../yaml/xyz/openbmc_project/State/SMC.events.yaml'],
+    output: ['event.cpp', 'event.hpp'],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog,
+        '--command',
+        'cpp',
+        '--output',
+        meson.current_build_dir(),
+        '--tool',
+        sdbusplusplus_prog,
+        '--directory',
+        meson.current_source_dir() / '../../../../../yaml',
+        'xyz/openbmc_project/State/SMC',
+    ],
+    install: should_generate_cpp,
+    install_dir: [false, get_option('includedir') / sdbusplus_current_path],
+    build_by_default: should_generate_cpp,
+)
+
diff --git a/gen/xyz/openbmc_project/State/meson.build b/gen/xyz/openbmc_project/State/meson.build
index b91ff29..e5f2a81 100644
--- a/gen/xyz/openbmc_project/State/meson.build
+++ b/gen/xyz/openbmc_project/State/meson.build
@@ -10,6 +10,7 @@
 subdir('Leak')
 subdir('OperatingSystem')
 subdir('PowerOnHours')
+subdir('SMC')
 subdir('ScheduledHostTransition')
 subdir('Shutdown')
 subdir('SystemdTarget')
@@ -207,6 +208,50 @@
 )
 
 generated_markdown += custom_target(
+    'xyz/openbmc_project/State/SMC__markdown'.underscorify(),
+    input: ['../../../../yaml/xyz/openbmc_project/State/SMC.events.yaml'],
+    output: ['SMC.md'],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog,
+        '--command',
+        'markdown',
+        '--output',
+        meson.current_build_dir(),
+        '--tool',
+        sdbusplusplus_prog,
+        '--directory',
+        meson.current_source_dir() / '../../../../yaml',
+        'xyz/openbmc_project/State/SMC',
+    ],
+    install: should_generate_markdown,
+    install_dir: [inst_markdown_dir / sdbusplus_current_path],
+    build_by_default: should_generate_markdown,
+)
+
+generated_registry += custom_target(
+    'xyz/openbmc_project/State/SMC__registry'.underscorify(),
+    input: ['../../../../yaml/xyz/openbmc_project/State/SMC.events.yaml'],
+    output: ['SMC.json'],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog,
+        '--command',
+        'registry',
+        '--output',
+        meson.current_build_dir(),
+        '--tool',
+        sdbusplusplus_prog,
+        '--directory',
+        meson.current_source_dir() / '../../../../yaml',
+        'xyz/openbmc_project/State/SMC',
+    ],
+    install: should_generate_registry,
+    install_dir: [inst_registry_dir / sdbusplus_current_path],
+    build_by_default: should_generate_registry,
+)
+
+generated_markdown += custom_target(
     'xyz/openbmc_project/State/ScheduledHostTransition__markdown'.underscorify(),
     input: [
         '../../../../yaml/xyz/openbmc_project/State/ScheduledHostTransition.interface.yaml',
diff --git a/yaml/xyz/openbmc_project/State/SMC.events.yaml b/yaml/xyz/openbmc_project/State/SMC.events.yaml
new file mode 100644
index 0000000..64155aa
--- /dev/null
+++ b/yaml/xyz/openbmc_project/State/SMC.events.yaml
@@ -0,0 +1,35 @@
+version: 1.0.0
+
+errors:
+    - name: SMCFailed
+      severity: error
+      metadata:
+          - name: Identifier
+            type: object_path
+            primary: true
+            description: The name or identifier of the SMC.
+          - name: FailureType
+            type: string
+            description: An [optional] identifier of the failure type.
+      en:
+          description:
+              A Satellite Management Controller (SMC) has been detected in
+              failure state.
+          message:
+              The Satellite Management Controller '{Identifier}' is in a failure
+              state.
+      errno: EHOSTUNREACH
+
+events:
+    - name: SMCRestored
+      metadata:
+          - name: Identifier
+            type: object_path
+            primary: true
+            description: The name or identifier of the SMC.
+      en:
+          description:
+              The Satellite Management Controller (SMC) status is restored.
+          message:
+              The Satellite Management Controller '{Identifier}' is in a
+              restored state.