>From DOS, Windows, Linux, iMac, Palm or PocketPC hacked to a drive, ?,
etc. ???
It matters what environment you are trying to access the drive from.
The more details you give, the more likely someone can point you in the
right direction.
Nathan.
;
; Read a hard disk sector into our allocated buffer, by
; directly accessing the hard disk at the hardware port level.
;
my_buff db 512 dup 0 ;allocate a storage buffer
;
mov dx,1F6h ;drive and head port
mov al,0A06h ;drive 0, head 6
out dx,al ;send it
mov dx,1F2h ;sector count port
mov al,1 ;read one sector
out dx,al ;send it
mov dx,1F3h ;sector number port
mov al,56 ;read sector 56
out dx,al ;send it
mov dx,1F4h ;cylinder low port
mov al,5 ;cylinder 5
out dx,al ;send it
mov dx,1F5h ;cylinder high port
mov al,0 ;the rest of the cylinder (here, 0)
out dx,al ;send it
mov dx,1F7h ;command port
mov al,20h ;read with retry
out dx,al ;send it
still_going:
in al,dx ;read a byte
test al,8 ;are we ready to proceed yet?
jz still_going ;no, so go again
mov cx,512/2 ;one sector (512 bytes/2 = 256 words)
mov di,offset my_buff ;point DI to our local storage buffer
mov dx,1F0h ;data port - data comes in and out here
more:
in ax,dx ;read a word from the port
mov [di],al ;store first byte in our local buffer
inc di ;bump the buffer pointer
mov [di],ah ;store second byte in our local buffer
inc di ;bump the buffer pointer
loop more ;go again if CX > 0
...
...
[ your code here ]
...
... _____
((( `\
This code is, of course, _ _`\ )
for DOS. (^ ) )
~-( )
If you're programming for _'((,,,)))
WinDoze, I can't help you. ,-' \_/ `\
( , |
You'll probably have to call `-.-'`-.-'/|_|
some wacky WinDoze API function, \ / | |
like ReadRawHardDiskSector4Me. =()=: / ,' aa
Hehehe!
> test al,8 ;are we ready to proceed yet? (wair for
> DRQ?)
> jz still_going ;no, so go again
> mov cx,512/2 ;one sector (512 bytes/2 = 256 words)
> mov di,offset my_buff ;point DI to our local storage buffer
> mov dx,1F0h ;data port - data comes in and out here
>
> more:
could use a "rep insw" or "rep insd" (ecx/4) here
This code will only work for the primary ide controller.
Still a good example though :]
>
>On 2005-01-05 ke...@kerb.eu.org said:
>
> > Hi,
> > can you please help me I want to read directly from ide hard drive
> > for example I want to read cylinder = 5 head = 6 sector 56
> > Thanks for your help.
>
>;
>; Read a hard disk sector into our allocated buffer, by
>; directly accessing the hard disk at the hardware port level.
>;
>my_buff db 512 dup 0 ;allocate a storage buffer
>;
> mov dx,1F6h ;drive and head port
> mov al,0A06h ;drive 0, head 6
How do you expect to fit "0A06h" into al?
<snip>
--
Arargh501 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html
To reply by email, remove the garbage from the reply address.
"kerb" <ke...@kerb.eu.org> wrote in message
news:1104962180.6...@z14g2000cwz.googlegroups.com...
*snip*
Annie, if you could be so kind as to paste the same thing regarding
the floppy, and the cdrom ;}... that would be great, or just post change
details if its the same sort of thing.
Also, do you have a table of the memory mapped ports laying around? That
would be very useful too =}.
I must say, I'm very much sufficiently impressed ;}
--
The Dragon
MHM 7x9, Hits ya harder than a 2x4.
--
"Oh dear, I think you'll find reality's on the blink again."
-- Marvin The Paranoid Android
> Annie wrote:
>
> > mov al,0A06h ;drive 0, head 6
>
> How do you expect to fit "0A06h" into al?
_____
Sorry. Brain slippage. Should be: ((( `\
_ _`\ )
> mov al,0A6h ;drive 0, head 6 (^ ) )
~-( )
The code is untested, but it _'((,,,)))
oughtta be pretty close. ,-' \_/ `\
( , |
`-.-'`-.-'/|_|
\ / | |
=()=: / ,' aa
> could use a "rep insw" or "rep insd" (ecx/4) here
Not with the 16-bit DOS assembler -I- use. Hehe!
> This code will only work for the primary ide controller.
The original poster didn't specify primary or otherwise...
but primary is a good guess.
_____
> Still a good example though :] ((( `\
_ _`\ )
Duh! (^ ) )
~-( )
_'((,,,)))
> Annie, if you could be so kind as to paste the same thing regarding
> the floppy, and the cdrom ;}... that would be great, or just post
> change details if its the same sort of thing.
D00d, I can't hand you EVERYTHING on a silver platter. Gawhh!
> Also, do you have a table of the memory mapped ports laying around?
> That would be very useful too =}.
Confucius say: "Google is your friend."
> I must say, I'm very much sufficiently impressed ;}
>
> -- _____
> The Dragon ((( `\
_ _`\ )
I'm a 'low-level' kind of girl. (^ ) )
Hehe! ~-( )
Sorry, but you will be unpleasantly disappointed to discover that none
of the code posted so far will work on Unix (FreeBSD).
The code that Annie posted will only work on DOS-compatible systems.
The API call that Chad posted will only work on Windows
NT/2k/XP-compatible systems.
Nathan.
| can you please help me I want to read directly from ide hard drive for
| example I want to read cylinder = 5 head = 6 sector 56
I'd look at RBIL (BIOS int13h services).
But ye olde CHS-addressing wont work for newer, larger drives.
Here the ATA-specs and LBA-addressing are the proper source.
__
wolfgang
--
"Oh dear, I think you'll find reality's on the blink again."
-- Marvin The Paranoid Android
Get the latest news on lumpen sluts with Google Alerts.
Had a look at nasm annie? ;-)
I don't know if you are using any libraries such as C libraries, but
fopen/fread can read "/dev/hda" fine.
"Evenbit" <nbake...@charter.net> wrote in message
news:1105010694.0...@c13g2000cwb.googlegroups.com...
There is no way that that will work. For one thing, /dev/ad0s5g
is not a disk, but a partition (and a Unix partition at that).
The real question is what are you really trying to do? Why do
you want to read a particular sector? In general, it is not a
good idea to do that in Unix (unless you are writing a disk
driver, of course). There may be another way of doing what you
want to do that will not involve reading sectors.
If you must read sectors, you might try asking on the
freebsd-hackers mailing list. Or go directly to the source.
--
Thomas M. Sommers -- t...@nj.net -- AB2SB
"T.M. Sommers" <t...@nj.net> wrote in message
news:IuzDd.78$0R4....@monger.newsread.com...
Anyone know where I might get this information?
>
> God dammit ;} I can't seem to find anything on floppies, found the
> IDE/EIDE/ATAPI specs, but no floppy raw access ={.
>
> Anyone know where I might get this information?
http://www.dwiles.demon.co.uk/Programming/Hardware/FDC/floppy.html
??
>
>
| > God dammit ;} I can't seem to find anything on floppies, found the
| > IDE/EIDE/ATAPI specs, but no floppy raw access ={.
| >
| > Anyone know where I might get this information?
|
| http://www.dwiles.demon.co.uk/Programming/Hardware/FDC/floppy.html
|
| ??
Yes 'Debs' FDC-pages hold very valuable info.
RBIL also covers ports and bits for many different devices.
You already started with the collection of the vital stuff ?
__
wolfgang
Well. I am a nosy person so I happen to take a look at a lot of things. As I told you, took me 5 years before I desided on RosAsm, might take 5 years more before I feel ready to start programming an OS. Debs stuff is impressive, but maybe I am not really a OS guys after all. After having read Pauls page, where he gives his views about why he is not doing it, I have been thinking. And my thinking now is this : I will wait to see Kesys, or some other OS become a useful alternative, (ReactOS maybe) and then switch to one of thoose. It could be any OS. In the mean time I will train up my asm skills in RosAsm, and speculate how to write RosAsm code in the future that would be portable with less work, to another OS. Of course, if ReactOS becomes real and useful OS, it could be a target, but so could potentially any OS, with some work. If some other OS will make real a good, fast alternative to windows, then I think it might be wisest for me to just go there instead. No code is as easily
portable as asm code btw. Of course that contradicts common belief, but is nevertheless true.
This is really about having a place to move my interesst, the day Win32 will be fully and completly stupid environment. (It allready is mind you) I am not firstly an OS kind of person, I am a enduser application writer kind of person, I think.
But I know this : They say Linux Torvald is one hell of a capable person, but evidently Linux suck, just as much, if not more than windows. It ran like a wounded animal on my PC. In windows, fast code, is at least "possible". Pauls rantings was written a few years ago. I admit that windows HLL functionality is slow, but the lowlevel functions if used sparingly, seem to me not that bad. And the help from hardware, when you must have speed, is a definitive pluss. What linux have is : Its free open software. Thats about it. It doesnt ROCK. Kesys ROCKs, but is too technical yet. When you have internet support, for instance, ability to read ng's, and commuicate with email, it will be 1000 times as interesting, from user point of view. And at that time, I will sign up for a licence. But only if the licence allows me to build software on top of it.
After having taken a look at Debs stuff, and yours as well, I think it might be better to leave createing an Os to the really competent guys. Its seems to me that many OS'es are now beeing cocked, and its very exiting. I think I just wait around for one that kicks ass, to become my home in my old age, which after all is approaching, soon enough. I am 37, but it still feels like just two weeks ago I was 30. :-)))
Sometimes I even think programming is maybe God way of telling us : Dont go there. :-)))))))
But I still dont belive it....
>
> __
> wolfgang
>
>
>
>
>
My main reason for coding KESYS was just that I couldn't find one single
Os around which at least partially fit my demands.
I'd bet and expect you soon will post first questions in AOD :)
__
wolfgang