Beginner Questions

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.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: Beginner Questions

Post by Omega »

VST_0201 wrote:Notice that most of this message assumes you are developing in a Windows environment, but is not solely dependent upon it.
testing the cpu for 386 or better:

Code: Select all

test386:
	pushf			; save old flags

	xor ah,ah		; clear/empty high byte of ax
	push ax			; push the value of ax onto the stack..
	popf			; and pop that into flags register
				; (flags = push'd value of ax)

	; now high nibble is empty (if it wasn't)..
	; try to set ceratain bits ourselves..
	; if we can't then it's < 386

	pushf			; push flags on the stack..
	pop ax			; and pop that into ax (so we can modify it)

        and ah, 0f0h		; try to set the high nibble
	cmp ah, 0f0h		; on a 386, the high nibble can't be 0f0h
 
	jne short .done		; restore flags and return (it's >= 386)

	popf			; restore original flags

	pushf			; save original flags again

	mov ah, 70h		; now try to set NT and IOPL

	push ax
	popf

	pushf
	pop ax

	and ah, 70h		; if fails, no 386 is installed
	jnz short .done		; restore flags and return (it's >= 386)

	mov si,no386msg		; put message into ds:si for printmsg
	call printmsg		; print the no386 msg

	call $		; halt the computer

.done:
	popf			; restore flags
	ret
Access Floppy from Pmode (v86): http://coding.derkeiler.com/Archive/@$$ ... 00099.html

Doing IDT/ISR/IRQ stuff: You are going to love this one: http://tools.assembla.com/svn/gustavo/osdev/tutorial/

Read up on booting: http://en.wikipedia.org/wiki/Booting

If you are having issues getting your loader to work, like you start out using a single stage and realize that you need more memory, so you attempt a stage 2 loader and cannot for the life of you get it to load your kernel, before you give up use grub instead:

ftp://alpha.gnu.org/gnu/grub/grub-0.94-i386-pc.tar.gz

Create a batch file (DOS) and write: copy \b stage1 + stage2 boot

Double-Click the batch file and use RawWrite to write the image to a floppy.

Check out this link for info on how to use GRUB: http://www.osdever.net/tutorials/grub.php

Then use BOCHS or MS Virtual PC to test it.

This should get you rolling on your OS. Hope it helps.
Free energy is indeed evil for it absorbs the light.
thestew42
Member
Member
Posts: 38
Joined: Thu Jun 19, 2008 6:20 pm
Location: San Diego, CA

Re: Beginner Questions

Post by thestew42 »

Thank you for that. I think I've got most of my issues cleared up now.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: Beginner Questions

Post by Omega »

Not a problem my friend. Don't worry, once you get past the loader the kernel coding is pretty much like everything else you have ever coded. Just have fun with it and make it however you want. Here is your chance to make your very own OS; you can't get much more über than that. Unless you graduate to PIC and then you're building the hardware we program for. Anyway, learning has its stale periods where you just kind of over learn everything until the final piece sets in and you finally see and comprehend the whole picture.

Meanwhile, here is your inspiration Linus Torvald, watch this video, because it will inspire you; it did me. Good luck.
Free energy is indeed evil for it absorbs the light.
eax
Member
Member
Posts: 57
Joined: Mon Jun 23, 2008 6:45 am

Re: Beginner Questions

Post by eax »

Im a newbie myself to some degree so take what I say with a pinch of salt :) but where as in real mode you can call dos interrupts well they have code already pre-written for them so you just in some cases do int X and it carrys out the specified interrupt based on the values you set in a couple of registers prior to calling the int.

In protected mode you have to write your own interrupt service routines and interrupt handler, what this means to my mere mortal mind :) is that you have 100% control over the hardware, this in turn means nothing is automated for you and you must fully control the hardware so that means writing code to service your own interrupts. (Also the limited hardware coding Ive done thanks to guides, well usually specific hardware is linked with specific hardware controllers so you need to read documentation on the hardware controller relevant to the hardware you want to control)

Also certain controllers are accessed(according the guides Ive read) via software ports, a software port from what I can gather is a special hex number which is used to let you read or write to hardware registers indirectly through the software ports(Hex numbers)

Im sorry folks if this isnt 100% correct I just figure if the guy is starting out well it sometimes helps to have as simplistic a view as possible and learn in small chunks rather than being overwhelmed and put off, see it in a managable way then refine by reading more and more as you go,

BTW what folk are saying about the guides is correct, Im guilty of it myself sometimes but they are quite good, at least a good portion of them, if your looking for something that throws you into practical stuff fast go with brans guide but from my personal experiance when you get to the gdt I would advise to spend a whole day on it making sure you understand the theory, I had to reference 2 or 3 sites at once when it came to the gdt and IDT. Anyway apologies if my comments arent much good its just its alot of dam reading and stick with it, I actually got my finger out attempting more theory this time around and it has gotten me much further and faster.

Go look at the guides because the guide writers on here no their OSDev to a really high caliber and I can still give credit in that respect no matter what.

I have made good progress but man an OS is crazy , you get one bunch of steps to an acceptable level then find the next stage is just as much :) Its great when you see code working though! So hopefully you wont be put off

hey vst I think I will check that vid out as well :) I can do with some inspiration to get the hefty reading out the way with the keyboard and graphics controllers :)
Post Reply