From d9bd42389f26a82c9d8f18181609f8c7e49fd253 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 18 Jun 2020 20:14:02 +0200 Subject: [PATCH] kernel: flush now write-buffered dcache of image before execution --- src/libdyld/src/image.rs | 2 +- src/libdyld/src/lib.rs | 2 +- src/runtime/src/kernel.rs | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libdyld/src/image.rs b/src/libdyld/src/image.rs index 3f76bd0..87fa665 100644 --- a/src/libdyld/src/image.rs +++ b/src/libdyld/src/image.rs @@ -23,7 +23,7 @@ pub struct DynamicSection { /// target memory image pub struct Image { layout: Layout, - data: &'static mut [u8], + pub data: &'static mut [u8], } impl Image { diff --git a/src/libdyld/src/lib.rs b/src/libdyld/src/lib.rs index 698b058..2103bbe 100644 --- a/src/libdyld/src/lib.rs +++ b/src/libdyld/src/lib.rs @@ -58,7 +58,7 @@ fn elf_hash(name: &[u8]) -> u32 { } pub struct Library { - image: Image, + pub image: Image, dyn_section: DynamicSection, } diff --git a/src/runtime/src/kernel.rs b/src/runtime/src/kernel.rs index 5e97ea9..a590b1e 100644 --- a/src/runtime/src/kernel.rs +++ b/src/runtime/src/kernel.rs @@ -3,7 +3,7 @@ use log::{debug, error}; use alloc::{vec::Vec, sync::Arc}; use cslice::CSlice; -use libcortex_a9::{mutex::Mutex, sync_channel::{self, sync_channel}}; +use libcortex_a9::{cache::dcci_slice, mutex::Mutex, sync_channel::{self, sync_channel}}; use libsupport_zynq::boot::Core1; use dyld; @@ -313,6 +313,10 @@ pub fn main_core1() { current_modinit = Some(__modinit__); current_typeinfo = library.lookup(b"typeinfo"); debug!("kernel loaded"); + // Flush data cache entries for the image in DDR, including + // Memory/Instruction Symchronization Barriers + dcci_slice(library.image.data); + core1_tx.send(Message::LoadCompleted); }, Err(error) => {