OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 12:02 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How to continue after completing most "easy" os tutorials?
PostPosted: Mon Jan 18, 2021 6:19 pm 
Offline

Joined: Fri Jan 15, 2021 8:12 pm
Posts: 1
Hi there! So I started tinkering with osdev a little while ago and it is one of those things that fascinated me. I decided to loosely follow a couple tutorials to learn a bit more and ended up, more or less with a similar result to https://github.com/cfenollosa/os-tutorial. I was looking into different project structures (specifically the meaty skeleton one here on the wiki) to expand my OS into something usable and easy to add to, however I quickly found myself overwhelmed with the sheer amount of different source code structures and build formats as well as most examples (I have come across) using grub as a bootloader. My main question is, what is the best way I can structure my OS if I want to roll my own bootloader?

I am sorry if this question seems kind of dumb with all of the information out there but with osdev being so open ended and without only one way to do it, I am at a loss for what I should do next so if someone could at least point me in the right direction, that would be great.


Top
 Profile  
 
 Post subject: Re: How to continue after completing most "easy" os tutorial
PostPosted: Mon Jan 18, 2021 7:52 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5145
Bootloader development has very little to do with OS development. Are you really sure you want to write your own bootloader?

The structure of your OS doesn't depend on the bootloader unless you're planning something exotic. Perhaps the biggest difference is that your own bootloader can do things that GRUB can't, like switching to long mode.


Top
 Profile  
 
 Post subject: Re: How to continue after completing most "easy" os tutorial
PostPosted: Mon Jan 18, 2021 11:18 pm 
Offline
Member
Member

Joined: Mon Dec 07, 2020 8:09 am
Posts: 212
TheRealJoe24 wrote:
expand my OS into something usable


This is a slippery and loooooog slope, might want to consider clearly define non-goals first.

For example 'replacing grub' is a non-goal for me as I've always been amazed by its capability, and convenience.

IMHO it is more like a real OS than many 'OS projects' out there. As you might know, grub has a shell that can display files in partitions that have filesystems ranging from ZFS to EXT4, with FUSE support on top of all that. I doubt more than a tiny percentage of 'hobby OSes' can do this.

Also, any bit of convenience felt by the user for a piece of program at such a low level and early stage likely amounts to great deal of incontinence for the developer.

TheRealJoe24 wrote:
source code structures, build formats, ....... I am at a loss for what I should do next


This is a super hard problem since it isn't about how to put source files into folders, but more about how to design the whole architecture. All the modules, interfaces and the general hierarchy that puts all of them into the right places.

I'm not qualified to answer this in this context, but the typically right way to start is to spend a long time writing design documents, and be prepared that way more than a long time will be spent on deleting (as the needed changes can be so extensive there's little to salvage from the previous revisions) and re-writing the design documents down the road. This is all before the first line of code should be written.

:lol: Or don't be so serious with a hobby and have some fun while learning what you can, just take the https://wiki.osdev.org/Cowboy_Coder route and pick whatever you are interested and start coding.

TheRealJoe24 wrote:
build formats


This is "easy", does the thing take more than a coffee break's time to build so you are annoyed? If not just use whatever lousy build system/method that builds the thing for now unless your aspiration is build engineering.


Top
 Profile  
 
 Post subject: Re: How to continue after completing most "easy" os tutorial
PostPosted: Tue Jan 19, 2021 3:49 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4597
Location: Chichester, UK
TheRealJoe24 wrote:
My main question is, what is the best way I can structure my OS if I want to roll my own bootloader?
There is no "best way". It's all a matter of personal choice.

But I strongly agree with others that it is more interesting to get on with developing the OS itself rather than re-inventing the bootloader. Is there something special that you want it to do that GRUB doesn't provide?


Top
 Profile  
 
 Post subject: Re: How to continue after completing most "easy" os tutorial
PostPosted: Wed Jan 27, 2021 2:24 pm 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 817
Location: Hyperspace
TheRealJoe24 wrote:
what is the best way I can structure my OS

As others have said, it depends what kind of OS you want. :) To look at this from a bit of a higher perspective, do you want to make a POSIX-compatible OS? This will make it easy to port a lot of software to your OS, but restricts your choices and makes your OS similar to hundreds of other OSs. (You may find the deeper differences between POSIX implementations interesting anyway.) If you don't, then you have more choices. What sort of IO interfaces do you want? Unix-like synchronous files or async i/o? Both? That's pretty fundamental. What about message passing? If it uses the same interfaces as IO, it will add flexibility to your system and might save you some work. How will service discovery work? That's less important, it could be omitted for a toy, retro, or perhaps embedded OS. I didn't consider the scheduler, if you even want a multitasking OS. ;)

I thought there was a wiki page covering this in more detail, but I can't find it now.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
 Post subject: Re: How to continue after completing most "easy" os tutorial
PostPosted: Wed Jan 27, 2021 8:41 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
Hi,

I wanted to address the original question on source code structure with respect to custom boot loaders by sharing what we do. I would like to emphasize however that there is no one single structure; this is designed this way for reasons that is specific to our goals and ideas. In fact, before deciding on a structure, you should decide on your build system and how you plan to automate the building of the image file (microkernel vs monolithic, auto-build out of date dependencies, architecture or firmware specific code, etc.) The system you use will have an effect on how you structure and plan the code base.
Code:
/src/env  -- global makefiles and environment
/src/sdktools -- plugins etc
/src/os/inc -- public definitions
/src/os/crt -- c runtime
/src/os/util -- utilities
/src/os/sdk -- tool chain
/src/os/ddk -- driver framework
/src/os/nexec -- executive (kernel)
/src/os/nboot -- boot loader   ]
/src/os/nbl -- boot libraries  ] loader
/src/os/bootsect -- boot code  ]
/src/os/nstart -- startup      ]
/src/os/lib -- libraries
/src/os/slib -- shared libraries
The basic idea is that the boot library defines a set of device objects and drivers and provides runtime support for the main boot loader program. To build with EFI, just link with the EFI boot library. To build with BIOS, link with the BIOS boot library and prepend nstart to the file. The firmware-specific library defines a common set of driver objects that the run time or program calls indirectly. The loader has very little effect on code structure -- except perhaps how you handle architecture specific code and firmware specific code with respect to the build system. We put architecture specific code in folders and there is one boot library for EFI and another for BIOS in "nbl" and other libraries for boot drivers and runtime support. The makefile system allows us to do something like "nbuild ARCH=x86 FW=BIOS" to target it.

Just have fun and work on what you are interested in. You will probably even see yourself changing the structure and basic designs a lot early on as the system gets more larger. Study existing operating systems and experiment with what interests you. My first boot loaders long ago were in assembly language, then I experimented with writing them in C and adopted it from there. This is what it should be about: experimenting and researching: if you want to try something, go for it. You should know though that writing good boot loaders can take a really long time as they can become as complex as small operating systems themselves -- so only do so if you are wanting it -- you don't have to, after all.

If this is the first time into OS development without guides or tutorials though, it can be a good idea to stick with something existing for now. If you have good need or are more confident later on you can always replace the loader (if you stick with something like GrUB for now, in theory it can be replaced with any multi-boot compliant loader.)

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject: Re: How to continue after completing most "easy" os tutorial
PostPosted: Thu Jan 28, 2021 5:40 am 
Offline
Member
Member

Joined: Fri Nov 22, 2019 5:46 am
Posts: 590
TheRealJoe24 wrote:
Hi there! So I started tinkering with osdev a little while ago and it is one of those things that fascinated me. I decided to loosely follow a couple tutorials to learn a bit more and ended up, more or less with a similar result to https://github.com/cfenollosa/os-tutorial. I was looking into different project structures (specifically the meaty skeleton one here on the wiki) to expand my OS into something usable and easy to add to, however I quickly found myself overwhelmed with the sheer amount of different source code structures and build formats as well as most examples (I have come across) using grub as a bootloader. My main question is, what is the best way I can structure my OS if I want to roll my own bootloader?

I am sorry if this question seems kind of dumb with all of the information out there but with osdev being so open ended and without only one way to do it, I am at a loss for what I should do next so if someone could at least point me in the right direction, that would be great.

I think that is a good time to buy a book about OS design, for example "Operating system design and implementation" by Tanenbaum.
And I think it is cool to develop your own bootloader, but that means you are kind of standing still, you don't move on to more advanced and exciting stuff.
(You didn't name your target architecture, so I guess it is x86 protected mode with legacy BIOS.)

Greetings
Peter


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 215 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group