Page 2 of 17

Re:Where do i start??

Posted: Sun Oct 06, 2002 5:40 pm
by Berserk
Hey,

No i don't use Linux, i use Windows XP Home Edition.
Not all my questions have been answered yet, so if you are reading this, go back to my previous post and read it, Please.

As for gcc, i download it from:
ftp://ftp.simtel.net/pub/simtelnet/gnu/ ... gcc32b.zip like Tom said. BUT, when i unzip the files, in the bin directory, there are 5 files ONLY, and whichever one of them i open it just closes straight away, THIS ALSO happens when i try to use DJPP (i don't get it) why do these files close straight away?? As for an assembler - i don't see one in the GCC bin directory. What do i do?? How do i use these compilers??

As i said: as soon as i open a file in the bin directory of gcc it closes straight away, and there are only 5 files. How do i use these tools when they close as soon as i open them??

Please Help!

ciao.

Re:Where do i start??

Posted: Sun Oct 06, 2002 6:32 pm
by Curufir
Ok, this may sound dumb (First thing that sprang to mind, so don't get insulted by it or anything).

GCC operates from the command line, so you use gcc <flags> <my c source> to use it (Or something similar, can't remember the specifics). If you're just clicking on the executables from windows then all that happens is windows runs the gcc command, gcc echoes back a response "No input files" and exits the program, at which point windows quite happily closes the gcc window. Without some form of IDE that works under windows xp you'll have to open up a command line window and work from there.

Curufir

Re:Where do i start??

Posted: Sun Oct 06, 2002 6:34 pm
by gtsphere
the reason they close when you open that is because they expect command line arguments, such as files you're trying to compile, flags and settings, etc.

and also, i would recommend using http://www.delorie.com/djgpp/zip-picker.html to pick the files you want to download, this will add lots more files, such as includes, more files in /bin, etc.

for manuals on how to use these, try www.google.com, search for DJGPP tutorials. or even look on www.delorie.com

Re:Where do i start??

Posted: Sun Oct 06, 2002 6:41 pm
by Berserk
Hey,

I used the zip picker for DJPP, i just don't get how to use the program?? do i use the command line??

I am talking about GCC (it doesn't have many fies in the bin directory.)

Ohh well. Now how do i start a kernel (i just want to mke an OS that boots from a floppy and prints some words ont he screen) I want it to be in C++.

Could somebody help me??

What does a kernel do??

Re:Where do i start??

Posted: Sun Oct 06, 2002 7:14 pm
by gtsphere
http://osdev.neopages.net/tutorials/ckernel.php

that is a great page to help you.

and just so you know, you need a way to boot your kernel, either via your own bootloader/someonelses or GRUB. Those are written in ASM, so you do need to know some asm if you decide on writing your own.

i've been working on my OS for about 7 months and i'm only just getting to setting up the kernel to where i want it with some simple C functions such as clrscr(); printf(); etc. A big part of OS designing is reading and learning.

i hope this helps

Re:Where do i start??

Posted: Sun Oct 06, 2002 7:28 pm
by Berserk
Thanks for the help,

i will make my own bootloader, Do you know where to get a free Assembler??

Also what does the bootloader do??

(as i said before, i am an absoloute beginner)

sorry for bothering you with these beginner questions, but someone has to explain this stuff to me, or i won't know.

Good luck on your own OS.:D

ciao.

Re:Where do i start??

Posted: Mon Oct 07, 2002 7:08 pm
by Curufir
When a PC starts up (I'll describe intel, as I'm most familiar with it) it looks for a valid bootsector on the device you selected in the BIOS (Eg the floppy, or a hard drive etc). A valid bootsector has the word 0xAA55 at the word occupying bytes 511 and 512 in sector 0 of the device (Note that apparently even if the device's sector size is bigger than 512 bytes BIOS still looks here for the "magic" word).

A bootsector itself is very limited in what it can do (There's a limit to just how much you can squeeze into 510 bytes), in general people (Or so it seems on the board) either use the bootsector to load some more sectors at a predefined point on the disk, or have some very simple (And usually weird because of the 510 byte limit ;D) filesystem code inside the bootsector to load a specific file (Eg A Fat12 filesystem).

Basically the bootsector is the point at which the machine enters, and starts running, your code. It's required, but the whole thing can rapidly run away from you unless you happen to be good at assembly language.

Apparently it is much easier to use something like GRUB and concentrate on your kernel itself. The bootsector is a fairly unimportant part of an actual OS, although you won't be able to run an OS without one, so spending huge amount of time learning assembler just for that is not worthwhile. Personally I found writing one quite worthwhile since it throws you right into the deep end as far as interacting with the hardware is concerned, but others disagree. Heck, if we all agreed then we wouldn't be writing an OS, right? ;D

So there you go. A bootsector is just the first sector of whatever you happen to be booting from, it contains the first code that gets run by the processor, and it's generally a pain in the neck to write one decently. Hope that helps, if not then perhaps someone else can be more enlightening.

***

Nearly forgot to answer the other question. Here's a link for NASM http://sourceforge.net/projects/nasm. It's pretty good, the syntax is nice, and pretty much everyone I've talked to uses it (Ok, except for you weirdoes that do it inline in GCC ;)).

Curufir

Re:Where do i start??

Posted: Tue Oct 08, 2002 12:22 am
by Whatever5k
and accept my excuses for misunderstanding
Calm down, we won't hate you for this ;)

Sorry, but I am using Linux, so I cannot help you with GRUB/Windows...
But you may ask K.J. for example, he uses GRUB and Windows...

Re:Where do i start??

Posted: Tue Oct 08, 2002 12:32 am
by Berserk
Thank you soo much for yopur help ;D

Now that i understand bootsectors, how do i load a bootsector into the first sector of a floppy or CD Rom, or even a hard drive??

So a bootsector just loads a kernel, what does a kernel do?? and can the OS run C/C++ applications as soon as it loads. I mean, does it need any extra code to get it to run C/C++ apps?

again i am sorry for these questions, but if you guys don't answer them for me i don't know who will ???

So Please help... :D

Re:Where do i start??

Posted: Tue Oct 08, 2002 12:59 am
by Whatever5k
Of course a kernel can load a C++-program. But it's up to *you* to program the kernel that it can do that - and that's not really simple...

Re:Where do i start??

Posted: Tue Oct 08, 2002 2:05 am
by Berserk
is the kernel written in assembler??

Re:Where do i start??

Posted: Tue Oct 08, 2002 2:28 am
by Whatever5k
Well, you can decide in which language you want to write your kernel. Most people write the low level stuff in assembler and the main kernel stuff in C...

Re:Where do i start??

Posted: Tue Oct 08, 2002 3:17 pm
by Curufir
From my dictionary :)

Kernel: Central or essential part; part within hard shell of nut or stone fruit.

Now the more cynical people on the board would go with the first part of that definition, but I'm a romantic so I'll go with the second part. A kernel is the root, the wellspring, the source of all good things about your OS. The mightiest oak can grow from the smallest seed (Zen OS design, cool 8)).

Back to reality. There are a few different types of kernel designs around (I'll go into it later), but essentially what a kernel does is attempt to place a layer between the hardware itself and the application software written above it, and control access to the hardware and resources in a controlled, understood manner. The idea of an OS is to remove the low level hardware programming requirements from the application programmer and provide them with much easier methods of controlling the machine (Some of you may not agree with that, but IMO a GUI is not part of an actual OS).

So your kernel will do such things as loading programs, dynamically linking those programs (If required), allocating memory, scheduling processes, handling inter-process communications (IPC), handling Input/Output to devices etc. If you are designing for multiple processors then you would also handle that in the kernel. The idea being to remove all these complex problems from the application software.

I suppose in very general terms you could think of the kernel as a controlling program, or the main loop of a program, and applications as sub-programs that get called at scheduled intervals. Eg Your entire kernel could consist of printing "Hello World" on the screen, of course it could also be as complex as real-time control of a nuclear power plant. How far to go is up to you.

Some basic designs (Hopefully someone can correct what's wrong here, I'm shaky on it myself):

Monolithic:
All the drivers, scheduler, IPC control etc are part of a single large program operating in kernel space (Ring 0 on x86 systems), usually with the kernel as one process. This gives you a speed boost because you don't require complex IPC code, but cuts down on flexibility. Windows and Linux (Yeah, I know about modules and I'm not buying it :)) are examples of monolithic kernels.

Micro-kernel:
This is where the kernel itself mostly consists of a message passing system that provides access to a number of service processes (Eg video services) that run in either kernel or user mode. You get a far more flexible system with micro-kernels, but pay a price in speed because of the IPC needed to use the service processes. I think Mach is an example of this.

Exo-kernel:
Very odd, very weird, any examples you're likely to come across are probably research projects at a Uni. Essentially an exo-kernel provides a few basic structures on top of the hardware and allows running apps to supersede these structures with their own OS modules. You can apparently get a huge speed increase using an exo-kernel, but to do so you need an app that has OS modules written with the app in mind instead of it using the defaults in the OS. This (IMHO) places part of the low level programming back into the realm of the application programmer, which may or may not be a good thing.

So where does that get you? A kernel is just a program, it can be as simple or complex as you like. In terms of an OS the kernel is the program(s) which controls all the other programs in a controlled fashion.

Hope that helps, if not hopefully someone else can fill in the blanks/correct my errors.

BTW, if you're just starting out I heartily reccomend a monolithic kernel designed for a single processor, it's a good place to begin, things just start getting weirder and weirder after that ;D.

Curufir

Re:Where do i start??

Posted: Tue Oct 08, 2002 6:59 pm
by Berserk
thanks, that helped. But i don't know where to start, know any good web-sites where there are (free) assembler tutorials. (for the assembly language)

i think i need to learn some assembler before starting on a kernel and bootsector. because now i know what a kernel does. but i don't know how to make one ??? (because i don't know assembler) i know the kernel can be written in C++, i will write it in C++, but it's the bootsector i'm worried about :'(

Re:Where do i start??

Posted: Tue Oct 08, 2002 10:46 pm
by bemular
a nice day to all.

to start off, i found the topic interesting as i played around the search engine google. i have seen a few documentations of developing an os and id like to try somehow. and an os with a gui would be a lot better.

i know a few kernel stuff. i have a fair knowledge in c programming, particularly using borland's turbo c. im running win98se and a crappy pentium 133. if there are some things (assembler, linker, whatever) i seem to need for developing such an os, i would certainly appreciate it.

my thanks to everyone.