-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathanthony-rocha-2026-02-12.patch
More file actions
321 lines (314 loc) · 9.04 KB
/
anthony-rocha-2026-02-12.patch
File metadata and controls
321 lines (314 loc) · 9.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
From 048e272b0d6ffc2a5a8e870c7316b08df33bda7c Mon Sep 17 00:00:00 2001
From: Anthony Rocha <anthony.rocha@amd.com>
Date: Thu, 12 Feb 2026 11:19:36 -0800
Subject: [PATCH] refactor(i3c): conditionally export ISR handlers with
isr-handlers feature
---
.gitignore | 3 +
BUILD.bazel | 165 +++++++++++++++++++++++++++++
Cargo.toml | 5 +-
src/i3c/ast1060_i3c.rs | 41 ++++++-
src/lib.rs | 1 +
src/tests/functional/i2c_test.rs | 1 +
src/tests/functional/timer_test.rs | 1 +
7 files changed, 209 insertions(+), 8 deletions(-)
create mode 100644 BUILD.bazel
diff --git a/.gitignore b/.gitignore
index 3a5a215..7128458 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@
# Bloat analysis reports
target/bloat-reports/
target/*-bloat-reports/
+
+# Auto-generated Bazel build file (regenerate via crate_universe)
+BUILD.bazel
diff --git a/BUILD.bazel b/BUILD.bazel
new file mode 100644
index 0000000..1ed5729
--- /dev/null
+++ b/BUILD.bazel
@@ -0,0 +1,165 @@
+###############################################################################
+# @generated
+# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
+# regenerate this file, run the following:
+#
+# bazel mod show_repo 'opentitan_pigweed'
+###############################################################################
+
+load(
+ "@rules_rust//cargo:defs.bzl",
+ "cargo_build_script",
+ "cargo_toml_env_vars",
+)
+
+load("@rules_rust//rust:defs.bzl", "rust_library")
+
+# buildifier: disable=bzl-visibility
+load("@rules_rust//crate_universe/private:selects.bzl", "selects")
+
+package(default_visibility = ["//visibility:public"])
+
+cargo_toml_env_vars(
+ name = "cargo_toml_env_vars",
+ src = "Cargo.toml",
+)
+
+rust_library(
+ name = "aspeed_ddk",
+ deps = [
+ "@oot_crates_no_std__aspeed-ddk-0.1.0//:build_script_build",
+ "@oot_crates_no_std__ast1060-pac-0.1.0//:ast1060_pac",
+ "@oot_crates_no_std__cortex-m-0.7.7//:cortex_m",
+ "@oot_crates_no_std__cortex-m-rt-0.7.5//:cortex_m_rt",
+ "@oot_crates_no_std__critical-section-1.2.0//:critical_section",
+ "@oot_crates_no_std__embedded-hal-1.0.0//:embedded_hal",
+ "@oot_crates_no_std__embedded-hal-1.0.0-alpha.1//:embedded_hal",
+ "@oot_crates_no_std__embedded-io-0.6.1//:embedded_io",
+ "@oot_crates_no_std__fugit-0.3.9//:fugit",
+ "@oot_crates_no_std__heapless-0.8.0//:heapless",
+ "@oot_crates_no_std__hex-literal-0.4.1//:hex_literal",
+ "@oot_crates_no_std__nb-1.1.0//:nb",
+ "@oot_crates_no_std__openprot-hal-blocking-0.1.0//:openprot_hal_blocking",
+ "@oot_crates_no_std__panic-halt-1.0.0//:panic_halt",
+ "@oot_crates_no_std__proposed-traits-0.1.0//:proposed_traits",
+ "@oot_crates_no_std__zerocopy-0.8.39//:zerocopy",
+ ],
+ proc_macro_deps = [
+ "@oot_crates_no_std__paste-1.0.15//:paste",
+ ],
+ aliases = {
+ "@oot_crates_no_std__embedded-hal-1.0.0-alpha.1//:embedded_hal": "embedded_hal_old",
+ },
+ compile_data = glob(
+ allow_empty = True,
+ include = ["**"],
+ exclude = [
+ "**/* *",
+ ".tmp_git_root/**/*",
+ "BUILD",
+ "BUILD.bazel",
+ "WORKSPACE",
+ "WORKSPACE.bazel",
+ ],
+ ),
+ crate_features = [
+ "default",
+ ],
+ crate_root = "src/lib.rs",
+ edition = "2021",
+ rustc_env_files = [
+ ":cargo_toml_env_vars",
+ ],
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ srcs = glob(
+ allow_empty = True,
+ include = ["**/*.rs"],
+ ),
+ tags = [
+ "cargo-bazel",
+ "crate-name=aspeed-ddk",
+ "manual",
+ "noclippy",
+ "norustfmt",
+ ],
+ target_compatible_with = select({
+ "@rules_rust//rust/platform:aarch64-apple-darwin": [],
+ "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [],
+ "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [],
+ "@rules_rust//rust/platform:thumbv6m-none-eabi": [],
+ "@rules_rust//rust/platform:thumbv7em-none-eabi": [],
+ "@rules_rust//rust/platform:thumbv7m-none-eabi": [],
+ "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [],
+ "@rules_rust//rust/platform:x86_64-apple-darwin": [],
+ "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [],
+ "//conditions:default": ["@platforms//:incompatible"],
+ }),
+ version = "0.1.0",
+)
+
+cargo_build_script(
+ name = "_bs",
+ compile_data = glob(
+ allow_empty = True,
+ include = ["**"],
+ exclude = [
+ "**/* *",
+ "**/*.rs",
+ ".tmp_git_root/**/*",
+ "BUILD",
+ "BUILD.bazel",
+ "WORKSPACE",
+ "WORKSPACE.bazel",
+ ],
+ ),
+ crate_features = [
+ "default",
+ ],
+ crate_name = "build_script_build",
+ crate_root = "build.rs",
+ data = glob(
+ allow_empty = True,
+ include = ["**"],
+ exclude = [
+ "**/* *",
+ ".tmp_git_root/**/*",
+ "BUILD",
+ "BUILD.bazel",
+ "WORKSPACE",
+ "WORKSPACE.bazel",
+ ],
+ ),
+ link_deps = [
+ "@oot_crates_no_std__cortex-m-0.7.7//:cortex_m",
+ "@oot_crates_no_std__cortex-m-rt-0.7.5//:cortex_m_rt",
+ ],
+ edition = "2021",
+ pkg_name = "aspeed-ddk",
+ rustc_env_files = [
+ ":cargo_toml_env_vars",
+ ],
+ rustc_flags = [
+ "--cap-lints=allow",
+ ],
+ srcs = glob(
+ allow_empty = True,
+ include = ["**/*.rs"],
+ ),
+ tags = [
+ "cargo-bazel",
+ "crate-name=aspeed-ddk",
+ "manual",
+ "noclippy",
+ "norustfmt",
+ ],
+ version = "0.1.0",
+ visibility = ["//visibility:private"],
+)
+
+alias(
+ name = "build_script_build",
+ actual = ":_bs",
+ tags = ["manual"],
+)
diff --git a/Cargo.toml b/Cargo.toml
index c667777..5b2cf39 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,7 @@ edition = "2021"
[features]
default = []
std = []
+isr-handlers = [] # Export ISR handlers with #[no_mangle] - disable for kernel integration
i2c_target = []
i3c_master = []
i3c_target = []
@@ -45,7 +46,3 @@ openprot-hal-blocking = { git="https://github.com/OpenPRoT/openprot" }
zerocopy = { version = "0.8.25", features = ["derive"] }
cortex-m-rt = { version = "0.7.5", features = ["device"] }
panic-halt = "1.0.0"
-
-[patch."https://github.com/AspeedTech-BMC/ast1060-pac.git"]
-ast1060-pac = { path = "ast1060-pac" }
-
diff --git a/src/i3c/ast1060_i3c.rs b/src/i3c/ast1060_i3c.rs
index 233b875..b3d6a7c 100644
--- a/src/i3c/ast1060_i3c.rs
+++ b/src/i3c/ast1060_i3c.rs
@@ -230,21 +230,54 @@ fn dispatch_irq(bus: usize) {
});
}
+/// I3C bus 0 interrupt handler - call this from your ISR
+#[inline]
+pub fn i3c_irq_handler() {
+ dispatch_irq(0);
+}
+
+/// I3C bus 1 interrupt handler - call this from your ISR
+#[inline]
+pub fn i3c1_irq_handler() {
+ dispatch_irq(1);
+}
+
+/// I3C bus 2 interrupt handler - call this from your ISR
+#[inline]
+pub fn i3c2_irq_handler() {
+ dispatch_irq(2);
+}
+
+/// I3C bus 3 interrupt handler - call this from your ISR
+#[inline]
+pub fn i3c3_irq_handler() {
+ dispatch_irq(3);
+}
+
+// ISR exports - only when isr-handlers feature is enabled
+// For kernel integration, disable this feature and define ISRs in target code
+#[cfg(feature = "isr-handlers")]
#[no_mangle]
pub extern "C" fn i3c() {
- dispatch_irq(0);
+ i3c_irq_handler();
}
+
+#[cfg(feature = "isr-handlers")]
#[no_mangle]
pub extern "C" fn i3c1() {
- dispatch_irq(1);
+ i3c1_irq_handler();
}
+
+#[cfg(feature = "isr-handlers")]
#[no_mangle]
pub extern "C" fn i3c2() {
- dispatch_irq(2);
+ i3c2_irq_handler();
}
+
+#[cfg(feature = "isr-handlers")]
#[no_mangle]
pub extern "C" fn i3c3() {
- dispatch_irq(3);
+ i3c3_irq_handler();
}
#[repr(u32)]
diff --git a/src/lib.rs b/src/lib.rs
index 34c72a7..fa9de7a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,6 +16,7 @@ pub mod rsa;
pub mod spi;
pub mod spimonitor;
pub mod syscon;
+#[cfg(feature = "isr-handlers")]
pub mod tests;
pub mod timer;
pub mod uart;
diff --git a/src/tests/functional/i2c_test.rs b/src/tests/functional/i2c_test.rs
index 2f33a50..c138b22 100644
--- a/src/tests/functional/i2c_test.rs
+++ b/src/tests/functional/i2c_test.rs
@@ -220,6 +220,7 @@ static mut I2C0_INSTANCE: Option<
> = None;
#[cfg(feature = "i2c_target")]
+#[cfg(feature = "isr-handlers")]
#[no_mangle]
pub extern "C" fn i2c() {
unsafe {
diff --git a/src/tests/functional/timer_test.rs b/src/tests/functional/timer_test.rs
index 43a1744..89a526a 100644
--- a/src/tests/functional/timer_test.rs
+++ b/src/tests/functional/timer_test.rs
@@ -12,6 +12,7 @@ use embedded_io::Write;
static mut UART_PTR: Option<&'static mut UartController<'static>> = None;
static mut TIMER_INSTANCE: Option<TimerController<Timer>> = None;
+#[cfg(feature = "isr-handlers")]
#[no_mangle]
pub extern "C" fn timer() {
unsafe {
--
2.34.1