Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update a653rs #13

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ panic_handler = [ "dep:log" ]

[dependencies]
cty = "*"
a653rs = { version = "0.3", features = ["strum"] }
a653rs = { version = "0.5", features = ["strum", "bindings"] }
log = { version = "0.4", optional = true }
10 changes: 5 additions & 5 deletions src/apex/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::XngHypervisor;
use crate::bindings::*;

impl ApexErrorP4 for XngHypervisor {
fn report_application_message<L: Locked>(message: &[ApexByte]) -> Result<(), ErrorReturnCode> {
fn report_application_message(message: &[ApexByte]) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
REPORT_APPLICATION_MESSAGE(
Expand All @@ -18,7 +18,7 @@ impl ApexErrorP4 for XngHypervisor {
}
}

fn raise_application_error<L: Locked>(
fn raise_application_error(
error_code: ErrorCode,
message: &[ApexByte],
) -> Result<(), ErrorReturnCode> {
Expand All @@ -36,7 +36,7 @@ impl ApexErrorP4 for XngHypervisor {
}

impl ApexErrorP1 for XngHypervisor {
fn create_error_handler<L: Locked>(
fn create_error_handler(
entry_point: SystemAddress,
stack_size: StackSize,
) -> Result<(), ErrorReturnCode> {
Expand All @@ -51,11 +51,11 @@ impl ApexErrorP1 for XngHypervisor {
}
}

fn get_error_status<L: Locked>() -> Result<ErrorStatus, ErrorReturnCode> {
fn get_error_status() -> Result<ErrorStatus, ErrorReturnCode> {
todo!()
}

fn configure_error_handler<L: Locked>(
fn configure_error_handler(
_concurrency_control: ErrorHandlerConcurrencyControl,
_processor_core_id: ProcessorCoreId,
) -> Result<(), ErrorReturnCode> {
Expand Down
6 changes: 2 additions & 4 deletions src/apex/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::XngHypervisor;
use crate::bindings::*;

impl ApexPartitionP4 for XngHypervisor {
fn get_partition_status<L: a653rs::Locked>() -> ApexPartitionStatus {
fn get_partition_status() -> ApexPartitionStatus {
let mut status = MaybeUninit::uninit();
unsafe {
GET_PARTITION_STATUS(status.as_mut_ptr(), MaybeUninit::uninit().as_mut_ptr());
Expand All @@ -28,9 +28,7 @@ impl ApexPartitionP4 for XngHypervisor {
}
}

fn set_partition_mode<L: a653rs::Locked>(
operating_mode: OperatingMode,
) -> Result<(), ErrorReturnCode> {
fn set_partition_mode(operating_mode: OperatingMode) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
SET_PARTITION_MODE(
Expand Down
41 changes: 17 additions & 24 deletions src/apex/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use super::XngHypervisor;
use crate::bindings::*;

impl ApexProcessP4 for XngHypervisor {
fn create_process<L: Locked>(
attributes: &ApexProcessAttribute,
) -> Result<ProcessId, ErrorReturnCode> {
fn create_process(attributes: &ApexProcessAttribute) -> Result<ProcessId, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut process_id = MaybeUninit::uninit();
// Ensure that the last two characters of the name are not used.
Expand Down Expand Up @@ -40,7 +38,7 @@ impl ApexProcessP4 for XngHypervisor {
}
}

fn start<L: Locked>(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
fn start(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
START(process_id as PROCESS_ID_TYPE, return_code.as_mut_ptr());
Expand All @@ -50,10 +48,7 @@ impl ApexProcessP4 for XngHypervisor {
}

impl ApexProcessP1 for XngHypervisor {
fn set_priority<L: Locked>(
process_id: ProcessId,
priority: Priority,
) -> Result<(), ErrorReturnCode> {
fn set_priority(process_id: ProcessId, priority: Priority) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
SET_PRIORITY(
Expand All @@ -65,45 +60,45 @@ impl ApexProcessP1 for XngHypervisor {
}
}

fn suspend_self<L: Locked>(time_out: ApexSystemTime) -> Result<(), ErrorReturnCode> {
fn suspend_self(time_out: ApexSystemTime) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
SUSPEND_SELF(time_out, return_code.as_mut_ptr());
ErrorReturnCode::from(return_code.assume_init())
}
}

fn suspend<L: Locked>(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
fn suspend(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
SUSPEND(process_id as PROCESS_ID_TYPE, return_code.as_mut_ptr());
ErrorReturnCode::from(return_code.assume_init())
}
}

fn resume<L: Locked>(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
fn resume(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
RESUME(process_id as PROCESS_ID_TYPE, return_code.as_mut_ptr());
ErrorReturnCode::from(return_code.assume_init())
}
}

fn stop_self<L: Locked>() {
fn stop_self() {
unsafe {
STOP_SELF();
}
}

fn stop<L: Locked>(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
fn stop(process_id: ProcessId) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
STOP(process_id as PROCESS_ID_TYPE, return_code.as_mut_ptr());
ErrorReturnCode::from(return_code.assume_init())
}
}

fn delayed_start<L: Locked>(
fn delayed_start(
process_id: ProcessId,
delay_time: ApexSystemTime,
) -> Result<(), ErrorReturnCode> {
Expand All @@ -118,7 +113,7 @@ impl ApexProcessP1 for XngHypervisor {
}
}

fn lock_preemption<L: Locked>() -> Result<LockLevel, ErrorReturnCode> {
fn lock_preemption() -> Result<LockLevel, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut lock_level = MaybeUninit::uninit();
unsafe {
Expand All @@ -128,7 +123,7 @@ impl ApexProcessP1 for XngHypervisor {
}
}

fn unlock_preemption<L: Locked>() -> Result<LockLevel, ErrorReturnCode> {
fn unlock_preemption() -> Result<LockLevel, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut lock_level = MaybeUninit::uninit();
unsafe {
Expand All @@ -138,7 +133,7 @@ impl ApexProcessP1 for XngHypervisor {
}
}

fn get_my_id<L: Locked>() -> Result<ProcessId, ErrorReturnCode> {
fn get_my_id() -> Result<ProcessId, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut process_id = MaybeUninit::uninit();
unsafe {
Expand All @@ -148,7 +143,7 @@ impl ApexProcessP1 for XngHypervisor {
}
}

fn get_process_id<L: Locked>(process_name: ProcessName) -> Result<ProcessId, ErrorReturnCode> {
fn get_process_id(process_name: ProcessName) -> Result<ProcessId, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut process_id = MaybeUninit::uninit();
unsafe {
Expand All @@ -162,9 +157,7 @@ impl ApexProcessP1 for XngHypervisor {
}
}

fn get_process_status<L: Locked>(
process_id: ProcessId,
) -> Result<ApexProcessStatus, ErrorReturnCode> {
fn get_process_status(process_id: ProcessId) -> Result<ApexProcessStatus, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut status = MaybeUninit::uninit();
unsafe {
Expand Down Expand Up @@ -197,7 +190,7 @@ impl ApexProcessP1 for XngHypervisor {
}
}

fn initialize_process_core_affinity<L: Locked>(
fn initialize_process_core_affinity(
_process_id: ProcessId,
_processor_core_id: ProcessorCoreId,
) -> Result<(), ErrorReturnCode> {
Expand All @@ -216,12 +209,12 @@ impl ApexProcessP1 for XngHypervisor {
Err(ErrorReturnCode::NotAvailable)
}

fn get_my_processor_core_id<L: Locked>() -> ProcessorCoreId {
fn get_my_processor_core_id() -> ProcessorCoreId {
// TODO check whether this is good
0
}

fn get_my_index<L: Locked>() -> Result<ProcessIndex, ErrorReturnCode> {
fn get_my_index() -> Result<ProcessIndex, ErrorReturnCode> {
// TODO check whether this is good
/*
let mut return_code = MaybeUninit::uninit();
Expand Down
28 changes: 17 additions & 11 deletions src/apex/queuing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::XngHypervisor;
use crate::bindings::*;

impl ApexQueuingPortP4 for XngHypervisor {
fn create_queuing_port<L: Locked>(
fn create_queuing_port(
queuing_port_name: QueuingPortName,
max_message_size: MessageSize,
max_nb_message: MessageRange,
Expand All @@ -30,7 +30,7 @@ impl ApexQueuingPortP4 for XngHypervisor {
}
}

fn send_queuing_message<L: Locked>(
fn send_queuing_message(
queuing_port_id: QueuingPortId,
message: &[ApexByte],
time_out: ApexSystemTime,
Expand All @@ -48,11 +48,11 @@ impl ApexQueuingPortP4 for XngHypervisor {
}
}

unsafe fn receive_queuing_message<L: Locked>(
unsafe fn receive_queuing_message(
queuing_port_id: QueuingPortId,
time_out: ApexSystemTime,
message: &mut [ApexByte],
) -> Result<MessageSize, ErrorReturnCode> {
) -> Result<(MessageSize, QueueOverflow), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut msg_len = MaybeUninit::uninit();
RECEIVE_QUEUING_MESSAGE(
Expand All @@ -62,11 +62,19 @@ impl ApexQueuingPortP4 for XngHypervisor {
msg_len.as_mut_ptr(),
return_code.as_mut_ptr(),
);
ErrorReturnCode::from(return_code.assume_init())?;
Ok(msg_len.assume_init() as MessageSize)
let error_code = ErrorReturnCode::from(return_code.assume_init());
let mut overflowed = false;
if let Err(e) = error_code {
if ErrorReturnCode::InvalidConfig == e {
overflowed = true;
} else {
error_code?;
}
};
Ok((msg_len.assume_init() as MessageSize, overflowed))
}

fn get_queuing_port_status<L: Locked>(
fn get_queuing_port_status(
queuing_port_id: QueuingPortId,
) -> Result<QueuingPortStatus, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
Expand All @@ -89,9 +97,7 @@ impl ApexQueuingPortP4 for XngHypervisor {
}
}

fn clear_queuing_port<L: Locked>(
queuing_port_id: QueuingPortId,
) -> Result<(), ErrorReturnCode> {
fn clear_queuing_port(queuing_port_id: QueuingPortId) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
CLEAR_QUEUING_PORT(
Expand All @@ -104,7 +110,7 @@ impl ApexQueuingPortP4 for XngHypervisor {
}

impl ApexQueuingPortP1 for XngHypervisor {
fn get_queuing_port_id<L: Locked>(
fn get_queuing_port_id(
queuing_port_name: QueuingPortName,
) -> Result<QueuingPortId, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
Expand Down
10 changes: 5 additions & 5 deletions src/apex/sampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::XngHypervisor;
use crate::bindings::*;

impl ApexSamplingPortP4 for XngHypervisor {
fn create_sampling_port<L: Locked>(
fn create_sampling_port(
sampling_port_name: SamplingPortName,
max_message_size: MessageSize,
port_direction: PortDirection,
Expand Down Expand Up @@ -34,7 +34,7 @@ impl ApexSamplingPortP4 for XngHypervisor {
}
}

fn write_sampling_message<L: Locked>(
fn write_sampling_message(
sampling_port_id: SamplingPortId,
message: &[ApexByte],
) -> Result<(), ErrorReturnCode> {
Expand All @@ -50,7 +50,7 @@ impl ApexSamplingPortP4 for XngHypervisor {
}
}

unsafe fn read_sampling_message<L: Locked>(
unsafe fn read_sampling_message(
sampling_port_id: SamplingPortId,
message: &mut [ApexByte],
) -> Result<(Validity, MessageSize), ErrorReturnCode> {
Expand All @@ -73,7 +73,7 @@ impl ApexSamplingPortP4 for XngHypervisor {
}

impl ApexSamplingPortP1 for XngHypervisor {
fn get_sampling_port_id<L: Locked>(
fn get_sampling_port_id(
sampling_port_name: SamplingPortName,
) -> Result<SamplingPortId, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
Expand All @@ -89,7 +89,7 @@ impl ApexSamplingPortP1 for XngHypervisor {
}
}

fn get_sampling_port_status<L: Locked>(
fn get_sampling_port_status(
sampling_port_id: SamplingPortId,
) -> Result<ApexSamplingPortStatus, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
Expand Down
8 changes: 3 additions & 5 deletions src/apex/schedules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use super::XngHypervisor;
use crate::bindings::*;

impl ApexScheduleP2 for XngHypervisor {
fn set_module_schedule<L: Locked>(schedule_id: ScheduleId) -> Result<(), ErrorReturnCode> {
fn set_module_schedule(schedule_id: ScheduleId) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
SET_MODULE_SCHEDULE(schedule_id as SCHEDULE_ID_TYPE, return_code.as_mut_ptr());
ErrorReturnCode::from(return_code.assume_init())
}
}

fn get_module_schedule_status<L: Locked>() -> Result<ApexScheduleStatus, ErrorReturnCode> {
fn get_module_schedule_status() -> Result<ApexScheduleStatus, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut status = MaybeUninit::uninit();
unsafe {
Expand All @@ -29,9 +29,7 @@ impl ApexScheduleP2 for XngHypervisor {
}
}

fn get_module_schedule_id<L: Locked>(
schedule_name: ScheduleName,
) -> Result<ScheduleId, ErrorReturnCode> {
fn get_module_schedule_id(schedule_name: ScheduleName) -> Result<ScheduleId, ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
let mut schedule_id = MaybeUninit::uninit();
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/apex/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ impl ApexTimeP4 for XngHypervisor {
}

impl ApexTimeP1 for XngHypervisor {
fn timed_wait<L: Locked>(delay_time: ApexSystemTime) -> Result<(), ErrorReturnCode> {
fn timed_wait(delay_time: ApexSystemTime) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
TIMED_WAIT(delay_time, return_code.as_mut_ptr());
ErrorReturnCode::from(return_code.assume_init())
}
}

fn replenish<L: Locked>(budget_time: ApexSystemTime) -> Result<(), ErrorReturnCode> {
fn replenish(budget_time: ApexSystemTime) -> Result<(), ErrorReturnCode> {
let mut return_code = MaybeUninit::uninit();
unsafe {
REPLENISH(budget_time, return_code.as_mut_ptr());
Expand Down
Loading