Skip to content

Commit 80b573d

Browse files
authored
Merge pull request #72 from kkebo/fix-actual-device
2 parents b76517b + 7dac34c commit 80b573d

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SWIFT := swift
77
SWIFT_BUILD_FLAGS := --triple $(TRIPLE) -c release -Xswiftc -Osize \
88
--experimental-lto-mode=full -Xswiftc -experimental-hermetic-seal-at-link
99
LD := clang -fuse-ld=lld
10-
LDFLAGS := --target=$(TRIPLE) -nostdlib -static -Wl,--gc-sections,--print-gc-sections,--strip-all,--allow-multiple-definition
10+
LDFLAGS := --target=$(TRIPLE) -nostdlib -static -Wl,--gc-sections,--print-gc-sections,--strip-all
1111
OBJCOPY := llvm-objcopy
1212
QEMU := qemu-system-aarch64
1313

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ let package = Package(
3535
),
3636
.target(
3737
name: "RaspberryPi",
38-
dependencies: ["Font", "Support", "AsmSupport"],
38+
dependencies: ["Font", "AsmSupport"],
3939
swiftSettings: swiftSettings + [
4040
.enableExperimentalFeature("Volatile")
4141
],
4242
),
4343
.target(name: "Font", swiftSettings: swiftSettings),
44-
.target(name: "Support", swiftSettings: swiftSettings),
4544
.target(name: "AsmSupport"),
4645
],
4746
)

Sources/RaspberryPi/Framebuffer.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,22 @@ package struct Framebuffer<Depth: UnsignedInteger>: ~Copyable {
8787
// success?
8888
guard mboxCall(ch: .property) else { fatalError() }
8989

90-
let pixelCount = unsafe Int(mbox.29) / MemoryLayout<Depth>.stride
90+
let pixelCount = unsafe Int(mbox.10 &* mbox.11)
91+
let byteCount = unsafe mbox.29
92+
let gpuAddr = unsafe mbox.28
9193

9294
guard
9395
unsafe mbox.20 == depth,
94-
unsafe mbox.28 != 0, // pointer is not null
95-
unsafe pixelCount == mbox.10 &* mbox.11
96+
gpuAddr != 0,
97+
byteCount >= pixelCount &* MemoryLayout<Depth>.size
9698
else { fatalError() }
9799

98100
self.width = unsafe mbox.10
99101
self.height = unsafe mbox.11
100102
// swift-format-ignore: NeverForceUnwrap
101103
self.pixelOrder = unsafe .init(rawValue: mbox.24)!
102104
// GPU address to ARM address
103-
let addr = unsafe UInt(mbox.28 & 0x3FFF_FFFF)
105+
let addr = UInt(gpuAddr & 0x3FFF_FFFF)
104106
// swift-format-ignore: NeverForceUnwrap
105107
unsafe self.baseAddress = UnsafeMutableRawPointer(bitPattern: addr)!
106108
.bindMemory(to: Depth.self, capacity: pixelCount)

Sources/RaspberryPi/mbox.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let mboxFull: UInt32 = 0x8000_0000
1313
let mboxEmpty: UInt32 = 0x4000_0000
1414

1515
@_alignment(16)
16-
struct Mbox: ~Copyable {
16+
struct Mbox {
1717
var `0`: UInt32 = 0
1818
var `1`: UInt32 = 0
1919
var `2`: UInt32 = 0

Sources/Support/memset.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)