HDD Access?

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.
Post Reply
User avatar
GeniusCobyWalker
Member
Member
Posts: 65
Joined: Mon Jan 12, 2009 4:17 pm

HDD Access?

Post 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)
Attachments
Luna Window.png
Luna Window.png (10.24 KiB) Viewed 1509 times
Full Knowledge in:
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: HDD Access?

Post 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
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
User avatar
GeniusCobyWalker
Member
Member
Posts: 65
Joined: Mon Jan 12, 2009 4:17 pm

Re: HDD Access?

Post by GeniusCobyWalker »

Thanks.

So this works?

Code: Select all

void outw(u16int port, u16int value)
{
asm volatile ("outw %w0, %1" : : "a" (value), "id" (port) );
}
Full Knowledge in:
GML, Ti-Basic, Zilog Z80 Assembly, SX28 Assembly and Blender
Experience in:
C++,OpenGl,NDS C++,Dark Basic,Dark Basic Pro,Dark Gdk and PSP Coding
Using:
Ubuntu ,GEdit ,NASM ,GCC ,LD ,Bochs
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: HDD Access?

Post by kop99 »

Ofcourse it will works.
There is no mistake.
Post Reply