Added bridging header for swift
c structures are now exposed to swift using a bridging header. it is possible to access bootinfo using the structure (as oppossed to doing bytesfifts blind) tested on aarch64 apple. please test on other systems
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "bootinfo.h"
|
||||
@@ -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<UInt>(bitPattern: bootInfo &+ 64)!.pointee
|
||||
let width = UnsafePointer<UInt64>(bitPattern: bootInfo &+ 80)!.pointee
|
||||
let height = UnsafePointer<UInt64>(bitPattern: bootInfo &+ 88)!.pointee
|
||||
|
||||
let pixels = UnsafeMutablePointer<UInt32>(bitPattern: fbBase)!
|
||||
let total = Int(width) &* Int(height)
|
||||
public func kernelMain(_ bootInfo: UnsafeMutablePointer<Bootinfo>) {
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user