2018-11-08 18:29:24 +08:00
|
|
|
use board_misoc::csr;
|
|
|
|
|
2016-10-17 00:24:25 +08:00
|
|
|
macro_rules! api {
|
|
|
|
($i:ident) => ({
|
2017-02-03 19:46:45 +08:00
|
|
|
extern { static $i: u8; }
|
2016-10-17 00:24:25 +08:00
|
|
|
api!($i = &$i as *const _)
|
|
|
|
});
|
|
|
|
($i:ident, $d:item) => ({
|
|
|
|
$d
|
|
|
|
api!($i = $i)
|
|
|
|
});
|
|
|
|
($i:ident = $e:expr) => {
|
|
|
|
(stringify!($i), unsafe { $e as *const () })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-25 02:57:29 +08:00
|
|
|
pub fn resolve(required: &[u8]) -> Option<u32> {
|
2016-10-17 00:24:25 +08:00
|
|
|
unsafe {
|
|
|
|
API.iter()
|
2017-02-25 02:57:29 +08:00
|
|
|
.find(|&&(exported, _)| exported.as_bytes() == required)
|
|
|
|
.map(|&(_, ptr)| ptr as u32)
|
2016-10-17 00:24:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
static mut API: &'static [(&'static str, *const ())] = &[
|
|
|
|
api!(__divsi3),
|
|
|
|
api!(__modsi3),
|
|
|
|
api!(__ledf2),
|
|
|
|
api!(__gedf2),
|
|
|
|
api!(__unorddf2),
|
|
|
|
api!(__eqdf2),
|
|
|
|
api!(__ltdf2),
|
|
|
|
api!(__nedf2),
|
|
|
|
api!(__gtdf2),
|
|
|
|
api!(__addsf3),
|
|
|
|
api!(__subsf3),
|
|
|
|
api!(__mulsf3),
|
|
|
|
api!(__divsf3),
|
|
|
|
api!(__lshrdi3),
|
|
|
|
api!(__muldi3),
|
|
|
|
api!(__divdi3),
|
|
|
|
api!(__ashldi3),
|
|
|
|
api!(__ashrdi3),
|
|
|
|
api!(__udivmoddi4),
|
|
|
|
api!(__floatsisf),
|
|
|
|
api!(__floatunsisf),
|
|
|
|
api!(__fixsfsi),
|
|
|
|
api!(__fixunssfsi),
|
|
|
|
api!(__adddf3),
|
|
|
|
api!(__subdf3),
|
|
|
|
api!(__muldf3),
|
|
|
|
api!(__divdf3),
|
|
|
|
api!(__floatsidf),
|
|
|
|
api!(__floatunsidf),
|
|
|
|
api!(__floatdidf),
|
|
|
|
api!(__fixdfsi),
|
|
|
|
api!(__fixdfdi),
|
|
|
|
api!(__fixunsdfsi),
|
|
|
|
api!(__udivdi3),
|
|
|
|
api!(__umoddi3),
|
|
|
|
api!(__moddi3),
|
|
|
|
api!(__powidf2),
|
|
|
|
|
|
|
|
/* libc */
|
2022-03-28 13:33:57 +08:00
|
|
|
api!(memcpy, extern { fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8; }),
|
|
|
|
api!(memmove, extern { fn memmove(dest: *mut u8, src: *const u8, n: usize) -> *mut u8; }),
|
|
|
|
api!(memset, extern { fn memset(s: *mut u8, c: i32, n: usize) -> *mut u8; }),
|
|
|
|
api!(memcmp, extern { fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32; }),
|
2016-10-17 00:24:25 +08:00
|
|
|
|
|
|
|
/* libm */
|
2020-08-12 13:36:06 +08:00
|
|
|
// commented out functions are not available with the libm used here, but are available in NAR3.
|
|
|
|
api!(acos),
|
|
|
|
api!(acosh),
|
|
|
|
api!(asin),
|
|
|
|
api!(asinh),
|
|
|
|
api!(atan),
|
|
|
|
api!(atan2),
|
|
|
|
api!(atanh),
|
|
|
|
api!(cbrt),
|
|
|
|
api!(ceil),
|
2020-11-11 05:24:04 +08:00
|
|
|
api!(copysign),
|
2020-08-12 13:36:06 +08:00
|
|
|
api!(cos),
|
|
|
|
api!(cosh),
|
|
|
|
api!(erf),
|
|
|
|
api!(erfc),
|
|
|
|
api!(exp),
|
|
|
|
//api!(exp2),
|
|
|
|
//api!(exp10),
|
|
|
|
api!(expm1),
|
|
|
|
api!(fabs),
|
2017-09-10 12:07:06 +08:00
|
|
|
api!(floor),
|
2020-11-11 05:24:04 +08:00
|
|
|
// api!(fmax),
|
|
|
|
// api!(fmin),
|
2020-08-12 13:36:06 +08:00
|
|
|
//api!(fma),
|
2020-01-10 14:33:02 +08:00
|
|
|
api!(fmod),
|
2020-08-12 13:36:06 +08:00
|
|
|
api!(hypot),
|
|
|
|
api!(j0),
|
|
|
|
api!(j1),
|
|
|
|
api!(jn),
|
|
|
|
api!(lgamma),
|
|
|
|
api!(log),
|
|
|
|
//api!(log2),
|
|
|
|
api!(log10),
|
2020-11-11 05:24:04 +08:00
|
|
|
api!(nextafter),
|
2020-08-12 13:36:06 +08:00
|
|
|
api!(pow),
|
|
|
|
api!(round),
|
|
|
|
api!(sin),
|
|
|
|
api!(sinh),
|
|
|
|
api!(sqrt),
|
|
|
|
api!(tan),
|
|
|
|
api!(tanh),
|
|
|
|
//api!(tgamma),
|
|
|
|
//api!(trunc),
|
|
|
|
api!(y0),
|
|
|
|
api!(y1),
|
|
|
|
api!(yn),
|
2016-10-17 00:24:25 +08:00
|
|
|
|
|
|
|
/* exceptions */
|
2017-02-04 15:59:02 +08:00
|
|
|
api!(_Unwind_Resume = ::unwind::_Unwind_Resume),
|
2022-02-23 11:04:53 +08:00
|
|
|
api!(__nac3_personality = ::eh_artiq::personality),
|
|
|
|
api!(__nac3_raise = ::eh_artiq::raise),
|
|
|
|
api!(__nac3_resume = ::eh_artiq::resume),
|
|
|
|
api!(__nac3_end_catch = ::eh_artiq::end_catch),
|
|
|
|
/* legacy exception symbols */
|
2018-08-10 23:24:51 +08:00
|
|
|
api!(__artiq_personality = ::eh_artiq::personality),
|
|
|
|
api!(__artiq_raise = ::eh_artiq::raise),
|
2022-01-25 15:10:09 +08:00
|
|
|
api!(__artiq_resume = ::eh_artiq::resume),
|
|
|
|
api!(__artiq_end_catch = ::eh_artiq::end_catch),
|
2016-10-17 00:24:25 +08:00
|
|
|
|
|
|
|
/* proxified syscalls */
|
|
|
|
api!(core_log),
|
|
|
|
|
2018-11-08 18:29:24 +08:00
|
|
|
api!(now = csr::rtio::NOW_HI_ADDR as *const _),
|
2016-10-17 00:24:25 +08:00
|
|
|
|
2017-02-25 22:12:58 +08:00
|
|
|
api!(rpc_send = ::rpc_send),
|
|
|
|
api!(rpc_send_async = ::rpc_send_async),
|
|
|
|
api!(rpc_recv = ::rpc_recv),
|
2016-10-17 00:24:25 +08:00
|
|
|
|
|
|
|
api!(cache_get = ::cache_get),
|
|
|
|
api!(cache_put = ::cache_put),
|
|
|
|
|
|
|
|
/* direct syscalls */
|
2016-11-22 01:09:58 +08:00
|
|
|
api!(rtio_init = ::rtio::init),
|
2018-09-15 19:11:22 +08:00
|
|
|
api!(rtio_get_destination_status = ::rtio::get_destination_status),
|
2016-11-22 01:09:58 +08:00
|
|
|
api!(rtio_get_counter = ::rtio::get_counter),
|
2016-10-17 00:24:25 +08:00
|
|
|
api!(rtio_log),
|
2016-11-22 01:09:58 +08:00
|
|
|
api!(rtio_output = ::rtio::output),
|
2016-11-24 00:35:02 +08:00
|
|
|
api!(rtio_output_wide = ::rtio::output_wide),
|
2016-11-22 01:09:58 +08:00
|
|
|
api!(rtio_input_timestamp = ::rtio::input_timestamp),
|
|
|
|
api!(rtio_input_data = ::rtio::input_data),
|
2018-12-12 04:49:42 +08:00
|
|
|
api!(rtio_input_timestamped_data = ::rtio::input_timestamped_data),
|
2016-10-17 00:24:25 +08:00
|
|
|
|
2017-02-26 10:50:20 +08:00
|
|
|
api!(dma_record_start = ::dma_record_start),
|
|
|
|
api!(dma_record_stop = ::dma_record_stop),
|
2017-03-01 05:28:27 +08:00
|
|
|
api!(dma_erase = ::dma_erase),
|
2017-04-18 16:11:14 +08:00
|
|
|
api!(dma_retrieve = ::dma_retrieve),
|
2017-03-01 05:28:27 +08:00
|
|
|
api!(dma_playback = ::dma_playback),
|
2017-02-26 10:50:20 +08:00
|
|
|
|
2023-10-05 14:39:19 +08:00
|
|
|
api!(subkernel_load_run = ::subkernel_load_run),
|
|
|
|
api!(subkernel_send_message = ::subkernel_send_message),
|
|
|
|
api!(subkernel_await_message = ::subkernel_await_message),
|
|
|
|
api!(subkernel_await_finish = ::subkernel_await_finish),
|
|
|
|
|
2017-06-18 12:45:07 +08:00
|
|
|
api!(i2c_start = ::nrt_bus::i2c::start),
|
2017-06-19 23:44:51 +08:00
|
|
|
api!(i2c_restart = ::nrt_bus::i2c::restart),
|
2017-06-18 12:45:07 +08:00
|
|
|
api!(i2c_stop = ::nrt_bus::i2c::stop),
|
|
|
|
api!(i2c_write = ::nrt_bus::i2c::write),
|
|
|
|
api!(i2c_read = ::nrt_bus::i2c::read),
|
2022-03-01 15:07:53 +08:00
|
|
|
api!(i2c_switch_select = ::nrt_bus::i2c::switch_select),
|
2017-06-18 12:45:07 +08:00
|
|
|
|
|
|
|
api!(spi_set_config = ::nrt_bus::spi::set_config),
|
|
|
|
api!(spi_write = ::nrt_bus::spi::write),
|
|
|
|
api!(spi_read = ::nrt_bus::spi::read),
|
2016-10-17 00:24:25 +08:00
|
|
|
];
|