Don't build the kernel image for cross compiler

This commit is contained in:
2025-07-13 17:26:36 +02:00
parent c6078a17ac
commit d77b7b8735
4 changed files with 54 additions and 93 deletions

View File

@@ -228,7 +228,7 @@ namespace :cross do
'HOSTCFLAGS' => "-D_UUID_T -D__GETHOSTUUID_H -I#{TMP + 'tools/include'}" 'HOSTCFLAGS' => "-D_UUID_T -D__GETHOSTUUID_H -I#{TMP + 'tools/include'}"
} }
sh env, 'make', 'rv32_defconfig', chdir: cwd.to_path sh env, 'make', 'rv32_defconfig', chdir: cwd.to_path
sh env, 'make', '-j', Etc.nprocessors.to_s, chdir: cwd.to_path # sh env, 'make', '-j', Etc.nprocessors.to_s, chdir: cwd.to_path
sh env, 'make', 'headers', chdir: cwd.to_path sh env, 'make', 'headers', chdir: cwd.to_path
user_directory = options.sysroot + 'usr' user_directory = options.sysroot + 'usr'
@@ -298,7 +298,7 @@ namespace :cross do
"--build=#{options.build}", "--build=#{options.build}",
"--host=#{options.build}" "--host=#{options.build}"
] ]
flags = '-O2 -fPIC' flags = '-O2 -fPIC -I/opt/homebrew/opt/flex/include'
env = { env = {
'CFLAGS' => flags, 'CFLAGS' => flags,
'CXXFLAGS' => flags, 'CXXFLAGS' => flags,

View File

@@ -2,7 +2,7 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can # v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/. # obtain one at https://mozilla.org/MPL/2.0/.
.global write_s, write_c, write_i, _print_i .global write_s, write_c
.global memcmp, memchr, memmem, memcpy .global memcmp, memchr, memmem, memcpy
.section .text .section .text
@@ -75,85 +75,6 @@ write_s:
addi sp, sp, 32 addi sp, sp, 32
ret ret
# Writes a number to a string buffer.
#
# t0 - Local buffer.
# t1 - Constant 10.
# t2 - Current character.
# t3 - Whether the number is negative.
#
# Parameters:
# a0 - Whole number.
# a1 - Buffer pointer.
#
# Sets a0 to the length of the written number.
.type _print_i, @function
_print_i:
addi sp, sp, -32
sw ra, 28(sp)
sw s0, 24(sp)
addi s0, sp, 32
li t1, 10
addi t0, s0, -9
li t3, 0
bgez a0, .Lprint_i_digit10
li t3, 1
neg a0, a0
.Lprint_i_digit10:
rem t2, a0, t1
addi t2, t2, '0'
sb t2, 0(t0)
div a0, a0, t1
addi t0, t0, -1
bne zero, a0, .Lprint_i_digit10
beq zero, t3, .Lprint_i_write_call
addi t2, zero, '-'
sb t2, 0(t0)
addi t0, t0, -1
.Lprint_i_write_call:
mv a0, a1
addi a1, t0, 1
sub a2, s0, t0
addi a2, a2, -9
sw a2, 0(sp)
call memcpy
lw a0, 0(sp)
lw ra, 28(sp)
lw s0, 24(sp)
addi sp, sp, 32
ret
# Writes a number to the standard output.
#
# Parameters:
# a0 - Whole number.
.type write_i, @function
write_i:
addi sp, sp, -32
sw ra, 28(sp)
sw s0, 24(sp)
addi s0, sp, 32
addi a1, sp, 0
call _print_i
mv a1, a0
addi a0, sp, 0
call write_s
lw ra, 28(sp)
lw s0, 24(sp)
addi sp, sp, 32
ret
# Prints a character from a0. # Prints a character from a0.
# #
# Arguments: # Arguments:

View File

@@ -170,19 +170,22 @@ handle_trap:
call write_c call write_c
csrr a0, scause csrr a0, scause
call write_i la a1, write_c
call print_i
call separator call separator
call write_c call write_c
csrr a0, stval csrr a0, stval
call write_i la a1, write_c
call print_i
call separator call separator
call write_c call write_c
csrr a0, sepc csrr a0, sepc
call write_i la a1, write_c
call print_i
call panic call panic

View File

@@ -26,7 +26,6 @@ type
var var
next_paddr*: Pointer; next_paddr*: Pointer;
proc write_i(value: Int); extern;
proc write_c(value: Char); extern; proc write_c(value: Char); extern;
proc write_s(value: String); extern; proc write_s(value: String); extern;
@@ -86,6 +85,44 @@ proc write_x*(value: Word, padding: Word) -> Word;
return print_x(value, padding, write_c) return print_x(value, padding, write_c)
end; end;
(* Writes a Word and puts it into the sink. *)
proc print_w*(value: Word, sink: proc(Char)) -> Word;
var
buffer: [10]Char;
i: Word;
result: Word;
character_code: Word;
begin
i := 0u;
if value = 0u then
i := 1u;
buffer[i] := '0'
end;
while value <> 0u do
i := i + 1u;
character_code := value % 10u + cast('0': Word);
buffer[i] := cast(character_code: Char);
value := value / 10u
end;
result := i;
while i > 0u do
sink(buffer[i]);
i := i - 1u
end;
return result
end;
(* Writes an Int and puts it into the sink. *)
proc print_i*(value: Int, sink: proc(Char)) -> Word;
begin
if value < 0 then
sink('-');
value := -value
end;
return print_w(cast(value: Word), sink)
end;
(* (*
Converts 4 bytes of the input in network byte order into an unsigned integer. Converts 4 bytes of the input in network byte order into an unsigned integer.
*) *)
@@ -113,7 +150,7 @@ begin
write_c('\n'); write_c('\n');
write_s("Total size: "); write_s("Total size: ");
write_i(cast(header^.totalsize: Int)); print_w(header^.totalsize, write_c);
write_c('\n'); write_c('\n');
write_s("Struct offset: 0x"); write_s("Struct offset: 0x");
@@ -129,23 +166,23 @@ begin
write_c('\n'); write_c('\n');
write_s("Version: "); write_s("Version: ");
write_i(cast(header^.version: Int)); print_w(header^.version, write_c);
write_c('\n'); write_c('\n');
write_s("Last compatible version: "); write_s("Last compatible version: ");
write_i(cast(header^.last_comp_version: Int)); print_w(header^.last_comp_version, write_c);
write_c('\n'); write_c('\n');
write_s("CPU id: "); write_s("CPU id: ");
write_i(cast(header^.boot_cpuid_phys: Int)); print_w(header^.boot_cpuid_phys, write_c);
write_c('\n'); write_c('\n');
write_s("Strings length: "); write_s("Strings length: ");
write_i(cast(header^.size_dt_strings: Int)); print_w(header^.size_dt_strings, write_c);
write_c('\n'); write_c('\n');
write_s("Struct length: "); write_s("Struct length: ");
write_i(cast(header^.size_dt_struct: Int)); print_w(header^.size_dt_struct, write_c);
write_c('\n') write_c('\n')
end; end;
@@ -198,7 +235,7 @@ begin
else else
write_c(' '); write_c(' ');
stream := stream + property.len; stream := stream + property.len;
write_i(cast(property.len: Int)) print_w(property.len, write_c)
end; end;
write_c('\n'); write_c('\n');