-
Notifications
You must be signed in to change notification settings - Fork 10
/
jslinux_original_disk.js
89 lines (64 loc) · 2.02 KB
/
jslinux_original_disk.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
Linux launcher
Copyright (c) 2011 Fabrice Bellard
Redistribution or commercial use is prohibited without the author's
permission.
*/
"use strict";
var term, pc, boot_start_time, sbd;
function uploadFile(file) {
sbd.storage.loadData(file);
}
function download() {
document.getElementById("download").innerHTML = sbd.storage.getDownloadLink();
}
function term_start()
{
term = new Term(80, 30, term_handler);
term.open();
}
/* send chars to the serial port */
function term_handler(str)
{
pc.serial.send_chars(str);
}
/* just used to display the boot time in the VM */
function get_boot_time()
{
return (+new Date()) - boot_start_time;
}
function start()
{
var start_addr, initrd_size, params, cmdline_addr;
params = new Object();
/* serial output chars */
params.serial_write = term.write.bind(term);
/* memory size (in bytes) */
params.mem_size = 12 * 1024 * 1024;
params.get_boot_time = get_boot_time;
pc = new PCEmulator(params);
sbd = new SBD(pc);
// Load the binary at 1mbyte:
// 0x00100000 == 2^20
//pc.load_binary("vmlinux-3.0.4.bin", 0x00100000);
pc.load_binary("vmlinux-3.0.4-simpleblock.bin", 0x00100000);
//pc.load_binary("vmlinux-3.0.4-net.bin", 0x00100000);
initrd_size = pc.load_binary("root.bin", 0x00500000);
start_addr = 0x10000;
pc.load_binary("linuxstart.bin", start_addr);
/* set the Linux kernel command line */
/* Note: we don't use initramfs because it is not possible to
disable gzip decompression in this case, which would be too
slow. */
cmdline_addr = 0xf800;
/* notsc=1 disables time stamp counter; time step counter since reset.
jslinux does not have one. */
pc.cpu.write_string(cmdline_addr, "console=ttyS0 root=/dev/ram0 rw init=/sbin/init notsc=1");
pc.cpu.eip = start_addr;
pc.cpu.regs[0] = params.mem_size; /* eax */
pc.cpu.regs[3] = initrd_size; /* ebx */
pc.cpu.regs[1] = cmdline_addr; /* ecx */
boot_start_time = (+new Date());
pc.start();
}
term_start();