Giter Site home page Giter Site logo

uart_16550's People

Contributors

dbeckwith avatar edigaryev avatar haraldh avatar imtsuki avatar josephlr avatar lachlansneff avatar olivercalder avatar phil-opp avatar phip1611 avatar remimimimimi avatar tsatke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

uart_16550's Issues

risc-v Support

Stumbled over this crate while writing a toy OS.

Currently only x86 is supported (via x86_64::...::Port).

Would PR with RISC-V support be accepted?

error[E0599]: no method named `init` found for unit type `()` in the current scope

I tried following the test part of the Rust OSDev Tutorial but when i try using serial_port.init(); I get this error.

error[E0599]: no method named `init` found for unit type `()` in the current scope
--> src/serial.rs:9:21
|
9 | serial_port.init();
| ^^^^ method not found in `()`

I am using uart_16550 version 0.2.0
I don't know if this is the right place.

x86_64 v0.12.3 No longer works on Nightly.

Error:

error[E0557]: feature has been removed
 --> C:\Users\chknm\.cargo\registry\src\github.com-1ecc6299db9ec823\x86_64-0.12.3\src\lib.rs:9:43
  |
9 | #![cfg_attr(feature = "const_fn", feature(const_in_array_repeat_expressions))]
  |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
  |
  = note: removed due to causing promotable bugs
error: could not compile `x86_64`

An update is required to work.

Suggestion: roll `init` into `new`, test with loopback + scratch pad register, and return `Result` instead of marking `SerialPort` as `unsafe`

I'll preface this by saying that it's very possible that I've totally misunderstood how this all works.

As I understand it from reading https://wiki.osdev.org/Serial_Ports#Port_Addresses, it's possible that not even COM1 may exist, and so it's recommended to always test a port via loopback and the "scratch pad register". There's some example code further down the page that appears to do this:

#define PORT 0x3f8          // COM1
 
static int init_serial() {
   outb(PORT + 1, 0x00);    // Disable all interrupts
   outb(PORT + 3, 0x80);    // Enable DLAB (set baud rate divisor)
   outb(PORT + 0, 0x03);    // Set divisor to 3 (lo byte) 38400 baud
   outb(PORT + 1, 0x00);    //                  (hi byte)
   outb(PORT + 3, 0x03);    // 8 bits, no parity, one stop bit
   outb(PORT + 2, 0xC7);    // Enable FIFO, clear them, with 14-byte threshold
   outb(PORT + 4, 0x0B);    // IRQs enabled, RTS/DSR set
   outb(PORT + 4, 0x1E);    // Set in loopback mode, test the serial chip
   outb(PORT + 0, 0xAE);    // Test serial chip (send byte 0xAE and check if serial returns same byte)
 
   // Check if serial is faulty (i.e: not same byte as sent)
   if(inb(PORT + 0) != 0xAE) {
      return 1;
   }
 
   // If serial is not faulty set it in normal operation mode
   // (not-loopback with IRQs enabled and OUT#1 and OUT#2 bits enabled)
   outb(PORT + 4, 0x0F);
   return 0;
}

I was thinking it might be nice if this crate, rather than marking SerialPort::new as unsafe, instead rolled init into new (I don't see that there would ever be a reason not to call init?), and that it does the loopback + scratch pad register test. new could then return a Result depending on the outcome.

Ways to disable backspace char escaping?

In one of my own projects, I had a case where binary data is transmitted through UART. But later I discovered that the code in this crate silently escapes the backspace character \x08 to \x08\x20\x08, which causes data corruption in my code:

match data {
    8 | 0x7F => {
        wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
        self.data.write(8);
        wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
        self.data.write(b' ');
        wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
        self.data.write(8)
    }
    [...]
}

Maybe this behavior should be clearly described in the documentation, and another method which disables escaping should be added?

Remove `nightly`/`stable` features when Rust 1.61 is released

The const_ptr_offset feature was stabilized in rust-lang/rust#93957. We removed that feature gate from this crate in #22. Right now, we still need the stable and nightly features of this crate to make MmioSerialPort::new a const function on nightly, but on Rust 1.61 this should be supported on stable as well. So we should remove the crate features when 1.61 is released.

use of unstable library feature 'renamed_spin_loop'

I have tried to add this crate to an empty project with rust nightly.
When trying to build compilation fails with error:
error[E0658]: use of unstable library feature 'renamed_spin_loop'
It also recommends to add the crate attribute #![feature(renamed_spin_loop)]
However, adding this to my crate does nothing.

I have then tried to clone this crate and build it directly.
This causes the same error.
However compilation is successfull after adding the crate attribute to the top of uart_16550's lib.rs.

Is this an error on my end?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.