Skip to content

Commit 50afdad

Browse files
Merge branch 'rust-nightly' of https://github.com/Andy-Python-Programmer/aero into rust-nightly
2 parents 4eaef55 + 0f6e461 commit 50afdad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3546
-1063
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ sysroot
1212

1313
# Bochs specific files:
1414
bx_enh_dbg.ini
15+
16+
# Objdump files:
17+
*.dump
18+
19+
# Remove doom port related files:
20+
base-files/doom1.wad

.vscode/launch.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "cppdbg",
66
"request": "launch",
77
"name": "Attach Qemu",
8-
"program": "${workspaceFolder}/src/target/x86_64-aero_os/debug/aero_kernel",
8+
"program": "${workspaceFolder}/src/target/x86_64-aero_os/release/aero_kernel",
99
"args": [],
1010
"cwd": "${workspaceFolder}",
1111
"externalConsole": false,
@@ -24,7 +24,7 @@
2424
"description": "Connect to QEMU remote debugger"
2525
},
2626
{
27-
"text": "symbol-file ${workspaceFolder}/src/target/x86_64-aero_os/debug/aero_kernel",
27+
"text": "symbol-file ${workspaceFolder}/src/target/x86_64-aero_os/release/aero_kernel",
2828
"description": "Get kernel symbols"
2929
}
3030
],
@@ -38,7 +38,7 @@
3838
"platform select remote-gdb-server"
3939
],
4040
"targetCreateCommands": [
41-
"target create ${workspaceFolder}/src/target/x86_64-aero_os/debug/aero_kernel"
41+
"target create ${workspaceFolder}/src/target/x86_64-aero_os/release/aero_kernel"
4242
],
4343
"processCreateCommands": [
4444
"gdb-remote 127.0.0.1:1234" // Connect to the GDB Server
@@ -59,4 +59,4 @@
5959
]
6060
}
6161
]
62-
}
62+
}

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ No, Aero runs its own kernel that does *not* originate from Linux and does not s
2020

2121
# Screenshots
2222
<img src="misc/demo.png">
23-
<p align="center"><i>Aero OS running in Qemu (the background image is by <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">Rick Astley</a>)</i></p>
23+
<p align="center"><i>Aero running TCC in Qemu (the background image is by <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">Rick Astley</a>)</i></p>
2424

2525
<img src="misc/qjs-in-aero.png">
26-
<p align="center">QJS running in Aero</p>
26+
<p align="center"><i>Aero running Quick JS in Qemu (the background image is by <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">Rick Astley</a>)</i></p>
27+
28+
<img src="misc/aero-doom.png">
29+
<p align="center"><i>Aero running DOOM in Qemu (the background image is by <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">Rick Astley</a>)</i></p>
2730

2831
# Features
2932
- 64-bit higher half kernel

aero.py

Lines changed: 115 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ def parse_args():
137137
action='store_true',
138138
help='build the full userland sysroot. If disabled, then the sysroot will only contain the aero_shell and the init binaries')
139139

140+
parser.add_argument('--disable-kvm',
141+
default=False,
142+
action='store_true',
143+
help='disable KVM acceleration even if its available')
144+
140145
parser.add_argument('remaining',
141146
nargs=argparse.REMAINDER,
142147
help='additional arguments to pass as the emulator')
@@ -188,13 +193,13 @@ def extract_artifacts(stdout):
188193
return result
189194

190195

191-
def build_cargo_workspace(cwd, command, args):
192-
code, _, _ = run_command(['cargo', command, *args], cwd=cwd)
196+
def build_cargo_workspace(cwd, command, args, cargo='cargo'):
197+
code, _, _ = run_command([cargo, command, *args], cwd=cwd)
193198

194199
if code != 0:
195200
return None
196201

197-
_, stdout, _ = run_command(['cargo', command, *args, '--message-format=json'],
202+
_, stdout, _ = run_command([cargo, command, *args, '--message-format=json'],
198203
stdout=subprocess.PIPE,
199204
stderr=subprocess.DEVNULL,
200205
cwd=cwd)
@@ -274,10 +279,13 @@ def build_userland(args):
274279
if args.check:
275280
command = 'check'
276281

282+
cargo = '../sysroot/tools/host-cargo/bin/cargo'
283+
cmd_args += ['--target', 'x86_64-unknown-aero-system']
284+
277285
if args.test:
278-
return build_cargo_workspace('userland', 'build', ['--package', 'utest', *cmd_args])
286+
return build_cargo_workspace('userland', 'build', ['--package', 'utest', *cmd_args], cargo)
279287
else:
280-
return build_cargo_workspace('userland', command, cmd_args)
288+
return build_cargo_workspace('userland', command, cmd_args, cargo)
281289

282290
# TODO: Userland check
283291
# elif args.check:
@@ -401,6 +409,16 @@ def cp(src, dest):
401409
limine_install = 'limine-install-win32.exe'
402410
elif platform.system() == 'Linux':
403411
limine_install = 'limine-install-linux-x86_64'
412+
elif platform.system() == 'Darwin':
413+
limine_install = 'limine-install'
414+
# Limine doesn't provide pre-built binaries, so we have to build from source
415+
code, _, limine_build_stderr = run_command(['make', '-C', limine_path],
416+
stdout=subprocess.PIPE,
417+
stderr=subprocess.PIPE)
418+
if code != 0:
419+
print('Failed to build `limine-install`')
420+
print(limine_build_stderr.decode('utf8'))
421+
exit(1)
404422

405423
limine_install = os.path.join(limine_path, limine_install)
406424

@@ -418,8 +436,9 @@ def cp(src, dest):
418436

419437

420438
def run_in_emulator(args, iso_path):
439+
is_kvm_available = is_kvm_supported()
440+
421441
qemu_args = ['-cdrom', iso_path,
422-
'-cpu', 'qemu64,+la57' if args.la57 else 'qemu64',
423442
'-M', 'q35',
424443
'-m', '5G',
425444
'-smp', '1',
@@ -436,9 +455,99 @@ def run_in_emulator(args, iso_path):
436455
if cmdline:
437456
qemu_args += cmdline
438457

458+
if is_kvm_available and not args.disable_kvm:
459+
print("Running with KVM acceleration enabled")
460+
461+
if platform.system() == 'Darwin':
462+
qemu_args += ['-accel', 'hvf']
463+
else:
464+
qemu_args += ['-enable-kvm']
465+
qemu_args += ['-cpu', 'host,+la57' if args.la57 else 'host']
466+
else:
467+
qemu_args += ["-cpu", "qemu64,+la57" if args.la57 else "qemu64"]
468+
439469
run_command(['qemu-system-x86_64', *qemu_args])
440470

441471

472+
def get_sysctl(name: str) -> str:
473+
"""
474+
Shell out to sysctl(1)
475+
476+
Returns the value as a string.
477+
Non-leaf nodes will return the value for each sub-node separated by newline characters.
478+
"""
479+
status, stdout, stderr = run_command(["sysctl", "-n", name],
480+
stdout=subprocess.PIPE,
481+
stderr=subprocess.PIPE)
482+
if status != 0:
483+
print("`sysctl` failed: ", end="")
484+
print(stderr.decode())
485+
486+
return stdout.strip().decode()
487+
488+
489+
def is_kvm_supported() -> bool:
490+
"""
491+
Returns True if KVM is supported on this machine
492+
"""
493+
494+
platform = sys.platform
495+
496+
if platform == "darwin":
497+
# Check for VMX support
498+
cpu_features = get_sysctl("machdep.cpu.features")
499+
vmx_support = "VMX" in cpu_features.split(' ')
500+
501+
# Check for HVF support
502+
hv_support = get_sysctl("kern.hv_support") == "1"
503+
504+
return hv_support and vmx_support
505+
506+
if platform == "linux":
507+
kvm_path = "/dev/kvm"
508+
509+
# Check if the `/dev/kvm` device exists.
510+
if not os.path.exists(kvm_path):
511+
return False
512+
513+
# Read out the cpuinfo from `/proc/cpuinfo`
514+
fd = open("/proc/cpuinfo")
515+
cpuinfo = fd.read()
516+
517+
# Parse the cpuinfo
518+
cpuinfo_array = cpuinfo.split("\n\n")
519+
processors_info = []
520+
521+
for cpu in cpuinfo_array:
522+
ret = {}
523+
for line in cpu.split("\n"):
524+
try:
525+
name, value = line.split(":")
526+
527+
name = name.strip()
528+
value = value.strip()
529+
530+
ret[name] = value
531+
except ValueError:
532+
pass
533+
534+
processors_info.append(ret)
535+
536+
for processor in processors_info:
537+
if processor["processor"] == "0":
538+
# KVM acceleration can be used
539+
if "vmx" in processor["flags"]:
540+
return True
541+
# KVM acceleration cannot be used
542+
else:
543+
return False
544+
545+
fd.close()
546+
547+
# KVM is not avaliable on Windows
548+
return False
549+
550+
442551
def main():
443552
args = parse_args()
444553

base-files/.bashrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PS1='\[\033[01;32m\]root@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '
2+
3+
HISTCONTROL=ignoredups
4+
HISTSIZE=-1
5+
HISTFILESIZE=-1
6+
7+
alias ls="ls --color=auto"
8+
alias clear='printf "\e[2J\e[H"'

bootstrap.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ sources:
4545

4646
- name: mlibc
4747
subdir: 'bundled'
48-
url: 'https://github.com/managarm/mlibc/archive/afd11daf4565943f8265b2c1ed2a9116e7a4ba4f.tar.gz'
48+
url: 'https://github.com/managarm/mlibc/archive/a569f1edddad6017177118713b3d42858305a4d0.tar.gz'
4949
format: 'tar.gz'
50-
extract_path: 'mlibc-afd11daf4565943f8265b2c1ed2a9116e7a4ba4f'
50+
extract_path: 'mlibc-a569f1edddad6017177118713b3d42858305a4d0'
5151
patch-path-strip: 1
5252
version: '12.rolling'
5353

@@ -186,8 +186,8 @@ tools:
186186
source:
187187
subdir: 'bundled'
188188
git: 'https://github.com/rust-lang/cargo.git'
189-
tag: '0.53.0'
190-
version: '0.53.0'
189+
branch: 'master'
190+
commit: '25fcb135d02ea897ce894b67ae021f48107d522b'
191191
tools_required:
192192
- tool: host-rust
193193
recursive: true
@@ -545,11 +545,12 @@ packages:
545545

546546
- name: bash
547547
source:
548+
git: 'https://git.savannah.gnu.org/git/bash.git'
549+
# Checkout bash 5.1
550+
branch: 'master'
551+
commit: '9439ce094c9aa7557a9d53ac7b412a23aa66e36b'
552+
version: '5.1.16'
548553
subdir: 'bundled'
549-
url: 'https://ftp.gnu.org/gnu/bash/bash-5.1.tar.gz'
550-
format: 'tar.gz'
551-
extract_path: 'bash-5.1'
552-
patch-path-strip: 3
553554
tools_required:
554555
- host-gcc
555556
- host-autoconf-v2.69
@@ -563,11 +564,12 @@ packages:
563564
- '--prefix=/usr'
564565
- '--without-bash-malloc'
565566
- '--disable-nls'
567+
- 'CFLAGS=-g -O0'
566568
environ:
567569
ac_cv_func_wcswidth: 'no'
568570
build:
569571
- args: ['make', '-j@PARALLELISM@']
570-
- args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install-strip']
572+
- args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install']
571573

572574
- name: tcc
573575
source:
@@ -645,6 +647,21 @@ packages:
645647
# environ:
646648
# DESTDIR: '@THIS_COLLECT_DIR@'
647649

650+
- name: doomgeneric
651+
source:
652+
subdir: 'bundled'
653+
git: 'https://github.com/ozkl/doomgeneric.git'
654+
branch: 'master'
655+
commit: '2d9b24f07c78c36becf41d89db30fa99863463e5'
656+
tools_required:
657+
- host-gcc
658+
pkgs_required:
659+
- mlibc
660+
build:
661+
- args: ['make', '-C', '@THIS_SOURCE_DIR@/doomgeneric', '-f', 'Makefile.aero', '-j@PARALLELISM@']
662+
- args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/bin']
663+
- args: ['cp', '@THIS_SOURCE_DIR@/doomgeneric/doomgeneric', '@THIS_COLLECT_DIR@/usr/bin/doomgeneric']
664+
648665
- name: lua
649666
source:
650667
subdir: bundled

misc/aero-doom.png

213 KB
Loading

0 commit comments

Comments
 (0)