You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.0 KiB
Rust
62 lines
2.0 KiB
Rust
4 years ago
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||
|
//
|
||
|
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||
|
|
||
|
//! BSP driver support.
|
||
|
|
||
|
use crate::driver;
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
4 years ago
|
// Private Definitions
|
||
4 years ago
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/// Device Driver Manager type.
|
||
4 years ago
|
struct BSPDriverManager {
|
||
4 years ago
|
device_drivers: [&'static (dyn DeviceDriver + Sync); 3],
|
||
4 years ago
|
}
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
// Global instances
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
static BSP_DRIVER_MANAGER: BSPDriverManager = BSPDriverManager {
|
||
4 years ago
|
device_drivers: [
|
||
|
&super::GPIO,
|
||
|
&super::PL011_UART,
|
||
|
&super::INTERRUPT_CONTROLLER,
|
||
|
],
|
||
4 years ago
|
};
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
// Public Code
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/// Return a reference to the driver manager.
|
||
|
pub fn driver_manager() -> &'static impl driver::interface::DriverManager {
|
||
|
&BSP_DRIVER_MANAGER
|
||
|
}
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
// OS Interface Code
|
||
|
//------------------------------------------------------------------------------
|
||
|
use driver::interface::DeviceDriver;
|
||
|
|
||
|
impl driver::interface::DriverManager for BSPDriverManager {
|
||
|
fn all_device_drivers(&self) -> &[&'static (dyn DeviceDriver + Sync)] {
|
||
|
&self.device_drivers[..]
|
||
|
}
|
||
|
|
||
4 years ago
|
fn early_print_device_drivers(&self) -> &[&'static (dyn DeviceDriver + Sync)] {
|
||
|
&self.device_drivers[0..=1]
|
||
|
}
|
||
|
|
||
|
fn non_early_print_device_drivers(&self) -> &[&'static (dyn DeviceDriver + Sync)] {
|
||
|
&self.device_drivers[2..]
|
||
|
}
|
||
|
|
||
|
fn post_early_print_device_driver_init(&self) {
|
||
4 years ago
|
// Configure PL011Uart's output pins.
|
||
|
super::GPIO.map_pl011_uart();
|
||
|
}
|
||
|
}
|