Page 1 of 1

I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 11:43 am
by andrewthompson555
I've learned many things with C. I know what to do with bootloaders in Assembly. How would I make a kernel? Do I need to enter any additional programming to do with video memory? I'm confused.

By the way, is it OK to include Java and GCC in my OS? Would it be illegal and could I end up in court? I don't want strange answers. I just want a simple answer.

Thank you.

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 12:01 pm
by matt11235
andrewthompson555 wrote:is it OK to include Java and GCC in my OS?
Read the licenses of each project. AFAIK it is okay to include GCC with your OS so long as you also release the source to go with it.
With Java, it depends on the implementation you use. It should be okay to use OpenJDK but I think that Oracle JDK has some proprietary components.

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 12:12 pm
by Octacone
andrewthompson555 wrote:I've learned many things with C. I know what to do with bootloaders in Assembly. How would I make a kernel? Do I need to enter any additional programming to do with video memory? I'm confused.

By the way, is it OK to include Java and GCC in my OS? Would it be illegal and could I end up in court? I don't want strange answers. I just want a simple answer.

Thank you.
Slow it down big boy. You won't be there in a long time. Writing an operating system in Java is a big big task that requires a huge amount of knowledge. Even if you want to code your OS in C you still have to do 9000 other small things in order to do anything Java related, GCC is not much different. I would suggest you to use GRUB if you want to head right into the kernel development. If you really know how to handle a bootloader then writing a C kernel shouldn't be a problem. Bootloader development can take months even years. Why not spend that time and do some C kernel. Video memory is really easy to understand and use. Writing an operating system means writing everything from scratch -> you need to have a base (functional kernel) that your GCC is supposed to run on top of. I think as long as you keep your project personal there shouldn't be any law related problems. Releasing an operating system is a whole different story that is way more different than doing it as a hobbyist. Cheers!

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 12:23 pm
by BrightLight
octacone wrote:Bootloader development can take months even years. Why not spend that time and do some C kernel.
I disagree. Boot loader development in assembly, some experience in real mode mode with the BIOS and switching between protected mode and real mode is a valuable experience that many, including myself, learn a lot from. My first "OSes" were 16-bit and built on top of the BIOS, and I taught myself a lot of theory and some practice from there.
Although in your first statement, you are right; a fully functional and flexible boot loader (such as GRUB) is very much a small OS on its own and implements much of the OS theory (memory management, file system, modules loading/management, ...)

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 12:37 pm
by Octacone
omarrx024 wrote:
octacone wrote:Bootloader development can take months even years. Why not spend that time and do some C kernel.
I disagree. Boot loader development in assembly, some experience in real mode mode with the BIOS and switching between protected mode and real mode is a valuable experience that many, including myself, learn a lot from. My first "OSes" were 16-bit and built on top of the BIOS, and I taught myself a lot of theory and some practice from there.
Although in your first statement, you are right; a fully functional and flexible boot loader (such as GRUB) is very much a small OS on its own and implements much of the OS theory (memory management, file system, modules loading/management, ...)
Yes, it is a great experience. You can learn a lot from it. I agree on that. But you need to have some previous assembly experience. You can't expect to code a decent bootloader without understanding the basic concepts.

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 12:48 pm
by BrightLight
octacone wrote:Yes, it is a great experience. You can learn a lot from it. I agree on that. But you need to have some previous assembly experience. You can't expect to code a decent bootloader without understanding the basic concepts.
TBH, unlike many others here, I taught myself assembly language in OSDev. I taught myself assembly language at the same time I was learning about BIOS interrupts and basic OS theory.
Perhaps we can get back on topic though...

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 12:58 pm
by crunch
octacone wrote:
andrewthompson555 wrote:I've learned many things with C. I know what to do with bootloaders in Assembly. How would I make a kernel? Do I need to enter any additional programming to do with video memory? I'm confused.

By the way, is it OK to include Java and GCC in my OS? Would it be illegal and could I end up in court? I don't want strange answers. I just want a simple answer.

Thank you.
Slow it down big boy. You won't be there in a long time. I would suggest you to use GRUB if you want to head right into the kernel development. If you really know how to handle a bootloader then writing a C kernel shouldn't be a problem. Bootloader development can take months even years. Why not spend that time and do some C kernel. Video memory is really easy to understand and use. Writing an operating system means writing everything from scratch -> you need to have a base (functional kernel) that your GCC is supposed to run on top of. I think as long as you keep your project personal there shouldn't be any law related problems. Releasing an operating system is a whole different story that is way more different than doing it as a hobbyist. Cheers!
Just because you refuse to learn assembly doesn't mean writing a bootloader is hard. In fact, it's rather quite easy if you read the wiki. It realistically shouldn't take more than a couple days, and is a fantastic learning experience. With qemu -kernel, using GRUB isn't even necessary.
Having a basic grasp of assembly language should be a pre-requisite to writing an operating system.

I don't think andrew was asking about writing his OS in Java, but including it to run from userland (if I understood correctly). In which case, the "slow it down" comment is warranted.
Andrew- I'd focus on reading the wiki and making sure you really understand the concepts there. Then write the basic core of your operating system, and write it well - before moving on to the more complex concepts.

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 1:20 pm
by Kevin
crunch wrote:Just because you refuse to learn assembly doesn't mean writing a bootloader is hard. In fact, it's rather quite easy if you read the wiki. It realistically shouldn't take more than a couple days
If it takes a beginner just a couple days, it's not worth being called a bootloader, but just a quick and dirty hack. Yes, everyone can hack together some boot code that loads a kernel from sector 2, but that's not a bootloader, it's crap that nobody should be using. It influences the kernel in negative ways because it doesn't support a proper binary format, it doesn't support a filesystem, it probably even breaks down when the kernel binary exceeds some hardcoded size, and of course it contains bugs.

Of course, it's also a question of focus: If your goal is to write a bootloader, by all means go ahead, but please plan with a few months at least and make a proper bootloader. If, however, your goal is writing an OS, then maybe you'd better use your time for, you know, writing an OS and just use some existing bootloader that does the job. (There is also the case where there is no existing bootloader that does the job for your specific OS, so you need to write one. This is rare, though, and certainly doesn't apply to beginners.)
With qemu -kernel, using GRUB isn't even necessary.
Yes, the point isn't that you should be using GRUB, but that you shouldn't waste your time on a hackish "bootloader" when your actual goal is an OS. Whether you use GRUB, syslinux, qemu -kernel or something else doesn't really matter.
Having a basic grasp of assembly language should be a pre-requisite to writing an operating system.
If you can learn it while writing some boot code, you can also learn it while writing a kernel. I recommend a little practice in a hosted environment, but people manage to do without it all the time.

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 1:28 pm
by Octacone
crunch wrote:
octacone wrote:
andrewthompson555 wrote:I've learned many things with C. I know what to do with bootloaders in Assembly. How would I make a kernel? Do I need to enter any additional programming to do with video memory? I'm confused.

By the way, is it OK to include Java and GCC in my OS? Would it be illegal and could I end up in court? I don't want strange answers. I just want a simple answer.

Thank you.
Slow it down big boy. You won't be there in a long time. I would suggest you to use GRUB if you want to head right into the kernel development. If you really know how to handle a bootloader then writing a C kernel shouldn't be a problem. Bootloader development can take months even years. Why not spend that time and do some C kernel. Video memory is really easy to understand and use. Writing an operating system means writing everything from scratch -> you need to have a base (functional kernel) that your GCC is supposed to run on top of. I think as long as you keep your project personal there shouldn't be any law related problems. Releasing an operating system is a whole different story that is way more different than doing it as a hobbyist. Cheers!
Just because you refuse to learn assembly doesn't mean writing a bootloader is hard. In fact, it's rather quite easy if you read the wiki. It realistically shouldn't take more than a couple days, and is a fantastic learning experience. With qemu -kernel, using GRUB isn't even necessary.
Having a basic grasp of assembly language should be a pre-requisite to writing an operating system.

I don't think andrew was asking about writing his OS in Java, but including it to run from userland (if I understood correctly). In which case, the "slow it down" comment is warranted.
Andrew- I'd focus on reading the wiki and making sure you really understand the concepts there. Then write the basic core of your operating system, and write it well - before moving on to the more complex concepts.
It is not about learning assembly not at all. It is about knowing what to do with it. I know assembly quite well but that really doesn't help me. I didn't make this up, many many people said what I am saying. Writing a bootloader is a huge task that can take a lot of your time. Knowing assembly != knowing how to write a bootloader. Also I couldn't find any in-depth data about bootloaders. There are many many hello world bootloader tutorials that are pointless. If you want to write a bootloader from scratch you MUST be really familiar with how the boot process and kernel loading work together.

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 1:31 pm
by crunch
Kevin wrote: If it takes a beginner just a couple days, it's not worth being called a bootloader, but just a quick and dirty hack. Yes, everyone can hack together some boot code that loads a kernel from sector 2, but that's not a bootloader, it's crap that nobody should be using. It influences the kernel in negative ways because it doesn't support a proper binary format, it doesn't support a filesystem, it probably even breaks down when the kernel binary exceeds some hardcoded size, and of course it contains bugs.

Of course, it's also a question of focus: If your goal is to write a bootloader, by all means go ahead, but please plan with a few months at least and make a proper bootloader. If, however, your goal is writing an OS, then maybe you'd better use your time for, you know, writing an OS and just use some existing bootloader that does the job. (There is also the case where there is no existing bootloader that does the job for your specific OS, so you need to write one. This is rare, though, and certainly doesn't apply to beginners.)
Sure, I agree. I was really addressing octacone with that statement. I'm not recommending writing a full-fledged bootloader for a novice. I should have prefaced with: "If you have already written (some semblance of) an operating system", writing a bootloader is quite easy. I.e. you already understand how to load and execute ELF files, you have some kind of filesystem knowledge, etc etc. That should not require "months" - if you're starting with a base of knowledge. Of course, it would take months if you came in a complete novice.

I used qemu -kernel until I wrote my bootloader just fine.

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 2:14 pm
by dchapiesky
andrewthompson555 wrote:I've learned many things with C. I know what to do with bootloaders in Assembly. How would I make a kernel? Do I need to enter any additional programming to do with video memory? I'm confused.

By the way, is it OK to include Java and GCC in my OS? Would it be illegal and could I end up in court? I don't want strange answers. I just want a simple answer.

Thank you.
1) How would I make a kernel?

A kernel enumerates and controls all the resources of the physical computer... An OS is a collection of software that makes use of what the kernel provides... Decide what you want to do in as simple a form as possible and then get to it. Your primary concern is the kernel portion. Your secondary concern is the supporting OS code. Your guide is what you wrote down as "What I want to do"

2) Do I need to enter any additional programming to do with video memory?

Yes if you want stuff to appear on the screen. No if you know about serial ports and/or networks...

3) is it OK to include Java and GCC in my OS?

Java and GCC both are technically applications which would run on top of your OS software stack which make use of the kernel you wrote which was loaded by the loader you wrote.

4) is it OK to include Java and GCC in my OS?

Technical mumbo jumbo follows: If you actually meant Java Bytecode or GCC object file/executable file outputs of the Java or GCC compilers then the answer is Yes and Yes - the former being dependent upon your ability to make a JVM function inside a kernel with probably little or no filesystem suppport (Java beats the hell out the filesystem for loading) - the later is what happens with any kernel/os stack - you use GCC to compile your code and object code comes out the other end.

5) is it OK to include Java and GCC in my OS?

Legal mumbo jumbo - addressed in other posts but I will add: you can find other licenses for JVM and even C compilers (clang/llvm come to mind and they have a JVM bonded to llvm - all permissive licenses) If you have the least smattering of an inkling of an idea that somehow someway someone somewhere might imagine the oddest notion of possibly offering you cash for the the diamond you eventually wrought from blood, sweat, tears, and at least 3 dead mice, then stay the hell away from the GPL and LGPL

6) I don't want strange answers....

Since strangeness is subjective I cannot gauge your reaction so I can only say that spending the next 52 weeks studying the OSDev wiki and forum posts will bring you up to speed on just how freakin' strange OS development is...

7) I just want a simple answer.

Ok.

Cheers

Re: I've learned some C. Now how would I make a kernel?

Posted: Fri Jan 06, 2017 4:27 pm
by dozniak
How to make a kernel - read here.