[Tracing] Add proto structure for ETW.

This is the first CL for the work to integrate ETW into perfetto. The
goal is to display ETW traces in the Perfetto UI similar to the way it
is currently done for ftrace. This adds ReadyThread[1] and CSwitch[2]
events.

This CL only includes a new ETW proto to be output-ed by Perfetto.

In upcoming CLs:
- add configuration for ETW
- Support ETW context switch in trace processor
- Display ETW context switch in UI

[1] https://learn.microsoft.com/en-us/windows/win32/etw/readythread
[2] https://learn.microsoft.com/en-us/windows/win32/etw/cswitch

Bug: 303263148

Change-Id: I5a2d51b82d8021d79e5951ee2eea2d57ea61f126
diff --git a/Android.bp b/Android.bp
index d668c2b..2b78b95 100644
--- a/Android.bp
+++ b/Android.bp
@@ -65,6 +65,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -151,6 +152,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -331,6 +333,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -426,6 +429,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -534,6 +538,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -639,6 +644,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -776,6 +782,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -860,6 +867,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -945,6 +953,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -1032,6 +1041,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -1084,6 +1094,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -1166,6 +1177,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -1243,6 +1255,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -1334,6 +1347,8 @@
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_cpp_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_cpp_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_cpp_gen",
@@ -1464,6 +1479,8 @@
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_cpp_gen_headers",
@@ -1533,6 +1550,8 @@
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_cpp_gen_headers",
@@ -1626,6 +1645,8 @@
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_cpp_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_cpp_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_cpp_gen",
@@ -1742,6 +1763,8 @@
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_cpp_gen_headers",
@@ -1811,6 +1834,8 @@
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_cpp_gen_headers",
@@ -2138,6 +2163,9 @@
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_lite_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_cpp_gen",
+        ":perfetto_protos_perfetto_trace_etw_lite_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_cpp_gen",
         ":perfetto_protos_perfetto_trace_filesystem_lite_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
@@ -2406,6 +2434,9 @@
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
@@ -5260,6 +5291,9 @@
         "protos/perfetto/trace/chrome/chrome_metadata.proto",
         "protos/perfetto/trace/chrome/chrome_trace_event.proto",
         "protos/perfetto/trace/clock_snapshot.proto",
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
         "protos/perfetto/trace/extension_descriptor.proto",
         "protos/perfetto/trace/filesystem/inode_file_map.proto",
         "protos/perfetto/trace/ftrace/android_fs.proto",
@@ -5398,6 +5432,136 @@
     ],
 }
 
+// GN: //protos/perfetto/trace/etw:cpp
+genrule {
+    name: "perfetto_protos_perfetto_trace_etw_cpp_gen",
+    srcs: [
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+    ],
+    tools: [
+        "aprotoc",
+        "perfetto_src_protozero_protoc_plugin_cppgen_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(in)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/etw/etw.gen.cc",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event.gen.cc",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event_bundle.gen.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/etw:cpp
+genrule {
+    name: "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+    srcs: [
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+    ],
+    tools: [
+        "aprotoc",
+        "perfetto_src_protozero_protoc_plugin_cppgen_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(in)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/etw/etw.gen.h",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event.gen.h",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event_bundle.gen.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/etw:lite
+genrule {
+    name: "perfetto_protos_perfetto_trace_etw_lite_gen",
+    srcs: [
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+    ],
+    tools: [
+        "aprotoc",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(in)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/etw/etw.pb.cc",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event.pb.cc",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event_bundle.pb.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/etw:lite
+genrule {
+    name: "perfetto_protos_perfetto_trace_etw_lite_gen_headers",
+    srcs: [
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+    ],
+    tools: [
+        "aprotoc",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(in)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/etw/etw.pb.h",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event.pb.h",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event_bundle.pb.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/etw:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_etw_zero_gen",
+    srcs: [
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(in)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/etw/etw.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event_bundle.pbzero.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/etw:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
+    srcs: [
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(in)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/etw/etw.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/etw/etw_event_bundle.pbzero.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
 // GN: //protos/perfetto/trace/filesystem:cpp
 genrule {
     name: "perfetto_protos_perfetto_trace_filesystem_cpp_gen",
@@ -12091,6 +12255,9 @@
         "protos/perfetto/trace/chrome/chrome_metadata.proto",
         "protos/perfetto/trace/chrome/chrome_trace_event.proto",
         "protos/perfetto/trace/clock_snapshot.proto",
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
         "protos/perfetto/trace/extension_descriptor.proto",
         "protos/perfetto/trace/filesystem/inode_file_map.proto",
         "protos/perfetto/trace/ftrace/android_fs.proto",
@@ -12246,6 +12413,7 @@
         ":perfetto_protos_perfetto_config_track_event_lite_gen",
         ":perfetto_protos_perfetto_trace_android_lite_gen",
         ":perfetto_protos_perfetto_trace_chrome_lite_gen",
+        ":perfetto_protos_perfetto_trace_etw_lite_gen",
         ":perfetto_protos_perfetto_trace_filesystem_lite_gen",
         ":perfetto_protos_perfetto_trace_ftrace_lite_gen",
         ":perfetto_protos_perfetto_trace_gpu_lite_gen",
@@ -12283,6 +12451,7 @@
         "perfetto_protos_perfetto_config_track_event_lite_gen_headers",
         "perfetto_protos_perfetto_trace_android_lite_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_lite_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_lite_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_lite_gen_headers",
@@ -12316,6 +12485,7 @@
         "perfetto_protos_perfetto_config_track_event_lite_gen_headers",
         "perfetto_protos_perfetto_trace_android_lite_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_lite_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_lite_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_lite_gen_headers",
@@ -12434,6 +12604,9 @@
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_lite_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_cpp_gen",
+        ":perfetto_protos_perfetto_trace_etw_lite_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_cpp_gen",
         ":perfetto_protos_perfetto_trace_filesystem_lite_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
@@ -12783,6 +12956,9 @@
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
@@ -12947,6 +13123,8 @@
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_cpp_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_cpp_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_cpp_gen",
@@ -13070,6 +13248,8 @@
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_cpp_gen_headers",
@@ -13139,6 +13319,8 @@
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_cpp_gen_headers",
@@ -13238,6 +13420,7 @@
         ":perfetto_protos_perfetto_config_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -13354,6 +13537,7 @@
         "perfetto_protos_perfetto_config_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -13471,6 +13655,7 @@
         ":perfetto_protos_perfetto_config_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -13588,6 +13773,7 @@
         "perfetto_protos_perfetto_config_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -13715,6 +13901,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -13813,6 +14000,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
@@ -13920,6 +14108,7 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
+        ":perfetto_protos_perfetto_trace_etw_zero_gen",
         ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
         ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
         ":perfetto_protos_perfetto_trace_gpu_zero_gen",
@@ -13993,6 +14182,7 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
         "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
         "perfetto_protos_perfetto_trace_gpu_zero_gen_headers",
diff --git a/BUILD b/BUILD
index 42122bd..26d176a 100644
--- a/BUILD
+++ b/BUILD
@@ -315,6 +315,7 @@
                ":protos_perfetto_config_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
+               ":protos_perfetto_trace_etw_zero",
                ":protos_perfetto_trace_filesystem_zero",
                ":protos_perfetto_trace_ftrace_zero",
                ":protos_perfetto_trace_gpu_zero",
@@ -402,6 +403,7 @@
         ":protos_perfetto_config_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
+        ":protos_perfetto_trace_etw_zero",
         ":protos_perfetto_trace_filesystem_zero",
         ":protos_perfetto_trace_ftrace_zero",
         ":protos_perfetto_trace_gpu_zero",
@@ -516,6 +518,7 @@
         ":protos_perfetto_ipc_ipc",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
+        ":protos_perfetto_trace_etw_zero",
         ":protos_perfetto_trace_filesystem_zero",
         ":protos_perfetto_trace_ftrace_zero",
         ":protos_perfetto_trace_gpu_zero",
@@ -3201,6 +3204,7 @@
         ":protos_perfetto_config_track_event_protos",
         ":protos_perfetto_trace_android_protos",
         ":protos_perfetto_trace_chrome_protos",
+        ":protos_perfetto_trace_etw_protos",
         ":protos_perfetto_trace_filesystem_protos",
         ":protos_perfetto_trace_ftrace_protos",
         ":protos_perfetto_trace_gpu_protos",
@@ -4283,6 +4287,27 @@
     ],
 )
 
+# GN target: //protos/perfetto/trace/etw:source_set
+perfetto_proto_library(
+    name = "protos_perfetto_trace_etw_protos",
+    srcs = [
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+    ],
+    visibility = [
+        PERFETTO_CONFIG.proto_library_visibility,
+    ],
+)
+
+# GN target: //protos/perfetto/trace/etw:zero
+perfetto_cc_protozero_library(
+    name = "protos_perfetto_trace_etw_zero",
+    deps = [
+        ":protos_perfetto_trace_etw_protos",
+    ],
+)
+
 # GN target: //protos/perfetto/trace/filesystem:source_set
 perfetto_proto_library(
     name = "protos_perfetto_trace_filesystem_protos",
@@ -4529,6 +4554,7 @@
         ":protos_perfetto_config_track_event_protos",
         ":protos_perfetto_trace_android_protos",
         ":protos_perfetto_trace_chrome_protos",
+        ":protos_perfetto_trace_etw_protos",
         ":protos_perfetto_trace_filesystem_protos",
         ":protos_perfetto_trace_ftrace_protos",
         ":protos_perfetto_trace_gpu_protos",
@@ -4569,6 +4595,7 @@
         ":protos_perfetto_config_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
+        ":protos_perfetto_trace_etw_zero",
         ":protos_perfetto_trace_filesystem_zero",
         ":protos_perfetto_trace_ftrace_zero",
         ":protos_perfetto_trace_gpu_zero",
@@ -5046,6 +5073,7 @@
         ":protos_perfetto_ipc_ipc",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
+        ":protos_perfetto_trace_etw_zero",
         ":protos_perfetto_trace_filesystem_zero",
         ":protos_perfetto_trace_ftrace_zero",
         ":protos_perfetto_trace_gpu_zero",
@@ -5137,6 +5165,7 @@
         ":protos_perfetto_ipc_ipc",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
+        ":protos_perfetto_trace_etw_zero",
         ":protos_perfetto_trace_filesystem_zero",
         ":protos_perfetto_trace_ftrace_zero",
         ":protos_perfetto_trace_gpu_zero",
@@ -5266,6 +5295,7 @@
                ":protos_perfetto_config_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
+               ":protos_perfetto_trace_etw_zero",
                ":protos_perfetto_trace_filesystem_zero",
                ":protos_perfetto_trace_ftrace_zero",
                ":protos_perfetto_trace_gpu_zero",
@@ -5418,6 +5448,7 @@
                ":protos_perfetto_config_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
+               ":protos_perfetto_trace_etw_zero",
                ":protos_perfetto_trace_filesystem_zero",
                ":protos_perfetto_trace_ftrace_zero",
                ":protos_perfetto_trace_gpu_zero",
@@ -5505,6 +5536,7 @@
         ":protos_perfetto_config_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
+        ":protos_perfetto_trace_etw_zero",
         ":protos_perfetto_trace_filesystem_zero",
         ":protos_perfetto_trace_ftrace_zero",
         ":protos_perfetto_trace_gpu_zero",
@@ -5639,6 +5671,7 @@
                ":protos_perfetto_config_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
+               ":protos_perfetto_trace_etw_zero",
                ":protos_perfetto_trace_filesystem_zero",
                ":protos_perfetto_trace_ftrace_zero",
                ":protos_perfetto_trace_gpu_zero",
diff --git a/protos/perfetto/trace/BUILD.gn b/protos/perfetto/trace/BUILD.gn
index f81b05c..c808a93 100644
--- a/protos/perfetto/trace/BUILD.gn
+++ b/protos/perfetto/trace/BUILD.gn
@@ -93,6 +93,7 @@
     "../config:@TYPE@",
     "android:@TYPE@",
     "chrome:@TYPE@",
+    "etw:@TYPE@",
     "filesystem:@TYPE@",
     "ftrace:@TYPE@",
     "gpu:@TYPE@",
diff --git a/protos/perfetto/trace/etw/BUILD.gn b/protos/perfetto/trace/etw/BUILD.gn
new file mode 100644
index 0000000..f22514c
--- /dev/null
+++ b/protos/perfetto/trace/etw/BUILD.gn
@@ -0,0 +1,29 @@
+# Copyright (C) 2023 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("../../../../gn/perfetto.gni")
+import("../../../../gn/proto_library.gni")
+import("all_protos.gni")
+
+perfetto_proto_library("@TYPE@") {
+  sources = etw_proto_names
+}
+
+if (perfetto_build_standalone) {
+  perfetto_proto_library("descriptor") {
+    proto_generators = [ "descriptor" ]
+    generate_descriptor = "etw.descriptor"
+    sources = [ "etw_event_bundle.proto" ]
+  }
+}
diff --git a/protos/perfetto/trace/etw/all_protos.gni b/protos/perfetto/trace/etw/all_protos.gni
new file mode 100644
index 0000000..e6c9e9a
--- /dev/null
+++ b/protos/perfetto/trace/etw/all_protos.gni
@@ -0,0 +1,19 @@
+# Copyright (C) 2023 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+etw_proto_names = [
+  "etw.proto",
+  "etw_event.proto",
+  "etw_event_bundle.proto",
+]
diff --git a/protos/perfetto/trace/etw/etw.proto b/protos/perfetto/trace/etw/etw.proto
new file mode 100644
index 0000000..c008be2
--- /dev/null
+++ b/protos/perfetto/trace/etw/etw.proto
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+package perfetto.protos;
+
+// Proto definition based on the Thread_v2 CSwitch class definition
+// See: https://learn.microsoft.com/en-us/windows/win32/etw/cswitch
+message CSwitchEtwEvent {
+  // New thread ID after the switch.
+  optional uint32 new_thread_id = 1;
+
+  // Previous thread ID.
+  optional uint32 old_thread_id = 2;
+
+  // Thread priority of the new thread.
+  optional sint32 new_thread_priority = 3;
+
+  // Thread priority of the previous thread.
+  optional sint32 old_thread_priority = 4;
+
+  // The index of the C-state that was last used by the processor. A value of 0
+  // represents the lightest idle state with higher values representing deeper
+  // C-states.
+  optional uint32 previous_c_state = 5;
+
+  // Wait reason for the previous thread. The ordering is important as based on
+  // the OldThreadWaitReason definition from the link above. The following are
+  // the possible values:
+  enum OldThreadWaitReason {
+    EXECUTIVE = 0;
+    FREE_PAGE = 1;
+    PAGE_IN = 2;
+    POOL_ALLOCATION = 3;
+    DELAY_EXECUTION = 4;
+    SUSPEND = 5;
+    USER_REQUEST = 6;
+    WR_EXECUTIVE = 7;
+    WR_FREE_PAGE = 8;
+    WR_PAGE_IN = 9;
+    WR_POOL_ALLOCATION = 10;
+    WR_DELAY_EXECUTION = 11;
+    WR_SUSPENDED = 12;
+    WR_USER_REQUEST = 13;
+    WR_EVENT_PAIR = 14;
+    WR_QUEUE = 15;
+    WR_LPC_RECEIVER = 16;
+    WR_LPC_REPLY = 17;
+    WR_VIRTUAL_MEMORY = 18;
+    WR_PAGE_OUT = 19;
+    WR_RENDEZ_VOUS = 20;
+    WR_KEYED_EVENT = 21;
+    WR_TERMINATED = 22;
+    WR_PROCESS_IN_SWAP = 23;
+    WR_CPU_RATE_CONTROL = 24;
+    WR_CALLOUT_STACK = 25;
+    WR_KERNEL = 26;
+    WR_RESOURCE = 27;
+    WR_PUSH_LOCK = 28;
+    WR_MUTEX = 29;
+    WR_QUANTUM_END = 30;
+    WR_DISPATCH_INT = 31;
+    WR_PREEMPTED = 32;
+    WR_YIELD_EXECUTION = 33;
+    WR_FAST_MUTEX = 34;
+    WR_GUARD_MUTEX = 35;
+    WR_RUNDOWN = 36;
+    MAXIMUM_WAIT_REASON = 37;
+  }
+
+  optional OldThreadWaitReason old_thread_wait_reason = 6;
+
+  // Wait mode for the previous thread. The ordering is important as based on
+  // the OldThreadWaitMode definition from the link above. The following are the
+  // possible values:
+  enum OldThreadWaitMode {
+    KERNEL_MODE = 0;
+    USER_MODE = 1;
+  }
+
+  optional OldThreadWaitMode old_thread_wait_mode = 7;
+
+  // State of the previous thread. The ordering is important as based on the
+  // OldThreadState definition from the link above. The following are the
+  // possible state values:
+  enum OldThreadState {
+    INITIALIZED = 0;
+    READY = 1;
+    RUNNING = 2;
+    STANDBY = 3;
+    TERMINATED = 4;
+    WAITING = 5;
+    TRANSITION = 6;
+    DEFERRED_READY = 7;
+  }
+
+  optional OldThreadState old_thread_state = 8;
+
+  // Ideal wait time of the previous thread.
+  optional sint32 old_thread_wait_ideal_processor = 9;
+
+  // Wait time for the new thread.
+  optional uint32 new_thread_wait_time = 10;
+}
+
+// Proto definition based on the Thread_v2 CSwitch class definition
+// See: https://learn.microsoft.com/en-us/windows/win32/etw/readythread
+message ReadyThreadEtwEvent {
+  // The thread identifier of the thread being readied for execution.
+  optional uint32 t_thread_id = 1;
+
+  // The reason for the priority boost. The ordering is important as based on
+  // the AdjustReason definition from the link above.
+  enum AdjustReason {
+    IGNORE_THE_INCREMENT = 0;
+    // Apply the increment, which will decay incrementally at the end of each
+    // quantum.
+    APPLY_INCREMENT = 1;
+    // Apply the increment as a boost that will decay in its entirety at quantum
+    // (typically for priority donation).
+    APPLY_INCREMENT_BOOST = 2;
+  }
+
+  optional AdjustReason adjust_reason = 2;
+
+  //  The value by which the priority is being adjusted.
+  optional sint32 adjust_increment = 3;
+
+  enum TraceFlag {
+    TRACE_FLAG_UNSPECIFIED = 0;
+    // The thread has been readied from DPC (deferred procedure call).
+    THREAD_READIED = 0x1;
+    // The kernel stack is currently swapped out.
+    KERNEL_STACK_SWAPPED_OUT = 0x2;
+    // The process address space is swapped out.
+    PROCESS_ADDRESS_SWAPPED_OUT = 0x4;
+  }
+
+  optional TraceFlag flag = 4;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/etw/etw_event.proto b/protos/perfetto/trace/etw/etw_event.proto
new file mode 100644
index 0000000..9ef1b4e
--- /dev/null
+++ b/protos/perfetto/trace/etw/etw_event.proto
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+package perfetto.protos;
+
+import "protos/perfetto/trace/etw/etw.proto";
+
+message EtwTraceEvent {
+  optional uint64 timestamp = 1;
+
+  oneof event {
+    CSwitchEtwEvent c_switch = 2;
+    ReadyThreadEtwEvent ready_thread = 3;
+  }
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/etw/etw_event_bundle.proto b/protos/perfetto/trace/etw/etw_event_bundle.proto
new file mode 100644
index 0000000..3ea3916
--- /dev/null
+++ b/protos/perfetto/trace/etw/etw_event_bundle.proto
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/etw/etw_event.proto";
+
+package perfetto.protos;
+
+// The result of tracing one or more etw event uses per-processor buffers where
+// an in-use buffer is assigned to each processor at all times. Therefore,
+// collecting multiple events they should already be synchronized.
+message EtwTraceEventBundle {
+  optional uint32 cpu = 1;
+  repeated EtwTraceEvent event = 2;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 16112ab..1c3e222 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -5166,6 +5166,167 @@
 
 // End of protos/perfetto/trace/clock_snapshot.proto
 
+// Begin of protos/perfetto/trace/etw/etw.proto
+
+// Proto definition based on the Thread_v2 CSwitch class definition
+// See: https://learn.microsoft.com/en-us/windows/win32/etw/cswitch
+message CSwitchEtwEvent {
+  // New thread ID after the switch.
+  optional uint32 new_thread_id = 1;
+
+  // Previous thread ID.
+  optional uint32 old_thread_id = 2;
+
+  // Thread priority of the new thread.
+  optional sint32 new_thread_priority = 3;
+
+  // Thread priority of the previous thread.
+  optional sint32 old_thread_priority = 4;
+
+  // The index of the C-state that was last used by the processor. A value of 0
+  // represents the lightest idle state with higher values representing deeper
+  // C-states.
+  optional uint32 previous_c_state = 5;
+
+  // Wait reason for the previous thread. The ordering is important as based on
+  // the OldThreadWaitReason definition from the link above. The following are
+  // the possible values:
+  enum OldThreadWaitReason {
+    EXECUTIVE = 0;
+    FREE_PAGE = 1;
+    PAGE_IN = 2;
+    POOL_ALLOCATION = 3;
+    DELAY_EXECUTION = 4;
+    SUSPEND = 5;
+    USER_REQUEST = 6;
+    WR_EXECUTIVE = 7;
+    WR_FREE_PAGE = 8;
+    WR_PAGE_IN = 9;
+    WR_POOL_ALLOCATION = 10;
+    WR_DELAY_EXECUTION = 11;
+    WR_SUSPENDED = 12;
+    WR_USER_REQUEST = 13;
+    WR_EVENT_PAIR = 14;
+    WR_QUEUE = 15;
+    WR_LPC_RECEIVER = 16;
+    WR_LPC_REPLY = 17;
+    WR_VIRTUAL_MEMORY = 18;
+    WR_PAGE_OUT = 19;
+    WR_RENDEZ_VOUS = 20;
+    WR_KEYED_EVENT = 21;
+    WR_TERMINATED = 22;
+    WR_PROCESS_IN_SWAP = 23;
+    WR_CPU_RATE_CONTROL = 24;
+    WR_CALLOUT_STACK = 25;
+    WR_KERNEL = 26;
+    WR_RESOURCE = 27;
+    WR_PUSH_LOCK = 28;
+    WR_MUTEX = 29;
+    WR_QUANTUM_END = 30;
+    WR_DISPATCH_INT = 31;
+    WR_PREEMPTED = 32;
+    WR_YIELD_EXECUTION = 33;
+    WR_FAST_MUTEX = 34;
+    WR_GUARD_MUTEX = 35;
+    WR_RUNDOWN = 36;
+    MAXIMUM_WAIT_REASON = 37;
+  }
+
+  optional OldThreadWaitReason old_thread_wait_reason = 6;
+
+  // Wait mode for the previous thread. The ordering is important as based on
+  // the OldThreadWaitMode definition from the link above. The following are the
+  // possible values:
+  enum OldThreadWaitMode {
+    KERNEL_MODE = 0;
+    USER_MODE = 1;
+  }
+
+  optional OldThreadWaitMode old_thread_wait_mode = 7;
+
+  // State of the previous thread. The ordering is important as based on the
+  // OldThreadState definition from the link above. The following are the
+  // possible state values:
+  enum OldThreadState {
+    INITIALIZED = 0;
+    READY = 1;
+    RUNNING = 2;
+    STANDBY = 3;
+    TERMINATED = 4;
+    WAITING = 5;
+    TRANSITION = 6;
+    DEFERRED_READY = 7;
+  }
+
+  optional OldThreadState old_thread_state = 8;
+
+  // Ideal wait time of the previous thread.
+  optional sint32 old_thread_wait_ideal_processor = 9;
+
+  // Wait time for the new thread.
+  optional uint32 new_thread_wait_time = 10;
+}
+
+// Proto definition based on the Thread_v2 CSwitch class definition
+// See: https://learn.microsoft.com/en-us/windows/win32/etw/readythread
+message ReadyThreadEtwEvent {
+  // The thread identifier of the thread being readied for execution.
+  optional uint32 t_thread_id = 1;
+
+  // The reason for the priority boost. The ordering is important as based on
+  // the AdjustReason definition from the link above.
+  enum AdjustReason {
+    IGNORE_THE_INCREMENT = 0;
+    // Apply the increment, which will decay incrementally at the end of each
+    // quantum.
+    APPLY_INCREMENT = 1;
+    // Apply the increment as a boost that will decay in its entirety at quantum
+    // (typically for priority donation).
+    APPLY_INCREMENT_BOOST = 2;
+  }
+
+  optional AdjustReason adjust_reason = 2;
+
+  //  The value by which the priority is being adjusted.
+  optional sint32 adjust_increment = 3;
+
+  enum TraceFlag {
+    TRACE_FLAG_UNSPECIFIED = 0;
+    // The thread has been readied from DPC (deferred procedure call).
+    THREAD_READIED = 0x1;
+    // The kernel stack is currently swapped out.
+    KERNEL_STACK_SWAPPED_OUT = 0x2;
+    // The process address space is swapped out.
+    PROCESS_ADDRESS_SWAPPED_OUT = 0x4;
+  }
+
+  optional TraceFlag flag = 4;
+}
+// End of protos/perfetto/trace/etw/etw.proto
+
+// Begin of protos/perfetto/trace/etw/etw_event.proto
+
+message EtwTraceEvent {
+  optional uint64 timestamp = 1;
+
+  oneof event {
+    CSwitchEtwEvent c_switch = 2;
+    ReadyThreadEtwEvent ready_thread = 3;
+  }
+}
+// End of protos/perfetto/trace/etw/etw_event.proto
+
+// Begin of protos/perfetto/trace/etw/etw_event_bundle.proto
+
+// The result of tracing one or more etw event uses per-processor buffers where
+// an in-use buffer is assigned to each processor at all times. Therefore,
+// collecting multiple events they should already be synchronized.
+message EtwTraceEventBundle {
+  optional uint32 cpu = 1;
+  repeated EtwTraceEvent event = 2;
+}
+// End of protos/perfetto/trace/etw/etw_event_bundle.proto
+
 // Begin of protos/perfetto/common/descriptor.proto
 
 // The protocol compiler can output a FileDescriptorSet containing the .proto
@@ -13081,7 +13242,7 @@
 // See the [Buffers and Dataflow](/docs/concepts/buffers.md) doc for details.
 //
 // Next reserved id: 14 (up to 15).
-// Next id: 95.
+// Next id: 96.
 message TracePacket {
   // The timestamp of the TracePacket.
   // By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -13201,6 +13362,9 @@
     LayersSnapshotProto surfaceflinger_layers_snapshot = 93;
     TransactionTraceEntry surfaceflinger_transactions = 94;
 
+    // Events from the Windows etw infrastructure.
+    EtwTraceEventBundle etw_events = 95;
+
     // This field is only used for testing.
     // In previous versions of this proto this field had the id 268435455
     // This caused many problems:
diff --git a/protos/perfetto/trace/trace_packet.proto b/protos/perfetto/trace/trace_packet.proto
index b47981b..0c60cf6 100644
--- a/protos/perfetto/trace/trace_packet.proto
+++ b/protos/perfetto/trace/trace_packet.proto
@@ -35,6 +35,7 @@
 import "protos/perfetto/trace/chrome/chrome_metadata.proto";
 import "protos/perfetto/trace/chrome/chrome_trace_event.proto";
 import "protos/perfetto/trace/clock_snapshot.proto";
+import "protos/perfetto/trace/etw/etw_event_bundle.proto";
 import "protos/perfetto/trace/filesystem/inode_file_map.proto";
 import "protos/perfetto/trace/ftrace/ftrace_event_bundle.proto";
 import "protos/perfetto/trace/ftrace/ftrace_stats.proto";
@@ -96,7 +97,7 @@
 // See the [Buffers and Dataflow](/docs/concepts/buffers.md) doc for details.
 //
 // Next reserved id: 14 (up to 15).
-// Next id: 95.
+// Next id: 96.
 message TracePacket {
   // The timestamp of the TracePacket.
   // By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -216,6 +217,9 @@
     LayersSnapshotProto surfaceflinger_layers_snapshot = 93;
     TransactionTraceEntry surfaceflinger_transactions = 94;
 
+    // Events from the Windows etw infrastructure.
+    EtwTraceEventBundle etw_events = 95;
+
     // This field is only used for testing.
     // In previous versions of this proto this field had the id 268435455
     // This caused many problems: