-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Comments for "https://os.phil-opp.com/vga-text-mode/" #405
Comments
Excellent Tutorial series.. As a Rust newbie its a great resource to learn about new things. |
Wow this was all sorts of fun... thanks for putting this together. I've both learned a lot about Rust (in a far gentler fashion than normal) and learned what's involved in building an OS. I look forward to future articles! By the way, for whatever reason, when I call my implementation of
|
@Danrien I had the same problem - make sure your |
Ah thanks, that did the trick!
|
@gurpreetshanky @Danrien Thanks a lot! Glad that you find the posts informative :). @Danrien @edupc I just pushed #417 to avoid this confusion. Thanks for the feedback! |
I think it should be useful to add an empty branch to println! macro. (Standard macro has this branch).
|
I don't think printing strings byte by byte is good in this case. The characters on screen are encoded in Code Page 437, which is identical to UTF-8 (which Rust strings use) only for a certain range of characters. The
I added Unicode to Code Page 437 translation to my implementation, but that's a lot of code. |
At first I got this error:
The reason is obvious: I forgot to add So I wonder: What are const functions exactly for and why do we need to use a const function here instead of a normal function? I found the (RFC)[https://github.com/rust-lang/rfcs/blob/master/text/0911-const-fn.md] on const functions, but that doesn't make me understand the concept behind const functions. |
@arjanvaneersel A |
@arjanvaneersel I removed the |
Thank you! This is a lot of fun :). Typical beginner mistakes, that compile, but lead to blank screen:
Some notes from a beginner perspective:
Very kool stuff! If someone else likes to use cargo-make, like I do, here is a usable [tasks.build]
description = "Build no-std rust binary. Combine it with a preconfigured bootloader from rust-osdev."
command = "bootimage"
args = ["build"]
[tasks.boot]
description="Boot the kernel in a qemu virtual machine."
command="bootimage"
args=["run"] # build 'bootimage.bin' via the bootimage tool
$ cargo make build
# run 'bootimage.bin' in qemu
$ cargo make boot |
@bugabinga Thanks for your comment!
You mean
Basically it's a way of transforming an integer to a memory reference. In C, the equivalent would be the cast
The problem is that the fmt::Write trait is defined that way that |
Hey, thanks for this excellent blog series. I noticed while following along a small adjustment that could be made. Perhaps it was done like this for clarity, but I think the blog series assumes a familiarity with Rust. let color_code = self.color_code;
self.buffer.chars[row][col] = ScreenChar {
ascii_character: byte,
- color_code: color_code,
+ color_code,
};
self.column_position += 1; I was also prompted by the latest nightly compiler to add match byte {
0x20..0x7e | b'\n' => self.write_byte(byte),
_ => self.write_byte(0xfe),
} I recommend changing it to look like this, so that - 0x20..0x7e
+ 0x20..=0x7e |
@c-edw Thanks, I agree with both suggestions! Could you open pull request that applies these changes to both src/vga_buffer.rs and blog/content/second-edition/posts/03-vga-text-buffer/index.md? |
First of all, thanks for the great tutorial! I was always scared by how the things work on low-level (just to read all this code without proper pre-study turns out to be rather difficult), and here's the possibility to get this way of thinking ready. I was a bit confused by this:
(emphasis mine). I was thinking for a moment that a bit later we'll run into some issue due to the |
Thanks, that's great to hear!
Good catch! Fixed in 1b52ff1. |
Really enjoying these tutorials, thanks for writing them! |
@amatho Yes, the layout of the
struct Buffer {
chars: [[Volatile<ScreenChar>; BUFFER_WIDTH]; BUFFER_HEIGHT],
} The struct ColorCode(u8);
struct ScreenChar {
ascii_character: u8,
color_code: ColorCode,
} The OSDev Wiki tutorial for printing to screen explains that in Text Mode the VGA buffer accepts a series of two byte inputs, the ascii character and an attribute. In our case, the attribute is the |
With latest rust nightly, we can ditch the |
@phil-opp BTW I still see some remaining instances of The ones like #[macro_use]
extern crate blog_os; can be replaced with e.g. use blog_os::{print, println, serial_print, serial_println}; // depending on which macros we use The one in #[macro_use]
pub mod vga_buffer; can be replaced in the modules that need it with (and this one confused me at first, but exported macros are moved to the crate root): use crate::{print, println}; And there's also still a couple of references to The need to write something like use blog_os::{print, println, serial_print, serial_println}; can be mildly annoying. You might consider the idea of adding something like // src/macros.rs
pub use crate::{print, println, serial_print, serial_println}; because then clients can write use blog_os::macros::*; in order to pick up all macros. |
@kballard I tried to remove What am I doing wrong? |
@phil-opp AIUI macros defined within the current crate don't participate in the new style of import resolution. Within the crate, they still behave the same as they always did. Which is to say, a macro isn't visible outside of its defining module unless the module itself is annotated with https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=802c9be1f5ec0961272c9ebdff32bd89 demonstrates the |
@DeathBySpork A common approach for this is to embed some kind of special escape code into the string to change the color. The most common standard for this are the ANSI escape codes. Using such escape codes, you can then build an abstraction such as the |
Ah thank you so much! I will work on embedding this into my code |
Any way to print to the top of the screen? |
@codic12 See some other comments in this issue, for example the most recent by @drzewiec: #405 (comment) |
@phil-opp awesome, thanks! |
I just started leaning rust but i understand everything! You are the best!!!! |
@ishlun Great to hear that, thanks for your comment! |
This is an awesome tutorial! I'm having trouble getting volatile working. cargo run is saying that it is an unresolved import and that the crate may be missing. It is present in my Cargo.toml though... |
Figured it out by taking a look at someone's github of their tutorial work. I was missing |
|
No, I'm missing that config key. Did I miss that in the tutorial? |
|
Might be worth to update the guide as the latest
Might be worth adding the E.g.
|
@martin-bucinskas The I'm currently working on a completely new version of this post, which will use a pixel-based framebuffer instead of the VGA text mode. I will use the new |
Sorry for this dumb question... // But what does this mean ?
0xb8000 as *mut Buffer It make sense that |
This is casting the address |
|
Compiling error! |
Did you add the |
Fixed. Just add a line |
Please modify the article to fix the issue.
|
@ssrlive The article already says that. |
Is there a setting to change/reason why all the test executables get recompiled every time I run |
@chrisbroome The |
I don't really understand why Writer doesn't own the Buffer, but only takes a mutable reference. |
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
This is a general purpose comment thread for the “VGA Text Mode” post.
The text was updated successfully, but these errors were encountered: