Page 1 of 2

Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 8:11 pm
by Saustin
I'm planning to program my own OS.

I'm just a noob.
I know C, and it is a HUGE challenge to program a operating system with nothing but simple procedures, and no includes.

Anyways, does anyone have a list of ram locations?
For example:
0xb8000 = VIdeo ram.


That's the only one I know of =/.
Thanks.

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 9:10 pm
by JohnnyTheDon
Most of them aren't fixed. You need to use ACPI or something similar to detect devices and their associated memory areas. The only exception AFAIK is legacy (ISA) devices that have fixed I/O port numbers for the most part.

And the locations you are looking for aren't RAM, they're memory mapped I/O areas.

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 9:14 pm
by bewing
The best place to start looking is in our wiki.
x86 memory map

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 9:29 pm
by Saustin
Bewing, thanks that isn' what I wanted, but it will certainly help later on.

Johnny, how would I go about.. Say, going about grabbing input, or status and data from the I\O buses?
I just want to make a simple operating system..

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 9:37 pm
by JohnnyTheDon
Depends what kind of input, status, and data. If you're staying simple, you may want to just stick with legacy ISA devices (keyboard, mouse, etc.). They're covered on the wiki.

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 9:54 pm
by Saustin
http://wiki.osdev.org/ISA
I looked at the following article, and the DMA & IRQ articles, but by input I ment keyboard input..
Do you have any examples?
Like I said, I just started this so PLEASE Make it broken down as much as possible.
Thanks alot!

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 9:57 pm
by JohnnyTheDon
From the wiki: PS2 Keyboard.

Don't worry that it says PS2 keyboard, most (maybe all?) chipsets emulate USB keyboards as PS2 keyboards.

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 10:44 pm
by Saustin
kernel.c:(.text+0x6f): undefined reference to `inb'

Yeah...
Little help, please.

Code: Select all

void kmain( void* mbd, unsigned int magic )
{
	unsigned char *videoram = (unsigned char *) 0xb8000;
	clearscreen();
	videoram[0] = KeyboardIsr();
       //YES - I know that I would need to add a loop for videoram, but I'm just testing atm.
	
}

void clearscreen()
{
	int clearint;
	unsigned char *videoram = (unsigned char *) 0xb8000;
	for( clearint = 0; clearint < 4000; clearint++ ) {
		videoram[clearint] = 32;
		clearint++;
		videoram[clearint] = 66;
	}
}

void haltcpu()
{
	asm( "hlt" ); //Halts CPU!
}

void KeyboardIsr()
{
	int new_scan_code = inb(0x60);
	//outportb(0x20, 0x20);
	return new_scan_code;
}
On second thought, if you don't mind helping me out, give me your FaceBook, MSN or Yahoo, if you have any and you don't mind helping out a poor old newbie.

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 10:55 pm
by Troy Martin
Saustin wrote:FaceBook
Hurk!

You need to write an inb and an outb function. Use inline assembly. There's an example on the wiki. Search.

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 10:56 pm
by JohnnyTheDon
A few things...

You haven't written inb. You need to write it. You can find an inb implementation on the wiki.

You can't call the ISR and put the return value in video memory like that. You need to remap the Programmable Interrupt Controler, setup a Global Descriptor Table, setup an Interrupt Descriptor Table, and put the ISR address in the proper address in the IDT. The ISR can't return anything, it must take actions itself to display something on the screen. IIRC you could poll the keyboard instead of using interrupts, but this uses up all of the CPU.

EDIT:
Troy, what was the point of the facebook rebuke? Weren't you recently aspiring to be a mod?
<ot ignore=true>
Facebook has its issues, but anything big and corporate will. Myspace is much worse, it practices blatant link censorship and is owned by News Corp. These are the same wonderful people who bring you Fox, the TV network that is fair and balanced (for republicans).
</ot>

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 11:07 pm
by Saustin
Heh, yes I know facebook sucks.
Anyways..
JohnnyTheDon wrote:A few things...

You haven't written inb. You need to write it. You can find an inb implementation on the wiki.

You can't call the ISR and put the return value in video memory like that. You need to remap the Programmable Interrupt Controler, setup a Global Descriptor Table, setup an Interrupt Descriptor Table, and put the ISR address in the proper address in the IDT. The ISR can't return anything, it must take actions itself to display something on the screen. IIRC you could poll the keyboard instead of using interrupts, but this uses up all of the CPU.

EDIT:
Troy, what was the point of the facebook rebuke? Weren't you recently aspiring to be a mod?
<ot ignore=true>
Facebook has its issues, but anything big and corporate will. Myspace is much worse, it practices blatant link censorship and is owned by News Corp. These are the same wonderful people who bring you Fox, the TV network that is fair and balanced (for republicans).
</ot>
Yes, MySpace sucks.

Like I said, I'm keeping this simple as possible.
INB.. Inb.. let me find that on the wiki real quick..
I love you, google.
"site wiki.osdev.org inb"

I found this:
http://wiki.osdev.org/Inline_Assembly/Examples#INx

One second, I'll try it and post.

Okay, I ran..


I typed random stuff, like "A", "B" etc, and all I got was random *** things on the ASCII chart.
//NOOB :Is that what interupts are for?

Where can I find these maps, and how do I implement them?

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 11:15 pm
by JohnnyTheDon
Saustin wrote:Like I said, I'm keeping this simple as possible.
It isn't a matter of simplicity, I'm pretty sure it just plain won't work. If the keyboard controller has no key to give you, it won't print the key on the screen. Also, the value you get from the controller is a scan code, not an ASCII key. You need to do the translation before you print anything on the screen.

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 11:17 pm
by Saustin
I know about interrupts. Basically, if I would be anoob and want to rape my processor [like I am now!], all I'm doing is while(1)'ing until it's declared a non null value.
So then I'd do a loop which would compare the scan code to a map?
Also, where can I get a map?

--PLEASE don't give me this: "http://wiki.osdev.org/GDT_Tutorial" I don't understand a bit!

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 11:27 pm
by JohnnyTheDon

Re: Need a list of x86 RAM Locations

Posted: Sat Mar 21, 2009 11:34 pm
by Saustin
Ah! I feel like such a moron..

So, is it just a case of comparing the hex numbers...
Or is it a case of calculating? #-o

Do you mind giving me your contact info, please?
Private message me if you want to.