HD driver working (was: Re: [movitz-devel] Re: Possible macroexpansion bug)

Peter Minten peter.minten at wanadoo.nl
Sun May 2 12:11:50 UTC 2004


Frode Vatvedt Fjeld wrote:

> However, I'd suggest using an approach like the one I've adopted in
> x86-pc/dp8390.lisp for such register accessors. However, this needs
> some fixing because it assumes 8-bit registers exclusively right
> now. I'll look into it shortly.

Well, the simple macro solution works best for me and it's IMHO easier to 
understand so I'll stick to it for now.

Anyway the reason I write this mail is to announce the first working version of 
the hd driver (at 'http://www.il.fontys.nl/~silvernerd/harddisk.lisp'). 
Currently read-sectors and write-sectors are implemented. I've used the 
following code in los0.lisp for testing:

(defun hdc-reset-test ()
   (muerte.x86-pc.harddisk:hdc-reset 0))

(defun read-test (&optional (s 1))
   (muerte.x86-pc.harddisk:hdc-reset 0)
   (muerte.x86-pc.harddisk:hd-read-sectors 0 s 1))

(defun read-multi-test (&optional (s 1))
   (muerte.x86-pc.harddisk:hdc-reset 0)
   (muerte.x86-pc.harddisk:hd-read-sectors 0 s 2))

(defun write-test (&optional (s 1))
   (muerte.x86-pc.harddisk:hdc-reset 0)
   (let ((data (make-array 512 :initial-element #xAB)))
     (dotimes (x 256)
       (setf (aref data (* x 2)) #xCD))
     (muerte.x86-pc.harddisk:hd-write-sectors 0 s data)))

(defun write-multi-test (&optional (s 1))
   (muerte.x86-pc.harddisk:hdc-reset 0)
   (let ((data (make-array 1024 :initial-element #xAB)))
     (dotimes (x 512)
       (setf (aref data (* x 2)) #xCD))
     (muerte.x86-pc.harddisk:hd-write-sectors 0 s data)))

Note that hdc-reset has to be invoked at least once (at boot) and takes a 
harddisk controller number. The numbering scheme for harddisks is simple:

0  primary master
1  primary slave
2  secondary master
3  secondary slave
...

The harddisk controller number is:
0  primary controller
1  secondary controller
...

aka (mod hd-number 2).

Hd-read-sectors takes three arguments: hd-number, first sector location in LBA 
format and number of sectors to be read. It returns a vector with size (* 512 
number-of-sectors) and elements of (unsigned-byte 8).

Hd-write-sectors take three arguments: hd-number, first sector location in LBA 
format and the data (a vector with size (* 512 number-of-sectors)). It returns 
nothing.

Note that for now only disks 0 and 1 work, though adding more disks is just a 
matter of adding a few make-instances to *hd-controllers*.

Greetings,

Peter





More information about the movitz-devel mailing list