File tree 4 files changed +33
-0
lines changed
4 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const LBAReader = require ( './read_lba' ) ;
4
+
5
+ module . exports . read = new LBAReader ( ) . read ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const driverUtils = require ( '../../core/driver-utils' ) ;
4
+
5
+ const ports = [ ] ;
6
+
7
+ for ( let i = 0 ; i < 8 ; i ++ ) {
8
+ ports [ i ] = driverUtils . ioPort ( 0x1F0 + i ) ;
9
+ }
10
+
11
+ class LBAReader {
12
+ read ( lba , num ) {
13
+ const buf = new Buffer ( num * 512 ) ;
14
+ ports [ 6 ] . write8 ( ( ( lba >> 24 ) & 0xff ) | 0b11100000 ) ;
15
+ ports [ 2 ] . write8 ( ( num ) & 0xff ) ;
16
+ ports [ 3 ] . write8 ( ( lba ) & 0xff ) ;
17
+ ports [ 4 ] . write8 ( ( lba >> 8 ) & 0xff ) ;
18
+ ports [ 5 ] . write8 ( ( lba >> 16 ) & 0xff ) ;
19
+ ports [ 7 ] . write8 ( 0x20 ) ;
20
+ while ( ! ( ports [ 7 ] . read8 ( ) & 8 ) ) ; // TODO: if HDD doesn't exist, fail
21
+ for ( let i = 0 ; i < num * 256 ; i ++ ) {
22
+ buf . writeUInt16LE ( ports [ 0 ] . read16 ( ) , i * 2 ) ;
23
+ }
24
+ return buf ;
25
+ }
26
+ }
27
+
28
+ module . exports = LBAReader ;
You can’t perform that action at this time.
0 commit comments