What to do after Bare Bones
What to do after Bare Bones
I've used the Bare bones tutorials to make a simple OS in C++ that displays text. Where should I go from here? I probably need some memory management, I guess...
Can anybody tell me what I should do now?
Can anybody tell me what I should do now?
- JackScott
- Member
- Posts: 1036
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- Matrix: @JackScottAU:matrix.org
- GitHub: https://github.com/JackScottAU
- Contact:
Re: What to do after Bare Bones
As a rough guide, you want to do three things simultaneously, all through development:
- Implement back-end stuff (ie the kernel core)
- Implement front-end stuff (a user interface)
- Come up with a solid design, and make sure your code fits that design.
- Set up a GDT, an IDT (and a basic fault handler), and if you are going to be using it, paging.
- You need a solid way to input and output text to the kernel to debug it (printf, scanf, etc). Eventually these routines will become a user interface.
- Spend a bit of time thinking about the build environment. Creating a makefile to automate builds is a great idea, and is helpful for even the smallest kernel.
- Think about how you want the user to interact with the computer. Not on a graphical level, that is of no importance yet. But on a semantic level. Is it batch-based? Is it multi-user, multi-tasking, multi-node, super computing? These questions will guide your design.
Re: What to do after Bare Bones
Thanks for the reply, it was really helpful. I think I'll begin with the text output methods, and then do the GDT and IDT.
Re: What to do after Bare Bones
I mostly followed JamesM's code and did some things in between, here's in what order I did things, if it's of any help to you:
- Created multiboot header for GRUB and entry point.
- Wrote some C++ support code (of course this is only necessary if you're coding in C++).
- Wrote some C standard functions, like strcpy and memcpy and some other basic port I/O functions like the traditional inb and outb.
- Wrote the GDT, IDT, support for IRQ's and ISR's.
- Console text output support.
- Keyboard driver.
- Paging.
- Heap.
- Input driver, shell.
- ...
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: What to do after Bare Bones
I'm currently undertaking a massive design phase. I'm leaving the bootloader for later, though: In fact, I'm actually thinking about releasing my Os with GrUB, if anything. Why make it Multiboot, if I don't use a multiboot bootloader?
Design has so far catered for the API, and interrupts, and the "Stream" scheme I discussed earlier. I'm planning to have modular kernel that has nothing more than a tie-iin module to handle calls to the Os. Upon recieving a call, the OS translates the call down to an API function, and jumps to the code in memory that is contained in a Shared ELF module.
My implementation should go in the order of:
1. ELF Support
2. STD Lib (custom)
3. Hardware Framework (not drivers yet)
4. Kernel Loader module which loads the ELF modules into memory in a protected page range
5. Kernel Tie-In module (the actual kernel), which terminates the Kernel Loader after being called by it, and holds a symbol table and string table for all syscalls.
The 5th one means that the kernel itself is pretty much the API wrapper. I don't want to implement Software Interrupts. I think it's very impractical. I just never liked interrupts myself. Syscalls are more logical and more orderly. There's nothing wrong with me just requiring ASM developers to do an EXTERN __zos_foo line.
In fact I think they'll like it better: interrupts require you to remember different values for different registers, etc. (mov ax 4c00h)
Design has so far catered for the API, and interrupts, and the "Stream" scheme I discussed earlier. I'm planning to have modular kernel that has nothing more than a tie-iin module to handle calls to the Os. Upon recieving a call, the OS translates the call down to an API function, and jumps to the code in memory that is contained in a Shared ELF module.
My implementation should go in the order of:
1. ELF Support
2. STD Lib (custom)
3. Hardware Framework (not drivers yet)
4. Kernel Loader module which loads the ELF modules into memory in a protected page range
5. Kernel Tie-In module (the actual kernel), which terminates the Kernel Loader after being called by it, and holds a symbol table and string table for all syscalls.
The 5th one means that the kernel itself is pretty much the API wrapper. I don't want to implement Software Interrupts. I think it's very impractical. I just never liked interrupts myself. Syscalls are more logical and more orderly. There's nothing wrong with me just requiring ASM developers to do an EXTERN __zos_foo line.
In fact I think they'll like it better: interrupts require you to remember different values for different registers, etc. (mov ax 4c00h)
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Re: What to do after Bare Bones
Just a quick question...
When I declare a function in one file and define it in another, I get this error:
Anybody knows why? I do link both files together. And it only happens when declaration and definition is in different files...
When I declare a function in one file and define it in another, I get this error:
Code: Select all
main.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: What to do after Bare Bones
Use "-fno-exceptions". The Wiki has a page with gotchas like this.Code: Select all
.eh_frame
Re: What to do after Bare Bones
Thanks, it worked!pcmattman wrote:Use "-fno-exceptions". The Wiki has a page with gotchas like this.Code: Select all
.eh_frame

Re: What to do after Bare Bones
I have another problem...
I'm setting up the GDT, and I have this function in gdt.h:
and in my assembly code, it is defined as global:
(and I also got the _gdt_flush function declared ofc)
and I call the function from gtd.cpp:
But when I link it, I get this error:
I do compile with -fno-leading-underscore. What could there problem be?
I'm setting up the GDT, and I have this function in gdt.h:
Code: Select all
extern void _gdt_flush(u32int);
Code: Select all
global _gdt_flush
and I call the function from gtd.cpp:
Code: Select all
_gdt_flush((u32int)&gdt_ptr);
Code: Select all
gdt.cpp:(.text+0x174): undefined reference to `_gdt_flush(unsigned int)'
Re: What to do after Bare Bones
In C++, you must use C linkage to get simpler symbol names, try extern "C" void _gdt_flush.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
- alethiophile
- Member
- Posts: 90
- Joined: Sat May 30, 2009 10:28 am
Re: What to do after Bare Bones
I'm not sure how that would work. Wouldn't it require that all the user programs be linked in with the kernel (in effect, be kernel modules)?The 5th one means that the kernel itself is pretty much the API wrapper. I don't want to implement Software Interrupts. I think it's very impractical. I just never liked interrupts myself. Syscalls are more logical and more orderly. There's nothing wrong with me just requiring ASM developers to do an EXTERN __zos_foo line.
If I had an OS, there would be a link here.
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: What to do after Bare Bones
Yup. It would mean I'll have to develop a compiler. I'm not sure how well that will work out, though. But by the time I'm ready to add general application support, I think I'd have found some partners to work with me.
I hope.
I hope.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
Re: What to do after Bare Bones
Even from an early stage you are going to be loading files from a real or virtue disk, so you might want to get the meta data (directory, inodes etc) down onto disk. You won't be writing a file system driver just yet, but you can write some crude utilities to get your operating system files onto, and off, of the disk. After that you might want keyboard input and text output, and, since you cannot go on with the ad hoc allocation of memory forever, a memory manager.Xunil wrote:I've used the Bare bones tutorials to make a simple OS in C++ that displays text. Where should I go from here? I probably need some memory management, I guess...
Can anybody tell me what I should do now?
The continuous image of a connected set is connected.