Thermal: Add events for temperature based faults

Define two events DeviceOverOperatingTemperature and
DeviceOverOperatingTemperatureFault to indicate device
thermal overrun events to provide information of their
x86 equivalent PROCHOT and THERMTRIP.

Change-Id: Iee45c6cdf6063c886043fe5e5b5a4ef8f434f6dd
Signed-off-by: Amithash Prasad <amithash@meta.com>
diff --git a/gen/xyz/openbmc_project/State/Thermal/meson.build b/gen/xyz/openbmc_project/State/Thermal/meson.build
new file mode 100644
index 0000000..29f6b40
--- /dev/null
+++ b/gen/xyz/openbmc_project/State/Thermal/meson.build
@@ -0,0 +1,26 @@
+# Generated file; do not modify.
+
+sdbusplus_current_path = 'xyz/openbmc_project/State/Thermal'
+
+generated_sources += custom_target(
+    'xyz/openbmc_project/State/Thermal__cpp'.underscorify(),
+    input: ['../../../../../yaml/xyz/openbmc_project/State/Thermal.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/Thermal',
+    ],
+    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 0b4feea..2d4861d 100644
--- a/gen/xyz/openbmc_project/State/meson.build
+++ b/gen/xyz/openbmc_project/State/meson.build
@@ -16,6 +16,7 @@
 subdir('ScheduledHostTransition')
 subdir('Shutdown')
 subdir('SystemdTarget')
+subdir('Thermal')
 subdir('Watchdog')
 
 sdbusplus_current_path = 'xyz/openbmc_project/State'
@@ -390,6 +391,50 @@
 )
 
 generated_markdown += custom_target(
+    'xyz/openbmc_project/State/Thermal__markdown'.underscorify(),
+    input: ['../../../../yaml/xyz/openbmc_project/State/Thermal.events.yaml'],
+    output: ['Thermal.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/Thermal',
+    ],
+    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/Thermal__registry'.underscorify(),
+    input: ['../../../../yaml/xyz/openbmc_project/State/Thermal.events.yaml'],
+    output: ['Thermal.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/Thermal',
+    ],
+    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/Watchdog__markdown'.underscorify(),
     input: [
         '../../../../yaml/xyz/openbmc_project/State/Watchdog.interface.yaml',
diff --git a/yaml/xyz/openbmc_project/State/Thermal.events.yaml b/yaml/xyz/openbmc_project/State/Thermal.events.yaml
new file mode 100644
index 0000000..88510ec
--- /dev/null
+++ b/yaml/xyz/openbmc_project/State/Thermal.events.yaml
@@ -0,0 +1,46 @@
+version: 1.0.0
+
+errors:
+    - name: DeviceOverOperatingTemperature
+      severity: error
+      metadata:
+          - name: Device
+            type: object_path
+            primary: true
+            description: The name or identifier of the device
+          - name: FailureData
+            type: string
+            description:
+                An [Optional] set of additional failure data to identify the
+                cause of thermal overrun.
+      en:
+          description:
+              A event signaling that a device is operating over a set operating
+              temperature has occurred. The device may continue to operate in a
+              potentially performance degraded mode. This is very similar to the
+              PROCHOT signal from some x86 processors.
+          message: Device {Device} is over safe operating temperature.
+      errno: ERANGE
+
+    - name: DeviceOverOperatingTemperatureFault
+      severity: critical
+      metadata:
+          - name: Device
+            type: object_path
+            primary: true
+            description: The name or identifier of the device
+          - name: FailureData
+            type: string
+            description:
+                An [Optional] set of additional failure data to identify the
+                cause of thermal overrun fault.
+      en:
+          description:
+              A event signaling that a device has potentially been powered off
+              due to it operating significantly in excess of the set operating
+              temperature. This is very similar to the THERMTRIP signal from
+              some x86 processors.
+          message:
+              Device {Device} is significantly over safe operating temperature
+              and may have been powered off
+      errno: ERANGE