forked from Bananymous/banan-os
All: Cleanup all files
Add newline to end of files and remove whitespace from end of lines
This commit is contained in:
@@ -171,7 +171,7 @@ namespace Kernel
|
||||
size_t needed_pages = range_page_count(header_paddr, header_length);
|
||||
vaddr_t page_vaddr = PageTable::kernel().reserve_free_contiguous_pages(needed_pages, KERNEL_OFFSET);
|
||||
ASSERT(page_vaddr);
|
||||
|
||||
|
||||
PageTable::kernel().map_range_at(
|
||||
header_paddr & PAGE_ADDR_MASK,
|
||||
page_vaddr,
|
||||
@@ -194,7 +194,7 @@ namespace Kernel
|
||||
paddr_t header_paddr = (m_entry_size == 4) ?
|
||||
((uint32_t*)m_header_table_vaddr)[i] :
|
||||
((uint64_t*)m_header_table_vaddr)[i];
|
||||
|
||||
|
||||
vaddr_t header_vaddr = map_header(header_paddr);
|
||||
if (header_vaddr == 0)
|
||||
continue;
|
||||
@@ -252,4 +252,4 @@ namespace Kernel
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace Kernel
|
||||
|
||||
void APIC::eoi(uint8_t)
|
||||
{
|
||||
write_to_local_apic(LAPIC_EIO_REG, 0);
|
||||
write_to_local_apic(LAPIC_EIO_REG, 0);
|
||||
}
|
||||
|
||||
void APIC::enable_irq(uint8_t irq)
|
||||
@@ -305,7 +305,7 @@ namespace Kernel
|
||||
for (int irq = 0; irq <= 0xFF; irq++)
|
||||
{
|
||||
uint32_t gsi = m_irq_overrides[irq];
|
||||
|
||||
|
||||
IOAPIC* ioapic = nullptr;
|
||||
for (IOAPIC& io : m_io_apics)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Kernel
|
||||
const auto& mmap_tag = *reinterpret_cast<const multiboot2_mmap_tag_t*>(tag);
|
||||
|
||||
const size_t entry_count = (mmap_tag.size - sizeof(multiboot2_mmap_tag_t)) / mmap_tag.entry_size;
|
||||
|
||||
|
||||
MUST(g_boot_info.memory_map_entries.resize(entry_count));
|
||||
|
||||
for (size_t i = 0; i < entry_count; i++)
|
||||
@@ -105,7 +105,7 @@ namespace Kernel
|
||||
return true;
|
||||
if (magic == BANAN_BOOTLOADER_MAGIC)
|
||||
return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void parse_boot_info(uint32_t magic, uint32_t info)
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Kernel
|
||||
TRY(result.append(parts[0]));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
line.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Debug
|
||||
|
||||
if (row >= g_terminal_driver->height())
|
||||
row = 0;
|
||||
|
||||
|
||||
if (row != row_copy)
|
||||
{
|
||||
for (uint32_t i = col; i < g_terminal_driver->width(); i++)
|
||||
@@ -134,4 +134,4 @@ namespace Debug
|
||||
s_debug_lock.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ namespace Kernel
|
||||
)
|
||||
{ }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Kernel
|
||||
|
||||
if ((size_t)offset >= m_width * m_height * (BANAN_FB_BPP / 8))
|
||||
return 0;
|
||||
|
||||
|
||||
size_t bytes_to_copy = BAN::Math::min<size_t>(m_width * m_height * (BANAN_FB_BPP / 8) - offset, buffer.size());
|
||||
memcpy(buffer.data(), reinterpret_cast<void*>(m_video_buffer->vaddr() + offset), bytes_to_copy);
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
if ((size_t)offset >= m_width * m_height * (BANAN_FB_BPP / 8))
|
||||
return 0;
|
||||
|
||||
|
||||
size_t bytes_to_copy = BAN::Math::min<size_t>(m_width * m_height * (BANAN_FB_BPP / 8) - offset, buffer.size());
|
||||
memcpy(reinterpret_cast<void*>(m_video_buffer->vaddr() + offset), buffer.data(), bytes_to_copy);
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace Kernel
|
||||
vaddr &= PAGE_ADDR_MASK;
|
||||
if (m_page_table.physical_address_of(vaddr))
|
||||
return false;
|
||||
|
||||
|
||||
paddr_t paddr = PageTable::kernel().physical_address_of(m_framebuffer->m_video_buffer->vaddr() + (vaddr - m_vaddr));
|
||||
m_page_table.map_page_at(paddr, vaddr, m_flags);
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ namespace Kernel
|
||||
return BAN::RefPtr<NullDevice>::adopt(result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,4 @@ namespace Kernel
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,4 +34,4 @@ namespace Kernel
|
||||
return s_error_strings[(uint32_t)error];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,4 +135,4 @@ namespace Kernel
|
||||
return next_dev++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,4 +503,4 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -807,4 +807,4 @@ needs_new_block:
|
||||
return BAN::Error::from_errno(ENOENT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,4 +153,4 @@ namespace Kernel
|
||||
return has_data_impl();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,4 +82,4 @@ namespace Kernel
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Kernel
|
||||
PageTable::with_fast_page(inode_location.paddr, [&] {
|
||||
inode_info = PageTable::fast_page_as_sized<TmpInodeInfo>(inode_location.index);
|
||||
});
|
||||
|
||||
|
||||
auto inode = TRY(TmpInode::create_from_existing(*this, ino, inode_info));
|
||||
TRY(m_inode_cache.insert(ino, inode));
|
||||
return inode;
|
||||
@@ -85,7 +85,7 @@ namespace Kernel
|
||||
void TmpFileSystem::remove_from_cache(BAN::RefPtr<TmpInode> inode)
|
||||
{
|
||||
LockGuard _(m_lock);
|
||||
|
||||
|
||||
ASSERT(m_inode_cache.contains(inode->ino()));
|
||||
m_inode_cache.remove(inode->ino());
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Kernel
|
||||
|
||||
if (result == 0)
|
||||
return BAN::Error::from_errno(ENOENT);
|
||||
|
||||
|
||||
auto inode = TRY(m_fs.open_inode(result));
|
||||
return BAN::RefPtr<Inode>(inode);
|
||||
}
|
||||
@@ -406,13 +406,13 @@ namespace Kernel
|
||||
}
|
||||
|
||||
auto block_index = this->block_index(data_block_index);
|
||||
|
||||
|
||||
list->entry_count = 0;
|
||||
|
||||
// if we reach a non-allocated block, it marks the end
|
||||
if (!block_index.has_value())
|
||||
return {};
|
||||
|
||||
|
||||
auto* dirp = list->array;
|
||||
|
||||
const size_t byte_count = BAN::Math::min<size_t>(size() - data_block_index * blksize(), blksize());
|
||||
|
||||
@@ -198,4 +198,4 @@ namespace Kernel
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Kernel
|
||||
|
||||
BAN::Vector<uint8_t> file_data;
|
||||
TRY(file_data.resize(inode->size()));
|
||||
|
||||
|
||||
TRY(inode->read(0, file_data.span()));
|
||||
|
||||
if (file_data.size() < 4)
|
||||
@@ -69,7 +69,7 @@ namespace Kernel
|
||||
uint8_t char_size;
|
||||
};
|
||||
const PSF1Header& header = *(const PSF1Header*)font_data.data();
|
||||
|
||||
|
||||
uint32_t glyph_count = header.mode & PSF1_MODE512 ? 512 : 256;
|
||||
uint32_t glyph_size = header.char_size;
|
||||
uint32_t glyph_data_size = glyph_size * glyph_count;
|
||||
@@ -225,7 +225,7 @@ namespace Kernel
|
||||
else
|
||||
{
|
||||
for (uint32_t i = 0; i < header.glyph_count; i++)
|
||||
TRY(glyph_offsets.insert(i, i * header.glyph_size));
|
||||
TRY(glyph_offsets.insert(i, i * header.glyph_size));
|
||||
}
|
||||
|
||||
if (invalid_utf)
|
||||
@@ -254,4 +254,4 @@ namespace Kernel
|
||||
return m_glyph_data.data() + m_glyph_offsets[codepoint];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Kernel::Input
|
||||
{
|
||||
dprintln("Invalid modifier instruction in keymap '{}'", line);
|
||||
dprintln(" format: include \"PATH\"");
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
}
|
||||
parts[1] = parts[1].substring(1, parts[1].size() - 2);
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Kernel::Input
|
||||
// Flush The Output Buffer
|
||||
while (!read_byte().is_error())
|
||||
continue;
|
||||
|
||||
|
||||
// Set the Controller Configuration Byte
|
||||
TRY(send_command(PS2::Command::READ_CONFIG));
|
||||
uint8_t config = TRY(read_byte());
|
||||
@@ -340,7 +340,7 @@ namespace Kernel::Input
|
||||
dwarnln("Could not reserve irq for PS/2 port 2");
|
||||
m_devices[1].clear();
|
||||
}
|
||||
|
||||
|
||||
if (!m_devices[0] && !m_devices[1])
|
||||
return {};
|
||||
|
||||
|
||||
@@ -126,6 +126,9 @@ namespace Kernel::Input
|
||||
|
||||
auto key = KeyboardLayout::get().get_key_from_event(KeyEvent { .modifier = 0, .keycode = keycode.value() });
|
||||
|
||||
if (key == Key::F1)
|
||||
panic("OOF");
|
||||
|
||||
uint16_t modifier_mask = 0;
|
||||
uint16_t toggle_mask = 0;
|
||||
switch (key)
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Kernel::Input
|
||||
{
|
||||
if ((new_button_mask & (1 << i)) == (m_button_mask & (1 << i)))
|
||||
continue;
|
||||
|
||||
|
||||
auto& event = events[event_count++];
|
||||
event.type = MouseEventType::MouseButtonEvent;
|
||||
event.button_event.button = button_index_to_button(i);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Kernel
|
||||
auto* region_ptr = new DMARegion(size, vaddr, paddr);
|
||||
if (region_ptr == nullptr)
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
|
||||
|
||||
vaddr_guard.disable();
|
||||
paddr_guard.disable();
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(ENOTSUP);
|
||||
if (m_type != Type::SHARED)
|
||||
return {};
|
||||
|
||||
|
||||
vaddr_t first_page = address & PAGE_ADDR_MASK;
|
||||
vaddr_t last_page = BAN::Math::div_round_up<vaddr_t>(address + size, PAGE_SIZE) * PAGE_SIZE;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Kernel
|
||||
|
||||
if (entry.type != 1)
|
||||
continue;
|
||||
|
||||
|
||||
paddr_t start = entry.address;
|
||||
if (start < V2P(g_kernel_end))
|
||||
start = V2P(g_kernel_end);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Kernel
|
||||
vaddr_t vaddr = address & PAGE_ADDR_MASK;
|
||||
if (m_page_table.physical_address_of(vaddr) != 0)
|
||||
return false;
|
||||
|
||||
|
||||
// Map new physcial page to address
|
||||
paddr_t paddr = Heap::get().take_free_page();
|
||||
if (paddr == 0)
|
||||
@@ -83,7 +83,7 @@ namespace Kernel
|
||||
continue;
|
||||
TRY(result->copy_data_to_region(offset, (const uint8_t*)(m_vaddr + offset), PAGE_SIZE));
|
||||
}
|
||||
|
||||
|
||||
return BAN::UniqPtr<MemoryRegion>(BAN::move(result));
|
||||
}
|
||||
|
||||
@@ -116,4 +116,4 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Kernel
|
||||
, m_flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MemoryRegion::~MemoryRegion()
|
||||
{
|
||||
if (m_vaddr)
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Kernel
|
||||
paddr_t paddr = Heap::get().take_free_page();
|
||||
if (paddr == 0)
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
result->m_page_table.map_page_at(paddr, vaddr() + offset, m_flags);
|
||||
result->m_page_table.map_page_at(paddr, vaddr() + offset, m_flags);
|
||||
}
|
||||
|
||||
CriticalScope _;
|
||||
@@ -218,4 +218,4 @@ namespace Kernel
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ struct kmalloc_node
|
||||
{
|
||||
uintptr_t node_end = end();
|
||||
set_end(data() + size);
|
||||
|
||||
|
||||
auto* next = after();
|
||||
next->set_end(node_end);
|
||||
next->set_align(0);
|
||||
@@ -124,10 +124,10 @@ void kmalloc_initialize()
|
||||
node->next = i - 1;
|
||||
node->prev = i + 1;
|
||||
}
|
||||
|
||||
|
||||
info.node_at(0)->next = kmalloc_fixed_info::node::invalid;
|
||||
info.node_at(info.node_count - 1)->prev = kmalloc_fixed_info::node::invalid;
|
||||
|
||||
|
||||
info.free_list_head = info.node_at(0);
|
||||
info.used_list_head = nullptr;
|
||||
}
|
||||
@@ -371,7 +371,7 @@ void kfree(void* address)
|
||||
else if (s_kmalloc_info.base <= address_uint && address_uint < s_kmalloc_info.end)
|
||||
{
|
||||
auto& info = s_kmalloc_info;
|
||||
|
||||
|
||||
auto* node = info.from_address(address);
|
||||
ASSERT(node);
|
||||
ASSERT(node->data() == (uintptr_t)address);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Kernel
|
||||
{
|
||||
if (other.validate_fd(fd).is_error())
|
||||
continue;
|
||||
|
||||
|
||||
auto& open_file = other.m_open_files[fd];
|
||||
|
||||
auto result = BAN::RefPtr<OpenFileDescription>::create(open_file->inode, open_file->path, open_file->offset, open_file->flags);
|
||||
@@ -93,7 +93,7 @@ namespace Kernel
|
||||
|
||||
int result = TRY(get_free_fd());
|
||||
m_open_files[result] = m_open_files[fildes];
|
||||
|
||||
|
||||
if (m_open_files[result]->flags & O_WRONLY && m_open_files[result]->inode->is_pipe())
|
||||
((Pipe*)m_open_files[result]->inode.ptr())->clone_writing();
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Kernel
|
||||
return fildes;
|
||||
|
||||
(void)close(fildes2);
|
||||
|
||||
|
||||
m_open_files[fildes2] = m_open_files[fildes];
|
||||
m_open_files[fildes2]->flags &= ~O_CLOEXEC;
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Kernel
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return BAN::Error::from_errno(ENOTSUP);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace Kernel
|
||||
|
||||
if (m_open_files[fd]->flags & O_WRONLY && m_open_files[fd]->inode->is_pipe())
|
||||
((Pipe*)m_open_files[fd]->inode.ptr())->close_writing();
|
||||
|
||||
|
||||
m_open_files[fd].clear();
|
||||
|
||||
return {};
|
||||
@@ -345,4 +345,4 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(EMFILE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Kernel::PCI
|
||||
{
|
||||
if (get_vendor_id(bus, dev, 0) == INVALID_VENDOR)
|
||||
return;
|
||||
|
||||
|
||||
check_function(bus, dev, 0);
|
||||
if (get_header_type(bus, dev, 0) & MULTI_FUNCTION)
|
||||
for (uint8_t func = 1; func < 8; func++)
|
||||
@@ -288,7 +288,7 @@ namespace Kernel::PCI
|
||||
{
|
||||
if (m_type == BarType::MEM && m_vaddr)
|
||||
PageTable::kernel().unmap_range(m_vaddr, m_size);
|
||||
m_vaddr = 0;
|
||||
m_vaddr = 0;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> BarRegion::initialize()
|
||||
@@ -628,4 +628,4 @@ namespace Kernel::PCI
|
||||
set_command_bits(PCI_CMD_INTERRUPT_DISABLE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Kernel
|
||||
m_reserved_irqs |= 1 << irq;
|
||||
return irq;
|
||||
}
|
||||
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace Kernel
|
||||
|
||||
if (!m_controlling_terminal)
|
||||
return BAN::Error::from_errno(ENOTTY);
|
||||
|
||||
|
||||
Kernel::termios ktermios = m_controlling_terminal->get_termios();
|
||||
termios->c_lflag = 0;
|
||||
if (ktermios.canonical)
|
||||
@@ -370,11 +370,11 @@ namespace Kernel
|
||||
|
||||
if (!m_controlling_terminal)
|
||||
return BAN::Error::from_errno(ENOTTY);
|
||||
|
||||
|
||||
Kernel::termios ktermios;
|
||||
ktermios.echo = termios->c_lflag & ECHO;
|
||||
ktermios.canonical = termios->c_lflag & ICANON;
|
||||
|
||||
|
||||
m_controlling_terminal->set_termios(ktermios);
|
||||
return 0;
|
||||
}
|
||||
@@ -530,7 +530,7 @@ namespace Kernel
|
||||
auto envp_region = MUST(create_region(str_envp.span()));
|
||||
m_userspace_info.envp = (char**)envp_region->vaddr();
|
||||
MUST(m_mapped_regions.push_back(BAN::move(envp_region)));
|
||||
|
||||
|
||||
m_userspace_info.argc = str_argv.size();
|
||||
|
||||
m_cmdline = BAN::move(str_argv);
|
||||
@@ -803,7 +803,7 @@ namespace Kernel
|
||||
{
|
||||
LockGuard _(m_lock);
|
||||
TRY(validate_string_access(path));
|
||||
|
||||
|
||||
auto absolute_path = TRY(absolute_path_of(path));
|
||||
|
||||
size_t index = absolute_path.size();
|
||||
@@ -822,7 +822,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<long> Process::readlink_impl(BAN::StringView absolute_path, char* buffer, size_t bufsize)
|
||||
{
|
||||
auto inode = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, O_NOFOLLOW | O_RDONLY)).inode;
|
||||
|
||||
|
||||
// FIXME: no allocation needed
|
||||
auto link_target = TRY(inode->link_target());
|
||||
|
||||
@@ -996,7 +996,7 @@ namespace Kernel
|
||||
// FIXME: gracefully kill all processes
|
||||
|
||||
DevFileSystem::get().initiate_sync(true);
|
||||
|
||||
|
||||
lai_api_error_t error;
|
||||
switch (command)
|
||||
{
|
||||
@@ -1009,7 +1009,7 @@ namespace Kernel
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
||||
// If we reach here, there was an error
|
||||
dprintln("{}", lai_api_error_to_string(error));
|
||||
return BAN::Error::from_errno(EUNKNOWN);
|
||||
@@ -1051,7 +1051,7 @@ namespace Kernel
|
||||
|
||||
if (size < m_working_directory.size() + 1)
|
||||
return BAN::Error::from_errno(ERANGE);
|
||||
|
||||
|
||||
memcpy(buffer, m_working_directory.data(), m_working_directory.size());
|
||||
buffer[m_working_directory.size()] = '\0';
|
||||
|
||||
@@ -1123,7 +1123,7 @@ namespace Kernel
|
||||
|
||||
BAN::UniqPtr<MemoryRegion> memory_region;
|
||||
if (inode->mode().ifreg())
|
||||
{
|
||||
{
|
||||
memory_region = TRY(FileBackedRegion::create(
|
||||
inode,
|
||||
page_table(),
|
||||
@@ -1141,7 +1141,7 @@ namespace Kernel
|
||||
region_type, page_flags
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
if (!memory_region)
|
||||
return BAN::Error::from_errno(ENODEV);
|
||||
|
||||
@@ -1175,7 +1175,7 @@ namespace Kernel
|
||||
|
||||
vaddr_t vaddr = (vaddr_t)addr;
|
||||
if (vaddr % PAGE_SIZE != 0)
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
|
||||
LockGuard _(m_lock);
|
||||
|
||||
@@ -1193,7 +1193,7 @@ namespace Kernel
|
||||
auto inode = TRY(m_open_file_descriptors.inode_of(fildes));
|
||||
if (!inode->is_tty())
|
||||
return BAN::Error::from_errno(ENOTTY);
|
||||
|
||||
|
||||
TRY(((TTY*)inode.ptr())->tty_ctrl(command, flags));
|
||||
|
||||
return 0;
|
||||
@@ -1476,7 +1476,7 @@ namespace Kernel
|
||||
// real user ID, then the saved set-user-ID of the current process shall be set equal to the new effective user ID.
|
||||
if (ruid != -1 || euid != m_credentials.ruid())
|
||||
m_credentials.set_suid(euid);
|
||||
|
||||
|
||||
if (ruid != -1)
|
||||
m_credentials.set_ruid(ruid);
|
||||
if (euid != -1)
|
||||
@@ -1498,7 +1498,7 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
|
||||
// The setregid() function shall set the real and effective group IDs of the calling process.
|
||||
|
||||
|
||||
// If rgid is -1, the real group ID shall not be changed; if egid is -1, the effective group ID shall not be changed.
|
||||
|
||||
// The real and effective group IDs may be set to different values in the same call.
|
||||
@@ -1522,7 +1522,7 @@ namespace Kernel
|
||||
// real group ID, then the saved set-group-ID of the current process shall be set equal to the new effective group ID.
|
||||
if (rgid != -1 || egid != m_credentials.rgid())
|
||||
m_credentials.set_sgid(egid);
|
||||
|
||||
|
||||
if (rgid != -1)
|
||||
m_credentials.set_rgid(rgid);
|
||||
if (egid != -1)
|
||||
@@ -1646,7 +1646,7 @@ namespace Kernel
|
||||
TRY(absolute_path.push_back('/'));
|
||||
|
||||
TRY(absolute_path.append(path));
|
||||
|
||||
|
||||
return absolute_path;
|
||||
}
|
||||
|
||||
@@ -1694,4 +1694,4 @@ unauthorized_access:
|
||||
return BAN::Error::from_errno(EINTR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ void __stack_chk_fail(void)
|
||||
abort();
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
__END_DECLS
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Kernel
|
||||
|
||||
if (m_active_threads.empty() || ¤t_thread() != m_idle_thread)
|
||||
return;
|
||||
|
||||
|
||||
if (save_current_thread())
|
||||
return;
|
||||
m_current_thread = m_active_threads.begin();
|
||||
@@ -199,7 +199,7 @@ namespace Kernel
|
||||
|
||||
ASSERT(thread->has_process());
|
||||
delete &thread->process();
|
||||
|
||||
|
||||
remove_and_advance_current_thread();
|
||||
|
||||
delete thread;
|
||||
@@ -247,7 +247,7 @@ namespace Kernel
|
||||
Thread* thread = m_current_thread->thread;
|
||||
if (thread->has_process())
|
||||
thread->process().on_thread_exit(*thread);
|
||||
|
||||
|
||||
remove_and_advance_current_thread();
|
||||
|
||||
delete thread;
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace Kernel
|
||||
Scheduler::get().unblock_threads(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Kernel
|
||||
void RecursiveSpinLock::unlock()
|
||||
{
|
||||
m_lock.lock();
|
||||
|
||||
|
||||
ASSERT(m_lock_depth > 0);
|
||||
ASSERT(m_locker == Scheduler::current_tid());
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Kernel
|
||||
|
||||
if (m_lock_depth == 0)
|
||||
m_locker = -1;
|
||||
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Kernel
|
||||
void RecursivePrioritySpinLock::unlock()
|
||||
{
|
||||
m_lock.lock();
|
||||
|
||||
|
||||
ASSERT(m_lock_depth > 0);
|
||||
ASSERT(m_locker == Scheduler::current_tid());
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Kernel
|
||||
|
||||
if (m_lock_depth == 0)
|
||||
m_locker = -1;
|
||||
|
||||
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
@@ -137,4 +137,4 @@ namespace Kernel
|
||||
return m_locker != -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Kernel
|
||||
|
||||
if (!(pi & 1))
|
||||
continue;
|
||||
|
||||
|
||||
auto type = check_port_type(abar_mem.ports[i]);
|
||||
if (!type.has_value())
|
||||
continue;
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Kernel
|
||||
while (port->cmd & HBA_PxCMD_CR)
|
||||
continue;
|
||||
port->cmd = port->cmd | HBA_PxCMD_FRE;
|
||||
port->cmd = port->cmd | HBA_PxCMD_ST;
|
||||
port->cmd = port->cmd | HBA_PxCMD_ST;
|
||||
}
|
||||
|
||||
|
||||
static void stop_cmd(volatile HBAPortMemorySpace* port)
|
||||
{
|
||||
port->cmd = port->cmd & ~HBA_PxCMD_ST;
|
||||
@@ -58,7 +58,7 @@ namespace Kernel
|
||||
|
||||
m_data_dma_region = TRY(DMARegion::create(PAGE_SIZE));
|
||||
memset((void*)m_data_dma_region->vaddr(), 0x00, m_data_dma_region->size());
|
||||
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -211,14 +211,14 @@ namespace Kernel
|
||||
ASSERT(m_dma_region);
|
||||
ASSERT(m_data_dma_region);
|
||||
ASSERT(0 < sector_count && sector_count <= 0xFFFF + 1);
|
||||
|
||||
|
||||
ASSERT(sector_count * sector_size() <= m_data_dma_region->size());
|
||||
|
||||
m_port->is = ~(uint32_t)0;
|
||||
|
||||
auto slot = find_free_command_slot();
|
||||
ASSERT(slot.has_value());
|
||||
|
||||
|
||||
volatile auto& command_header = reinterpret_cast<volatile HBACommandHeader*>(m_dma_region->paddr_to_vaddr(m_port->clb))[slot.value()];
|
||||
command_header.cfl = sizeof(FISRegisterH2D) / sizeof(uint32_t);
|
||||
command_header.prdtl = 1;
|
||||
@@ -265,11 +265,11 @@ namespace Kernel
|
||||
fis_command.lba1 = (lba >> 8) & 0xFF;
|
||||
fis_command.lba2 = (lba >> 16) & 0xFF;
|
||||
fis_command.device = 1 << 6; // LBA mode
|
||||
|
||||
|
||||
fis_command.lba3 = (lba >> 24) & 0xFF;
|
||||
fis_command.lba4 = (lba >> 32) & 0xFF;
|
||||
fis_command.lba5 = (lba >> 40) & 0xFF;
|
||||
|
||||
|
||||
fis_command.count_lo = (sector_count >> 0) & 0xFF;
|
||||
fis_command.count_hi = (sector_count >> 8) & 0xFF;
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace Kernel
|
||||
return BAN::Error::from_error_code(ErrorCode::ATA_UNC);
|
||||
if (err & ATA_ERROR_BBK)
|
||||
return BAN::Error::from_error_code(ErrorCode::ATA_BBK);
|
||||
|
||||
|
||||
return BAN::Error::from_error_code(ErrorCode::None);
|
||||
}
|
||||
|
||||
@@ -331,4 +331,4 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,4 +96,4 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Kernel
|
||||
|
||||
if (!(m_capabilities & ATA_CAPABILITIES_LBA))
|
||||
return BAN::Error::from_error_code(ErrorCode::ATA_NoLBA);
|
||||
|
||||
|
||||
if ((identify_data[ATA_IDENTIFY_SECTOR_INFO] & (1 << 15)) == 0 &&
|
||||
(identify_data[ATA_IDENTIFY_SECTOR_INFO] & (1 << 14)) != 0 &&
|
||||
(identify_data[ATA_IDENTIFY_SECTOR_INFO] & (1 << 12)) != 0)
|
||||
@@ -132,4 +132,4 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Kernel
|
||||
continue;
|
||||
if (cache.first_sector > page_cache_start)
|
||||
break;
|
||||
|
||||
|
||||
{
|
||||
CriticalScope _;
|
||||
PageTable::map_fast_page(cache.paddr);
|
||||
@@ -205,4 +205,4 @@ namespace Kernel
|
||||
release_pages(m_cache.size());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Kernel
|
||||
if (m_bar0->size() < 0x1000)
|
||||
{
|
||||
dwarnln("NVMe controller BAR0 is too small {} bytes", m_bar0->size());
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
}
|
||||
|
||||
m_controller_registers = reinterpret_cast<volatile NVMe::ControllerRegisters*>(m_bar0->vaddr());
|
||||
@@ -171,7 +171,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<void> NVMeController::identify_namespaces()
|
||||
{
|
||||
auto dma_page = TRY(DMARegion::create(PAGE_SIZE));
|
||||
|
||||
|
||||
BAN::Vector<uint32_t> namespace_ids;
|
||||
TRY(namespace_ids.resize(PAGE_SIZE / sizeof(uint32_t)));
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Kernel
|
||||
m_done = false;
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
while (SystemTimer::get().ms_since_boot() < start_time + s_nvme_command_timeout_ms)
|
||||
{
|
||||
if (!m_done)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Kernel
|
||||
if (partition_ptr == nullptr)
|
||||
return BAN::Error::from_errno(ENOMEM);
|
||||
return BAN::RefPtr<Partition>::adopt(partition_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
Partition::Partition(BAN::RefPtr<BlockDevice> device, const BAN::GUID& type, const BAN::GUID& guid, uint64_t first_block, uint64_t last_block, uint64_t attr, const char* label, uint32_t index, BAN::StringView name_prefix)
|
||||
: BlockDevice(0660, 0, 0)
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Kernel
|
||||
BAN::UTF8::from_codepoints(entry.partition_name, 36, utf8_name);
|
||||
|
||||
auto partition = TRY(Partition::create(
|
||||
this,
|
||||
this,
|
||||
entry.partition_type_guid,
|
||||
entry.unique_partition_guid,
|
||||
entry.starting_lba,
|
||||
@@ -239,7 +239,7 @@ namespace Kernel
|
||||
TRY(read_sectors_impl(lba + offset, 1, sector_buffer));
|
||||
(void)m_disk_cache->write_to_cache(lba + offset, sector_buffer, false);
|
||||
}
|
||||
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -237,4 +237,4 @@ namespace Kernel
|
||||
return ret.value();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Kernel
|
||||
const char* ptr = query;
|
||||
while (*ptr)
|
||||
putchar(*ptr++);
|
||||
|
||||
|
||||
if (getchar() != '\033')
|
||||
return false;
|
||||
if (getchar() != '[')
|
||||
@@ -272,4 +272,4 @@ namespace Kernel
|
||||
m_serial.putchar(ch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Kernel
|
||||
m_width = new_width;
|
||||
m_height = new_height;
|
||||
}
|
||||
|
||||
|
||||
for (uint32_t y = 0; y < m_height; y++)
|
||||
for (uint32_t x = 0; x < m_width; x++)
|
||||
render_from_buffer(x, y);
|
||||
@@ -230,7 +230,7 @@ namespace Kernel
|
||||
{
|
||||
dprintln("Unsupported ANSI CSI character J");
|
||||
}
|
||||
|
||||
|
||||
if (m_ansi_state.nums[0] == 3)
|
||||
{
|
||||
// FIXME: Clear scroll backbuffer if/when added
|
||||
@@ -307,7 +307,7 @@ namespace Kernel
|
||||
void VirtualTTY::putchar_impl(uint8_t ch)
|
||||
{
|
||||
ASSERT(m_lock.is_locked());
|
||||
|
||||
|
||||
uint32_t codepoint = ch;
|
||||
|
||||
switch (m_state)
|
||||
@@ -425,4 +425,4 @@ namespace Kernel
|
||||
set_cursor_position(m_column, m_row);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Kernel
|
||||
PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present,
|
||||
true
|
||||
));
|
||||
|
||||
|
||||
thread->m_interrupt_stack = TRY(VirtualRange::create_to_vaddr_range(
|
||||
process->page_table(),
|
||||
0x300000, KERNEL_OFFSET,
|
||||
@@ -190,7 +190,7 @@ namespace Kernel
|
||||
{
|
||||
((Process*)process)->cleanup_function();
|
||||
Scheduler::get().delete_current_process_and_thread();
|
||||
ASSERT_NOT_REACHED();
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
);
|
||||
m_rsp = stack_base() + stack_size();
|
||||
@@ -392,4 +392,4 @@ namespace Kernel
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
|
||||
uint64_t ticks_per_ms = FS_PER_MS / m_counter_tick_period_fs;
|
||||
|
||||
|
||||
{
|
||||
const char* units[] = { "fs", "ps", "ns" };
|
||||
int index = 0;
|
||||
@@ -174,4 +174,4 @@ namespace Kernel
|
||||
return MMIO::read64(m_mmio_base + reg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Kernel
|
||||
last_time = time;
|
||||
get_time(time);
|
||||
}
|
||||
|
||||
|
||||
uint8_t regB = read_register8(0x0B);
|
||||
|
||||
// Convert BCD to binary values if necessary
|
||||
@@ -87,4 +87,4 @@ namespace Kernel
|
||||
return time;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,4 +86,4 @@ namespace Kernel
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user