Skip to content
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

How would we define STDIN? #37

Open
nsallis opened this issue Apr 26, 2018 · 4 comments
Open

How would we define STDIN? #37

nsallis opened this issue Apr 26, 2018 · 4 comments

Comments

@nsallis
Copy link

nsallis commented Apr 26, 2018

I'm poking around the kernel code, and wanted to try reading from stdin. Obviously I'm new to kernel programming, so excuse my lack of knowledge in this area. I think the next really useful piece of code would be to add some kind of STDIN and STDOUT that we could use to read and write. How would we go about creating an STDIN? Is there a way to pull keystrokes yet? Perhaps some C code we could utilize?

@SplittyDev
Copy link
Member

SplittyDev commented Apr 26, 2018

Hey,

thanks for your interest in our project!

What version of the kernel were you looking at?
There is the master branch and the rewrite branch.

The master branch is more advanced and comes with a simple keyboard driver.
The rewrite branch is the default one, but it's new and not very usable at the moment.

You can find the keyboard driver in the master branch here: Keyboard Driver.
The keyboard driver is pretty easy to use, and you can see it in action here: Nuumshell

However, NuummiteOS isn't really being maintained at the moment.

I started a new project called Fluorite, it's got a more stable core,
but it's still in early stages and I don't have much time to work on it.

To answer your question properly:

NuummiteOS doesn't have streams at the moment, so there's no STDIN, STDOUT, or STDERR.
We've been using the Keyboard module for reading user input, and the write macro with the ttys0 device to print to the screen, which is basically just a fancy way to access the default Terminal.

@nsallis
Copy link
Author

nsallis commented Apr 26, 2018

I think I was looking at the rewrite branch. I'll check out master when I get home. I'll check out Fluorite as well. It's really exciting to see someone building kernels in Crystal! These are a great tool for learning about kernel operations without having to know too much low-level c and asm code :)

@nsallis
Copy link
Author

nsallis commented Apr 26, 2018

tried the master branch. Looks like there's currently an error: Invalid memory access (signal 11) at address 0x28 when building with scons. Definitely looks promising and much more complete than what I was looking at yesterday though. Very nice!

The full stack trace:

scons: Reading SConscript files ...
Checking whether nasm program exists.../usr/bin/nasm
Checking whether i686-elf-gcc program exists.../home/silvertail/builds/barebones-toolchain/cross/x86_64/bin/i686-elf-gcc
Checking whether crystal program exists.../usr/bin/crystal
Checking whether grub-mkrescue program exists.../usr/bin/grub-mkrescue
ValidateArchitecture([], [])
Target: [arch: `i386`; host: `i686-elf`]
Mkdir("isodir/boot/grub")
scons: done reading SConscript files.
scons: Building targets ...
crystal build --emit=obj --cross-compile --target=i386-unknown-nuummite-none --prelude=empty -o kernel/src/kernel kernel/src/kernel.cr
Invalid memory access (signal 11) at address 0x28
[0x7f092668c616] ???
[0x7f0925e570ca] ???
[0x7f0927ad4f0b] ???
scons: *** [kernel/src/kernel] Error 11
scons: building terminated because of errors.

@SplittyDev
Copy link
Member

@silvertale uh oh, that shouldn't happen.
Maybe it breaks with one of the latest Crystal versions.
I don't remember what version we used for building, but it was probably a lot older.

Since this is happening at compilation stage, it looks like a bug with the crystal compiler, rather than a bug with our source. I have no idea what could be causing this though..

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

No branches or pull requests

2 participants