Skip to content

Commit 1f6cc10

Browse files
committed
build system stabilization and symbol resolution tasks
1. Update Makefile Link Order & Objects - Link Order : Modified the Makefile to place -lgcc at the very end of the link command. This ensures that any implicit 64-bit math symbols (like __udivdi3 ) required by the object files are correctly resolved by the compiler's support library. - LDFLAGS : Cleaned up LDFLAGS to focus on -T linker.ld -nostdlib -m32 , letting the link command handle the output and library ordering. - Object Inclusion : Verified that all critical objects (from src/arch/ , src/cpu/ , etc.) are automatically included in the build via the wildcard and patsubst rules. 2. Fix framebuffer.c - Splash Function : Implemented a non-static vga_display_splash directly in framebuffer.c . - Modern Driver : This version uses the modern fb_console and fb_clear APIs, providing a clean, colorized boot splash that works with the current linear framebuffer driver while maintaining compatibility with the kernel's initialization sequence. 3. Standardize linker.ld - Simplified Layout : Rewrote the linker script to follow a standard, robust layout. - PHDR Prevention : Replaced complex address offsets with standard BLOCK(4K) : ALIGN(4K) directives. This prevents "Program Header" errors and ensures sections like .text (which now correctly includes .multiboot ), .rodata , and .data are properly aligned on 4KB page boundaries. 4. Assembly Export Check - Symbol Visibility : Updated isr.s to explicitly mark isr_handler and irq_handler as global in addition to extern . This ensures the assembly stubs can correctly "talk" to the C implementations in isr.c .
1 parent 3ee4e21 commit 1f6cc10

4 files changed

Lines changed: 61 additions & 8 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ OBJCOPY := i686-linux-gnu-objcopy
55

66
CFLAGS := -ffreestanding -O2 -Wall -Wextra -m32 -fno-pie -fno-stack-protector -nostdlib -nostdinc -Iinclude -msse -msse2
77
ASFLAGS := -f elf32
8-
LDFLAGS := -T linker.ld -o kernel.bin -nostdlib -lgcc -m32
8+
LDFLAGS := -T linker.ld -nostdlib -m32
99

1010
SRC_DIR := src
1111
BUILD_DIR := build
@@ -40,7 +40,7 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
4040
$(CC) $(CFLAGS) -c $< -o $@
4141

4242
kernel.bin: $(OBJS) linker.ld
43-
$(LD) $(LDFLAGS) $(OBJS)
43+
$(LD) $(LDFLAGS) $(OBJS) -lgcc
4444

4545
$(MODEL_OBJ): $(MODEL_BLOB)
4646
mkdir -p $(dir $@)

linker.ld

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,32 @@ ENTRY(_start)
22

33
SECTIONS
44
{
5-
.multiboot 0x100000 : AT(0x0) {
6-
KEEP(*(.multiboot))
7-
}
8-
9-
. = 0x100000 + SIZEOF(.multiboot);
10-
kernel_start = .;
5+
. = 1M;
116

7+
.text BLOCK(4K) : ALIGN(4K)
128
.text : {
9+
*(.multiboot)
1310
*(.text*)
1411
}
1512

13+
.rodata BLOCK(4K) : ALIGN(4K)
1614
.rodata : {
1715
*(.rodata*)
1816
}
1917

18+
.ai_model BLOCK(4K) : ALIGN(4K)
2019
.ai_model : {
2120
_ai_model_start = .;
2221
KEEP(*(.ai_model*))
2322
_ai_model_end = .;
2423
}
2524

25+
.data BLOCK(4K) : ALIGN(4K)
2626
.data : {
2727
*(.data*)
2828
}
2929

30+
.bss BLOCK(4K) : ALIGN(4K)
3031
.bss : {
3132
*(COMMON)
3233
*(.bss*)

src/cpu/isr.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
extern isr_handler
44
extern irq_handler
5+
global isr_handler
6+
global irq_handler
57

68
%macro ISR_NOERR 1
79
global isr%1

src/video/framebuffer.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,56 @@ void vga_hide_cursor(void) {
489489
outb(0x3D5, 0x20);
490490
}
491491

492+
void vga_display_splash(void) {
493+
static const char* logo[] = {
494+
" ____ _ _ _ _ _ ",
495+
"| __ ) __ _ ___ (_) ___ __| | ___| (_)_ __ ___| |_ ___ _ __ ",
496+
"| _ \\ / _` / __| | |/ _ \\/ _` |/ _ \\ | | '__/ __| __/ _ \\ '__|",
497+
"| |_) | (_| \\__ \\ | | __/ (_| | __/ | | | \\__ \\ || __/ | ",
498+
"|____/ \\__,_|___/ |_|\\___|\\__,_|\\___|_|_|_| |___/\\__\\___|_| ",
499+
" BasicallyLinux "
500+
};
501+
static const char* disclaimer = "(It's definitely not)";
502+
static const char* messages[] = {
503+
"Initializing GDT...",
504+
"Loading IDT...",
505+
"Enabling Paging...",
506+
"Initializing Heap...",
507+
"Starting Scheduler...",
508+
"Bringing up Devices...",
509+
"Launching Shell..."
510+
};
511+
512+
fb_clear(0);
513+
fb_console_init(0x00FF00, 0); // Green logo
514+
for (uint32_t i = 0; i < sizeof(logo) / sizeof(logo[0]); ++i) {
515+
fb_console_write(logo[i]);
516+
fb_console_write("\n");
517+
}
518+
fb_console_init(0xFF0000, 0); // Red disclaimer
519+
fb_console_write(disclaimer);
520+
fb_console_write("\n\n");
521+
522+
fb_console_init(0xFFFFFF, 0); // White messages
523+
for (uint32_t i = 0; i < sizeof(messages) / sizeof(messages[0]); ++i) {
524+
const char* msg = messages[i];
525+
for (uint32_t c = 0; msg[c] != 0; ++c) {
526+
char buf[2] = {msg[c], 0};
527+
fb_console_write(buf);
528+
// Simple wait loop since we don't have a reliable wait_ticks here
529+
for (volatile int j = 0; j < 1000000; j++);
530+
}
531+
fb_console_write("\n");
532+
}
533+
534+
fb_console_write("\n");
535+
fb_console_init(0x00FFFF, 0); // Cyan build info
536+
fb_console_write("Build Info: v0.0.1 | i686-linux-gnu\n");
537+
538+
for (volatile int j = 0; j < 50000000; j++);
539+
fb_clear(0);
540+
}
541+
492542
void vga_print_art(void) {
493543
vga_display_splash();
494544
}

0 commit comments

Comments
 (0)