Skip to content

Implement copy for volatile? #9

Description

@BuggStream

So I have been following the 'Writing an OS in Rust' guide. And while I was experimenting and reading through the code I noticed that Copy hasn't been implemented for Volatile.

This could be useful when writing code:

impl<T: Copy> Copy for Volatile<T> {
    // Empty.
}

After this the new line function for the VGA buffer can be implemented as follows:

fn new_line(&mut self) {
    &self.buffer.chars.copy_within(1.., 0);
        
    self.clear_row(BUFFER_HEIGHT - 1);
    self.column_position = 0;
}

Now I did notice that copy_within uses the normal ptr::copy instead of volatile_copy_memory. Is this a potential issue?

Anyway let me know if you want to add this, if so I will make a short MR.

Activity

  1. videah commented on Nov 8, 2019

    @videah

    See #6 (comment) and #5 (comment) as to why this hasn't been done yet.

    I would like to see VolatileArray be implemented, is that possible now? @phil-opp

  2. BuggStream commented on Nov 9, 2019

    @BuggStream
    Author

    See #6 (comment) and #5 (comment) as to why this hasn't been done yet.

    I would like to see VolatileArray be implemented, is that possible now? @phil-opp

    Oh it seems like I forgot to look at the MRs to check if this was already asked. Sorry about that. Anyway thanks for your answer.

    I'd also be interested to know if something like VolatileArray could be useful.

  3. phil-opp commented on Nov 26, 2019

    @phil-opp
    Member

    I think it should be possible to implement VolatileArray and VolatileSlice types now that we have basic support for const generics in Rust, but I'm not 100% sure.

  4. phil-opp commented on Jun 24, 2023

    @phil-opp
    Member

    The new v0.5.0 release includes both a VolatilePtr type that implements Copy and (unstable) methods for accessing slices and arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions