Live data from Hacker News

Booting to 'Hello Rust' on x86_64

micouy.github.io

11–20 of 37 posts

Re: Booting to 'Hello Rust' on x86_64

#11
post #4
post #2

It's my first post. I'd appreciate your feedback :)

Hey, just a couple of points 1. Don't link the bootsector and the rest of your binary together. It's more trouble than it's worth, and if you ever progress to loading off a filesystem, then you won't be linking them together anyway. 2. You can use LBA addressing in real mode with int 13h (just specify a hard disk rather than a floppy when booting): https://wiki.osdev.org/ATA_in_x86_RealMode_(BIOS)#LBA_in_Ext... 3. Yo…

I am extremely biased, but I’ve always found the rust tool chain far easier than the C ones, especially as a Windows user. No need to set up a cross compiler, given that rustc already is one, and is easy to add more targets to via the JSON target spec.

Re: Booting to 'Hello Rust' on x86_64

#13
post #4

Earlier quoted context omitted.

Hey, just a couple of points 1. Don't link the bootsector and the rest of your binary together. It's more trouble than it's worth, and if you ever progress to loading off a filesystem, then you won't be linking them together anyway. 2. You can use LBA addressing in real mode with int 13h (just specify a hard disk rather than a floppy when booting): https://wiki.osdev.org/ATA_in_x86_RealMode_(BIOS)#LBA_in_Ext... 3. Yo…

I am extremely biased, but I’ve always found the rust tool chain far easier than the C ones, especially as a Windows user. No need to set up a cross compiler, given that rustc already is one, and is easy to add more targets to via the JSON target spec.

A cross compiler is easy enough to set up with clang too (just specify the -target command line option).

I just think that when starting out in kernel development, you're likely going to be dealing with linker scripts for likely the first time. It's been a while since I tried rust for this, but C generates pretty clean object files, so the linker scripts from the OSDev wiki can often be copied verbatim.

Re: Booting to 'Hello Rust' on x86_64

#14
post #2

It's my first post. I'd appreciate your feedback :)

I think there's a typo in the final screenshot. It looks like your original code outputs "RM" (maybe "real mode" or "hello Rust" in a different language?), but the example source seems like it should output "HR."

That or I'm very confused.

Re: Booting to 'Hello Rust' on x86_64

#15
post #14
post #2

It's my first post. I'd appreciate your feedback :)

I think there's a typo in the final screenshot. It looks like your original code outputs "RM" (maybe "real mode" or "hello Rust" in a different language?), but the example source seems like it should output "HR." That or I'm very confused.

The HR is in the top left, it overwrites the pre-initialized text console.

Re: Booting to 'Hello Rust' on x86_64

#19
If anybody enjoys this and wants to take it much further, you might want to check out https://os.phil-opp.com/. This is basically a book-in-progress that shows how to build an OS in Rust OS from scratch. It shows how boot up an OS, and it goes on to show how to set up basic drivers and memory management. He does a great job of explaining each step as he goes.

(This is linked near the end of the article, but I think it's worth pointing out.)

Full disclosure: I think he uses a library I wrote to initialize the keyboard controller.

Re: Booting to 'Hello Rust' on x86_64

#20
post #13

Earlier quoted context omitted.

I am extremely biased, but I’ve always found the rust tool chain far easier than the C ones, especially as a Windows user. No need to set up a cross compiler, given that rustc already is one, and is easy to add more targets to via the JSON target spec.

A cross compiler is easy enough to set up with clang too (just specify the -target command line option). I just think that when starting out in kernel development, you're likely going to be dealing with linker scripts for likely the first time. It's been a while since I tried rust for this, but C generates pretty clean object files, so the linker scripts from the OSDev wiki can often be copied verbatim.

That’s fair re:clang, seems like gcc is used way more often in tutorials.

I don’t think that the linker script stuff ends up different but it’s been a minute since I started from scratch.

Post reply on HN