mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:35:07 +00:00
Kernel: Ensure proper locking when mutating boot console cursor
The BootFramebufferConsole highly depends on using the m_lock spinlock, therefore setting and changing the cursor state should be done under that spinlock too to avoid crashing.
This commit is contained in:
parent
0a5416a87a
commit
37ed1b28fa
2 changed files with 30 additions and 0 deletions
|
@ -71,6 +71,31 @@ void BootFramebufferConsole::write(size_t x, size_t y, char ch, Color background
|
|||
GenericFramebufferConsoleImpl::write(x, y, ch, background, foreground, critical);
|
||||
}
|
||||
|
||||
void BootFramebufferConsole::set_cursor(size_t x, size_t y)
|
||||
{
|
||||
// Note: To ensure we don't trigger a deadlock, let's assert in
|
||||
// case we already locked the spinlock, so we know there's a bug
|
||||
// in the call path.
|
||||
VERIFY(!m_lock.is_locked());
|
||||
SpinlockLocker lock(m_lock);
|
||||
hide_cursor();
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
show_cursor();
|
||||
}
|
||||
|
||||
void BootFramebufferConsole::hide_cursor()
|
||||
{
|
||||
VERIFY(m_lock.is_locked());
|
||||
GenericFramebufferConsoleImpl::hide_cursor();
|
||||
}
|
||||
|
||||
void BootFramebufferConsole::show_cursor()
|
||||
{
|
||||
VERIFY(m_lock.is_locked());
|
||||
GenericFramebufferConsoleImpl::show_cursor();
|
||||
}
|
||||
|
||||
u8* BootFramebufferConsole::framebuffer_data()
|
||||
{
|
||||
VERIFY(m_lock.is_locked());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue