-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add basic userspace #228
Add basic userspace #228
Conversation
To produce the binary of an example program to run in userspace, first create a file bits 64
start:
mov rax, 0x0
mov rdi, 0x3ff0000000000000
mov rsi, 0x0
mov rdx, 0x0
int 0x80
jmp start Then run the following command: nasm -f bin prog.asm -o prog.bin && xxd -i prog.bin And you will get this byte array: 0xb8, 0x00, 0x00, 0x00, 0x00, 0x48, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xf0, 0x3f, 0xbe, 0x00, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00,
0x00, 0xcd, 0x80, 0xeb, 0xe3 In MOROS this program will call |
We can use |
The debug outputs from the above screenshot are now replaced by a program This should suffice to show communication between userspace and the kernel. |
The address from a user code segment just needed to be translated by the kernel to fix the exception above. |
Next step will be to add an ELF loader. |
This PR is an experiment into implementing a userspace mode.
I started from this article: https://nfil.dev/kernel/rust/coding/rust-kernel-to-userspace-and-back/
And the OSDev wiki as usual: https://wiki.osdev.org/Getting_to_Ring_3
Then I found this gem: https://github.com/WartaPoirier-corp/ananos/blob/dev/docs/notes/context-switch.md
Along with the associated code in the repo that is a perfect starting point to get an idea of how to get something working.