forked from M-Labs/artiq
1
0
Fork 0

firmware: suppress warning

This commit is contained in:
occheung 2021-08-25 15:22:19 +08:00
parent 1da0554a49
commit eecd825d23
14 changed files with 56 additions and 68 deletions

View File

@ -47,7 +47,7 @@ fn memory_test(total: &mut usize, wrong: &mut usize) -> bool {
MEMORY[$index:expr] = $data:expr MEMORY[$index:expr] = $data:expr
} }
) => ({ ) => ({
$prepare; $prepare
for $i in $range { for $i in $range {
unsafe { ptr::write_volatile(MEMORY.offset($index as isize), $data) }; unsafe { ptr::write_volatile(MEMORY.offset($index as isize), $data) };
*total += 1; *total += 1;
@ -56,7 +56,7 @@ fn memory_test(total: &mut usize, wrong: &mut usize) -> bool {
cache::flush_cpu_dcache(); cache::flush_cpu_dcache();
cache::flush_l2_cache(); cache::flush_l2_cache();
$prepare; $prepare
for $i in $range { for $i in $range {
if unsafe { ptr::read_volatile(MEMORY.offset($index as isize)) } != $data { if unsafe { ptr::read_volatile(MEMORY.offset($index as isize)) } != $data {
*wrong += 1; *wrong += 1;

View File

@ -8,7 +8,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![allow(private_no_mangle_fns, non_camel_case_types)] #![allow(non_camel_case_types)]
use core::{ptr, mem}; use core::{ptr, mem};
use cslice::CSlice; use cslice::CSlice;

View File

@ -1,5 +1,5 @@
#![feature(lang_items, llvm_asm, panic_unwind, libc, unwind_attributes, #![feature(lang_items, llvm_asm, panic_unwind, libc, unwind_attributes,
panic_handler, panic_info_message, nll)] panic_info_message, nll)]
#![no_std] #![no_std]
extern crate libc; extern crate libc;
@ -204,15 +204,13 @@ fn terminate(exception: &eh_artiq::Exception, backtrace: &mut [usize]) -> ! {
#[unwind(aborts)] #[unwind(aborts)]
extern fn cache_get<'a>(ret: &'a mut CSlice<i32>, key: &CSlice<u8>) -> &'a CSlice<'a, i32> { extern fn cache_get<'a>(ret: &'a mut CSlice<i32>, key: &CSlice<u8>) -> &'a CSlice<'a, i32> {
unsafe { send(&CacheGetRequest {
send(&CacheGetRequest { key: str::from_utf8(key.as_ref()).unwrap()
key: str::from_utf8(key.as_ref()).unwrap() });
}); recv!(&CacheGetReply { value } => {
recv!(&CacheGetReply { value } => { *ret = value.as_c_slice();
*ret = value.as_c_slice(); ret
ret })
})
}
} }
#[unwind(allowed)] #[unwind(allowed)]

View File

@ -1,12 +1,10 @@
#![feature(asm, lang_items, never_type)] #![feature(lang_items, never_type)]
#![no_std] #![no_std]
extern crate failure; extern crate failure;
#[cfg(has_drtio)] #[cfg(has_drtio)]
#[macro_use] #[macro_use]
extern crate failure_derive; extern crate failure_derive;
#[macro_use]
extern crate bitflags;
extern crate byteorder; extern crate byteorder;
extern crate crc; extern crate crc;
#[macro_use] #[macro_use]

View File

@ -77,10 +77,10 @@ mod imp {
mod lock { mod lock {
use core::slice; use core::slice;
use core::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use core::sync::atomic::{AtomicUsize, Ordering};
use super::Error; use super::Error;
static LOCKED: AtomicUsize = ATOMIC_USIZE_INIT; static LOCKED: AtomicUsize = AtomicUsize::new(0);
pub struct Lock; pub struct Lock;
@ -216,7 +216,7 @@ mod imp {
let mut offset = 0; let mut offset = 0;
let mut iter = Iter::new(old_data); let mut iter = Iter::new(old_data);
'iter: while let Some(result) = iter.next() { 'iter: while let Some(result) = iter.next() {
let (key, mut value) = result?; let (key, value) = result?;
if value.is_empty() { if value.is_empty() {
// This is a removed entry, ignore it. // This is a removed entry, ignore it.
continue continue

View File

@ -31,7 +31,7 @@ mod ddr {
} }
#[cfg(ddrphy_wlevel)] #[cfg(ddrphy_wlevel)]
unsafe fn write_level_scan(logger: &mut Option<&mut fmt::Write>) { unsafe fn write_level_scan(logger: &mut Option<&mut dyn fmt::Write>) {
#[cfg(kusddrphy)] #[cfg(kusddrphy)]
log!(logger, "DQS initial delay: {} taps\n", ddrphy::wdly_dqs_taps_read()); log!(logger, "DQS initial delay: {} taps\n", ddrphy::wdly_dqs_taps_read());
log!(logger, "Write leveling scan:\n"); log!(logger, "Write leveling scan:\n");
@ -82,7 +82,7 @@ mod ddr {
} }
#[cfg(ddrphy_wlevel)] #[cfg(ddrphy_wlevel)]
unsafe fn write_level(logger: &mut Option<&mut fmt::Write>, unsafe fn write_level(logger: &mut Option<&mut dyn fmt::Write>,
delay: &mut [u16; DQS_SIGNAL_COUNT], delay: &mut [u16; DQS_SIGNAL_COUNT],
high_skew: &mut [bool; DQS_SIGNAL_COUNT]) -> bool { high_skew: &mut [bool; DQS_SIGNAL_COUNT]) -> bool {
#[cfg(kusddrphy)] #[cfg(kusddrphy)]
@ -172,7 +172,7 @@ mod ddr {
} }
#[cfg(ddrphy_wlevel)] #[cfg(ddrphy_wlevel)]
unsafe fn read_bitslip(logger: &mut Option<&mut fmt::Write>, unsafe fn read_bitslip(logger: &mut Option<&mut dyn fmt::Write>,
delay: &[u16; DQS_SIGNAL_COUNT], delay: &[u16; DQS_SIGNAL_COUNT],
high_skew: &[bool; DQS_SIGNAL_COUNT]) { high_skew: &[bool; DQS_SIGNAL_COUNT]) {
let threshold_opt = delay.iter().zip(high_skew.iter()) let threshold_opt = delay.iter().zip(high_skew.iter())
@ -203,7 +203,7 @@ mod ddr {
} }
} }
unsafe fn read_level_scan(logger: &mut Option<&mut fmt::Write>) { unsafe fn read_level_scan(logger: &mut Option<&mut dyn fmt::Write>) {
log!(logger, "Read leveling scan:\n"); log!(logger, "Read leveling scan:\n");
// Generate pseudo-random sequence // Generate pseudo-random sequence
@ -286,7 +286,7 @@ mod ddr {
spin_cycles(15); spin_cycles(15);
} }
unsafe fn read_level(logger: &mut Option<&mut fmt::Write>) -> bool { unsafe fn read_level(logger: &mut Option<&mut dyn fmt::Write>) -> bool {
log!(logger, "Read leveling: "); log!(logger, "Read leveling: ");
// Generate pseudo-random sequence // Generate pseudo-random sequence
@ -417,7 +417,7 @@ mod ddr {
true true
} }
pub unsafe fn level(logger: &mut Option<&mut fmt::Write>) -> bool { pub unsafe fn level(logger: &mut Option<&mut dyn fmt::Write>) -> bool {
#[cfg(ddrphy_wlevel)] #[cfg(ddrphy_wlevel)]
{ {
let mut delay = [0; DQS_SIGNAL_COUNT]; let mut delay = [0; DQS_SIGNAL_COUNT];
@ -442,7 +442,7 @@ use core::fmt;
use csr; use csr;
use sdram_phy; use sdram_phy;
pub unsafe fn init(mut _logger: Option<&mut fmt::Write>) -> bool { pub unsafe fn init(mut _logger: Option<&mut dyn fmt::Write>) -> bool {
sdram_phy::initialize(); sdram_phy::initialize();
#[cfg(has_ddrphy)] #[cfg(has_ddrphy)]

View File

@ -159,7 +159,7 @@ impl<'a> Library<'a> {
Ok(()) Ok(())
} }
fn resolve_rela(&self, rela: &Elf32_Rela, resolve: &Fn(&[u8]) -> Option<Elf32_Word>) fn resolve_rela(&self, rela: &Elf32_Rela, resolve: &dyn Fn(&[u8]) -> Option<Elf32_Word>)
-> Result<(), Error<'a>> { -> Result<(), Error<'a>> {
let sym; let sym;
if ELF32_R_SYM(rela.r_info) == 0 { if ELF32_R_SYM(rela.r_info) == 0 {
@ -204,7 +204,7 @@ impl<'a> Library<'a> {
self.update_rela(rela, value) self.update_rela(rela, value)
} }
pub fn load(data: &[u8], image: &'a mut [u8], resolve: &Fn(&[u8]) -> Option<Elf32_Word>) pub fn load(data: &[u8], image: &'a mut [u8], resolve: &dyn Fn(&[u8]) -> Option<Elf32_Word>)
-> Result<Library<'a>, Error<'a>> { -> Result<Library<'a>, Error<'a>> {
#![allow(unused_assignments)] #![allow(unused_assignments)]

View File

@ -14,11 +14,8 @@
// //
// By design, this personality function is only ever called in the search phase, although // By design, this personality function is only ever called in the search phase, although
// to keep things simple and close to upstream, it is not modified // to keep things simple and close to upstream, it is not modified
#![allow(private_no_mangle_fns)]
use unwind as uw; use unwind as uw;
use libc::{c_int, uintptr_t}; use libc::{c_int, uintptr_t};
use cslice::AsCSlice;
use dwarf::{self, EHAction, EHContext}; use dwarf::{self, EHAction, EHContext};

View File

@ -1,6 +1,5 @@
#![no_std] #![no_std]
#![feature(never_type)] #![feature(never_type)]
#![cfg_attr(feature = "alloc", feature(alloc))]
extern crate failure; extern crate failure;
#[macro_use] #[macro_use]

View File

@ -1,5 +1,4 @@
#![no_std] #![no_std]
#![cfg_attr(feature = "alloc", feature(alloc))]
extern crate failure; extern crate failure;
#[macro_use] #[macro_use]

View File

@ -18,7 +18,7 @@ unsafe fn align_ptr_mut<T>(ptr: *mut ()) -> *mut T {
} }
unsafe fn recv_value<R, E>(reader: &mut R, tag: Tag, data: &mut *mut (), unsafe fn recv_value<R, E>(reader: &mut R, tag: Tag, data: &mut *mut (),
alloc: &Fn(usize) -> Result<*mut (), E>) alloc: &dyn Fn(usize) -> Result<*mut (), E>)
-> Result<(), E> -> Result<(), E>
where R: Read + ?Sized, where R: Read + ?Sized,
E: From<Error<R::ReadError>> E: From<Error<R::ReadError>>
@ -63,7 +63,7 @@ unsafe fn recv_value<R, E>(reader: &mut R, tag: Tag, data: &mut *mut (),
} }
Tag::List(it) => { Tag::List(it) => {
#[repr(C)] #[repr(C)]
struct List { elements: *mut (), length: u32 }; struct List { elements: *mut (), length: u32 }
consume_value!(List, |ptr| { consume_value!(List, |ptr| {
(*ptr).length = reader.read_u32()?; (*ptr).length = reader.read_u32()?;
let length = (*ptr).length as usize; let length = (*ptr).length as usize;
@ -151,7 +151,7 @@ unsafe fn recv_value<R, E>(reader: &mut R, tag: Tag, data: &mut *mut (),
} }
pub fn recv_return<R, E>(reader: &mut R, tag_bytes: &[u8], data: *mut (), pub fn recv_return<R, E>(reader: &mut R, tag_bytes: &[u8], data: *mut (),
alloc: &Fn(usize) -> Result<*mut (), E>) alloc: &dyn Fn(usize) -> Result<*mut (), E>)
-> Result<(), E> -> Result<(), E>
where R: Read + ?Sized, where R: Read + ?Sized,
E: From<Error<R::ReadError>> E: From<Error<R::ReadError>>
@ -208,7 +208,7 @@ unsafe fn send_value<W>(writer: &mut W, tag: Tag, data: &mut *const ())
} }
Tag::List(it) => { Tag::List(it) => {
#[repr(C)] #[repr(C)]
struct List { elements: *const (), length: u32 }; struct List { elements: *const (), length: u32 }
consume_value!(List, |ptr| { consume_value!(List, |ptr| {
let length = (*ptr).length as usize; let length = (*ptr).length as usize;
writer.write_u32((*ptr).length)?; writer.write_u32((*ptr).length)?;
@ -287,7 +287,7 @@ unsafe fn send_value<W>(writer: &mut W, tag: Tag, data: &mut *const ())
} }
Tag::Keyword(it) => { Tag::Keyword(it) => {
#[repr(C)] #[repr(C)]
struct Keyword<'a> { name: CSlice<'a, u8> }; struct Keyword<'a> { name: CSlice<'a, u8> }
consume_value!(Keyword, |ptr| { consume_value!(Keyword, |ptr| {
writer.write_string(str::from_utf8((*ptr).name.as_ref()).unwrap())?; writer.write_string(str::from_utf8((*ptr).name.as_ref()).unwrap())?;
let tag = it.clone().next().expect("truncated tag"); let tag = it.clone().next().expect("truncated tag");
@ -299,7 +299,7 @@ unsafe fn send_value<W>(writer: &mut W, tag: Tag, data: &mut *const ())
} }
Tag::Object => { Tag::Object => {
#[repr(C)] #[repr(C)]
struct Object { id: u32 }; struct Object { id: u32 }
consume_value!(*const Object, |ptr| consume_value!(*const Object, |ptr|
writer.write_u32((**ptr).id)) writer.write_u32((**ptr).id))
} }

View File

@ -1,5 +1,4 @@
#![feature(lang_items, alloc, try_from, nonzero, asm, #![feature(lang_items, panic_info_message)]
panic_handler, panic_info_message)]
#![no_std] #![no_std]
extern crate eh; extern crate eh;
@ -280,32 +279,30 @@ pub struct TrapFrame {
#[no_mangle] #[no_mangle]
pub extern fn exception(regs: *const TrapFrame) { pub extern fn exception(regs: *const TrapFrame) {
unsafe { let pc = mepc::read();
let pc = mepc::read(); let cause = mcause::read().cause();
let cause = mcause::read().cause(); match cause {
match cause { mcause::Trap::Interrupt(source) => {
mcause::Trap::Interrupt(source) => { info!("Called interrupt with {:?}", source);
info!("Called interrupt with {:?}", source); },
}, mcause::Trap::Exception(e) => {
mcause::Trap::Exception(e) => { println!("Trap frame: {:x?}", unsafe { *regs });
println!("Trap frame: {:x?}", unsafe { *regs });
fn hexdump(addr: u32) { fn hexdump(addr: u32) {
let addr = (addr - addr % 4) as *const u32; let addr = (addr - addr % 4) as *const u32;
let mut ptr = addr; let mut ptr = addr;
println!("@ {:08p}", ptr); println!("@ {:08p}", ptr);
for _ in 0..4 { for _ in 0..4 {
print!("+{:04x}: ", ptr as usize - addr as usize); print!("+{:04x}: ", ptr as usize - addr as usize);
print!("{:08x} ", unsafe { *ptr }); ptr = ptr.wrapping_offset(1); print!("{:08x} ", unsafe { *ptr }); ptr = ptr.wrapping_offset(1);
print!("{:08x} ", unsafe { *ptr }); ptr = ptr.wrapping_offset(1); print!("{:08x} ", unsafe { *ptr }); ptr = ptr.wrapping_offset(1);
print!("{:08x} ", unsafe { *ptr }); ptr = ptr.wrapping_offset(1); print!("{:08x} ", unsafe { *ptr }); ptr = ptr.wrapping_offset(1);
print!("{:08x}\n", unsafe { *ptr }); ptr = ptr.wrapping_offset(1); print!("{:08x}\n", unsafe { *ptr }); ptr = ptr.wrapping_offset(1);
}
} }
hexdump(u32::try_from(pc).unwrap());
panic!("exception {:?} at PC 0x{:x}", e, u32::try_from(pc).unwrap())
} }
hexdump(u32::try_from(pc).unwrap());
panic!("exception {:?} at PC 0x{:x}", e, u32::try_from(pc).unwrap())
} }
} }
} }

View File

@ -35,7 +35,7 @@ type SocketSet = ::smoltcp::socket::SocketSet<'static, 'static, 'static>;
#[derive(Debug)] #[derive(Debug)]
struct WaitRequest { struct WaitRequest {
event: Option<*mut FnMut() -> bool>, event: Option<*mut dyn FnMut() -> bool>,
timeout: Option<u64> timeout: Option<u64>
} }
@ -240,7 +240,7 @@ impl<'a> Io<'a> {
} }
pub fn until<F: FnMut() -> bool>(&self, mut f: F) -> Result<(), Error> { pub fn until<F: FnMut() -> bool>(&self, mut f: F) -> Result<(), Error> {
let f = unsafe { mem::transmute::<&mut FnMut() -> bool, *mut FnMut() -> bool>(&mut f) }; let f = unsafe { mem::transmute::<&mut dyn FnMut() -> bool, *mut dyn FnMut() -> bool>(&mut f) };
self.suspend(WaitRequest { self.suspend(WaitRequest {
timeout: None, timeout: None,
event: Some(f) event: Some(f)

View File

@ -539,7 +539,7 @@ pub extern fn main() -> i32 {
} }
while !drtiosat_link_rx_up() { while !drtiosat_link_rx_up() {
drtiosat_process_errors(); drtiosat_process_errors();
for mut rep in repeaters.iter_mut() { for rep in repeaters.iter_mut() {
rep.service(&routing_table, rank); rep.service(&routing_table, rank);
} }
#[cfg(all(soc_platform = "kasli", hw_rev = "v2.0"))] #[cfg(all(soc_platform = "kasli", hw_rev = "v2.0"))]
@ -568,7 +568,7 @@ pub extern fn main() -> i32 {
while drtiosat_link_rx_up() { while drtiosat_link_rx_up() {
drtiosat_process_errors(); drtiosat_process_errors();
process_aux_packets(&mut repeaters, &mut routing_table, &mut rank); process_aux_packets(&mut repeaters, &mut routing_table, &mut rank);
for mut rep in repeaters.iter_mut() { for rep in repeaters.iter_mut() {
rep.service(&routing_table, rank); rep.service(&routing_table, rank);
} }
#[cfg(all(soc_platform = "kasli", hw_rev = "v2.0"))] #[cfg(all(soc_platform = "kasli", hw_rev = "v2.0"))]