my os design, just getting started, help please

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
anon19287473
Member
Member
Posts: 97
Joined: Thu Mar 15, 2007 2:27 pm

my os design, just getting started, help please

Post by anon19287473 »

I am just getting started w/ os development, and i have a clear idea of what i want to accomplish: a minimal self hosting os, to perform basic tasks (text editing etc.) and MAYBE a small gui in userspace later if it makes it that far. I think i sufficient programming experience; its more of a fun project, not functional.

So, getting the the point. I've started trying to write a small bootsector that will load my kernel, however, i cannot get into protected mode correctly, or jump to the loaded sector :(

I was wondering if there was some REALLY SIMPLE code, that compiles, and runs that i could take a look at as a starting point. Just a small kernel and bootsector, w/o any features.

Is protected mode needed for something as simple as i am doing? I would like to have some sort of multitasking, and im not sure if this is plausible in real mode. Real mode would let me use BIOS, which would make my job easier, however, im afraid that migrating the code to protected mode when i need to use it for features like multitasking will difficult, and would require a full rewrite.

What are your thoughts?
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

I suggest you stay with 32-bit. It might be harder, but it has a lot more benefits than real mode. As for the boot code, did you try the wiki?
C8H10N4O2 | #446691 | Trust the nodes.
anon19287473
Member
Member
Posts: 97
Joined: Thu Mar 15, 2007 2:27 pm

wiki license

Post by anon19287473 »

How is the wiki licensed (the code, + tutorial code)? gpl? free domain?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: wiki license

Post by Brynet-Inc »

anon19287473 wrote:How is the wiki licensed (the code, + tutorial code)? gpl? free domain?
I'm pretty sure all source code on the Wiki is Public Domain... unless otherwise noted?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

There is no notice about how the documentation is licensed. Officially this means 'all rights reserved' but everybody treats the wiki as being public domain, and as such a lot of people can be sued for copyright infringement :shock:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

I would go for realmode, as you already saying, if i get that far, i have post some code that may help, MiniDos is a dos clone, i made that can load and run many old dos programs including game, i written it as a realmode OS tut, it less than 2k in size.
Next is nanoos2, a realmode multi-tasking demo that fits into boot sector (512bytes), you can do MT in realmode.
Also it very easy to go from realmode to pmode do anything you want, than go back to your realmode OS's CLI.
Minidos
http://board.flatassembler.net/topic.php?t=5275&start=0
Realmode multi-tasking
http://www.dex4u.com/ASMcompo512b/nanoos2.zip
Crazed123
Member
Member
Posts: 248
Joined: Thu Oct 21, 2004 11:00 pm

Re: my os design, just getting started, help please

Post by Crazed123 »

anon19287473 wrote:I am just getting started w/ os development, and i have a clear idea of what i want to accomplish: a minimal self hosting os, to perform basic tasks (text editing etc.) and MAYBE a small gui in userspace later if it makes it that far. I think i sufficient programming experience; its more of a fun project, not functional.

So, getting the the point. I've started trying to write a small bootsector that will load my kernel, however, i cannot get into protected mode correctly, or jump to the loaded sector :(

I was wondering if there was some REALLY SIMPLE code, that compiles, and runs that i could take a look at as a starting point. Just a small kernel and bootsector, w/o any features.

Is protected mode needed for something as simple as i am doing? I would like to have some sort of multitasking, and im not sure if this is plausible in real mode. Real mode would let me use BIOS, which would make my job easier, however, im afraid that migrating the code to protected mode when i need to use it for features like multitasking will difficult, and would require a full rewrite.

What are your thoughts?
Just use GRUB, for God's sake. It loads your kernel and jumps to the kernel entry point in protected mode, with flat segmentation and no paging. You'll want to change those early on yourself, depending on what you want to accomplish, but GRUB gets the job done with no fuss.

Real mode can only address 1 MB of memory, and that using segmentation. Use protected mode with flat segmentation; it's far simpler than real mode.
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

If you are on beginning on OS developing, you have five choices:

1. Real mode. Simplicity. BIOS does all the work for you, you can access the machine ports with IN and OUT just like pmode does. In pure real mode exists a segmentation - each segment is splitted to 64K. Simple. You can use multitasking too, without worries.
They are also the limitations - you can access no more than 1 MB of RAM and BIOS is not good for every action your OS does, like RS232 COM terminal - i have this written by hand, not using BIOS (except basic text I/O routines etc.). In other words, you will have 16-bit operating system, and, dated.

2. Unreal mode, a.k.a. Big Real Mode/Flat mode/Voodoo mode.
This is a modification of real mode - you can access more than 1 MB of RAM, theoretically, to pmode segment limits - 4 GB (!). BIOS, of course, allowed. But unreal mode has some limitations too:
Accessing up to 4GB RAM is accepted only by data segment registers; CS, IP, SS,SP and other seg registers are unaffected. So the code size must be less than 64K or UPXed, just like real mode.
BIOS doesn't like that you are combining unreal mode with it - if you want to use unreal mode properly, just load the data from BIOS onto conventional memory (640K) and THEN move above 1 MB limit. (And clear the used memory in 640K limit). Multitasking is, by the way, allowed.
Using unreal mode you will get a 16-bit operating system but the OS will be not that limited as standard RM is. I use this mode too.

3. Protected mode.
Do you feel the difference between real mode? No 1 MB limit, no 64K code limits anymore, all registers are 32-bit (i think), there is a protection system and many more, like big chaos :) if you are converting your OS from real mode to pmode. You will need to learn how to live without BIOS present, also, new memory managment. You must do it all with REP MOVS,OUT,IN,MOV,etc. No INT.

4. Virtual 8086 mode, a.k.a. V8086 or vm8086 mode.
This is a sub-mode of protected mode, when you can access BIOS and real mode things. You will do all this by multitasking (task switch seg), and in protected mode. Switching and working V8086 mode isn't that easy so most programmers are here using other modes.

5. Long mode.
I dunno much of information about this mode. But I think this is the native mode of 64-bit processors.

The choice is yours. ;)
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

Multitasking can be done in real mode. I had my old 16 bit os which used to run in dosbox as a .com file (it never used any of dos interrupts). It could do multitasking nicely with different time slices for different tasks.
anon19287473
Member
Member
Posts: 97
Joined: Thu Mar 15, 2007 2:27 pm

thanks

Post by anon19287473 »

Thanks for the replies. I think I'm going to start w/ real mode, just to get the swing of things, and then rewrite the functions for pmode when i think im ready (or perhaps unreal). Thanks again.

EDIT: As for GrUB, unfortunately I'm running Windows at the moment, becuase Fedora Core crapped out on me, and I wouldn't be able to operate a linker and related tools well in such an unfamilier environment. Hopefully I'll have time to install slackware, but until then, I'm just gonna bootstrap from DOS.

If I use DOSBox for emulation, can i redefine the interrupts?
Do i lidt to load an interrupt table in real mode?

Peace.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Re: thanks

Post by Alboin »

anon19287473 wrote:Do i lidt to load an interrupt table in real mode?
You use the IVT. It's pretty simple, but I can't find my old code to remember how exactly....
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

Oh and as for using DOS for starting a system, this only works if you actually have a real DOS. In old Win9x systems you have one when you exit Windows, since those were built to start from DOS, but what NT gives you when you start a DOS program is nothing more than a VM86 monitor and some emulation to redirect BIOS requests and raw device access to NT drivers.

NTs emulation isn't the best around even if you stayed in "real mode" so don't develop an OS under this environment, because there won't be much of a guarantee it'll actually work on real machines.

So since from a modern Windows you need to use some emulator anyway, you could use something like Bochs or VMWare just as well. And if you do that, there'll be little point loading DOS inside it, instead of just working on the hardware directly (with or without BIOS).
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
anon19287473
Member
Member
Posts: 97
Joined: Thu Mar 15, 2007 2:27 pm

...

Post by anon19287473 »

Like i said, hopefully in the next week or so ill have Slackware set up, and i can use qemu, but becuase Windows doesn't have any tools to effectively mount images etc. ill just use the lame Windows emulation for now, periodically testing it on a real machine.
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: ...

Post by AndrewAPrice »

anon19287473 wrote:Like i said, hopefully in the next week or so ill have Slackware set up, and i can use qemu
qemu is on Windows
anon19287473 wrote: but becuase Windows doesn't have any tools to effectively mount images etc
try WinImage for now
My OS is Perception.
pcmattman
Member
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:

Post by pcmattman »

VFD is good if you're working with floppy images. The best part is that you can load an image into RAM which exponentially increases access speed.
Post Reply