diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 4134daa..0f4e984 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -70,6 +70,8 @@ add_custom_command( -wmo -O -Xcc -fno-stack-protector + -Xcc -I${CMAKE_CURRENT_SOURCE_DIR}/../Common + -import-bridging-header ${CMAKE_CURRENT_SOURCE_DIR}/Source/BridgingHeader.h -resource-dir ${SWIFT_RESOURCE_DIR} -c ${SWIFT_SOURCES} -o ${SWIFT_OBJ} diff --git a/Kernel/Source/BridgingHeader.h b/Kernel/Source/BridgingHeader.h new file mode 100644 index 0000000..49e7ea7 --- /dev/null +++ b/Kernel/Source/BridgingHeader.h @@ -0,0 +1 @@ +#include "bootinfo.h" diff --git a/Kernel/Source/kernel.swift b/Kernel/Source/kernel.swift index 384daaf..4dee551 100644 --- a/Kernel/Source/kernel.swift +++ b/Kernel/Source/kernel.swift @@ -1,12 +1,10 @@ @_cdecl("kmain") -public func kernelMain(_ bootInfo: UInt) { - // Bootinfo offsets: fb starts at 64, then base(8), baseSize(8), width(8), height(8) - let fbBase = UnsafePointer(bitPattern: bootInfo &+ 64)!.pointee - let width = UnsafePointer(bitPattern: bootInfo &+ 80)!.pointee - let height = UnsafePointer(bitPattern: bootInfo &+ 88)!.pointee - - let pixels = UnsafeMutablePointer(bitPattern: fbBase)! - let total = Int(width) &* Int(height) +public func kernelMain(_ bootInfo: UnsafeMutablePointer) { + let fb = bootInfo.pointee.framebuffer + let pixels = fb.base! + let width = Int(fb.width) + let height = Int(fb.height) + let total = width * height let stripe = total / 5 var i = 0 @@ -15,7 +13,7 @@ public func kernelMain(_ bootInfo: UInt) { let color: UInt32 if s == 0 || s >= 4 { color = 0x5BCEFA } else if s == 2 { color = 0xFFFFFF } - else { color = 0xF5A7B8 } + else { color = 0xF5A7B8 } pixels[i] = color i &+= 1 }