Skip to content
New issue

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

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

Already on GitHub? # to your account

Implement a time service #318

Merged
merged 39 commits into from
Aug 1, 2019
Merged

Conversation

marysaka
Copy link
Member

No one asked for it but here it is: The Civil Time PR!

This PR adds a new process "time" in charge of handling the RTC and Timezones.
Also, The "clock" process was renamed to "wall-clock" and was updated to use the IPC interface accordingly.

PS: This PR needs #317

@marysaka marysaka requested review from roblabla and Orycterope June 12, 2019 13:45
@todo
Copy link

todo bot commented Jul 21, 2019

Implement get_rtc_event

We need CreateEvent, SignalEvent and ClearEvent syscalls before being able to implement it


SunriseOS/time/src/main.rs

Lines 125 to 135 in ee0f1e6

/// TODO: Implement get_rtc_event
/// BODY: We need CreateEvent, SignalEvent and ClearEvent syscalls before being able to implement it
pub fn get_irq_event_handle(&self) -> HandleRef<'static> {
unimplemented!()
}
/// Read from a CMOS register.
fn read_reg(&mut self, reg: u8) -> u8 {
self.command.write(reg);
self.data.read()
}


This comment was generated by todo based on a TODO comment in ee0f1e6 in #318. cc @Thog.

@todo
Copy link

todo bot commented Jul 21, 2019

Move to FileSystem interface after implementation

// TODO: Move to FileSystem interface after implementation
include!(concat!(env!("OUT_DIR"), "/timezone_data.rs"));
/// Represent the file I/O interface with tzdata.
struct TimeZoneFileSystem;
/// Represent a file inside a TimeZoneFileSystem.
struct TimeZoneFile {
/// The content of the file.
data: &'static [u8]
}


This comment was generated by todo based on a TODO comment in ee0f1e6 in #318. cc @Thog.

@todo
Copy link

todo bot commented Jul 21, 2019

Use plain

// TODO: Use plain
(tz_rules as *mut _ as *mut TimeZoneRule).as_mut().unwrap()
};
TZ_MANAGER.lock().load_timezone_rule(location, Some(tz_rules))
}
#[inline(never)]
fn to_calendar_time(&mut self, _manager: &WaitableManager, time: PosixTime, timezone_buffer: &IpcTimeZoneRule, ) -> Result<(CalendarTime, CalendarAdditionalInfo), Error> {
let timezones = unsafe {
// TODO: Use plain
(timezone_buffer as *const _ as *const TimeZoneRule).as_ref().unwrap()


This comment was generated by todo based on a TODO comment in ee0f1e6 in #318. cc @Thog.

@todo
Copy link

todo bot commented Jul 21, 2019

Use plain

// TODO: Use plain
(timezone_buffer as *const _ as *const TimeZoneRule).as_ref().unwrap()
};
let res = timezones.to_calendar_time(time);
if let Err(error) = res {
return Err(to_timezone_to_time_error(error));
}
let (calendar_time, calendar_additional_data) = calendar_to_ipc(res.unwrap());
Ok((calendar_time, calendar_additional_data, ))


This comment was generated by todo based on a TODO comment in ee0f1e6 in #318. cc @Thog.

@todo
Copy link

todo bot commented Jul 21, 2019

Use plain

// TODO: Use plain
(timezone_buffer as *const _ as *const TimeZoneRule).as_ref().unwrap()
};
let res = timezones.to_posix_time(&calendar_to_tzlib(calendar_time));
if let Err(error) = res {
return Err(to_timezone_to_time_error(error));
}
Ok(res.unwrap())
}


This comment was generated by todo based on a TODO comment in ee0f1e6 in #318. cc @Thog.

@todo
Copy link

todo bot commented Jul 21, 2019

Use get_rtc_event event handle

We need CreateEvent, SignalEvent and ClearEvent syscalls before using this.


// TODO: Use get_rtc_event event handle
// BODY: We need CreateEvent, SignalEvent and ClearEvent syscalls before using this.
syscalls::sleep_thread(1000000000).unwrap();
//syscalls::wait_synchronization(&[rtc_event.as_ref()], None).unwrap();
let timestamp = rtc.get_rtc_time().unwrap();
let res = timezone_service.to_calendar_time_with_my_rule(timestamp).unwrap();
let res_custom_timezone = timezone_service.to_calendar_time(timestamp, &rule.inner).unwrap();
let _ = writeln!(&mut logger);


This comment was generated by todo based on a TODO comment in ee0f1e6 in #318. cc @Thog.

Copy link
Member

@roblabla roblabla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few tweaks

@marysaka marysaka requested review from Orycterope and roblabla July 27, 2019 12:17
Copy link
Member

@roblabla roblabla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the couple of nits about Safety comment format, this looks good!

@marysaka marysaka merged commit 63b0b01 into sunriseos:master Aug 1, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants