mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00:00
More coding style changes.
This commit is contained in:
parent
d824442e3e
commit
f6e27c2abe
39 changed files with 216 additions and 216 deletions
|
@ -23,7 +23,7 @@ Console::~Console()
|
|||
{
|
||||
}
|
||||
|
||||
bool Console::hasDataAvailableForRead() const
|
||||
bool Console::has_data_available_for_reading() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ void Console::putChar(char ch)
|
|||
IO::out8(0xe9, ch);
|
||||
#endif
|
||||
if (m_implementation)
|
||||
m_implementation->onConsoleReceive(ch);
|
||||
m_implementation->on_sysconsole_receive(ch);
|
||||
}
|
||||
|
||||
ConsoleImplementation::~ConsoleImplementation()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
class ConsoleImplementation {
|
||||
public:
|
||||
virtual ~ConsoleImplementation();
|
||||
virtual void onConsoleReceive(byte) = 0;
|
||||
virtual void on_sysconsole_receive(byte) = 0;
|
||||
};
|
||||
|
||||
class Console final : public CharacterDevice {
|
||||
|
@ -18,7 +18,7 @@ public:
|
|||
Console();
|
||||
virtual ~Console() override;
|
||||
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
virtual ssize_t read(byte* buffer, size_t size) override;
|
||||
virtual ssize_t write(const byte* data, size_t size) override;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ void FIFO::close(Direction direction)
|
|||
|
||||
bool FIFO::can_read() const
|
||||
{
|
||||
return !m_queue.isEmpty() || !m_writers;
|
||||
return !m_queue.is_empty() || !m_writers;
|
||||
}
|
||||
|
||||
bool FIFO::can_write() const
|
||||
|
@ -59,7 +59,7 @@ bool FIFO::can_write() const
|
|||
|
||||
ssize_t FIFO::read(byte* buffer, size_t size)
|
||||
{
|
||||
if (!m_writers && m_queue.isEmpty())
|
||||
if (!m_writers && m_queue.is_empty())
|
||||
return 0;
|
||||
#ifdef FIFO_DEBUG
|
||||
dbgprintf("fifo: read(%u)\n",size);
|
||||
|
|
|
@ -100,7 +100,7 @@ bool IDEDiskDevice::wait_for_irq()
|
|||
return true;
|
||||
}
|
||||
|
||||
void IDEDiskDevice::handleIRQ()
|
||||
void IDEDiskDevice::handle_irq()
|
||||
{
|
||||
#ifdef DISK_DEBUG
|
||||
byte status = IO::in8(0x1f7);
|
||||
|
@ -123,13 +123,13 @@ void IDEDiskDevice::initialize()
|
|||
|
||||
while (IO::in8(IDE0_STATUS) & BUSY);
|
||||
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
|
||||
IO::out8(0x1F6, 0xA0); // 0xB0 for 2nd device
|
||||
IO::out8(0x3F6, 0xA0); // 0xB0 for 2nd device
|
||||
IO::out8(IDE0_COMMAND, IDENTIFY_DRIVE);
|
||||
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
wait_for_irq();
|
||||
|
||||
ByteBuffer wbuf = ByteBuffer::createUninitialized(512);
|
||||
|
@ -180,7 +180,7 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
|
|||
count,
|
||||
start_sector);
|
||||
#endif
|
||||
disableIRQ();
|
||||
disable_irq();
|
||||
|
||||
auto chs = lba_to_chs(start_sector);
|
||||
|
||||
|
@ -202,7 +202,7 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
|
|||
|
||||
IO::out8(IDE0_COMMAND, READ_SECTORS);
|
||||
m_interrupted = false;
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
wait_for_irq();
|
||||
|
||||
byte status = IO::in8(0x1f7);
|
||||
|
@ -228,7 +228,7 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
|
|||
current->pid(),
|
||||
count,
|
||||
start_sector);
|
||||
disableIRQ();
|
||||
disable_irq();
|
||||
|
||||
auto chs = lba_to_chs(start_sector);
|
||||
|
||||
|
@ -259,7 +259,7 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
|
|||
}
|
||||
|
||||
m_interrupted = false;
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
wait_for_irq();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -20,7 +20,7 @@ protected:
|
|||
|
||||
private:
|
||||
// ^IRQHandler
|
||||
virtual void handleIRQ() override;
|
||||
virtual void handle_irq() override;
|
||||
|
||||
// ^DiskDevice
|
||||
virtual const char* class_name() const override;
|
||||
|
|
|
@ -3,23 +3,23 @@
|
|||
#include "PIC.h"
|
||||
|
||||
IRQHandler::IRQHandler(byte irq)
|
||||
: m_irqNumber(irq)
|
||||
: m_irq_number(irq)
|
||||
{
|
||||
registerIRQHandler(m_irqNumber, *this);
|
||||
register_irq_handler(m_irq_number, *this);
|
||||
}
|
||||
|
||||
IRQHandler::~IRQHandler()
|
||||
{
|
||||
unregisterIRQHandler(m_irqNumber, *this);
|
||||
unregister_irq_handler(m_irq_number, *this);
|
||||
}
|
||||
|
||||
void IRQHandler::enableIRQ()
|
||||
void IRQHandler::enable_irq()
|
||||
{
|
||||
PIC::enable(m_irqNumber);
|
||||
PIC::enable(m_irq_number);
|
||||
}
|
||||
|
||||
void IRQHandler::disableIRQ()
|
||||
void IRQHandler::disable_irq()
|
||||
{
|
||||
PIC::disable(m_irqNumber);
|
||||
PIC::disable(m_irq_number);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
class IRQHandler {
|
||||
public:
|
||||
virtual ~IRQHandler();
|
||||
virtual void handleIRQ() = 0;
|
||||
virtual void handle_irq() = 0;
|
||||
|
||||
byte irqNumber() const { return m_irqNumber; }
|
||||
byte irq_number() const { return m_irq_number; }
|
||||
|
||||
void enableIRQ();
|
||||
void disableIRQ();
|
||||
void enable_irq();
|
||||
void disable_irq();
|
||||
|
||||
protected:
|
||||
explicit IRQHandler(byte irq);
|
||||
|
||||
private:
|
||||
byte m_irqNumber { 0 };
|
||||
byte m_irq_number { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ void Keyboard::emit(byte ch)
|
|||
key.character = ch;
|
||||
key.modifiers = m_modifiers;
|
||||
if (m_client)
|
||||
m_client->onKeyPress(key);
|
||||
m_client->on_key_pressed(key);
|
||||
m_queue.enqueue(key);
|
||||
}
|
||||
|
||||
void Keyboard::handleIRQ()
|
||||
void Keyboard::handle_irq()
|
||||
{
|
||||
while (IO::in8(0x64) & 1) {
|
||||
byte ch = IO::in8(0x60);
|
||||
|
@ -107,23 +107,23 @@ Keyboard::Keyboard()
|
|||
while (IO::in8(I8042_STATUS ) & DATA_AVAILABLE)
|
||||
IO::in8(I8042_BUFFER);
|
||||
|
||||
enableIRQ();
|
||||
enable_irq();
|
||||
}
|
||||
|
||||
Keyboard::~Keyboard()
|
||||
{
|
||||
}
|
||||
|
||||
bool Keyboard::hasDataAvailableForRead() const
|
||||
bool Keyboard::has_data_available_for_reading() const
|
||||
{
|
||||
return !m_queue.isEmpty();
|
||||
return !m_queue.is_empty();
|
||||
}
|
||||
|
||||
ssize_t Keyboard::read(byte* buffer, size_t size)
|
||||
{
|
||||
ssize_t nread = 0;
|
||||
while ((size_t)nread < size) {
|
||||
if (m_queue.isEmpty())
|
||||
if (m_queue.is_empty())
|
||||
break;
|
||||
buffer[nread++] = m_queue.dequeue().character;
|
||||
}
|
||||
|
|
|
@ -30,16 +30,16 @@ public:
|
|||
virtual ~Keyboard() override;
|
||||
Keyboard();
|
||||
|
||||
void setClient(KeyboardClient* client) { m_client = client; }
|
||||
void set_client(KeyboardClient* client) { m_client = client; }
|
||||
|
||||
private:
|
||||
// ^IRQHandler
|
||||
virtual void handleIRQ() override;
|
||||
virtual void handle_irq() override;
|
||||
|
||||
// ^CharacterDevice
|
||||
virtual ssize_t read(byte* buffer, size_t) override;
|
||||
virtual ssize_t write(const byte* buffer, size_t) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
|
||||
void emit(byte);
|
||||
|
||||
|
@ -51,5 +51,5 @@ private:
|
|||
class KeyboardClient {
|
||||
public:
|
||||
virtual ~KeyboardClient();
|
||||
virtual void onKeyPress(Keyboard::Key) = 0;
|
||||
virtual void on_key_pressed(Keyboard::Key) = 0;
|
||||
};
|
||||
|
|
|
@ -167,30 +167,30 @@ ByteBuffer procfs$pid_cwd(Process& process)
|
|||
return VFS::the().absolute_path(*inode).toByteBuffer();
|
||||
}
|
||||
|
||||
void ProcFS::addProcess(Process& process)
|
||||
void ProcFS::add_process(Process& process)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
char buf[16];
|
||||
ksprintf(buf, "%d", process.pid());
|
||||
auto dir = addFile(create_directory(buf));
|
||||
auto dir = add_file(create_directory(buf));
|
||||
m_pid2inode.set(process.pid(), dir.index());
|
||||
addFile(create_generated_file("vm", [&process] { return procfs$pid_vm(process); }), dir.index());
|
||||
addFile(create_generated_file("vmo", [&process] { return procfs$pid_vmo(process); }), dir.index());
|
||||
addFile(create_generated_file("stack", [&process] { return procfs$pid_stack(process); }), dir.index());
|
||||
addFile(create_generated_file("regs", [&process] { return procfs$pid_regs(process); }), dir.index());
|
||||
addFile(create_generated_file("fds", [&process] { return procfs$pid_fds(process); }), dir.index());
|
||||
add_file(create_generated_file("vm", [&process] { return procfs$pid_vm(process); }), dir.index());
|
||||
add_file(create_generated_file("vmo", [&process] { return procfs$pid_vmo(process); }), dir.index());
|
||||
add_file(create_generated_file("stack", [&process] { return procfs$pid_stack(process); }), dir.index());
|
||||
add_file(create_generated_file("regs", [&process] { return procfs$pid_regs(process); }), dir.index());
|
||||
add_file(create_generated_file("fds", [&process] { return procfs$pid_fds(process); }), dir.index());
|
||||
if (process.executable_inode())
|
||||
addFile(create_generated_file("exe", [&process] { return procfs$pid_exe(process); }, 00120777), dir.index());
|
||||
addFile(create_generated_file("cwd", [&process] { return procfs$pid_cwd(process); }, 00120777), dir.index());
|
||||
add_file(create_generated_file("exe", [&process] { return procfs$pid_exe(process); }, 00120777), dir.index());
|
||||
add_file(create_generated_file("cwd", [&process] { return procfs$pid_cwd(process); }, 00120777), dir.index());
|
||||
}
|
||||
|
||||
void ProcFS::removeProcess(Process& process)
|
||||
void ProcFS::remove_process(Process& process)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
auto pid = process.pid();
|
||||
auto it = m_pid2inode.find(pid);
|
||||
ASSERT(it != m_pid2inode.end());
|
||||
bool success = removeFile((*it).value);
|
||||
bool success = remove_file((*it).value);
|
||||
ASSERT(success);
|
||||
m_pid2inode.remove(pid);
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ ByteBuffer procfs$summary()
|
|||
process->ppid(),
|
||||
process->timesScheduled(),
|
||||
process->number_of_open_file_descriptors(),
|
||||
process->tty() ? strrchr(process->tty()->ttyName().characters(), '/') + 1 : "n/a",
|
||||
process->tty() ? strrchr(process->tty()->tty_name().characters(), '/') + 1 : "n/a",
|
||||
process->name().characters());
|
||||
}
|
||||
*ptr = '\0';
|
||||
|
@ -364,8 +364,8 @@ ByteBuffer procfs$vnodes()
|
|||
path = vfs.absolute_path(*vnode.core_inode());
|
||||
if (path.isEmpty()) {
|
||||
if (auto* dev = vnode.characterDevice()) {
|
||||
if (dev->isTTY())
|
||||
path = static_cast<const TTY*>(dev)->ttyName();
|
||||
if (dev->is_tty())
|
||||
path = static_cast<const TTY*>(dev)->tty_name();
|
||||
}
|
||||
}
|
||||
ptr += ksprintf(ptr, "vnode %03u: %02u:%08u (%u) %s\n", i, vnode.inode.fsid(), vnode.inode.index(), vnode.retain_count(), path.characters());
|
||||
|
@ -378,13 +378,13 @@ ByteBuffer procfs$vnodes()
|
|||
bool ProcFS::initialize()
|
||||
{
|
||||
SynthFS::initialize();
|
||||
addFile(create_generated_file("mm", procfs$mm));
|
||||
addFile(create_generated_file("regions", procfs$regions));
|
||||
addFile(create_generated_file("mounts", procfs$mounts));
|
||||
addFile(create_generated_file("kmalloc", procfs$kmalloc));
|
||||
addFile(create_generated_file("summary", procfs$summary));
|
||||
addFile(create_generated_file("cpuinfo", procfs$cpuinfo));
|
||||
addFile(create_generated_file("vnodes", procfs$vnodes));
|
||||
add_file(create_generated_file("mm", procfs$mm));
|
||||
add_file(create_generated_file("regions", procfs$regions));
|
||||
add_file(create_generated_file("mounts", procfs$mounts));
|
||||
add_file(create_generated_file("kmalloc", procfs$kmalloc));
|
||||
add_file(create_generated_file("summary", procfs$summary));
|
||||
add_file(create_generated_file("cpuinfo", procfs$cpuinfo));
|
||||
add_file(create_generated_file("vnodes", procfs$vnodes));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ public:
|
|||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
|
||||
void addProcess(Process&);
|
||||
void removeProcess(Process&);
|
||||
void add_process(Process&);
|
||||
void remove_process(Process&);
|
||||
|
||||
private:
|
||||
ProcFS();
|
||||
|
|
|
@ -255,7 +255,7 @@ Process* Process::fork(RegisterDump& regs)
|
|||
dbgprintf("fork: child will begin executing at %w:%x with stack %w:%x\n", child->m_tss.cs, child->m_tss.eip, child->m_tss.ss, child->m_tss.esp);
|
||||
#endif
|
||||
|
||||
ProcFS::the().addProcess(*child);
|
||||
ProcFS::the().add_process(*child);
|
||||
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
@ -491,7 +491,7 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid,
|
|||
if (error != 0)
|
||||
return nullptr;
|
||||
|
||||
ProcFS::the().addProcess(*process);
|
||||
ProcFS::the().add_process(*process);
|
||||
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
@ -554,7 +554,7 @@ Process* Process::create_kernel_process(void (*e)(), String&& name)
|
|||
g_processes->prepend(process);
|
||||
system.nprocess++;
|
||||
}
|
||||
ProcFS::the().addProcess(*process);
|
||||
ProcFS::the().add_process(*process);
|
||||
#ifdef TASK_DEBUG
|
||||
kprintf("Kernel process %u (%s) spawned @ %p\n", process->pid(), process->name().characters(), process->m_tss.eip);
|
||||
#endif
|
||||
|
@ -684,7 +684,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
|
|||
Process::~Process()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ProcFS::the().removeProcess(*this);
|
||||
ProcFS::the().remove_process(*this);
|
||||
system.nprocess--;
|
||||
|
||||
gdt_free_entry(selector());
|
||||
|
@ -976,9 +976,9 @@ int Process::sys$ttyname_r(int fd, char* buffer, size_t size)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (!descriptor->isTTY())
|
||||
if (!descriptor->is_tty())
|
||||
return -ENOTTY;
|
||||
auto ttyName = descriptor->tty()->ttyName();
|
||||
auto ttyName = descriptor->tty()->tty_name();
|
||||
if (size < ttyName.length() + 1)
|
||||
return -ERANGE;
|
||||
strcpy(buffer, ttyName.characters());
|
||||
|
@ -996,7 +996,7 @@ ssize_t Process::sys$write(int fd, const void* data, size_t size)
|
|||
if (!descriptor)
|
||||
return -EBADF;
|
||||
ssize_t nwritten = 0;
|
||||
if (descriptor->isBlocking()) {
|
||||
if (descriptor->is_blocking()) {
|
||||
while (nwritten < (ssize_t)size) {
|
||||
#ifdef IO_DEBUG
|
||||
dbgprintf("while %u < %u\n", nwritten, size);
|
||||
|
@ -1053,8 +1053,8 @@ ssize_t Process::sys$read(int fd, void* outbuf, size_t nread)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (descriptor->isBlocking()) {
|
||||
if (!descriptor->hasDataAvailableForRead()) {
|
||||
if (descriptor->is_blocking()) {
|
||||
if (!descriptor->has_data_available_for_reading()) {
|
||||
m_fdBlockedOnRead = fd;
|
||||
block(BlockedRead);
|
||||
sched_yield();
|
||||
|
@ -1180,7 +1180,7 @@ int Process::sys$readlink(const char* path, char* buffer, size_t size)
|
|||
if (!descriptor->metadata().isSymbolicLink())
|
||||
return -EINVAL;
|
||||
|
||||
auto contents = descriptor->readEntireFile();
|
||||
auto contents = descriptor->read_entire_file();
|
||||
if (!contents)
|
||||
return -EIO; // FIXME: Get a more detailed error from VFS.
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ int Process::sys$chdir(const char* path)
|
|||
auto descriptor = VFS::the().open(path, error, 0, cwd_inode()->identifier());
|
||||
if (!descriptor)
|
||||
return error;
|
||||
if (!descriptor->isDirectory())
|
||||
if (!descriptor->is_directory())
|
||||
return -ENOTDIR;
|
||||
m_cwd = descriptor->vnode();
|
||||
return 0;
|
||||
|
@ -1241,7 +1241,7 @@ int Process::sys$open(const char* path, int options)
|
|||
auto descriptor = VFS::the().open(path, error, options, cwd_inode()->identifier());
|
||||
if (!descriptor)
|
||||
return error;
|
||||
if (options & O_DIRECTORY && !descriptor->isDirectory())
|
||||
if (options & O_DIRECTORY && !descriptor->is_directory())
|
||||
return -ENOTDIR; // FIXME: This should be handled by VFS::open.
|
||||
|
||||
int fd = 0;
|
||||
|
@ -1326,7 +1326,7 @@ int Process::sys$isatty(int fd)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (!descriptor->isTTY())
|
||||
if (!descriptor->is_tty())
|
||||
return -ENOTTY;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ bool Scheduler::pick_next()
|
|||
if (process.state() == Process::BlockedRead) {
|
||||
ASSERT(process.m_fdBlockedOnRead != -1);
|
||||
// FIXME: Block until the amount of data wanted is available.
|
||||
if (process.m_fds[process.m_fdBlockedOnRead].descriptor->hasDataAvailableForRead())
|
||||
if (process.m_fds[process.m_fdBlockedOnRead].descriptor->has_data_available_for_reading())
|
||||
process.unblock();
|
||||
return true;
|
||||
}
|
||||
|
@ -167,9 +167,9 @@ void Scheduler::pick_next_and_switch_now()
|
|||
|
||||
void Scheduler::switch_now()
|
||||
{
|
||||
Descriptor& descriptor = getGDTEntry(current->selector());
|
||||
Descriptor& descriptor = get_gdt_entry(current->selector());
|
||||
descriptor.type = 9;
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
asm("sti\n"
|
||||
"ljmp *(%%eax)\n"
|
||||
::"a"(¤t->farPtr())
|
||||
|
@ -204,7 +204,7 @@ bool Scheduler::context_switch(Process& process)
|
|||
|
||||
if (!process.selector()) {
|
||||
process.setSelector(gdt_alloc_entry());
|
||||
auto& descriptor = getGDTEntry(process.selector());
|
||||
auto& descriptor = get_gdt_entry(process.selector());
|
||||
descriptor.setBase(&process.tss());
|
||||
descriptor.setLimit(0xffff);
|
||||
descriptor.dpl = 0;
|
||||
|
@ -215,9 +215,9 @@ bool Scheduler::context_switch(Process& process)
|
|||
descriptor.descriptor_type = 0;
|
||||
}
|
||||
|
||||
auto& descriptor = getGDTEntry(process.selector());
|
||||
auto& descriptor = get_gdt_entry(process.selector());
|
||||
descriptor.type = 11; // Busy TSS
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ int sched_yield()
|
|||
|
||||
static void initialize_redirection()
|
||||
{
|
||||
auto& descriptor = getGDTEntry(s_redirection.selector);
|
||||
auto& descriptor = get_gdt_entry(s_redirection.selector);
|
||||
descriptor.setBase(&s_redirection.tss);
|
||||
descriptor.setLimit(0xffff);
|
||||
descriptor.dpl = 0;
|
||||
|
@ -238,12 +238,12 @@ static void initialize_redirection()
|
|||
descriptor.operation_size = 1;
|
||||
descriptor.descriptor_type = 0;
|
||||
descriptor.type = 9;
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
}
|
||||
|
||||
void Scheduler::prepare_for_iret_to_new_process()
|
||||
{
|
||||
auto& descriptor = getGDTEntry(s_redirection.selector);
|
||||
auto& descriptor = get_gdt_entry(s_redirection.selector);
|
||||
descriptor.type = 9;
|
||||
s_redirection.tss.backlink = current->selector();
|
||||
load_task_register(s_redirection.selector);
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Syscall {
|
|||
|
||||
void initialize()
|
||||
{
|
||||
registerUserCallableInterruptHandler(0x80, syscall_ISR);
|
||||
register_user_callable_interrupt_handler(0x80, syscall_ISR);
|
||||
kprintf("syscall: int 0x80 handler installed\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@ ssize_t TTY::write(const byte* buffer, size_t size)
|
|||
#ifdef TTY_DEBUG
|
||||
dbgprintf("TTY::write %b {%u}\n", buffer[0], size);
|
||||
#endif
|
||||
onTTYWrite(buffer, size);
|
||||
on_tty_write(buffer, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool TTY::hasDataAvailableForRead() const
|
||||
bool TTY::has_data_available_for_reading() const
|
||||
{
|
||||
return !m_buffer.is_empty();
|
||||
}
|
||||
|
@ -68,12 +68,12 @@ void TTY::emit(byte ch)
|
|||
{
|
||||
if (should_generate_signals()) {
|
||||
if (ch == m_termios.c_cc[VINTR]) {
|
||||
dbgprintf("%s: VINTR pressed!\n", ttyName().characters());
|
||||
dbgprintf("%s: VINTR pressed!\n", tty_name().characters());
|
||||
generate_signal(SIGINT);
|
||||
return;
|
||||
}
|
||||
if (ch == m_termios.c_cc[VQUIT]) {
|
||||
dbgprintf("%s: VQUIT pressed!\n", ttyName().characters());
|
||||
dbgprintf("%s: VQUIT pressed!\n", tty_name().characters());
|
||||
generate_signal(SIGQUIT);
|
||||
return;
|
||||
}
|
||||
|
@ -85,10 +85,10 @@ void TTY::generate_signal(int signal)
|
|||
{
|
||||
if (!pgid())
|
||||
return;
|
||||
dbgprintf("%s: Send signal %d to everyone in pgrp %d\n", ttyName().characters(), signal, pgid());
|
||||
dbgprintf("%s: Send signal %d to everyone in pgrp %d\n", tty_name().characters(), signal, pgid());
|
||||
InterruptDisabler disabler; // FIXME: Iterate over a set of process handles instead?
|
||||
Process::for_each_in_pgrp(pgid(), [&] (auto& process) {
|
||||
dbgprintf("%s: Send signal %d to %d\n", ttyName().characters(), signal, process.pid());
|
||||
dbgprintf("%s: Send signal %d to %d\n", tty_name().characters(), signal, process.pid());
|
||||
process.send_signal(signal, nullptr);
|
||||
return true;
|
||||
});
|
||||
|
@ -98,7 +98,7 @@ void TTY::set_termios(const Unix::termios& t)
|
|||
{
|
||||
m_termios = t;
|
||||
dbgprintf("%s set_termios: IECHO? %u, ISIG? %u, ICANON? %u\n",
|
||||
ttyName().characters(),
|
||||
tty_name().characters(),
|
||||
should_echo_input(),
|
||||
should_generate_signals(),
|
||||
in_canonical_mode()
|
||||
|
|
|
@ -34,10 +34,10 @@ public:
|
|||
|
||||
virtual ssize_t read(byte*, size_t) override;
|
||||
virtual ssize_t write(const byte*, size_t) override;
|
||||
virtual bool hasDataAvailableForRead() const override;
|
||||
virtual bool has_data_available_for_reading() const override;
|
||||
virtual int ioctl(Process&, unsigned request, unsigned arg) override final;
|
||||
|
||||
virtual String ttyName() const = 0;
|
||||
virtual String tty_name() const = 0;
|
||||
|
||||
unsigned short rows() const { return m_rows; }
|
||||
unsigned short columns() const { return m_columns; }
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
bool in_canonical_mode() const { return m_termios.c_lflag & ICANON; }
|
||||
|
||||
protected:
|
||||
virtual void onTTYWrite(const byte*, size_t) = 0;
|
||||
virtual void on_tty_write(const byte*, size_t) = 0;
|
||||
void set_size(unsigned short columns, unsigned short rows);
|
||||
|
||||
TTY(unsigned major, unsigned minor);
|
||||
|
@ -60,7 +60,7 @@ protected:
|
|||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual bool isTTY() const final override { return true; }
|
||||
virtual bool is_tty() const final override { return true; }
|
||||
|
||||
void generate_signal(int signal);
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ void VirtualConsole::set_active(bool b)
|
|||
set_vga_start_row(0);
|
||||
flush_vga_cursor();
|
||||
|
||||
Keyboard::the().setClient(this);
|
||||
Keyboard::the().set_client(this);
|
||||
}
|
||||
|
||||
inline bool is_valid_parameter_character(byte ch)
|
||||
|
@ -441,7 +441,7 @@ void VirtualConsole::on_char(byte ch)
|
|||
set_cursor(m_cursor_row, m_cursor_column);
|
||||
}
|
||||
|
||||
void VirtualConsole::onKeyPress(Keyboard::Key key)
|
||||
void VirtualConsole::on_key_pressed(Keyboard::Key key)
|
||||
{
|
||||
if (key.ctrl()) {
|
||||
if (key.character >= 'a' && key.character <= 'z') {
|
||||
|
@ -455,7 +455,7 @@ void VirtualConsole::onKeyPress(Keyboard::Key key)
|
|||
emit(key.character);
|
||||
}
|
||||
|
||||
void VirtualConsole::onConsoleReceive(byte ch)
|
||||
void VirtualConsole::on_sysconsole_receive(byte ch)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
auto old_attribute = m_current_attribute;
|
||||
|
@ -464,14 +464,14 @@ void VirtualConsole::onConsoleReceive(byte ch)
|
|||
m_current_attribute = old_attribute;
|
||||
}
|
||||
|
||||
void VirtualConsole::onTTYWrite(const byte* data, size_t size)
|
||||
void VirtualConsole::on_tty_write(const byte* data, size_t size)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
on_char(data[i]);
|
||||
}
|
||||
|
||||
String VirtualConsole::ttyName() const
|
||||
String VirtualConsole::tty_name() const
|
||||
{
|
||||
char buf[16];
|
||||
ksprintf(buf, "/dev/tty%u", m_index);
|
||||
|
|
|
@ -17,14 +17,14 @@ public:
|
|||
|
||||
private:
|
||||
// ^KeyboardClient
|
||||
virtual void onKeyPress(Keyboard::Key) override;
|
||||
virtual void on_key_pressed(Keyboard::Key) override;
|
||||
|
||||
// ^ConsoleImplementation
|
||||
virtual void onConsoleReceive(byte) override;
|
||||
virtual void on_sysconsole_receive(byte) override;
|
||||
|
||||
// ^TTY
|
||||
virtual void onTTYWrite(const byte*, size_t) override;
|
||||
virtual String ttyName() const override;
|
||||
virtual void on_tty_write(const byte*, size_t) override;
|
||||
virtual String tty_name() const override;
|
||||
|
||||
void set_active(bool);
|
||||
void on_char(byte);
|
||||
|
|
|
@ -297,18 +297,18 @@ static void writeRawGDTEntry(word selector, dword low, dword high)
|
|||
}
|
||||
}
|
||||
|
||||
void writeGDTEntry(word selector, Descriptor& descriptor)
|
||||
void write_gdt_entry(word selector, Descriptor& descriptor)
|
||||
{
|
||||
writeRawGDTEntry(selector, descriptor.low, descriptor.high);
|
||||
}
|
||||
|
||||
Descriptor& getGDTEntry(word selector)
|
||||
Descriptor& get_gdt_entry(word selector)
|
||||
{
|
||||
word i = (selector & 0xfffc) >> 3;
|
||||
return *(Descriptor*)(&s_gdt[i]);
|
||||
}
|
||||
|
||||
void flushGDT()
|
||||
void flush_gdt()
|
||||
{
|
||||
s_gdtr.address = s_gdt;
|
||||
s_gdtr.size = (s_gdtLength * 8) - 1;
|
||||
|
@ -335,7 +335,7 @@ void gdt_init()
|
|||
writeRawGDTEntry(0x0018, 0x0000ffff, 0x00cffa00);
|
||||
writeRawGDTEntry(0x0020, 0x0000ffff, 0x00cff200);
|
||||
|
||||
flushGDT();
|
||||
flush_gdt();
|
||||
}
|
||||
|
||||
static void unimp_trap()
|
||||
|
@ -344,34 +344,34 @@ static void unimp_trap()
|
|||
HANG;
|
||||
}
|
||||
|
||||
void registerIRQHandler(byte irq, IRQHandler& handler)
|
||||
void register_irq_handler(byte irq, IRQHandler& handler)
|
||||
{
|
||||
ASSERT(!s_irqHandler[irq]);
|
||||
s_irqHandler[irq] = &handler;
|
||||
registerInterruptHandler(IRQ_VECTOR_BASE + irq, asm_irq_entry);
|
||||
register_interrupt_handler(IRQ_VECTOR_BASE + irq, asm_irq_entry);
|
||||
}
|
||||
|
||||
void unregisterIRQHandler(byte irq, IRQHandler& handler)
|
||||
void unregister_irq_handler(byte irq, IRQHandler& handler)
|
||||
{
|
||||
ASSERT(s_irqHandler[irq] == &handler);
|
||||
s_irqHandler[irq] = nullptr;
|
||||
}
|
||||
|
||||
void registerInterruptHandler(byte index, void (*f)())
|
||||
void register_interrupt_handler(byte index, void (*f)())
|
||||
{
|
||||
s_idt[index].low = 0x00080000 | LSW((f));
|
||||
s_idt[index].high = ((dword)(f) & 0xffff0000) | 0x8e00;
|
||||
flushIDT();
|
||||
flush_idt();
|
||||
}
|
||||
|
||||
void registerUserCallableInterruptHandler(byte index, void (*f)())
|
||||
void register_user_callable_interrupt_handler(byte index, void (*f)())
|
||||
{
|
||||
s_idt[index].low = 0x00080000 | LSW((f));
|
||||
s_idt[index].high = ((dword)(f) & 0xffff0000) | 0xef00;
|
||||
flushIDT();
|
||||
flush_idt();
|
||||
}
|
||||
|
||||
void flushIDT()
|
||||
void flush_idt()
|
||||
{
|
||||
asm("lidt %0"::"m"(s_idtr));
|
||||
}
|
||||
|
@ -396,34 +396,34 @@ void idt_init()
|
|||
s_idtr.size = 0x100 * 8;
|
||||
|
||||
for (byte i = 0xff; i > 0x10; --i)
|
||||
registerInterruptHandler(i, unimp_trap);
|
||||
register_interrupt_handler(i, unimp_trap);
|
||||
|
||||
registerInterruptHandler(0x00, _exception0);
|
||||
registerInterruptHandler(0x01, _exception1);
|
||||
registerInterruptHandler(0x02, _exception2);
|
||||
registerInterruptHandler(0x03, _exception3);
|
||||
registerInterruptHandler(0x04, _exception4);
|
||||
registerInterruptHandler(0x05, _exception5);
|
||||
registerInterruptHandler(0x06, exception_6_entry);
|
||||
registerInterruptHandler(0x07, _exception7);
|
||||
registerInterruptHandler(0x08, _exception8);
|
||||
registerInterruptHandler(0x09, _exception9);
|
||||
registerInterruptHandler(0x0a, _exception10);
|
||||
registerInterruptHandler(0x0b, _exception11);
|
||||
registerInterruptHandler(0x0c, _exception12);
|
||||
registerInterruptHandler(0x0d, exception_13_entry);
|
||||
registerInterruptHandler(0x0e, exception_14_entry);
|
||||
registerInterruptHandler(0x0f, _exception15);
|
||||
registerInterruptHandler(0x10, _exception16);
|
||||
register_interrupt_handler(0x00, _exception0);
|
||||
register_interrupt_handler(0x01, _exception1);
|
||||
register_interrupt_handler(0x02, _exception2);
|
||||
register_interrupt_handler(0x03, _exception3);
|
||||
register_interrupt_handler(0x04, _exception4);
|
||||
register_interrupt_handler(0x05, _exception5);
|
||||
register_interrupt_handler(0x06, exception_6_entry);
|
||||
register_interrupt_handler(0x07, _exception7);
|
||||
register_interrupt_handler(0x08, _exception8);
|
||||
register_interrupt_handler(0x09, _exception9);
|
||||
register_interrupt_handler(0x0a, _exception10);
|
||||
register_interrupt_handler(0x0b, _exception11);
|
||||
register_interrupt_handler(0x0c, _exception12);
|
||||
register_interrupt_handler(0x0d, exception_13_entry);
|
||||
register_interrupt_handler(0x0e, exception_14_entry);
|
||||
register_interrupt_handler(0x0f, _exception15);
|
||||
register_interrupt_handler(0x10, _exception16);
|
||||
|
||||
registerInterruptHandler(0x57, irq7_handler);
|
||||
register_interrupt_handler(0x57, irq7_handler);
|
||||
|
||||
s_irqHandler = static_cast<IRQHandler**>(kmalloc_eternal(sizeof(IRQHandler*) * 16));
|
||||
for (byte i = 0; i < 16; ++i) {
|
||||
s_irqHandler[i] = nullptr;
|
||||
}
|
||||
|
||||
flushIDT();
|
||||
flush_idt();
|
||||
}
|
||||
|
||||
void load_task_register(word selector)
|
||||
|
@ -450,7 +450,7 @@ void handle_irq()
|
|||
}
|
||||
|
||||
if (s_irqHandler[irq])
|
||||
s_irqHandler[irq]->handleIRQ();
|
||||
s_irqHandler[irq]->handle_irq();
|
||||
PIC::eoi(irq);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,17 +61,17 @@ class IRQHandler;
|
|||
|
||||
void gdt_init();
|
||||
void idt_init();
|
||||
void registerInterruptHandler(byte number, void (*f)());
|
||||
void registerUserCallableInterruptHandler(byte number, void (*f)());
|
||||
void registerIRQHandler(byte number, IRQHandler&);
|
||||
void unregisterIRQHandler(byte number, IRQHandler&);
|
||||
void flushIDT();
|
||||
void flushGDT();
|
||||
void register_interrupt_handler(byte number, void (*f)());
|
||||
void register_user_callable_interrupt_handler(byte number, void (*f)());
|
||||
void register_irq_handler(byte number, IRQHandler&);
|
||||
void unregister_irq_handler(byte number, IRQHandler&);
|
||||
void flush_idt();
|
||||
void flush_gdt();
|
||||
void load_task_register(word selector);
|
||||
word gdt_alloc_entry();
|
||||
void gdt_free_entry(word);
|
||||
Descriptor& getGDTEntry(word selector);
|
||||
void writeGDTEntry(word selector, Descriptor&);
|
||||
Descriptor& get_gdt_entry(word selector);
|
||||
void write_gdt_entry(word selector, Descriptor&);
|
||||
|
||||
#define HANG asm volatile( "cli; hlt" );
|
||||
#define LSW(x) ((dword)(x) & 0xFFFF)
|
||||
|
@ -82,7 +82,7 @@ void writeGDTEntry(word selector, Descriptor&);
|
|||
#define cli() asm volatile("cli")
|
||||
#define sti() asm volatile("sti")
|
||||
|
||||
static inline dword cpuFlags()
|
||||
static inline dword cpu_flags()
|
||||
{
|
||||
dword flags;
|
||||
asm volatile(
|
||||
|
@ -95,14 +95,14 @@ static inline dword cpuFlags()
|
|||
|
||||
inline bool are_interrupts_enabled()
|
||||
{
|
||||
return cpuFlags() & 0x200;
|
||||
return cpu_flags() & 0x200;
|
||||
}
|
||||
|
||||
class InterruptDisabler {
|
||||
public:
|
||||
InterruptDisabler()
|
||||
{
|
||||
m_flags = cpuFlags();
|
||||
m_flags = cpu_flags();
|
||||
cli();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void initialize()
|
|||
IO::out8(TIMER0_CTL, LSB(timer_reload));
|
||||
IO::out8(TIMER0_CTL, MSB(timer_reload));
|
||||
|
||||
registerInterruptHandler(IRQ_VECTOR_BASE + IRQ_TIMER, tick_ISR);
|
||||
register_interrupt_handler(IRQ_VECTOR_BASE + IRQ_TIMER, tick_ISR);
|
||||
|
||||
PIC::enable(IRQ_TIMER);
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ static void init_stage2()
|
|||
if (!descriptor) {
|
||||
kprintf("Failed to open /kernel.map\n");
|
||||
} else {
|
||||
auto buffer = descriptor->readEntireFile();
|
||||
auto buffer = descriptor->read_entire_file();
|
||||
ASSERT(buffer);
|
||||
loadKsyms(buffer);
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
|
|||
#define CRASH() do { asm volatile("ud2"); } while(0)
|
||||
#define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0)
|
||||
#define ASSERT_NOT_REACHED() ASSERT(false)
|
||||
#define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpuFlags() & 0x200))
|
||||
#define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpuFlags() & 0x200)
|
||||
#define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpu_flags() & 0x200))
|
||||
#define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpu_flags() & 0x200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue