runtime/kernel: fixed memory corruption for cache and DMA.
This commit is contained in:
parent
e7752a3d6d
commit
5becf0af0a
@ -1,6 +1,6 @@
|
|||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use cslice::{CSlice, AsCSlice};
|
use cslice::{CSlice, AsCSlice};
|
||||||
use core::mem::transmute;
|
use core::mem::{transmute, forget};
|
||||||
use super::{KERNEL_CHANNEL_0TO1, KERNEL_CHANNEL_1TO0, Message};
|
use super::{KERNEL_CHANNEL_0TO1, KERNEL_CHANNEL_1TO0, Message};
|
||||||
|
|
||||||
pub extern fn get(key: CSlice<u8>) -> CSlice<'static, i32> {
|
pub extern fn get(key: CSlice<u8>) -> CSlice<'static, i32> {
|
||||||
@ -8,12 +8,11 @@ pub extern fn get(key: CSlice<u8>) -> CSlice<'static, i32> {
|
|||||||
KERNEL_CHANNEL_1TO0.lock().as_mut().unwrap().send(Message::CacheGetRequest(key));
|
KERNEL_CHANNEL_1TO0.lock().as_mut().unwrap().send(Message::CacheGetRequest(key));
|
||||||
let msg = KERNEL_CHANNEL_0TO1.lock().as_mut().unwrap().recv();
|
let msg = KERNEL_CHANNEL_0TO1.lock().as_mut().unwrap().recv();
|
||||||
if let Message::CacheGetReply(v) = msg {
|
if let Message::CacheGetReply(v) = msg {
|
||||||
let slice = v.as_c_slice();
|
let slice = unsafe { transmute(v.as_c_slice()) };
|
||||||
// we intentionally leak the memory here,
|
// we intentionally leak the memory here,
|
||||||
// which does not matter as core1 would restart
|
// which does not matter as core1 would restart
|
||||||
unsafe {
|
forget(v);
|
||||||
transmute(slice)
|
slice
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
panic!("Expected CacheGetReply for CacheGetRequest");
|
panic!("Expected CacheGetReply for CacheGetRequest");
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ pub extern fn dma_playback(timestamp: i64, ptr: i32) {
|
|||||||
while csr::rtio_dma::enable_read() != 0 {}
|
while csr::rtio_dma::enable_read() != 0 {}
|
||||||
csr::cri_con::selected_write(0);
|
csr::cri_con::selected_write(0);
|
||||||
|
|
||||||
mem::drop(v);
|
mem::forget(v);
|
||||||
debug!("DMA playback finished");
|
debug!("DMA playback finished");
|
||||||
|
|
||||||
let error = csr::rtio_dma::error_read();
|
let error = csr::rtio_dma::error_read();
|
||||||
|
Loading…
Reference in New Issue
Block a user