This commit is contained in:
c0repwn3r 2022-06-12 15:25:30 -04:00
parent 172fdd98db
commit 8ccd6e9c6d
Signed by: core
GPG Key ID: FDBF740DADDCEECF
8 changed files with 101 additions and 0 deletions

25
CMakeLists.txt Normal file
View File

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.10)
project(shadeOS LANGUAGES C ASM_NASM)
# Configure CFLAGS
set(CMAKE_C_FLAGS -ffreestanding)
set(CMAKE_LINKER x86_64-elf-ld)
set(CMAKE_C_COMPILER x86_64-elf-gcc)
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> -n <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
# Configure versioning info
set(SHADE_KERNEL_VERSION "0.1.1-alpha")
set(SHADE_RELEASE_STREAM "shade-development")
execute_process(COMMAND "git rev-parse --short HEAD | tr -d '\n'" SHADE_GIT_BUILD)
execute_process(COMMAND "date | tr -d '\n'" OUTPUT_VARIABLE SHADE_COMPILE_DATE)
set(SHADE_CODENAME willow)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/libc)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/kernel)
# Generate the iso
#add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/shadeOS.iso COMMAND ${CMAKE_SOURCE_DIR}/shade-build/mkiso.sh ${CMAKE_CURRENT_BINARY_DIR}/shadeOS.bin ${CMAKE_CURRENT_SOURCE_DIR}/../iso/ ${CMAKE_CURRENT_BINARY_DIR}/shadeOS.iso ${CMAKE_SOURCE_DIR}/shade-build/checkbin.sh)
# Add target to run the file
#add_custom_target(run COMMAND ${CMAKE_SOURCE_DIR}/shade-build/run_qemu.sh DEPENDS shadeOS.iso WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

6
include/shade/terminal.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef SHADE_TERMINAL_H
#define SHADE_TERMINAL_H
#endif

View File

@ -0,0 +1,11 @@
#ifndef SHADE_VERSION_H
#define SHADE_VERSION_H
// This file was autogenerated by the shadeOS build system.
// It should not be modified by hand.
// To change these values, modify them in CMakeLists.txt.
#define SHADE_OS_KERNEL_VERSION "${SHADE_KERNEL_VERSION}"
#define SHADE_OS_KERNEL "${SHADE_RELEASE_STREAM}"
#define SHADE_OS_BUILD "${SHADE_GIT_BUILD}"
#define SHADE_OS_COMPILE_DATE "${SHADE_COMPILE_DATE}"
#define SHADE_OS_CODENAME "${SHADE_CODENAME}"
#endif

5
shade-build/checkbin.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
echo "Checking binary $1"
grub-file --is-x86-multiboot2 $1
echo "$1 is a valid mb2 binary"

7
shade-build/mkiso.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
$4 $1
echo "Packaging $1 into shadeOS ISO $3"
# mkiso.sh build/src/kernel/shadeOS.bin src/iso/ build/shade.iso check_command
cp $1 $2/boot/shade.bin
grub-mkrescue $2 -o $3

2
shade-build/run_qemu.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
qemu-system-x86_64 -drive file=build/src/kernel/shade.iso,index=0,media=disk,format=raw -no-reboot

35
src/kernel/CMakeLists.txt Normal file
View File

@ -0,0 +1,35 @@
# Define ASM source files
set(KERNEL_ASM_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/platform/interrupts/int.asm)
# Define C source files
set(KERNEL_C_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/platform/drivers/keyboard.c
${CMAKE_CURRENT_SOURCE_DIR}/platform/drivers/vga_text_mode.c
${CMAKE_CURRENT_SOURCE_DIR}/platform/interrupts/idt.c
${CMAKE_CURRENT_SOURCE_DIR}/platform/interrupts/isr.c
${CMAKE_CURRENT_SOURCE_DIR}/platform/interrupts/pic.c
${CMAKE_CURRENT_SOURCE_DIR}/platform/ports.c
${CMAKE_CURRENT_SOURCE_DIR}/cansid.c
${CMAKE_CURRENT_SOURCE_DIR}/kernel.c
${CMAKE_CURRENT_SOURCE_DIR}/kmsg.c
${CMAKE_CURRENT_SOURCE_DIR}/util.c)
set(SBOOT_ASM_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../boot/entry.asm
${CMAKE_CURRENT_SOURCE_DIR}/../boot/entry64.asm
${CMAKE_CURRENT_SOURCE_DIR}/../boot/mb2_header.asm)
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../linker.ld)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${LINKER_SCRIPT}")
configure_file(${CMAKE_SOURCE_DIR}/include/shade/version.h.in ${CMAKE_SOURCE_DIR}/include/shade/version.h)
add_executable(shadeOS.bin ${SBOOT_ASM_SOURCE_FILES} ${KERNEL_ASM_SOURCE_FILES} ${KERNEL_C_SOURCE_FILES})
target_link_libraries(shadeOS.bin LINK_PUBLIC shadeOS_libc) # Link the kernel to libc
# Generate the iso
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/shade.iso COMMAND ${CMAKE_SOURCE_DIR}/shade-build/mkiso.sh ${CMAKE_CURRENT_BINARY_DIR}/shadeOS.bin ${CMAKE_CURRENT_SOURCE_DIR}/../iso/ ${CMAKE_CURRENT_BINARY_DIR}/shade.iso ${CMAKE_SOURCE_DIR}/shade-build/checkbin.sh DEPENDS shadeOS.bin)
# Add target to run the file
add_custom_target(run COMMAND ${CMAKE_SOURCE_DIR}/shade-build/run_qemu.sh DEPENDS shade.iso WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

10
src/libc/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
# Define C source files
set(LIBC_C_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/printf.c
${CMAKE_CURRENT_SOURCE_DIR}/strings.c)
# Define ASM source files
# none currently
add_library(shadeOS_libc ${LIBC_C_SOURCE_FILES}) # Create the libc library
target_include_directories(shadeOS_libc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include) # Set the include dir