Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollable framebuffer logs #364

Open
hawkw opened this issue Oct 23, 2022 · 1 comment
Open

scrollable framebuffer logs #364

hawkw opened this issue Oct 23, 2022 · 1 comment
Labels
kind/enhancement New feature or request

Comments

@hawkw
Copy link
Owner

hawkw commented Oct 23, 2022

now that we can handle keyboard input (see #358 and #363), it would be cool to make the text that mycelium logs to the framebuffer be scrollable with the up and down arrow keys (and Page Up / Page Down as well).

this would actually be a kind of big and annoying change, since we currently log by writing pixels directly to the framebuffer, and once we've written them, we throw away the text that we formatted the log line to. this is good, since it means logging is very lightweight and we can start logging stuff really early in the boot process, and inside the allocator...but it's also bad, because once text has scrolled off the top of the framebuffer, it's Gone Forever.

we probably want to change this so that we can log stuff to a text buffer, and print that to the framebuffer.

as i see it, we have two options here:

  • a dynamically allocated text buffer.
    • this means that we can't log to the buffer until we have the allocator set up
    • we also couldn't log to this buffer from inside the allocator, or from ISRs (probably). so, we would need to either never log in those cases, or switch between logging to the text buffer and logging directly to the framebuffer (annoying!)
  • a fixed-size ring buffer
    • this is almost certainly the better option because it can be written to from anywhere, and it also means we can't oom the kernel by buffering too many logs (we would probably want to implement some kind of max capacity if we used a dynamically allocated buffer anyway)
    • this could be either statically allocated or dynamically allocated
    • if it's dynamically allocated, we would still need to wait until the heap exists to set it up, but once it's set up, we can write to it from anywhere without having to allocate
    • if it's statically allocated, we can just create a big static array and not have to worry about alloc at all, which is nice, but there isn't really a great way to allow the user to configure how much of a scrollback buffer they want...
@hawkw hawkw added the kind/enhancement New feature or request label Oct 23, 2022
@hawkw hawkw mentioned this issue Oct 23, 2022
5 tasks
@hawkw
Copy link
Owner Author

hawkw commented Oct 23, 2022

we probably need to dynamically allocate the text ring buffer because we don't know how many characters long the frame buffer will be at compile-time, unless we want to figure out line wrapping when drawing the text instead of when generating it.

the other option is to just have a ring buffer of characters, rather than of lines, but since the goal is to scroll the logs, a ring buffer of lines seems nicer...

hawkw added a commit that referenced this issue Nov 5, 2022
At one point in time, Mycelium contained a bump pointer allocator that
could be used for very early allocations before a better heap allocator
is initialized with information from the BIOS memory map. This was
removed in #130, since it was possible to use the buddy-block allocator
for all heap allocations.

In order to add a scrollback capability to framebuffer logging (#364),
though, we want to be able to allocate a dynamically sized scrollback
buffer. This is because we don't know the actual size of the framebuffer
at compile time, and need to determine how long the lines in the
scrollback ring are based on the dimensions of the framebuffer. However,
we want to preallocate the entire scrollback ring, since we want to be
able to store logs from inside the allocator in the scrollback ring.
Also, if the scrollback ring isn't allocated until after the heap is
initialized, we won't include early log messages in the scrollback ring.
Therefore, it would be nice to be able to allocate the scrollback ring
before we initialize the heap.

This PR puts back the bump pointer allocator so that it can be used for
allocating the scrollback ring. We could potentially use it for other
very early dynamic allocations as well, if we can guarantee that they
will live for the entire lifetime of the kernel.

We may want to emit a warning, or even panic, if we try to deallocate a
bump-allocated address?
hawkw added a commit that referenced this issue Nov 5, 2022
At one point in time, Mycelium contained a bump pointer allocator that
could be used for very early allocations before a better heap allocator
is initialized with information from the BIOS memory map. This was
removed in #130, since it was possible to use the buddy-block allocator
for all heap allocations.

In order to add a scrollback capability to framebuffer logging (#364),
though, we want to be able to allocate a dynamically sized scrollback
buffer. This is because we don't know the actual size of the framebuffer
at compile time, and need to determine how long the lines in the
scrollback ring are based on the dimensions of the framebuffer. However,
we want to preallocate the entire scrollback ring, since we want to be
able to store logs from inside the allocator in the scrollback ring.
Also, if the scrollback ring isn't allocated until after the heap is
initialized, we won't include early log messages in the scrollback ring.
Therefore, it would be nice to be able to allocate the scrollback ring
before we initialize the heap.

This PR puts back the bump pointer allocator so that it can be used for
allocating the scrollback ring. We could potentially use it for other
very early dynamic allocations as well, if we can guarantee that they
will live for the entire lifetime of the kernel.

We may want to emit a warning, or even panic, if we try to deallocate a
bump-allocated address?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant