Skip to content

Commit df468dc

Browse files
hoshinolinajannau
authored andcommitted
fixup! rust: soc: apple: rtkit: Add Apple RTKit abstraction
1 parent 0e3cc94 commit df468dc

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

rust/kernel/soc/apple/rtkit.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub trait Operations {
4040
type Buffer: Buffer;
4141

4242
/// Called when RTKit crashes.
43-
fn crashed(_data: <Self::Data as ForeignOwnable>::Borrowed<'_>) {}
43+
fn crashed(_data: <Self::Data as ForeignOwnable>::Borrowed<'_>, _crashlog: Option<&[u8]>) {}
4444

4545
/// Called when a message was received on a non-system endpoint. Called in non-IRQ context.
4646
fn recv_message(
@@ -92,9 +92,19 @@ pub struct RtKit<T: Operations> {
9292
_p: PhantomData<T>,
9393
}
9494

95-
unsafe extern "C" fn crashed_callback<T: Operations>(cookie: *mut core::ffi::c_void) {
95+
unsafe extern "C" fn crashed_callback<T: Operations>(
96+
cookie: *mut core::ffi::c_void,
97+
crashlog: *const core::ffi::c_void,
98+
crashlog_size: usize,
99+
) {
100+
let crashlog = if !crashlog.is_null() && crashlog_size > 0 {
101+
// SAFETY: The crashlog is either missing or a byte buffer of the specified size
102+
Some(unsafe { core::slice::from_raw_parts(crashlog as *const u8, crashlog_size) })
103+
} else {
104+
None
105+
};
96106
// SAFETY: cookie is always a T::Data in this API
97-
T::crashed(unsafe { T::Data::borrow(cookie) });
107+
T::crashed(unsafe { T::Data::borrow(cookie) }, crashlog);
98108
}
99109

100110
unsafe extern "C" fn recv_message_callback<T: Operations>(

0 commit comments

Comments
 (0)