Move assembly into the arch directory

This commit is contained in:
2025-07-18 22:40:30 +02:00
parent d77b7b8735
commit a5ef7a0906
4 changed files with 35 additions and 3 deletions

21
README.md Normal file
View File

@@ -0,0 +1,21 @@
Experimenting with operating system development.
- Programming language: [Elna](https://git.caraus.tech/belka/elna).
- Architecture: RISC-V 32-bit.
- Target machine: Qemu.
This repository contains some rake (ruby's task runner) tasks to build
a cross compiler and the code. Assuming that all dependencies needed to build
GCC are installed in the system the build is tested on Linux an MacOS.
To build the cross compiler do:
```sh
rake cross
```
To build and run the rest in qemu:
```sh
rake
```

View File

@@ -324,14 +324,19 @@ def relative_from_tmp(path)
Pathname.new(path).relative_path_from(TMP).each_filename Pathname.new(path).relative_path_from(TMP).each_filename
end end
def architecture_instruction_set(architecture)
architecture.gsub /[[:digit:]]+$/, ''
end
CLEAN.include(TMP + 'riscv32') CLEAN.include(TMP + 'riscv32')
directory(TMP + 'riscv32') directory(TMP + 'riscv32')
rule '.s.o' => ->(match) { rule '.s.o' => ->(match) {
architecture, *path_components = relative_from_tmp(match).to_a architecture, *path_components = relative_from_tmp(match).to_a
path_components[-1] = path_components.last.ext('') path_components[-1] = path_components.last.ext('')
instruction_set = architecture_instruction_set architecture
[File.join(path_components), TMP + architecture] [File.join('arch', instruction_set, path_components), TMP + architecture]
} do |t| } do |t|
options = BuildTarget.new relative_from_tmp(t.name).first options = BuildTarget.new relative_from_tmp(t.name).first
compiler = options.rootfs + "bin/#{options.target}-gcc" compiler = options.rootfs + "bin/#{options.target}-gcc"
@@ -356,9 +361,15 @@ rule '.elna.o' => ->(match) {
end end
rule 'kernel.elf' => ->(match) { rule 'kernel.elf' => ->(match) {
architecture_tmp = TMP + relative_from_tmp(match).first architecture = relative_from_tmp(match).first
instruction_set = architecture_instruction_set architecture
FileList['*.s', '*.elna'].map { |source| (architecture_tmp + source).to_path + '.o' } << 'kernel.ld' arch_objects = FileList["arch/#{instruction_set}/*.s"]
.map { |source| Pathname.new(source).relative_path_from("arch/#{instruction_set}").sub_ext('.s.o') }
.map { |source| TMP + architecture + source }
.map(&:to_path)
arch_objects + FileList['*.elna'].map { |source| (TMP + architecture + source).to_path + '.o' } << 'kernel.ld'
} do |t| } do |t|
options = BuildTarget.new relative_from_tmp(t.name).first options = BuildTarget.new relative_from_tmp(t.name).first
compiler = options.rootfs + "bin/#{options.target}-gcc" compiler = options.rootfs + "bin/#{options.target}-gcc"