Page 1 of 3

STARTING A NEW OS (Operating System)

Posted: Mon Oct 07, 2002 3:32 am
by Berserk
I am staring a new os.

I see an os as a program (witch it is) what i want is a premade bootsector and kernel that i boot off a floppy. i want the kernel to load a program, which will be in C/C++ and from this Console app i could load other C/C++ programs. Is this possible?? i have Windows XP so please make all source code compatible with XP, DJPP, NASM, Visual C/C++ 6 or anything else which i can download for free.

Please help. and when i get the source code i need, i will build on what i have. Later i will post more questions. But for now, please help me start off.....

Re:STARTING A NEW OS (Operating System)

Posted: Mon Oct 07, 2002 4:02 am
by Pype.Clicker
what exactly do you plan to write by yourself ? virtually everyone on this forum will answer you can use his kernel (if any) or linux kernel. Where do *you* want to start (today)?

If you just plan to write a GUI system or filesystem, you can start in an emulated environment (i.e. emulating VRAM by a window, disk with a large area of memory / file in another OS, etc.) and try your algorithms . then you'll find plenty of kernel developer that will ask you to port your code to their OS (which will be easy because only the emulation layer will need changes if things are well done ;)

Re:STARTING A NEW OS (Operating System)

Posted: Mon Oct 07, 2002 6:52 am
by Berserk
i want my kernel to load a C++ program, (this will be the OS) and this program will have a menu leading to things like a calculator, text editor etc.

So i only have to program in C++. and i don't have to make a bootsector or kernel. of course i might edit the kernel and bootesector i use. I think this is the best way for me to learn, because i am a beginner in C++ & do not know ANY assembler, although i got nasm, tasm, masm and some others. But i know quite a bit of C++, and i also know basic C.

I will make my own kernel one day & a bootsector, but for now, i just want to do this (if it is possible) so is it possible for the kernel to load a C/C++ app, which i program (it will be a console app) if it is possible to do this, then i'm in luck ;)

Please help.....

Re:STARTING A NEW OS (Operating System)

Posted: Tue Oct 08, 2002 12:35 am
by Berserk
Come on people.....help out if you can..... :'(

Re:STARTING A NEW OS (Operating System)

Posted: Tue Oct 08, 2002 12:58 am
by Whatever5k
Of course a kernel can load a program, but that's not the easiest step...you don't want to do that...

You want to program a small and simple kernel, first. You want to read some documents, and then you want to start to build your kernel. You want your kernel to be loaded by GRUB and you want to set up a own GDT and IDT...

Re:STARTING A NEW OS (Operating System)

Posted: Tue Oct 08, 2002 6:55 pm
by Berserk
i wouldn't know where to start ???

Re:STARTING A NEW OS (Operating System)

Posted: Wed Oct 09, 2002 4:42 pm
by Warmaster199
If you want to make an OS, don't take our source code. We all worked very hard to get where we are... You can't just expect to have someone make a boot sector and kernel for you... It's not YOUR operating system no matter what you say then...

Windows NT, 2000, and XP are not good for developing with. First of all, if you want to test out sections of code such as make a test program to access the hard disk, then an operating system that does not restrict hardware access (like Win95, 98, ME[oh god forbid it...], 3.1, or DOS). Next, for developement software, goto djgpp.org and get DJGPP. It's the Cnu C Compiler (GCC) and LD linker. DJGPP is the DOS port. As far as I know, then is no windows version.

If possible, install Win95/98 or DOS on another partition...(not hard to do).

To make a console OS that loads other programs, you need to choose Real Mode (Very very easy - can only access 1MByte) or Protected Mode (Harder, but allows access to all mem if A20 enabled). You need to implement code to read a filesystem. To do this use Int13h(real), or make a disk driver (PMode). The file system driver will load programs into memory. I highly recommend Protected Mode developement

Re:STARTING A NEW OS (Operating System)

Posted: Thu Oct 10, 2002 2:13 am
by Pype.Clicker
Warmaster199 wrote: If you want to make an OS, don't take our source code. We all worked very hard to get where we are... You can't just expect to have someone make a boot sector and kernel for you... It's not YOUR operating system no matter what you say then...
i don't agree with you on this point. If your code is open source, this is not only because you're proud to show it but also because you agree other people to re-use it. There's no point to force everyone that whish to do an OS to start with a bootsector and a pmode switcher. There's GRUB to do that!

i personally have a multithreaded microkernel that could be ready to receive a console driver and a program-loader ...

Re:STARTING A NEW OS (Operating System)

Posted: Tue Oct 15, 2002 3:19 am
by Tim
Warmaster199 wrote:Windows NT, 2000, and XP are not good for developing with.
I don't agree with this either. I use only Windows 2000 and it's probably the best OS I've used (apart from mine, of course ;) ).
First of all, if you want to test out sections of code such as make a test program to access the hard disk, then an operating system that does not restrict hardware access (like Win95, 98, ME[oh god forbid it...], 3.1, or DOS).
It's far easier to access disks directly under NT than Win9x.
On NT, open \\.\C: etc. and read and write as normal (as long as you align accesses to sector boundaries and access one sector at a time).
On Win9x, use the BIOS emulation through the DeviceIoControl function (you have to write a special program).
DJGPP is the DOS port. As far as I know, then is no windows version.
There is; it's called Cygwin, and it's much more extensive than DJGPP. http://www.cygwin.com/

Re:STARTING A NEW OS (Operating System)

Posted: Tue Oct 15, 2002 10:44 am
by grey wolf
There is; it's called Cygwin, and it's much more extensive than DJGPP. http://www.cygwin.com/
there's another one which seems more appropriate to OS development: http://mingw.sf.net/ MinGW32 is a very slim compiler set, which does away with dependence on CygWin.dll when writing win32 apps. AFAIK, it's also a smaller download. and, if you want to work in a Unix-ish environment, a terminal emulation package is also available, called MSYS. (Minimum SYStem)

Re:STARTING A NEW OS (Operating System)

Posted: Tue Oct 15, 2002 10:50 am
by Tim
Very true. You can also compile minimal apps with Cygwin (Cygwin includes Mingw AFAIK), but if you will never use the Unix stuff, Mingw will be smaller.

Re:STARTING A NEW OS (Operating System)

Posted: Wed Oct 16, 2002 5:33 am
by Berserk
You guys don't understand. I do not have a clue about OS Dev. I do NOT know any anssembler, i do not have a clue about how it works???

SO please explain anything you post in reply to me, IN a way assuming that i DO NOT have a clue on what it means or how to do it.

And just in case your thinking "I can't be bothered with this beginner, why doesn't he just piss off, then remember when you were starting out in OS Dev, it is extremely hard to start."

Please help if you can :'(

Re:STARTING A NEW OS (Operating System)

Posted: Wed Oct 16, 2002 6:00 am
by Tim
All we've mentioned is what compiler and tools to use. There is absolutely nothing wrong without knowing where to start -- everyone started somewhere.

Browse the various OS development sites, do some searches in Google, and come back here to ask questions.

Re:STARTING A NEW OS (Operating System)

Posted: Wed Oct 16, 2002 10:44 am
by Curufir
Ok, a fairly unpopular opinion I know ;), but start by writing an assembly language bootsector. It's unlikely you'll keep it, or use it to boot anything aside from a simple test kernel, but here's the reasons to go ahead and do it anyway:

a) It gets you into the swing of researching, and interacting with <insert platform here> hardware at the operating system level.

b) Since bootsectors are pretty much the province of OS and apps that run directly on the hardware the sites you find and bookmark while researching your bootsector will most likely be OS related. No doubt most people on this board have a large set of bookmarks relating to OS design/implementation for reference, this gives you a start.

c) Since the program is written in assembly language you're forced into verifying your understanding of things like Hex numbers, how memory actually works, which instructions a program can actually use etc. Even if your main OS is developed in <Insert preferred HLL here> or some other language this knowledge of the processor will assist you. Even if your code is destined to be multi-platform there are still some basic instructions common to ALL processors (Eg all processors must have some method of moving a number of bits from one place to another place) whose operation is worthwhile understanding.

d) If you use your own bootsector you know exactly what state the computer is at when handed over to your kernel, which saves wandering around checking on what exactly an existing bootloader (Eg GRUB) is handing to you. There's nothing wrong with GRUB or any of the other bootloaders out there, it's just handy to see the chain of execution passing from your bootsector to your kernel knowing everything that's happened from bootup to kernel. GRUB can chainload the bootsector from a partition anyhow, so you're not preventing anyone multi-booting doing it this way.

e) It slows you down. An OS isn't something you should just decide to do and start coding immediately. Writing your bootsector (A fairly unimportant part of any OS) gives you some coding to work at straight away whilst figuring out the structure of your OS. Otherwise the temptation is to just dive straight in, usually resulting in having to rip everything back out again a few weeks later (Yup, that was me ;D).

Most people will disagree with that, think the FAQ actually disagrees with it too, but that's my opinion of where to start.

Curufir

Re:STARTING A NEW OS (Operating System)

Posted: Wed Oct 16, 2002 2:14 pm
by Tim
I'm normally one who says "no!!! don't write your own boot sector", but you have some very good points there.

Another one:
f) Writing a boot sector exposes just how hard writing an OS is. Imagine the most difficult program you've written so far; a boot sector is ten times that. A simple kernel is ten times a boot sector, and a full OS is tens of thousands of times harder (even the gigantic Microsoft or all the coders working on Linux haven't got it completely right).