build: BIOS stage2only build improvements
diff --git a/common/GNUmakefile b/common/GNUmakefile
index c0f878dd..8c9ee474 100644
--- a/common/GNUmakefile
+++ b/common/GNUmakefile
@@ -148,6 +148,7 @@ override ASM32_FILES := $(shell find ./ -type f -name '*.asm_ia32')
override ASMB_FILES := $(shell find ./ -type f -name '*.asm_bios_ia32')
override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM32_FILES:.asm_ia32=.o) $(ASMB_FILES:.asm_bios_ia32=.o) $(ASMX86_FILES:.asm_x86=.o))
+override OBJ_S2 := $(filter %.s2.o,$(OBJ))
endif
ifeq ($(TARGET), uefi-x86-64)
override ASMX86_FILES := $(shell find ./ -type f -name '*.asm_x86')
@@ -227,7 +228,7 @@ $(call MKESCAPE,$(BUILDDIR))/linker_stage2only.ld: linker_bios.ld.in
mkdir -p '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef -DLINKER_STAGE2ONLY linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld'
-$(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o
+$(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf: $(OBJ_S2) ../libgcc-binaries/libgcc-i686.a
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld'
$(CROSS_LD) '$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' -o '$(call SHESCAPE,$@)' || \
( echo "This error may mean that stage 2 was trying to use stage 3 symbols before loading stage 3" && \
diff --git a/common/lib/real.asm_bios_ia32 b/common/lib/real.s2.asm_bios_ia32
similarity index 100%
rename from common/lib/real.asm_bios_ia32
rename to common/lib/real.s2.asm_bios_ia32
diff --git a/common/lib/term.c b/common/lib/term.c
index f816895c..911d0bae 100644
--- a/common/lib/term.c
+++ b/common/lib/term.c
@@ -13,8 +13,6 @@
extern void reset_term(void);
extern void set_cursor_pos_helper(size_t x, size_t y);
-bool early_term = false;
-
void term_deinit(void) {
switch (term_backend) {
case VBE:
@@ -82,39 +80,6 @@ void term_vbe(size_t width, size_t height) {
// Tries to implement this standard for terminfo
// https://man7.org/linux/man-pages/man4/console_codes.4.html
-no_unwind int current_video_mode = -1;
-int term_backend = NOT_READY;
-size_t term_rows, term_cols;
-bool term_runtime = false;
-
-void (*raw_putchar)(uint8_t c);
-void (*clear)(bool move);
-void (*enable_cursor)(void);
-bool (*disable_cursor)(void);
-void (*set_cursor_pos)(size_t x, size_t y);
-void (*get_cursor_pos)(size_t *x, size_t *y);
-void (*set_text_fg)(size_t fg);
-void (*set_text_bg)(size_t bg);
-void (*set_text_fg_bright)(size_t fg);
-void (*set_text_bg_bright)(size_t bg);
-void (*set_text_fg_default)(void);
-void (*set_text_bg_default)(void);
-bool (*scroll_disable)(void);
-void (*scroll_enable)(void);
-void (*term_move_character)(size_t new_x, size_t new_y, size_t old_x, size_t old_y);
-void (*term_scroll)(void);
-void (*term_revscroll)(void);
-void (*term_swap_palette)(void);
-void (*term_save_state)(void);
-void (*term_restore_state)(void);
-
-void (*term_double_buffer_flush)(void);
-
-uint64_t (*term_context_size)(void);
-void (*term_context_save)(uint64_t ptr);
-void (*term_context_restore)(uint64_t ptr);
-void (*term_full_refresh)(void);
-
uint64_t term_arg = 0;
void (*term_callback)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t) = NULL;
diff --git a/common/lib/term.s2.c b/common/lib/term.s2.c
index 876c320c..15f6e323 100644
--- a/common/lib/term.s2.c
+++ b/common/lib/term.s2.c
@@ -5,6 +5,41 @@
#include <lib/blib.h>
#include <lib/real.h>
+bool early_term = false;
+
+no_unwind int current_video_mode = -1;
+int term_backend = NOT_READY;
+size_t term_rows, term_cols;
+bool term_runtime = false;
+
+void (*raw_putchar)(uint8_t c);
+void (*clear)(bool move);
+void (*enable_cursor)(void);
+bool (*disable_cursor)(void);
+void (*set_cursor_pos)(size_t x, size_t y);
+void (*get_cursor_pos)(size_t *x, size_t *y);
+void (*set_text_fg)(size_t fg);
+void (*set_text_bg)(size_t bg);
+void (*set_text_fg_bright)(size_t fg);
+void (*set_text_bg_bright)(size_t bg);
+void (*set_text_fg_default)(void);
+void (*set_text_bg_default)(void);
+bool (*scroll_disable)(void);
+void (*scroll_enable)(void);
+void (*term_move_character)(size_t new_x, size_t new_y, size_t old_x, size_t old_y);
+void (*term_scroll)(void);
+void (*term_revscroll)(void);
+void (*term_swap_palette)(void);
+void (*term_save_state)(void);
+void (*term_restore_state)(void);
+
+void (*term_double_buffer_flush)(void);
+
+uint64_t (*term_context_size)(void);
+void (*term_context_save)(uint64_t ptr);
+void (*term_context_restore)(uint64_t ptr);
+void (*term_full_refresh)(void);
+
// --- fallback ---
#if bios == 1
diff --git a/common/lib/pxe.asm_bios_ia32 b/common/pxe/pxe_asm.s2.asm_bios_ia32
similarity index 100%
rename from common/lib/pxe.asm_bios_ia32
rename to common/pxe/pxe_asm.s2.asm_bios_ia32
