Page 1 of 2

How to start?

Posted: Fri Aug 01, 2008 8:06 am
by eddyb
Hi!
I'm a newbie in os developing. I want to learn more about it, before to start to develop a small os.
I know some C, C++, a little asm. What do you recomend for a beginer? Bran's Kernel Development Tutorial it's good to start with? What is the order that should I do the things?(there is a page on wiki about this, but is not complete)
Thanks! :mrgreen:

Re: How to start?

Posted: Fri Aug 01, 2008 8:08 am
by JamesM
There is a page on the wiki about it, and it is complete enough. There are also at least 2 open threads on the first page of this subforum which ask this exact same question. Please read those first.

Re: How to start?

Posted: Sun Aug 03, 2008 5:47 am
by eddyb
Hi!
I made my first build. I used only ASM, no C files. No boot problem.
Version 0.0.0.1. Succesfully booting.
Version 0.0.0.1. Succesfully booting.
I aded this code after the start of the kernel:

Code: Select all

	mov AH, 0x7A
	mov AL, 'H'
	mov [0xB8640], AX
	mov AL, 'e'
	mov [0xB8642], AX
	mov AL, 'l'
	mov [0xB8644], AX
	mov AL, 'l'
	mov [0xB8646], AX
	mov AL, 'o'
	mov [0xB8648], AX
	mov AL, ' '
	mov [0xB864A], AX
	mov AL, 'W'
	mov [0xB864C], AX
	mov AL, 'o'
	mov [0xB864E], AX
	mov AL, 'r'
	mov [0xB8650], AX
	mov AL, 'l'
	mov [0xB8652], AX
	mov AL, 'd'
	mov [0xB8654], AX
	mov AL, '!'
	mov [0xB8656], AX
And then I got a nice green on grey "Hello World!".
Version 0.0.0.2. Nice "Hello World!";).
Version 0.0.0.2. Nice "Hello World!";).
What is the next point? Is good to follow Bran's Kernel Development Tutorial?
Or i need to do something else?
PS: I atached some screenshots

Re: How to start?

Posted: Sun Aug 03, 2008 6:45 am
by Adek336
Nice :)

Tutorials are great to follow, they give you some insight. The next step now would be reading old posts in this forum - there have been a few discussions about the order of implementation.

Re: How to start?

Posted: Mon Aug 04, 2008 12:27 am
by eddyb
I followed the Bran's tut, and i have all modules.
What i must do next? write more drivers?
or is better to use graphics and develop a gui?
Thanks :mrgreen:
PS: I have more screenshots... If you want, i'll post them

Re: How to start?

Posted: Mon Aug 04, 2008 12:32 am
by Adek336
If they print out something more than what the tutorial says then sure post 'em this ya thread :P Have you read the recent threads about starting an os?

Re: How to start?

Posted: Mon Aug 04, 2008 1:28 am
by codemastersnake
you can also check my wiki if you want to!

Re: How to start?

Posted: Mon Aug 04, 2008 7:31 am
by eddyb
Snake, your wiki is very tricky. I can't get to any page.
I've understood that i must have memory manager and multi-tasking before loadin programs from hardisk, and having gui.
I'll play a little with drivers, I want make some drivers, so i don't need to make them later.

Re: How to start?

Posted: Mon Aug 04, 2008 7:52 am
by AJ
shiner wrote:I followed the Bran's tut, and i have all modules.
What i must do next?
Hi,

I know it's a good feeling when you get a kernel working for the first time, but the secret now is not to rush. Bran's tutorial is good for teaching you the basics, but is not so good to use as the base of your own OS.

I think that the next stage should be one of design and reading. What do you want to get out of OS dev? Do you have a target audience (or, like me, do you just develop for the enjoyment?). How do you want drivers to interface to the kernel? Do you want a monolithic or microkernel? How do you want user apps to interface with the kernel?

While the GUI is an important part of the design process, it should not be the next thing you implement (perhaps try a decent memory manager first).

Cheers,
Adam

Re: How to start?

Posted: Mon Aug 04, 2008 8:41 am
by eddyb
I want my kernel to be a monolithic one. It has all drivers in it, and after start, it gives control to a text or graphic interface.
I think it's the way linux works.
So, I need to work on drivers(i've got only keyb, timer, and textscreen)-what are the most neccesary?

Re: How to start?

Posted: Tue Aug 05, 2008 8:48 am
by eddyb
I'm working on pci driver. If someone can explain to me how BAR and other pci stuff works, is welcome.
And I have a problem with VS2008: why in the output of build there is only echo output :evil: ? I'm reffering at the NMake tool, for using my own build script. I can't see gcc, or linker output. i haven't this problem in the past...

Re: How to start?

Posted: Tue Aug 05, 2008 9:20 am
by AJ
shiner wrote:I'm working on pci driver. If someone can explain to me how BAR and other pci stuff works, is welcome.
Have a look at PCI.

Cheers,
Adam

Re: How to start?

Posted: Tue Aug 05, 2008 9:31 am
by eddyb
i've readed it already, but is a little confuzing.
my pci driver goes mad... the scan does't show any detected message and at the end it says that found 0 devices...
Can be from VMWare? some sort of pci disabled?

Re: How to start?

Posted: Tue Aug 05, 2008 3:03 pm
by Adek336
(I think a base address register's lowest bit means if it is IO space address)
So you read the class and subclasses codes for all the buses and slots, right? And all of them are 0?
Vmware can't have PCI disabled.

Re: How to start?

Posted: Tue Aug 05, 2008 10:28 pm
by eddyb
i read the vendor's id, and skip device if is 0xFFFF.
here is the code:

Code: Select all

int pci_read(int bus, int dev, int func, int reg)
{
  outportl(0xCF8, ((unsigned long) 0x80000000 | (bus << 16) | (dev << 11) | (func << 8) | reg));
  return inportl(0xCFC);
}

PCI_Device_t* pci_readdevice(int bus, int dev, int func)
{
	PCI_Device_t* ret;
	ret->VendorID      =   (short) (pci_read(bus,dev,func,0)&0x0000FFFF);
	ret->DeviceID      =   (short)((pci_read(bus,dev,func,0)&0xFFFF0000) >> 16);
	ret->CommandReg    =   (short) (pci_read(bus,dev,func,4)&0x0000FFFF);
	ret->StatusReg     =   (short)((pci_read(bus,dev,func,4)&0xFFFF0000) >> 16);
	ret->RevisionID    =   (short) (pci_read(bus,dev,func,8)&0x0000FFFF);
	ret->SubClass      =   (char) ((pci_read(bus,dev,func,8)&0x00FF0000) >> 16);
	ret->ClassCode     =   (char) ((pci_read(bus,dev,func,8)&0xFF000000) >> 24);
	ret->CachelineSize =   (char)  (pci_read(bus,dev,func,12)&0x000000FF);
	ret->Latency       =   (char) ((pci_read(bus,dev,func,12)&0x0000FF00) >> 8);
	ret->HeaderType    =   (char) ((pci_read(bus,dev,func,12)&0x00FF0000) >> 16);
	ret->BIST          =   (char) ((pci_read(bus,dev,func,12)&0xFF000000) >> 24);
	ret->BAR0          =    pci_read(bus, dev, func, 16);
	ret->BAR1          =    pci_read(bus, dev, func, 20);
	ret->BAR2          =    pci_read(bus, dev, func, 24);
	ret->BAR3          =    pci_read(bus, dev, func, 28);
	ret->BAR4          =    pci_read(bus, dev, func, 32);
	ret->BAR5          =    pci_read(bus, dev, func, 36);
	ret->CardbusCISPtr =    pci_read(bus, dev, func, 40);
	ret->SubVendorID   =   (short) (pci_read(bus,dev,func,44)&0x0000FFFF);
	ret->SubDeviceID   =   (short)((pci_read(bus,dev,func,44)&0xFFFF0000) >> 16);
	ret->ExRomAddress  =    pci_read(bus, dev, func, 48);
	ret->Reserved1     =    pci_read(bus, dev, func, 52);
	ret->Reserved2     =    pci_read(bus, dev, func, 56);
	ret->IRQ           =   (char)  (pci_read(bus,dev,func,60)&0x000000FF);
	ret->PIN           =   (char) ((pci_read(bus,dev,func,60)&0x0000FF00) >> 8);
	ret->MinGrant      =   (char) ((pci_read(bus,dev,func,60)&0x00FF0000) >> 16);
	ret->MaxLatency    =   (char) ((pci_read(bus,dev,func,60)&0xFF000000) >> 24);
	return ret;
}
void scanpci()
{
	int bus, dev, func, i;
	i=0;
	PCI_Device_t* device;
	printf("PCI Scan...\n");
	for (bus = 0; bus < 255; bus++)
	{
		putch('-');
		for (dev = 0; dev < 32; dev++)
		{
			for (func = 0; func < 8; func++)
			{
				device = pci_readdevice(bus, dev, func);
				if(device->VendorID != 0xFFFF)
				{
					i++;
					printf("\n--bus %u|device %u|function %u|has Vendor ID = 0x%x and Device ID = 0x%x", bus, dev, func, device->VendorID, device->DeviceID);
				}
				//else
					//printf("\n--bus %u | device %u | function %u | is null", bus, dev, func);
			}
		}
	}
	printf("Scan complete! %u devices found!", i);

}