48cf/limine-zig-template

Terminal Request returning a null response

Closed this issue · 1 comments

I tried modifying the example to work with a terminal, but no matter what the terminal response will be null even thought the framebuffer response will be present.
Example code:

const std = @import("std");

inline fn done() noreturn {
    while (true) {
        asm volatile ("hlt");
    }
}

pub export var framebuffer_request: @import("limine").FramebufferRequest = .{};
pub export var terminal_request: @import("limine").TerminalRequest = .{};

export fn _start() callconv(.C) noreturn {
    // From the example repo; works
    if (framebuffer_request.response) |framebuffer_response| {
        if (framebuffer_response.framebuffer_count < 1) {
            done();
        }

        const framebuffer = framebuffer_response.framebuffers()[0];

        for (0..100) |i| {
            const pixel_offset = i * framebuffer.pitch + i * 4;
            @as(*u32, @ptrCast(@alignCast(framebuffer.address + pixel_offset))).* = 0xFFFFFFFF;
        }
    }

    // Written by me, doesn't work
    if (terminal_request.response) |response| {
        if (response.terminal_count < 1) {
            done();
        }
        const term = response.terminals()[0];
        // Neither of these are called, because control flow doesn't get here
        response.write(term, "Hello, World\n");
        response.write_fn(term, "Hello, World\n", 13);
    }

    done();
}

Using zig 0.11.0

Support for the terminal request was removed in Limine v5. Alternatives include https://github.com/mintsuki/flanterm and/or writing to a serial port instead, the latter of which has the benefit of not losing output when it scrolls off-screen.