mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 18:35:09 +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);
|
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()
|
u8* BootFramebufferConsole::framebuffer_data()
|
||||||
{
|
{
|
||||||
VERIFY(m_lock.is_locked());
|
VERIFY(m_lock.is_locked());
|
||||||
|
|
|
@ -30,6 +30,11 @@ public:
|
||||||
BootFramebufferConsole(PhysicalAddress framebuffer_addr, size_t width, size_t height, size_t pitch);
|
BootFramebufferConsole(PhysicalAddress framebuffer_addr, size_t width, size_t height, size_t pitch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void set_cursor(size_t x, size_t y) override;
|
||||||
|
virtual void hide_cursor() override;
|
||||||
|
virtual void show_cursor() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void clear_glyph(size_t x, size_t y) override;
|
virtual void clear_glyph(size_t x, size_t y) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue