Page 1 of 1

HDD Access?

Posted: Tue Jul 07, 2009 8:13 pm
by GeniusCobyWalker
I have been working a lot on the OS I'm developing lately. I believe that I
am at the point where I need to start writing and reading from the HDD.

I have written code for this using this tutorial: http://www.osdever.net/tutorials/lba.php
However it seems to not be working. I tested it by reading displaying Buffer, then writing,
rereading the buffer, then printing. But it all turns out the same. I believe I want to use LBA.

I currently have: GDT, IDT, ISR, IRQs, PIC, PIT driver, Keyboard driver, and a basic CLI.

Attached is my CLI so far.

Code: Select all

void outb(u16int port, u8int value)
	{
	asm volatile ("outb %1, %0" : : "dN" (port), "a" (value));
	}
/* Not sure if works
void outw(u16int port, u8int value)
	{
	asm volatile ("outw %w0, %1" : : "a" (value), "id" (port) );
	}*/
u8int inb(u16int port)
	{
	u8int ret;
	asm volatile("inb %1, %0" : "=a" (ret) : "dN" (port));
	return ret;
	}

u16int inw(u16int port)
	{
	u16int ret;
	asm volatile ("inw %1, %0" : "=a" (ret) : "dN" (port));
	return ret;
	} 
I have 3 questions.
Is this enough to access the HDD?
Is this tutorial correct?
Last of all is my OutW correct? (first time I needed it)

Re: HDD Access?

Posted: Tue Jul 07, 2009 10:46 pm
by gzaloprgm
/* Not sure if works
void outw(u16int port, u8int value)
{
asm volatile ("outw %w0, %1" : : "a" (value), "id" (port) );
}*/
No, it doesn't work. You want to output a 16 bit word. By changing "u8int value" to "u16int value" AFAIK it will work perfectly.

By the way, I think before coding about HDD access, you should sit down and design how you want the kernel to be.

Before doing any driver, I would code at least a memory manager (at least physical mm if you don't want to have multitasking). Otherwise, where would the data you get from the disk go?

Cheers,
Gzaloprgm

Re: HDD Access?

Posted: Wed Jul 08, 2009 7:02 am
by GeniusCobyWalker
Thanks.

So this works?

Code: Select all

void outw(u16int port, u16int value)
{
asm volatile ("outw %w0, %1" : : "a" (value), "id" (port) );
}

Re: HDD Access?

Posted: Sat Jul 11, 2009 2:11 am
by kop99
Ofcourse it will works.
There is no mistake.