Skip to content

Commit 2c8bea9

Browse files
committed
Merge branch 'master' of https://github.com/PROPHESSOR/runtime
2 parents 5501811 + 8e30927 commit 2c8bea9

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

.initrd

787 Bytes
Binary file not shown.

JsOS.iso

-20.8 MB
Binary file not shown.

js/driver/ata/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
const LBAReader = require('./read_lba');
4+
5+
module.exports.read = new LBAReader().read;

js/driver/ata/read_lba.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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;

0 commit comments

Comments
 (0)