From 148da8ed91f17c6fb367f52c927629b0f4cacb5e Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 18 Apr 2025 09:26:57 +0200 Subject: Initial commit --- run.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 run.rb (limited to 'run.rb') diff --git a/run.rb b/run.rb new file mode 100755 index 0000000..ac8fc3d --- /dev/null +++ b/run.rb @@ -0,0 +1,46 @@ +#!/usr/bin/env ruby + +require 'open3' +require 'fileutils' +require 'pathname' + +TMP = Pathname.new 'build' +CROSS_GCC = '../riscv32-ilp32d--glibc/bin/riscv32-linux-gcc' +SYSROOT = '../riscv32-ilp32d--glibc/riscv32-buildroot-linux-gnu/sysroot' + +COMMON_BOOT_OBJECT = TMP + 'common-boot.o' + +FileUtils.rm_rf TMP +FileUtils.mkdir_p TMP + +FileUtils.cp 'boot/asm-boot.s', TMP + +def stage(source_elna, stage_name, output) + boot_exe = (TMP + stage_name).to_path + stage_path = TMP + "#{stage_name}.s" + arguments = [CROSS_GCC, '-nostdlib', '-o', boot_exe, stage_path.to_path, COMMON_BOOT_OBJECT.to_path] + + puts(arguments * ' ') + system *arguments, exception: true + + arguments = ['qemu-riscv32', '-L', SYSROOT, boot_exe] + + puts(arguments * ' ') + puts + Open3.popen2(*arguments) do |qemu_in, qemu_out| + qemu_in.write source_elna + qemu_in.close + + IO.copy_stream qemu_out, output + qemu_out.close + end +end + +system CROSS_GCC, '-nostdlib', '-c', '-o', COMMON_BOOT_OBJECT.to_path, 'boot/common-boot.s', exception: true +source_elna = File.read 'boot/goto-boot.elna' + +next_stage = TMP + 'goto-boot.s' +File.open next_stage, 'w' do |output| + stage source_elna, 'asm-boot', output +end +stage(source_elna, 'goto-boot', $stdout) -- cgit v1.2.3