forked from M-Labs/artiq
1
0
Fork 0

firmware: use Rust naming conventions for enum variants.

This commit is contained in:
whitequark 2017-02-25 22:34:11 +00:00
parent 2a81819eb0
commit a07bd918f0
4 changed files with 51 additions and 51 deletions

View File

@ -219,21 +219,21 @@ extern fn cache_put(key: CSlice<u8>, list: CSlice<i32>) {
}
extern fn i2c_start(busno: i32) {
send(&I2CStartRequest { busno: busno as u8 });
send(&I2cStartRequest { busno: busno as u8 });
}
extern fn i2c_stop(busno: i32) {
send(&I2CStopRequest { busno: busno as u8 });
send(&I2cStopRequest { busno: busno as u8 });
}
extern fn i2c_write(busno: i32, data: i32) -> bool {
send(&I2CWriteRequest { busno: busno as u8, data: data as u8 });
recv!(&I2CWriteReply { ack } => ack)
send(&I2cWriteRequest { busno: busno as u8, data: data as u8 });
recv!(&I2cWriteReply { ack } => ack)
}
extern fn i2c_read(busno: i32, ack: bool) -> i32 {
send(&I2CReadRequest { busno: busno as u8, ack: ack });
recv!(&I2CReadReply { data } => data) as i32
send(&I2cReadRequest { busno: busno as u8, ack: ack });
recv!(&I2cReadReply { data } => data) as i32
}
unsafe fn attribute_writeback(typeinfo: *const ()) {

View File

@ -13,7 +13,7 @@ const RTIO_I_STATUS_EMPTY: u32 = 1;
const RTIO_I_STATUS_OVERFLOW: u32 = 2;
pub extern fn init() {
send(&RTIOInitRequest);
send(&RtioInitRequest);
}
pub extern fn get_counter() -> i64 {
@ -190,31 +190,31 @@ pub mod drtio_dbg {
pub struct ChannelState(i32, i64);
pub extern fn get_channel_state(channel: i32) -> ChannelState {
send(&DRTIOChannelStateRequest { channel: channel as u32 });
recv!(&DRTIOChannelStateReply { fifo_space, last_timestamp }
send(&DrtioChannelStateRequest { channel: channel as u32 });
recv!(&DrtioChannelStateReply { fifo_space, last_timestamp }
=> ChannelState(fifo_space as i32, last_timestamp as i64))
}
pub extern fn reset_channel_state(channel: i32) {
send(&DRTIOResetChannelStateRequest { channel: channel as u32 })
send(&DrtioResetChannelStateRequest { channel: channel as u32 })
}
pub extern fn get_fifo_space(channel: i32) {
send(&DRTIOGetFIFOSpaceRequest { channel: channel as u32 })
send(&DrtioGetFifoSpaceRequest { channel: channel as u32 })
}
#[repr(C)]
pub struct PacketCounts(i32, i32);
pub extern fn get_packet_counts() -> PacketCounts {
send(&DRTIOPacketCountRequest);
recv!(&DRTIOPacketCountReply { tx_cnt, rx_cnt }
send(&DrtioPacketCountRequest);
recv!(&DrtioPacketCountReply { tx_cnt, rx_cnt }
=> PacketCounts(tx_cnt as i32, rx_cnt as i32))
}
pub extern fn get_fifo_space_req_count() -> i32 {
send(&DRTIOFIFOSpaceReqCountRequest);
recv!(&DRTIOFIFOSpaceReqCountReply { cnt }
send(&DrtioFifoSpaceReqCountRequest);
recv!(&DrtioFifoSpaceReqCountReply { cnt }
=> cnt as i32)
}
}

View File

@ -27,16 +27,16 @@ pub enum Message<'a> {
NowInitReply(u64),
NowSave(u64),
RTIOInitRequest,
RtioInitRequest,
DRTIOChannelStateRequest { channel: u32 },
DRTIOChannelStateReply { fifo_space: u16, last_timestamp: u64 },
DRTIOResetChannelStateRequest { channel: u32 },
DRTIOGetFIFOSpaceRequest { channel: u32 },
DRTIOPacketCountRequest,
DRTIOPacketCountReply { tx_cnt: u32, rx_cnt: u32 },
DRTIOFIFOSpaceReqCountRequest,
DRTIOFIFOSpaceReqCountReply { cnt: u32 },
DrtioChannelStateRequest { channel: u32 },
DrtioChannelStateReply { fifo_space: u16, last_timestamp: u64 },
DrtioResetChannelStateRequest { channel: u32 },
DrtioGetFifoSpaceRequest { channel: u32 },
DrtioPacketCountRequest,
DrtioPacketCountReply { tx_cnt: u32, rx_cnt: u32 },
DrtioFifoSpaceReqCountRequest,
DrtioFifoSpaceReqCountReply { cnt: u32 },
RunFinished,
RunException {
@ -63,12 +63,12 @@ pub enum Message<'a> {
CachePutRequest { key: &'a str, value: &'a [i32] },
CachePutReply { succeeded: bool },
I2CStartRequest { busno: u8 },
I2CStopRequest { busno: u8 },
I2CWriteRequest { busno: u8, data: u8 },
I2CWriteReply { ack: bool },
I2CReadRequest { busno: u8, ack: bool },
I2CReadReply { data: u8 },
I2cStartRequest { busno: u8 },
I2cStopRequest { busno: u8 },
I2cWriteRequest { busno: u8, data: u8 },
I2cWriteReply { ack: bool },
I2cReadRequest { busno: u8, ack: bool },
I2cReadReply { data: u8 },
Log(fmt::Arguments<'a>),
LogSlice(&'a str)

View File

@ -388,32 +388,32 @@ fn process_kern_message(io: &Io,
kern_acknowledge()
}
&kern::RTIOInitRequest => {
&kern::RtioInitRequest => {
info!("resetting RTIO");
rtio_mgt::init_core();
kern_acknowledge()
}
&kern::DRTIOChannelStateRequest { channel } => {
&kern::DrtioChannelStateRequest { channel } => {
let (fifo_space, last_timestamp) = rtio_mgt::drtio_dbg::get_channel_state(channel);
kern_send(io, &kern::DRTIOChannelStateReply { fifo_space: fifo_space,
kern_send(io, &kern::DrtioChannelStateReply { fifo_space: fifo_space,
last_timestamp: last_timestamp })
}
&kern::DRTIOResetChannelStateRequest { channel } => {
&kern::DrtioResetChannelStateRequest { channel } => {
rtio_mgt::drtio_dbg::reset_channel_state(channel);
kern_acknowledge()
}
&kern::DRTIOGetFIFOSpaceRequest { channel } => {
&kern::DrtioGetFifoSpaceRequest { channel } => {
rtio_mgt::drtio_dbg::get_fifo_space(channel);
kern_acknowledge()
}
&kern::DRTIOPacketCountRequest => {
&kern::DrtioPacketCountRequest => {
let (tx_cnt, rx_cnt) = rtio_mgt::drtio_dbg::get_packet_counts();
kern_send(io, &kern::DRTIOPacketCountReply { tx_cnt: tx_cnt, rx_cnt: rx_cnt })
kern_send(io, &kern::DrtioPacketCountReply { tx_cnt: tx_cnt, rx_cnt: rx_cnt })
}
&kern::DRTIOFIFOSpaceReqCountRequest => {
&kern::DrtioFifoSpaceReqCountRequest => {
let cnt = rtio_mgt::drtio_dbg::get_fifo_space_req_count();
kern_send(io, &kern::DRTIOFIFOSpaceReqCountReply { cnt: cnt })
kern_send(io, &kern::DrtioFifoSpaceReqCountReply { cnt: cnt })
}
&kern::WatchdogSetRequest { ms } => {
@ -454,41 +454,41 @@ fn process_kern_message(io: &Io,
}
#[cfg(has_i2c)]
&kern::I2CStartRequest { busno } => {
&kern::I2cStartRequest { busno } => {
board::i2c::start(busno);
kern_acknowledge()
}
#[cfg(has_i2c)]
&kern::I2CStopRequest { busno } => {
&kern::I2cStopRequest { busno } => {
board::i2c::stop(busno);
kern_acknowledge()
}
#[cfg(has_i2c)]
&kern::I2CWriteRequest { busno, data } => {
&kern::I2cWriteRequest { busno, data } => {
let ack = board::i2c::write(busno, data);
kern_send(io, &kern::I2CWriteReply { ack: ack })
kern_send(io, &kern::I2cWriteReply { ack: ack })
}
#[cfg(has_i2c)]
&kern::I2CReadRequest { busno, ack } => {
&kern::I2cReadRequest { busno, ack } => {
let data = board::i2c::read(busno, ack);
kern_send(io, &kern::I2CReadReply { data: data })
kern_send(io, &kern::I2cReadReply { data: data })
}
#[cfg(not(has_i2c))]
&kern::I2CStartRequest { .. } => {
&kern::I2cStartRequest { .. } => {
kern_acknowledge()
}
#[cfg(not(has_i2c))]
&kern::I2CStopRequest { .. } => {
&kern::I2cStopRequest { .. } => {
kern_acknowledge()
}
#[cfg(not(has_i2c))]
&kern::I2CWriteRequest { .. } => {
kern_send(io, &kern::I2CWriteReply { ack: false })
&kern::I2cWriteRequest { .. } => {
kern_send(io, &kern::I2cWriteReply { ack: false })
}
#[cfg(not(has_i2c))]
&kern::I2CReadRequest { .. } => {
kern_send(io, &kern::I2CReadReply { data: 0xff })
&kern::I2cReadRequest { .. } => {
kern_send(io, &kern::I2cReadReply { data: 0xff })
}
&kern::RunFinished => {