I've learned some C. Now how would I make a kernel?
-
- Member
- Posts: 27
- Joined: Thu Oct 13, 2016 2:07 pm
I've learned some C. Now how would I make a kernel?
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.
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?
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.andrewthompson555 wrote:is it OK to include Java and GCC in my OS?
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.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
Compiler Development Forum
Re: I've learned some C. Now how would I make a kernel?
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!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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: I've learned some C. Now how would I make a 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.octacone wrote:Bootloader development can take months even years. Why not spend that time and do some C kernel.
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, ...)
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: I've learned some C. Now how would I make a kernel?
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.omarrx024 wrote: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.octacone wrote:Bootloader development can take months even years. Why not spend that time and do some C kernel.
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, ...)
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: I've learned some C. Now how would I make a kernel?
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.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.
Perhaps we can get back on topic though...
You know your OS is advanced when you stop using the Intel programming guide as a reference.
- crunch
- Member
- Posts: 81
- Joined: Wed Aug 31, 2016 9:53 pm
- Libera.chat IRC: crunch
- Location: San Diego, CA
Re: I've learned some C. Now how would I make a kernel?
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.octacone wrote: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!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.
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.
Some of my open-source projects:
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C
Re: I've learned some C. Now how would I make a kernel?
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.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
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.)
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.With qemu -kernel, using GRUB isn't even necessary.
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.Having a basic grasp of assembly language should be a pre-requisite to writing an operating system.
Re: I've learned some C. Now how would I make a kernel?
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.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, and is a fantastic learning experience. With qemu -kernel, using GRUB isn't even necessary.octacone wrote: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!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.
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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
- crunch
- Member
- Posts: 81
- Joined: Wed Aug 31, 2016 9:53 pm
- Libera.chat IRC: crunch
- Location: San Diego, CA
Re: I've learned some C. Now how would I make a kernel?
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.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.)
I used qemu -kernel until I wrote my bootloader just fine.
Some of my open-source projects:
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C
- dchapiesky
- Member
- Posts: 204
- Joined: Sun Dec 25, 2016 1:54 am
- Libera.chat IRC: dchapiesky
Re: I've learned some C. Now how would I make a kernel?
1) How would I make a kernel?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.
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
Plagiarize. Plagiarize. Let not one line escape thine eyes...
Re: I've learned some C. Now how would I make a kernel?
How to make a kernel - read here.
Learn to read.