1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Exceptions support.

/// Exception routines.
pub trait Exception {
  /// Exception configuration data.
  type Config;

  /// Configures an exception.
  ///
  /// # Safety
  ///
  /// Must be called only by [`exceptions::config`](fn.config.html).
  unsafe fn config(config: Self::Config);

  /// The exception entry.
  fn run(&mut self);
}

/// A vector tables to exception routines.
pub trait ExceptionTable {
  /// Exceptions configuration.
  type Config;

  /// Configures exceptions.
  ///
  /// # Safety
  ///
  /// Must be called no less and no more than once, before exceptions begins
  /// executing.
  unsafe fn config<F>(f: F)
  where
    F: Send + 'static,
    F: FnOnce() -> Self::Config;
}

/// Pointer to an exception routine.
pub type Handler = Option<extern "C" fn()>;

/// Pointer to a reset routine.
pub type ResetHandler = Option<extern "C" fn() -> !>;

/// Reserved vector in a vector table.
#[derive(Clone, Copy)]
#[repr(usize)]
pub enum Reserved {
  /// The only allowed zero-value.
  Vector = 0,
}