Page 1 of 1

New Here+First try in OSdev+[Some basic Questions]

Posted: Mon Jan 31, 2005 9:30 am
by 0mni
Hello People . i am 0mni from Germany

I am very new to the OSDEV Topic and to this forum either.
well the couse i was brought here, you geussed right :),i am about to start designing/coding my own OS.
and thats the point where i need some help / answers.

I never ever tried this before so i am not experienced
at all with OSdev, still i have some expreience with C++
several years, but only coding for Windows 98/2k/xp
so maybe some questions will sound a little sily so pls
bear with it.

The main reason is for fun, i dont expect to make profit in the first place
but it would be nice to control a box completly with selfwritten software =).

The basic idea is to make a OS with good points from Win / nix and some ideas of my self,
I know its a long way to somewhat usable like os, well i read its
a long way i dont know realy.

Wel i know most ppl dont want to read that much but i couldnt get it eny shorter :(
------------------------------------------------------------------
The Plan:

-The Os should be AS MODULAR AS POSSIBLE, so i can switch parts easyly.
wel i know the big problem is if you define the interfaces and forget
something and after some time you think you'll need this feature
very much, you need to (in some cases)revrite the basic interface functions and
maybe some modules will get unusable, maybe somone can point me to
a good paper for Modular Osdev or something like this.

-it should go like this i think.

1. I write(or even get a prevritten ,cos i dont know Assambler at all-.-) smal bootloader
#There is no way to write this thing in C/c++ so i am out of luck building one for my self
#pls some sugestion if it change and somhow its possible in C/C++

2. Write a Minimal working Kernel+Keyboard/screen support

3. write a compiler like gcc for the os to start developing on the actual os
# i think i read in the past that somhow gcc can be ported to eny os and also
# there should be free Standard lib C availible out there
# because its also a little hard try to write a compiler i think.
# if i mistaken pls correct.

4. Concentrate on a Basic shell

5. Make a GUI modul like X-windows or something
# well here i am not very knowlegeble because
# i dont realy know how linux / nix Os and Xwin (X11)
# works together but like i think nix in his basic form
# is only a shel with multitasking and things, and Xwin
# is something like a plugin, but still i am not shure on it.

*It Should not be a copy of Win/nix in enyway its just i dislike some things in nix and some in win
and would like to do it better. some koncepts i think can't be done in another way so i have to copy
imitate this things like say a desktop envirnoment or other things :)

to be continued

Re:New Here+First try in OSdev+[Some basic Questions]

Posted: Mon Jan 31, 2005 9:31 am
by 0mni
Part 2:

now that you have basic Idea what i am about to do
there are some questions that came up my mind
as i was reading the osfaq on mega-tokyo.

1. Are there some routines that cant be written in a random way
i mean something that is the same on all Os for example
let say like creating a basic window in WinXP/98/2k
you fill a windowclass and call the basic 3 ROutines
and as far as i know the only way to do it you cant tweak it
realy to make the creation faster and you cant do much wrong
you do all the same thing all the time. so if some things in the os
dev are like this i could just take the concept instead of
figuring it all on my own :| ?

2. Is the Bootloader and IRQ the only things needed to be in plain ASM ?


3. I think about implementing something like scripting
like shellscripts in nix so it can make life easyier
but duno if i should creat new language or take
existing one, and i am not shure what should be done
to make this scripting engine usable on my os ?

4. Is there enywhere something like a Uberkoncept for
Os's, like the neumann thing for Computers?

5. is it possible to write only in C++, without c, aside from ASM ?

6. I dont know realy if this is true, but Is there a standard
interface for all Hardware in the same category, i mean
you can setup basic videomodes like vga or something on all
possible Graficcards without drivers, (if i am correct)
is there also a thing like this for NIC's Monitors and so on ?

7. I would also like to read about how to creat a system for manage
reusable funktions like DLL in windows but maybe in another way
bc in win they load sooo meny of them, it takes a half of performance
and memory lol.


8. Should i create a new file system or just use existing
ones. I thought about tkaing a free one and extendin it or cut something
out for my needs but i dont know of such basic and simple FS. if you know some
let me now please .


---------
BTW: I think as its my first OS ever it wont be very good or usable but i
would learn much of things so maybe something i say maybe stupid
from a view of a os developer who has a goal of writing a fully
usable os.
---------

9. Are there eny papres for the diffrent os design patterns like
fuly modular or dos style or something, i dont know realy if its
right way to ask or maybe its not clear at all what i mean.

It would also be nice to see your way how you did your first os
i mean the order and steps in which u created/coded it.

Its about all i want to ask now, i am in the planning of it so no actual
coding or learning at all right now.

i think i will be on this forum much of the time if my motivation dont cease

.SORRYS.
And i am very sorry about the size of this post. hopefuly you read it
if there are eny sugestions on the things i wrote pls tell me them.

Also i am sory for the bad english, but i am not a native english speaker
so pls bear with me

Thanks In advance
---------------------


0mni.

Re:New Here+First try in OSdev+[Some basic Questions]

Posted: Mon Jan 31, 2005 12:11 pm
by bubach
You can start out with reading the FAQ (click on the top banner), and reading tutorials from osdever.net

Re:New Here+First try in OSdev+[Some basic Questions]

Posted: Mon Jan 31, 2005 3:29 pm
by Ytinasni
1. I dont understand what you mean here.
2. The only large things, yes. you'll need a few small ones (reading/writing control registers etc...)
3. IIRC, scripts in *nix are done by the shell, so think about this when you get there....
4 not really.
5. Yes, but most people dont, and it can be hard to find help if you come across problems with your compiler/code....
6. Again, I dont understand what you mean here.
7. IIRC, *nix has 'shared objects' which are like DLLs, and probably used just as much. Also, loading many DLLs has no effect on system performance........
8. Whichever you think you will learn more from :)
9. There are some, but i dont know where to find them. Some people like to divide kernels into microkernels(very modular, very minimalistic kernel) and monolithic kernels(not so modular[or not modularat all], lots of services provided by the kernel)

The order i have/am creating my kernel:
have done:
1. Create a very basic kernel, as a base to be added onto.
2. Look at the various ways of loading the kernel into memory

am doing:
3. Using (1), create 'kernels' that use one or more of the features offered by the cpu, with the least possible other code in the kernel
4. Combine all of my kernels from (3) together, to form a single, full-featured kernel.

will do:
5. Create an OS, by taking a specific set of features from (3) and combining it and using it as the kernel, then adding user-application support, etc...

Re:New Here+First try in OSdev+[Some basic Questions]

Posted: Mon Jan 31, 2005 7:30 pm
by mystran
1. When you talk to hardware, you can basicly do it in one way only, although sometimes small variations are possible. Rest of the stuff you can mostly do whatever way you want. Just remember that if you need something, you must write it yourself.

2. You don't necessarily need to write a bootload (I would not do bother). You can use GRUB instead. But yes, in a sense you are correct. You need assembler every time you are entering or leaving the kernel. This means boot, interrupts, exceptions and system calls. Ignoring boot, most of the time all you need to do is save (or restore) some registers, and possibly setup a stack.

You also need macros for IO port access and some other special instructions, but those can be done with oneliners of inline assembler.

3. You've got plenty of time to think about this while you are working with your kernel. The shell in Unix is just a regular program. You need a working kernel first. :)

4. Well, I haven't seen such. But OS basicly does three things: it allows several applications to share the same hardware, it provides applications with unified, high-level access to all kinds of different device, and keeps the applications from hurting each other. Additionally, it might also try to keep users from hurting each other. You can think of OS as an abstraction layer:

one real computer -> many virtual computers
complex real devices -> simple virtual devices

5. You can write in C++ if you want. You need to write your own support for things like new/delete, exceptions and RTTI if you want to use them, but AFAIK you don't need to use any C; just expect some of your C++ to look very C-like.

6. Yes, it's called BIOS and it's useless in protected mode. So the answer is really "no." There are some standards, but not all hardware follows them, and sometimes several standards are incompatible with each other. In short, it's a mess. Expect to write a lot of drivers, or to support just a little hardware.

Some devices are better than others. Virtually all (regular, non USB) keyboards are essentially the same. Virtual all PS/2 mouse work more or less the same way. USB devices also have standards, and HID devices (keyboards and mice) and many storage devices (like those USB memory-cards) actually seem to follow them.

For graphics there is VESA which usually works, but you need to do almost everything in software, so it's awfully slow and you want a real driver instead if possible.

7. Google for "dynamic linking" or "shared libraries" or something like that.

8. Hmm, I was actually thinking of writing a document about the basic structure of a filesystem. But for now, Google for "ext2 structure". That's the traditional filesystem of Linux and the basic structure is quite simple and easy to understand. You might also want to support FAT at some point, but do yourself a favour and base your design on something more modern.

9. Google for "microkernels" should get you started on the possible architectures. There are also tons of papers for more specific parts like inter-process communication, memory management or scheduling. If you want research papers, try scholar.google.com.

Re:New Here+First try in OSdev+[Some basic Questions]

Posted: Thu Feb 03, 2005 5:58 pm
by 0mni
That was a load on info BIG thx (i realized that this things are for much much later but still i will remember them :) ).

ok I am a bit further now.
I found some tutorials on writing Kernel in C/C++.
As of my understanding now, the questions i asked
are faar faaar away in the future :-X, as i read the
answers i was like *BANG* you are absolutley newbie.
and someone like me need tutorial like OS dev for Stupid
ppl. but its getting better now :).

I now also better understand your answers, Read today about 200 pages tutorials.

1st. About Bootloading with the grub, as i understand correctly i need aditional assambler code for it :S maybe there is a way like a ready bootsector/loader for this thing so i dont need to write the grub code. or kernel setup for grub ?

2nd. As i understand correctly there is nothing to do in realmode, i mean some tutorials say just get a bootloader which switches in pmode and opens the A0 Gate or something like this. Or is there some setups that need to be done in the real mode ?

3rd and last. Is there a way to stick with Visual (studio)C 6.0
and not change to gcc on cygwin or DJGPP, i know that the VC compiler and linke only do 32bit code and link it into PE format , i mean i would change to ld for the linking or maybe its possible to exchange the VC linker with the ld so its acceced through VC :s
and maybe a way to get nasm to work with vc for inline asm
or real asm files. Because imho the VC6.0 is the best IDE ever done, i cant find a better and dont like to code in notepad.

its just to good even better then the damn vc7.net but only my opinion :)
---------------------

Well i thought about how the codin proces would look for the first few steps again now:

1. The ASM file for calling main and Allowing Global variables / Objects.

2. Create Basic Video function so i can put out some text/ response or eny other things

3. Create malloc / free

4. More advanced functions like printf with variable list and things

5 (its actualy a question) Do i need some other esential function like free/malloc to start coding on advanced things like paging, because i cant think of more then this two for now.?

oh well BTW, i think it will be a microkernel where only paging, task management/scheduling and stuff like this will be... which are the esentials that must be directly in the kernel and cant be elsewhere?


Enyway very big thanks for taking the time to answer my newbiesh qeustions :).

0mni.


[EDIT]
I came across some topics here, sayin about,You switch in Pmode with grub & load kernel then switch back to real mode
and switch video settings?

Cant you just switch resolutions/video settings out of pmode ?

[/EDIT]

[EDIT2]
uhm one more thing i read ppl first get a function working, called like kprint(), whats its purpose, is it k-for Kernel and what would be the diffrence to normal printf() or something.
[/EDIT2]
thx in advance

Re:New Here+First try in OSdev+[Some basic Questions]

Posted: Fri Feb 04, 2005 4:34 am
by Pype.Clicker
uhm one more thing i read ppl first get a function working, called like kprint(), whats its purpose, is it k-for Kernel and what would be the diffrence to normal printf() or something.
Well, if you toroughly read the "printf" description, you'll figure that there are *many* things it does that OSdevers don't care, like the ability of printing right-aligned strings, floats, etc.

So in some sense, your 'kprint' will probably still use the "%d", "%x" and "%s", perhaps with the additionnal form "%2x" and "%4x" for printing words and bytes but that will roughly be all...