Compare commits

..

No commits in common. "45ffa1b79ca8c4776f74598c998f5a6492018417" and "18e7cf20699551b84241263cfc31196d06055131" have entirely different histories.

7 changed files with 11 additions and 75 deletions

View File

@ -18,12 +18,8 @@ You can find a live demo [here](https://bananymous.com/banan-os)
- [x] Network stack - [x] Network stack
- [x] ELF executable loading - [x] ELF executable loading
- [x] AML interpreter (partial) - [x] AML interpreter (partial)
- [x] Basic graphical environment
- [x] Terminal emulator
- [ ] Task bar
- [ ] Program launcher
- [ ] Some nice apps
- [ ] ELF dynamic linking - [ ] ELF dynamic linking
- [ ] Graphical desktop
- [ ] copy-on-write memory - [ ] copy-on-write memory
#### Drivers #### Drivers
@ -32,12 +28,7 @@ You can find a live demo [here](https://bananymous.com/banan-os)
- [x] E1000 and E1000E NICs - [x] E1000 and E1000E NICs
- [x] PS2 keyboard (all scancode sets) - [x] PS2 keyboard (all scancode sets)
- [x] PS2 mouse - [x] PS2 mouse
- [x] USB - [ ] USB
- [x] Keyboard
- [x] Mouse
- [ ] Hubs
- [ ] Mass storage
- [ ] ...
- [ ] virtio devices (network, storage) - [ ] virtio devices (network, storage)
#### Network #### Network
@ -47,7 +38,6 @@ You can find a live demo [here](https://bananymous.com/banan-os)
- [x] UDP - [x] UDP
- [x] TCP (partial and buggy) - [x] TCP (partial and buggy)
- [x] Unix domain sockets - [x] Unix domain sockets
- [ ] SSL
#### Filesystems #### Filesystems
- [x] Virtual filesystem - [x] Virtual filesystem

View File

@ -9,9 +9,6 @@ extern uint8_t g_kernel_end[];
extern uint8_t g_kernel_execute_start[]; extern uint8_t g_kernel_execute_start[];
extern uint8_t g_kernel_execute_end[]; extern uint8_t g_kernel_execute_end[];
extern uint8_t g_kernel_writable_start[];
extern uint8_t g_kernel_writable_end[];
extern uint8_t g_userspace_start[]; extern uint8_t g_userspace_start[];
extern uint8_t g_userspace_end[]; extern uint8_t g_userspace_end[];
@ -151,7 +148,7 @@ namespace Kernel
V2P(g_kernel_start), V2P(g_kernel_start),
(vaddr_t)g_kernel_start, (vaddr_t)g_kernel_start,
g_kernel_end - g_kernel_start, g_kernel_end - g_kernel_start,
Flags::Present Flags::ReadWrite | Flags::Present
); );
// Map executable kernel memory as executable // Map executable kernel memory as executable
@ -162,14 +159,6 @@ namespace Kernel
Flags::Execute | Flags::Present Flags::Execute | Flags::Present
); );
// Map writable kernel memory as writable
map_range_at(
V2P(g_kernel_writable_start),
(vaddr_t)g_kernel_writable_start,
g_kernel_writable_end - g_kernel_writable_start,
Flags::ReadWrite | Flags::Present
);
// Map userspace memory // Map userspace memory
map_range_at( map_range_at(
V2P(g_userspace_start), V2P(g_userspace_start),

View File

@ -34,14 +34,12 @@ SECTIONS
} }
.data ALIGN(4K) : AT(ADDR(.data) - KERNEL_OFFSET) .data ALIGN(4K) : AT(ADDR(.data) - KERNEL_OFFSET)
{ {
g_kernel_writable_start = .;
*(.data) *(.data)
} }
.bss ALIGN(4K) : AT(ADDR(.bss) - KERNEL_OFFSET) .bss ALIGN(4K) : AT(ADDR(.bss) - KERNEL_OFFSET)
{ {
*(COMMON) *(COMMON)
*(.bss) *(.bss)
g_kernel_writable_end = .;
} }
g_kernel_end = .; g_kernel_end = .;
} }

View File

@ -11,9 +11,6 @@ extern uint8_t g_kernel_end[];
extern uint8_t g_kernel_execute_start[]; extern uint8_t g_kernel_execute_start[];
extern uint8_t g_kernel_execute_end[]; extern uint8_t g_kernel_execute_end[];
extern uint8_t g_kernel_writable_start[];
extern uint8_t g_kernel_writable_end[];
extern uint8_t g_userspace_start[]; extern uint8_t g_userspace_start[];
extern uint8_t g_userspace_end[]; extern uint8_t g_userspace_end[];
@ -173,7 +170,7 @@ namespace Kernel
V2P(g_kernel_start), V2P(g_kernel_start),
(vaddr_t)g_kernel_start, (vaddr_t)g_kernel_start,
g_kernel_end - g_kernel_start, g_kernel_end - g_kernel_start,
Flags::Present Flags::ReadWrite | Flags::Present
); );
// Map executable kernel memory as executable // Map executable kernel memory as executable
@ -184,14 +181,6 @@ namespace Kernel
Flags::Execute | Flags::Present Flags::Execute | Flags::Present
); );
// Map writable kernel memory as writable
map_range_at(
V2P(g_kernel_writable_start),
(vaddr_t)g_kernel_writable_start,
g_kernel_writable_end - g_kernel_writable_start,
Flags::ReadWrite | Flags::Present
);
// Map userspace memory // Map userspace memory
map_range_at( map_range_at(
V2P(g_userspace_start), V2P(g_userspace_start),

View File

@ -34,14 +34,12 @@ SECTIONS
} }
.data ALIGN(4K) : AT(ADDR(.data) - KERNEL_OFFSET) .data ALIGN(4K) : AT(ADDR(.data) - KERNEL_OFFSET)
{ {
g_kernel_writable_start = .;
*(.data) *(.data)
} }
.bss ALIGN(4K) : AT(ADDR(.bss) - KERNEL_OFFSET) .bss ALIGN(4K) : AT(ADDR(.bss) - KERNEL_OFFSET)
{ {
*(COMMON) *(COMMON)
*(.bss) *(.bss)
g_kernel_writable_end = .;
} }
g_kernel_end = .; g_kernel_end = .;
} }

View File

@ -91,13 +91,6 @@ void Terminal::run()
m_font = MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"_sv)); m_font = MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"_sv));
{
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
m_cursor_blink_shown = true;
m_cursor_blink_ms = ts.tv_sec * 1'000 + ts.tv_nsec / 1'000'000;
}
MUST(m_cursor_buffer.resize(m_font.width() * m_font.height(), m_bg_color)); MUST(m_cursor_buffer.resize(m_font.width() * m_font.height(), m_bg_color));
show_cursor(); show_cursor();
@ -111,35 +104,13 @@ void Terminal::run()
FD_SET(m_shell_info.pts_master, &fds); FD_SET(m_shell_info.pts_master, &fds);
FD_SET(m_window->server_fd(), &fds); FD_SET(m_window->server_fd(), &fds);
timespec ts; select(max_fd + 1, &fds, nullptr, nullptr, nullptr);
clock_gettime(CLOCK_MONOTONIC, &ts);
const uint64_t current_ms = ts.tv_sec * 1'000 + ts.tv_nsec / 1'000'000;
const uint64_t ms_until_blink = 500 - BAN::Math::min<uint64_t>(current_ms - m_cursor_blink_ms, 500);
timeval timeout;
timeout.tv_sec = ms_until_blink / 1'000;
timeout.tv_usec = ms_until_blink * 1'000;
if (select(max_fd + 1, &fds, nullptr, nullptr, &timeout) == 0)
{
m_cursor_blink_shown = !m_cursor_blink_shown;
m_cursor_blink_ms = current_ms + ms_until_blink;
}
m_got_key_event = false;
hide_cursor();
if (FD_ISSET(m_shell_info.pts_master, &fds)) if (FD_ISSET(m_shell_info.pts_master, &fds))
if (!read_shell()) if (!read_shell())
break; break;
if (FD_ISSET(m_window->server_fd(), &fds)) if (FD_ISSET(m_window->server_fd(), &fds))
m_window->poll_events(); m_window->poll_events();
if (m_got_key_event)
{
m_cursor_blink_shown = true;
m_cursor_blink_ms = current_ms;
}
show_cursor();
} }
} }
@ -160,7 +131,7 @@ void Terminal::show_cursor()
for (uint32_t y = 0; y < m_font.height(); y++) for (uint32_t y = 0; y < m_font.height(); y++)
for (uint32_t x = 0; x < m_font.width(); x++) for (uint32_t x = 0; x < m_font.width(); x++)
m_cursor_buffer[y * m_font.width() + x] = m_window->get_pixel(cursor_base_x + x, cursor_base_y + y); m_cursor_buffer[y * m_font.width() + x] = m_window->get_pixel(cursor_base_x + x, cursor_base_y + y);
if (m_cursor_shown && m_cursor_blink_shown) if (m_cursor_shown)
{ {
for (uint32_t y = m_font.height() * 13 / 16; y < m_font.height() - 1; y++) for (uint32_t y = m_font.height() * 13 / 16; y < m_font.height() - 1; y++)
for (uint32_t x = 0; x < m_font.width(); x++) for (uint32_t x = 0; x < m_font.width(); x++)
@ -171,6 +142,8 @@ void Terminal::show_cursor()
bool Terminal::read_shell() bool Terminal::read_shell()
{ {
hide_cursor();
char buffer[128]; char buffer[128];
ssize_t nread = read(m_shell_info.pts_master, buffer, sizeof(buffer) - 1); ssize_t nread = read(m_shell_info.pts_master, buffer, sizeof(buffer) - 1);
if (nread < 0) if (nread < 0)
@ -179,6 +152,9 @@ bool Terminal::read_shell()
return false; return false;
for (ssize_t i = 0; i < nread; i++) for (ssize_t i = 0; i < nread; i++)
putchar(buffer[i]); putchar(buffer[i]);
show_cursor();
return true; return true;
} }
@ -474,5 +450,4 @@ void Terminal::on_key_event(LibGUI::EventPacket::KeyEvent event)
return; return;
if (const char* text = LibInput::key_to_utf8_ansi(event.key, event.modifier)) if (const char* text = LibInput::key_to_utf8_ansi(event.key, event.modifier))
write(m_shell_info.pts_master, text, strlen(text)); write(m_shell_info.pts_master, text, strlen(text));
m_got_key_event = true;
} }

View File

@ -60,11 +60,8 @@ private:
CSIInfo m_csi_info; CSIInfo m_csi_info;
bool m_cursor_shown { true }; bool m_cursor_shown { true };
bool m_cursor_blink_shown { true };
uint64_t m_cursor_blink_ms { 0 };
Cursor m_cursor { 0, 0 }; Cursor m_cursor { 0, 0 };
BAN::Vector<uint32_t> m_cursor_buffer; BAN::Vector<uint32_t> m_cursor_buffer;
bool m_got_key_event { false };
uint8_t m_utf8_index { 0 }; uint8_t m_utf8_index { 0 };
uint8_t m_utf8_bytes[4] { }; uint8_t m_utf8_bytes[4] { };