- Changed grub.cfg from 'multiboot' to 'multiboot2' command. The PMM parses Multiboot2 tag structures, but GRUB was booting with Multiboot1 protocol, causing the memory map parsing to silently fail (all memory stayed marked as used, leading to OOM on every allocation). - Fixed BITMAP_SIZE calculation to properly round up instead of truncating, ensuring the last few pages of the address space are covered. - Fixed sign comparison warning in bitmap init loop. - Added debug output to PMM init (mem_upper, region count) for diagnostics. - Removed stale Multiboot1 magic constant and (void)addr cast from kernel.c. - Added documentation for the interrupt subsystem and PMM in docs/. - Checked off 'Implement a PIC handler' and 'Create a physical memory allocator' in the task list. Tested: kernel boots in QEMU with both 4MB and 128MB RAM, PMM correctly allocates from NORMAL zone (0x01000000) and DMA zone (0x00001000).
41 lines
1.5 KiB
CMake
41 lines
1.5 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(ClaudeOS C ASM)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
# We are building a kernel, so we don't want standard libraries
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffreestanding -m32 -fno-pie -fno-pic -fno-builtin -fno-stack-protector -mno-sse -mno-mmx -g -O2 -Wall -Wextra")
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -m32 -fno-pie -fno-pic")
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32 -nostdlib -no-pie")
|
|
|
|
# Define build output directory
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
add_subdirectory(src)
|
|
|
|
# Create output directories
|
|
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/release)
|
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/isodir/boot/grub)
|
|
|
|
# Create grub.cfg for ISO
|
|
file(WRITE ${CMAKE_BINARY_DIR}/isodir/boot/grub/grub.cfg "set timeout=0\nset default=0\nsearch --set=root --file /boot/kernel.bin\nmenuentry \"ClaudeOS\" { multiboot2 /boot/kernel.bin }")
|
|
|
|
|
|
# ISO Generation
|
|
add_custom_target(iso ALL
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/kernel ${CMAKE_BINARY_DIR}/isodir/boot/kernel.bin
|
|
COMMAND grub-mkrescue -o ${CMAKE_SOURCE_DIR}/release/claude-os.iso ${CMAKE_BINARY_DIR}/isodir
|
|
DEPENDS kernel
|
|
COMMENT "Generating bootable ISO image"
|
|
)
|
|
|
|
# Test target
|
|
add_custom_target(test_images
|
|
COMMAND sh ${CMAKE_SOURCE_DIR}/test_images.sh
|
|
DEPENDS iso
|
|
COMMENT "Testing generated images in QEMU"
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|