Page 1 of 1

Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 12:54 pm
by me
Hey everyone :) Just thought I'd introduce myself to the board and perhaps ask a few questions to fill in a few gaps in my knowledge.

First some background on myself.

I have about 10 years of experience in C++ and am passingly familiar with C. I'm familiar with the C standard library and even some of the idioms, but I would not call myself experienced in pure ANSI C. Over the last 1.5 years I've found myself using mostly C# professionally (3.5) and, while it pays well, it doesn't really scratch the itch that caused me to fall in love with development in the first place. So here I am. I'm thinking a superhero archetype would describe me best. Plain C# hacker during the day, tight wearing, OS dev'ing wild eyed caffeine fueled leaper of tall buildings lover of beautiful women hacker dude in the evenings :)

So with that out of the way, here are the tools I've settled on.

Gentoo Linux
ANSI C
gcc (make, ld, etc).
nasm
bochs
bash (for automation and the like) Note: unless you guys recommend against this approach for some reason.

Now for the questions. Also, if I need to RTFM, please at least link TFM that I need to R :)

1. I see 2 book recommendations for hardware, which do you guys feel is better for someone who is just starting? The books are "The Indispensable PC Hardware Book" and "The Undocumented PC".

2. Are there any recommended resources for assembly/nasm?

3. This is probably just a gap in my knowledge, but I was following the loopback device article on the wiki, and it talks about creating floppies, and hd images. It also talks about formatting the disk and putting files on it manually. Is formatting even necessary at this point? How do you guys normally go about pushing your bootloader and/or kernel onto an image?

4. automation wise, what do you guys recommend I do first, and if you don't mind, perhaps a little of the how or links? What I mean is, instead of telling me to automate pushing my images onto a disk, perhaps a little insight into how I do this please?

Ok, that's all I have for now. Since this is a part time pasttime for me it's probably going to go a little slow, but hopefully I'll soon be answering questions for others :)

Also, I believe my weak spots are knowledge of hardware and assembly so any extra recommendations in this area are not going to be ignored.

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 1:12 pm
by stephenj
Welcome to the board.

1&2. Personally I use YASM rather than NASM (you may want to take a look at it). In the General Programming and OS Development stickies of this board (not to mention old threads) there are tons of links to tutorials and discussions about books (you are getting a pointer to a pointer here). Re-hashing the discussions here is of little value. I'd recommend you spend a little time learning about assembly in user space before starting OS development.

3. "Is formatting at this point?" Could you restate the question?

4. If you are using Bochs then you don't have to worry about this. Using a file as a disk is an option away (read the bochs man pages).

5. Are you using the word "automation" to describe the functions make performs?

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 1:18 pm
by Alboin
I would also suggest you use Ubuntu rather than Gentoo. It should install quickly, and easily, and get you osdeving almost immediately.

As for the reading material, the Intel manuals should be your first read. After reading those, assembly should come almost naturally. (ie. Doing some online research should suffice.)

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 1:39 pm
by DeletedAccount
I would suggest Slackware , all others are simply not on par with Slackware . You can probly look at advanced 386 programming techniques , a book i found in libarary , this book is of great help and do not forget the wiki .
For automation purpose i would prefer a scripting language like python

Regards
Shrek

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 2:32 pm
by Combuster
me wrote:1. I see 2 book recommendations for hardware, which do you guys feel is better for someone who is just starting? The books are "The Indispensable PC Hardware Book" and "The Undocumented PC".
I never felt the need for any such books. All the information you need is available off the web and IMO you can better get yourself an old computer for that price :wink:
3. This is probably just a gap in my knowledge, but I was following the loopback device article on the wiki, and it talks about creating floppies, and hd images. It also talks about formatting the disk and putting files on it manually. Is formatting at this point? How do you guys normally go about pushing your bootloader and/or kernel onto an image?
The idea of a loopback device is to pretend that there is an extra floppy or harddisk, which is actually a image. You can then do with that virtual piece of hardware whatever you would do with other pieces of hardware.

Since using the loopback requires some root privileges I personally prefer a tool that works on images directly. In my case, MTools. It also happens to be fairly platform independent.
4. automation wise, what do you guys recommend I do first, and if you don't mind, perhaps a little of the how or links? What I mean is, instead of telling me to automate pushing my images onto a disk, perhaps a little insight into how I do this please?
If you know make, use it. If you can do shell scripting, use it. You can try the Makefile tutorial otherwise.

As for those distro recommendations, use what you feel comfortable with. You can do OSDev under windows. No need to install linux for that. If you already have linux installed, don't bother with getting a different distro just for OS development as they all should work equally well.
In other words: no need to install any form of linux specifically for OS development :D

And hence, no reason to start a distro war, Shrek, Alboin :wink:

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 3:24 pm
by Alboin
Combuster wrote:As for those distro recommendations, use what you feel comfortable with. You can do OSDev under windows. No need to install linux for that. If you already have linux installed, don't bother with getting a different distro just for OS development as they all should work equally well.
In other words: no need to install any form of linux specifically for OS development :D

And hence, no reason to start a distro war, Shrek, Alboin :wink:
He seems to want to use Linux and in his post he makes himself seem to have more experience with Windows. If this is true, and he has little Linux experience, then he may have seen the various topics on this board suggesting Gentoo and decided to use that. This, however, would be a mistake, because learning how to use Linux in general is difficult enough without having to manually install the smallest piece of software. I thus suggested Ubuntu, following these assumptions. My point is still valid. :wink:

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 3:52 pm
by me
My apologies, I should have specified. I've been a Linux user for close to 10 years. All of my personal work is done in linux (I know Linux better than windows truthfully), and I run Linux as my desktop at home, so unless there's a specific reason for switching to another distro I'm going to stay with Gentoo.

I'm an old slacker, and agree that it's a superb OS, but the lack of a package manager eventually caused me to move over to Gentoo. For whatever reason I like emerge better than apt-get (no rational reason, just preference), and the build times don't bother me, so there you have it :) I've also played with Ubuntu, and if I were recommending a distro to a "noob" Ubuntu would be it, but for me I don't need the shiny packaging (that's just me though).


stephenj
3. "Is formatting at this point?" Could you restate the question?
That should have read :"Is formatting even necessary at this point?" By "this point" I really mean someone just trying to get a bootloader to load up a rudimentary kernel. Is there a reason why I'd want to do this?
5. Are you using the word "automation" to describe the functions make performs?
partially. Perhaps an example would help. I can foresee kicking off a build and at the end of it launching bochs with a debugger attached, or pushing it to another machine, updating a bootloader and rebooting said machine. "automation" in this case would be a set of scripts written so all I have to do is kick off the process and then go grab another cup of coffee :)

Things of that nature. Just wanted to see how the experienced OS dev'ers saved themselves time.
The idea of a loopback device is to pretend that there is an extra floppy or harddisk, which is actually a image. You can then do with that virtual piece of hardware whatever you would do with other pieces of hardware.
I think I asked that question badly. I've never had to push 512 bytes to the first sector of a HD before. I haven't come across anything on the wiki yet and I'm not even sure what keywords I would google on to find the information (in other words I'm very ignorant in this respect). A nudge in the right direction would be invaluable to me.

He seems to want to use Linux and in his post he makes himself seem to have more experience with Windows. If this is true, and he has little Linux experience
I mentioned the Windows only to offer a reason why I'm jumping into OS dev. To make a long story short, I've always been interested in it. I recently took a fulltime position at one of the companies I contract with (to lessen the effects of the current economy) and I'm finding the development there to be mostly web stuff in C#. It's enjoyable enough, but not what I really enjoy about developing, so I decided to scratch that itch outside of work.

So here I am in all of my noob glory :)

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 5:52 pm
by Combuster
That should have read :"Is formatting even necessary at this point?" By "this point" I really mean someone just trying to get a bootloader to load up a rudimentary kernel. Is there a reason why I'd want to do this?
If you have a floppy with a filesystem, and the bootloader has already been installed, then the only thing you need to do is to replace the kernel file. To get started that way, you can get precompiled floppy images with GRUB off the wiki.

If the bootloader isn't fixed, you need to rebuild the floppy on each iteration.

Maybe you should try the Bare Bones tutorial and see where you get stuck, that also makes it easier for us to answer questions when they're more specific.
Just wanted to see how the experienced OS dev'ers saved themselves time.
In my case, makefiles. With lots of phony targets doing useful stuff so that all I ever need to do is type "make (...)" at the console. (You can use my source browser to get ideas)

Re: Advice on Tools, methodologies, and introductions :)

Posted: Tue Jan 27, 2009 11:12 pm
by me
Maybe you should try the Bare Bones tutorial and see where you get stuck, that also makes it easier for us to answer questions when they're more specific.
Fair enough. I was planning on starting with Hello World Bootloader, but I'll start with the bare bones and work backwards. I know the bootloader isn't technically kernel hacking, but I'm here for the fun and it'll let me dive into assembly a bit :)

and thanks for the link, I'll definitely check it out.

Re: Advice on Tools, methodologies, and introductions :)

Posted: Wed Jan 28, 2009 1:31 am
by me
I've successfully worked through the bare bones tutorial. There isn't a note in the tutorial about this, but bochs insisted on a floppy with an expected size (I padded it out to 1474560 bytes) before it would work as expected. I've updated the wiki accordingly.

Re: Advice on Tools, methodologies, and introductions :)

Posted: Wed Jan 28, 2009 6:39 am
by Brendan
Hi,
me wrote:3. This is probably just a gap in my knowledge, but I was following the loopback device article on the wiki, and it talks about creating floppies, and hd images. It also talks about formatting the disk and putting files on it manually. Is formatting even necessary at this point? How do you guys normally go about pushing your bootloader and/or kernel onto an image?
If your floppy image uses a common file system (e.g. FAT), then you'd need to create the blank image, format it, then copy files to it (where formatting and copying files can be done with a loopback device). If your floppy image doesn't use a common file system then there's no point mounting it as a loopback device.

As an example, I use both methods. For my bootable GRUB floppy image I've got a pre-formatted (FAT) floppy image with GRUB already installed, and I use mtools to add my OS's files to a copy of this floppy image to create the final floppy image. Alternatively it's possible to use "dd" to create images in some cases, or you could use NASM for more complex cases (see this web page for an example of using NASM to create a bootable ISO9660/El Torito CD image).

Note: I think Bochs uses the floppy image's size to determine the disk type. For e.g. a 1440 KiB file would be emulated as a floppy disk with 80 cylinders, 18 sectors per track and 2 heads; while a 160 KiB file would be emulated as a single-sided floppy disk with 40 tracks and 8 sectors per track.


Cheers,

Brendan