mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
Kernel: Run clang-format on everything.
This commit is contained in:
parent
98eeb8f22d
commit
bc951ca565
63 changed files with 974 additions and 856 deletions
|
@ -1,29 +1,29 @@
|
|||
#include <Kernel/Devices/BXVGADevice.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/PCI.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
#define VBE_DISPI_IOPORT_INDEX 0x01CE
|
||||
#define VBE_DISPI_IOPORT_DATA 0x01CF
|
||||
#define VBE_DISPI_IOPORT_INDEX 0x01CE
|
||||
#define VBE_DISPI_IOPORT_DATA 0x01CF
|
||||
|
||||
#define VBE_DISPI_INDEX_ID 0x0
|
||||
#define VBE_DISPI_INDEX_XRES 0x1
|
||||
#define VBE_DISPI_INDEX_YRES 0x2
|
||||
#define VBE_DISPI_INDEX_BPP 0x3
|
||||
#define VBE_DISPI_INDEX_ENABLE 0x4
|
||||
#define VBE_DISPI_INDEX_BANK 0x5
|
||||
#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
||||
#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
||||
#define VBE_DISPI_INDEX_X_OFFSET 0x8
|
||||
#define VBE_DISPI_INDEX_Y_OFFSET 0x9
|
||||
#define VBE_DISPI_DISABLED 0x00
|
||||
#define VBE_DISPI_ENABLED 0x01
|
||||
#define VBE_DISPI_LFB_ENABLED 0x40
|
||||
#define VBE_DISPI_INDEX_ID 0x0
|
||||
#define VBE_DISPI_INDEX_XRES 0x1
|
||||
#define VBE_DISPI_INDEX_YRES 0x2
|
||||
#define VBE_DISPI_INDEX_BPP 0x3
|
||||
#define VBE_DISPI_INDEX_ENABLE 0x4
|
||||
#define VBE_DISPI_INDEX_BANK 0x5
|
||||
#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
||||
#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
||||
#define VBE_DISPI_INDEX_X_OFFSET 0x8
|
||||
#define VBE_DISPI_INDEX_Y_OFFSET 0x9
|
||||
#define VBE_DISPI_DISABLED 0x00
|
||||
#define VBE_DISPI_ENABLED 0x01
|
||||
#define VBE_DISPI_LFB_ENABLED 0x40
|
||||
|
||||
#define BXVGA_DEV_IOCTL_SET_Y_OFFSET 1982
|
||||
#define BXVGA_DEV_IOCTL_SET_RESOLUTION 1985
|
||||
#define BXVGA_DEV_IOCTL_SET_Y_OFFSET 1982
|
||||
#define BXVGA_DEV_IOCTL_SET_RESOLUTION 1985
|
||||
struct BXVGAResolution {
|
||||
int width;
|
||||
int height;
|
||||
|
@ -75,7 +75,7 @@ dword BXVGADevice::find_framebuffer_address()
|
|||
static const PCI::ID bochs_vga_id = { 0x1234, 0x1111 };
|
||||
static const PCI::ID virtualbox_vga_id = { 0x80ee, 0xbeef };
|
||||
dword framebuffer_address = 0;
|
||||
PCI::enumerate_all([&framebuffer_address] (const PCI::Address& address, PCI::ID id) {
|
||||
PCI::enumerate_all([&framebuffer_address](const PCI::Address& address, PCI::ID id) {
|
||||
if (id == bochs_vga_id || id == virtualbox_vga_id) {
|
||||
framebuffer_address = PCI::get_BAR0(address) & 0xfffffff0;
|
||||
kprintf("BXVGA: framebuffer @ P%x\n", framebuffer_address);
|
||||
|
@ -95,11 +95,10 @@ KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, LinearA
|
|||
move(vmo),
|
||||
0,
|
||||
"BXVGA Framebuffer",
|
||||
prot
|
||||
);
|
||||
prot);
|
||||
kprintf("BXVGA: %s(%u) created Region{%p} with size %u for framebuffer P%x with laddr L%x\n",
|
||||
process.name().characters(), process.pid(),
|
||||
region, region->size(), framebuffer_address().as_ptr(), region->laddr().get());
|
||||
process.name().characters(), process.pid(),
|
||||
region, region->size(), framebuffer_address().as_ptr(), region->laddr().get());
|
||||
ASSERT(region);
|
||||
return region;
|
||||
}
|
||||
|
|
|
@ -25,4 +25,3 @@ ssize_t DebugLogDevice::write(FileDescription&, const byte* data, ssize_t data_s
|
|||
IO::out8(0xe9, data[i]);
|
||||
return data_size;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include <LibC/errno_numbers.h>
|
||||
|
||||
Device::Device(unsigned major, unsigned minor)
|
||||
: m_major(major)
|
||||
, m_minor(minor)
|
||||
: m_major(major)
|
||||
, m_minor(minor)
|
||||
{
|
||||
VFS::the().register_device({}, *this);
|
||||
}
|
||||
|
|
|
@ -27,4 +27,3 @@ bool DiskDevice::write(DiskOffset offset, unsigned length, const byte* in)
|
|||
ASSERT(end_block <= 0xffffffff);
|
||||
return write_blocks(first_block, end_block - first_block, in);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ Retained<DiskPartition> DiskPartition::create(Retained<DiskDevice>&& device, uns
|
|||
}
|
||||
|
||||
DiskPartition::DiskPartition(Retained<DiskDevice>&& device, unsigned block_offset)
|
||||
: m_device(move(device)), m_block_offset(block_offset)
|
||||
: m_device(move(device))
|
||||
, m_block_offset(block_offset)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -79,4 +79,3 @@ const char* FileBackedDiskDevice::class_name() const
|
|||
{
|
||||
return "FileBackedDiskDevice";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "FullDevice.h"
|
||||
#include <LibC/errno_numbers.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/kstdio.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
FullDevice::FullDevice()
|
||||
: CharacterDevice(1, 7)
|
||||
|
@ -30,4 +30,3 @@ ssize_t FullDevice::write(FileDescription&, const byte*, ssize_t size)
|
|||
return 0;
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,81 +1,81 @@
|
|||
#include <Kernel/Devices/IDEDiskDevice.h>
|
||||
#include <Kernel/FileSystem/ProcFS.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/PIC.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
||||
//#define DISK_DEBUG
|
||||
|
||||
#define IRQ_FIXED_DISK 14
|
||||
|
||||
#define ATA_SR_BSY 0x80
|
||||
#define ATA_SR_DRDY 0x40
|
||||
#define ATA_SR_DF 0x20
|
||||
#define ATA_SR_DSC 0x10
|
||||
#define ATA_SR_DRQ 0x08
|
||||
#define ATA_SR_CORR 0x04
|
||||
#define ATA_SR_IDX 0x02
|
||||
#define ATA_SR_ERR 0x01
|
||||
#define ATA_SR_BSY 0x80
|
||||
#define ATA_SR_DRDY 0x40
|
||||
#define ATA_SR_DF 0x20
|
||||
#define ATA_SR_DSC 0x10
|
||||
#define ATA_SR_DRQ 0x08
|
||||
#define ATA_SR_CORR 0x04
|
||||
#define ATA_SR_IDX 0x02
|
||||
#define ATA_SR_ERR 0x01
|
||||
|
||||
#define ATA_ER_BBK 0x80
|
||||
#define ATA_ER_UNC 0x40
|
||||
#define ATA_ER_MC 0x20
|
||||
#define ATA_ER_IDNF 0x10
|
||||
#define ATA_ER_MCR 0x08
|
||||
#define ATA_ER_ABRT 0x04
|
||||
#define ATA_ER_TK0NF 0x02
|
||||
#define ATA_ER_AMNF 0x01
|
||||
#define ATA_ER_BBK 0x80
|
||||
#define ATA_ER_UNC 0x40
|
||||
#define ATA_ER_MC 0x20
|
||||
#define ATA_ER_IDNF 0x10
|
||||
#define ATA_ER_MCR 0x08
|
||||
#define ATA_ER_ABRT 0x04
|
||||
#define ATA_ER_TK0NF 0x02
|
||||
#define ATA_ER_AMNF 0x01
|
||||
|
||||
#define ATA_CMD_READ_PIO 0x20
|
||||
#define ATA_CMD_READ_PIO_EXT 0x24
|
||||
#define ATA_CMD_READ_DMA 0xC8
|
||||
#define ATA_CMD_READ_DMA_EXT 0x25
|
||||
#define ATA_CMD_WRITE_PIO 0x30
|
||||
#define ATA_CMD_WRITE_PIO_EXT 0x34
|
||||
#define ATA_CMD_WRITE_DMA 0xCA
|
||||
#define ATA_CMD_WRITE_DMA_EXT 0x35
|
||||
#define ATA_CMD_CACHE_FLUSH 0xE7
|
||||
#define ATA_CMD_CACHE_FLUSH_EXT 0xEA
|
||||
#define ATA_CMD_PACKET 0xA0
|
||||
#define ATA_CMD_IDENTIFY_PACKET 0xA1
|
||||
#define ATA_CMD_IDENTIFY 0xEC
|
||||
#define ATA_CMD_READ_PIO 0x20
|
||||
#define ATA_CMD_READ_PIO_EXT 0x24
|
||||
#define ATA_CMD_READ_DMA 0xC8
|
||||
#define ATA_CMD_READ_DMA_EXT 0x25
|
||||
#define ATA_CMD_WRITE_PIO 0x30
|
||||
#define ATA_CMD_WRITE_PIO_EXT 0x34
|
||||
#define ATA_CMD_WRITE_DMA 0xCA
|
||||
#define ATA_CMD_WRITE_DMA_EXT 0x35
|
||||
#define ATA_CMD_CACHE_FLUSH 0xE7
|
||||
#define ATA_CMD_CACHE_FLUSH_EXT 0xEA
|
||||
#define ATA_CMD_PACKET 0xA0
|
||||
#define ATA_CMD_IDENTIFY_PACKET 0xA1
|
||||
#define ATA_CMD_IDENTIFY 0xEC
|
||||
|
||||
#define ATAPI_CMD_READ 0xA8
|
||||
#define ATAPI_CMD_EJECT 0x1B
|
||||
#define ATAPI_CMD_READ 0xA8
|
||||
#define ATAPI_CMD_EJECT 0x1B
|
||||
|
||||
#define ATA_IDENT_DEVICETYPE 0
|
||||
#define ATA_IDENT_CYLINDERS 2
|
||||
#define ATA_IDENT_HEADS 6
|
||||
#define ATA_IDENT_SECTORS 12
|
||||
#define ATA_IDENT_SERIAL 20
|
||||
#define ATA_IDENT_MODEL 54
|
||||
#define ATA_IDENT_DEVICETYPE 0
|
||||
#define ATA_IDENT_CYLINDERS 2
|
||||
#define ATA_IDENT_HEADS 6
|
||||
#define ATA_IDENT_SECTORS 12
|
||||
#define ATA_IDENT_SERIAL 20
|
||||
#define ATA_IDENT_MODEL 54
|
||||
#define ATA_IDENT_CAPABILITIES 98
|
||||
#define ATA_IDENT_FIELDVALID 106
|
||||
#define ATA_IDENT_MAX_LBA 120
|
||||
#define ATA_IDENT_COMMANDSETS 164
|
||||
#define ATA_IDENT_MAX_LBA_EXT 200
|
||||
#define ATA_IDENT_FIELDVALID 106
|
||||
#define ATA_IDENT_MAX_LBA 120
|
||||
#define ATA_IDENT_COMMANDSETS 164
|
||||
#define ATA_IDENT_MAX_LBA_EXT 200
|
||||
|
||||
#define IDE_ATA 0x00
|
||||
#define IDE_ATAPI 0x01
|
||||
#define IDE_ATA 0x00
|
||||
#define IDE_ATAPI 0x01
|
||||
|
||||
#define ATA_REG_DATA 0x00
|
||||
#define ATA_REG_ERROR 0x01
|
||||
#define ATA_REG_FEATURES 0x01
|
||||
#define ATA_REG_SECCOUNT0 0x02
|
||||
#define ATA_REG_LBA0 0x03
|
||||
#define ATA_REG_LBA1 0x04
|
||||
#define ATA_REG_LBA2 0x05
|
||||
#define ATA_REG_HDDEVSEL 0x06
|
||||
#define ATA_REG_COMMAND 0x07
|
||||
#define ATA_REG_STATUS 0x07
|
||||
#define ATA_REG_SECCOUNT1 0x08
|
||||
#define ATA_REG_LBA3 0x09
|
||||
#define ATA_REG_LBA4 0x0A
|
||||
#define ATA_REG_LBA5 0x0B
|
||||
#define ATA_REG_CONTROL 0x0C
|
||||
#define ATA_REG_ALTSTATUS 0x0C
|
||||
#define ATA_REG_DATA 0x00
|
||||
#define ATA_REG_ERROR 0x01
|
||||
#define ATA_REG_FEATURES 0x01
|
||||
#define ATA_REG_SECCOUNT0 0x02
|
||||
#define ATA_REG_LBA0 0x03
|
||||
#define ATA_REG_LBA1 0x04
|
||||
#define ATA_REG_LBA2 0x05
|
||||
#define ATA_REG_HDDEVSEL 0x06
|
||||
#define ATA_REG_COMMAND 0x07
|
||||
#define ATA_REG_STATUS 0x07
|
||||
#define ATA_REG_SECCOUNT1 0x08
|
||||
#define ATA_REG_LBA3 0x09
|
||||
#define ATA_REG_LBA4 0x0A
|
||||
#define ATA_REG_LBA5 0x0B
|
||||
#define ATA_REG_CONTROL 0x0C
|
||||
#define ATA_REG_ALTSTATUS 0x0C
|
||||
#define ATA_REG_DEVADDRESS 0x0D
|
||||
|
||||
Retained<IDEDiskDevice> IDEDiskDevice::create()
|
||||
|
@ -137,14 +137,14 @@ bool IDEDiskDevice::write_block(unsigned index, const byte* data)
|
|||
static void print_ide_status(byte status)
|
||||
{
|
||||
kprintf("DRQ=%u BSY=%u DRDY=%u DSC=%u DF=%u CORR=%u IDX=%u ERR=%u\n",
|
||||
(status & ATA_SR_DRQ) != 0,
|
||||
(status & ATA_SR_BSY) != 0,
|
||||
(status & ATA_SR_DRDY) != 0,
|
||||
(status & ATA_SR_DSC) != 0,
|
||||
(status & ATA_SR_DF) != 0,
|
||||
(status & ATA_SR_CORR) != 0,
|
||||
(status & ATA_SR_IDX) != 0,
|
||||
(status & ATA_SR_ERR) != 0);
|
||||
(status & ATA_SR_DRQ) != 0,
|
||||
(status & ATA_SR_BSY) != 0,
|
||||
(status & ATA_SR_DRDY) != 0,
|
||||
(status & ATA_SR_DSC) != 0,
|
||||
(status & ATA_SR_DF) != 0,
|
||||
(status & ATA_SR_CORR) != 0,
|
||||
(status & ATA_SR_IDX) != 0,
|
||||
(status & ATA_SR_ERR) != 0);
|
||||
}
|
||||
|
||||
bool IDEDiskDevice::wait_for_irq()
|
||||
|
@ -184,7 +184,7 @@ void IDEDiskDevice::initialize()
|
|||
{
|
||||
static const PCI::ID piix3_ide_id = { 0x8086, 0x7010 };
|
||||
static const PCI::ID piix4_ide_id = { 0x8086, 0x7111 };
|
||||
PCI::enumerate_all([this] (const PCI::Address& address, PCI::ID id) {
|
||||
PCI::enumerate_all([this](const PCI::Address& address, PCI::ID id) {
|
||||
if (id == piix3_ide_id || id == piix4_ide_id) {
|
||||
m_pci_address = address;
|
||||
kprintf("PIIX%u IDE device found!\n", id == piix3_ide_id ? 3 : 4);
|
||||
|
@ -199,7 +199,8 @@ void IDEDiskDevice::initialize()
|
|||
|
||||
m_interrupted = false;
|
||||
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY);
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY)
|
||||
;
|
||||
|
||||
enable_irq();
|
||||
|
||||
|
@ -236,8 +237,7 @@ void IDEDiskDevice::initialize()
|
|||
bbuf.pointer() + 54,
|
||||
m_cylinders,
|
||||
m_heads,
|
||||
m_sectors_per_track
|
||||
);
|
||||
m_sectors_per_track);
|
||||
|
||||
// Let's try to set up DMA transfers.
|
||||
if (!m_pci_address.is_null()) {
|
||||
|
@ -260,8 +260,8 @@ bool IDEDiskDevice::read_sectors_with_dma(dword lba, word count, byte* outbuf)
|
|||
LOCKER(m_lock);
|
||||
#ifdef DISK_DEBUG
|
||||
dbgprintf("%s(%u): IDEDiskDevice::read_sectors_with_dma (%u x%u) -> %p\n",
|
||||
current->process().name().characters(),
|
||||
current->pid(), lba, count, outbuf);
|
||||
current->process().name().characters(),
|
||||
current->pid(), lba, count, outbuf);
|
||||
#endif
|
||||
|
||||
disable_irq();
|
||||
|
@ -286,7 +286,8 @@ bool IDEDiskDevice::read_sectors_with_dma(dword lba, word count, byte* outbuf)
|
|||
m_interrupted = false;
|
||||
enable_irq();
|
||||
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY);
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY)
|
||||
;
|
||||
|
||||
bool is_slave = false;
|
||||
|
||||
|
@ -337,13 +338,14 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
|
|||
LOCKER(m_lock);
|
||||
#ifdef DISK_DEBUG
|
||||
dbgprintf("%s: Disk::read_sectors request (%u sector(s) @ %u)\n",
|
||||
current->process().name().characters(),
|
||||
count,
|
||||
start_sector);
|
||||
current->process().name().characters(),
|
||||
count,
|
||||
start_sector);
|
||||
#endif
|
||||
disable_irq();
|
||||
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY);
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY)
|
||||
;
|
||||
|
||||
#ifdef DISK_DEBUG
|
||||
kprintf("IDEDiskDevice: Reading %u sector(s) @ LBA %u\n", count, start_sector);
|
||||
|
@ -356,7 +358,8 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
|
|||
IO::out8(m_io_base + ATA_REG_HDDEVSEL, 0xe0 | ((start_sector >> 24) & 0xf)); // 0xf0 for 2nd device
|
||||
|
||||
IO::out8(0x3F6, 0x08);
|
||||
while (!(IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_DRDY));
|
||||
while (!(IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_DRDY))
|
||||
;
|
||||
|
||||
IO::out8(m_io_base + ATA_REG_COMMAND, ATA_CMD_READ_PIO);
|
||||
m_interrupted = false;
|
||||
|
@ -381,8 +384,8 @@ bool IDEDiskDevice::write_sectors_with_dma(dword lba, word count, const byte* in
|
|||
LOCKER(m_lock);
|
||||
#ifdef DISK_DEBUG
|
||||
dbgprintf("%s(%u): IDEDiskDevice::write_sectors_with_dma (%u x%u) <- %p\n",
|
||||
current->process().name().characters(),
|
||||
current->pid(), lba, count, inbuf);
|
||||
current->process().name().characters(),
|
||||
current->pid(), lba, count, inbuf);
|
||||
#endif
|
||||
|
||||
disable_irq();
|
||||
|
@ -406,7 +409,8 @@ bool IDEDiskDevice::write_sectors_with_dma(dword lba, word count, const byte* in
|
|||
m_interrupted = false;
|
||||
enable_irq();
|
||||
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY);
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY)
|
||||
;
|
||||
|
||||
bool is_slave = false;
|
||||
|
||||
|
@ -455,14 +459,15 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
|
|||
LOCKER(m_lock);
|
||||
#ifdef DISK_DEBUG
|
||||
dbgprintf("%s(%u): IDEDiskDevice::write_sectors request (%u sector(s) @ %u)\n",
|
||||
current->process().name().characters(),
|
||||
current->pid(),
|
||||
count,
|
||||
start_sector);
|
||||
current->process().name().characters(),
|
||||
current->pid(),
|
||||
count,
|
||||
start_sector);
|
||||
#endif
|
||||
disable_irq();
|
||||
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY);
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY)
|
||||
;
|
||||
|
||||
//dbgprintf("IDEDiskDevice: Writing %u sector(s) @ LBA %u\n", count, start_sector);
|
||||
|
||||
|
@ -476,7 +481,8 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
|
|||
|
||||
IO::out8(m_io_base + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
|
||||
|
||||
while (!(IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_DRQ));
|
||||
while (!(IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_DRQ))
|
||||
;
|
||||
|
||||
byte status = IO::in8(m_io_base + ATA_REG_STATUS);
|
||||
ASSERT(status & ATA_SR_DRQ);
|
||||
|
@ -488,7 +494,8 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
|
|||
|
||||
disable_irq();
|
||||
IO::out8(m_io_base + ATA_REG_COMMAND, ATA_CMD_CACHE_FLUSH);
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY);
|
||||
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY)
|
||||
;
|
||||
m_interrupted = false;
|
||||
enable_irq();
|
||||
wait_for_irq();
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
#include <AK/Types.h>
|
||||
#include "i386.h"
|
||||
#include "IO.h"
|
||||
#include "PIC.h"
|
||||
#include "i386.h"
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Devices/KeyboardDevice.h>
|
||||
#include <Kernel/TTY/VirtualConsole.h>
|
||||
#include <AK/Assertions.h>
|
||||
|
||||
//#define KEYBOARD_DEBUG
|
||||
|
||||
#define IRQ_KEYBOARD 1
|
||||
#define I8042_BUFFER 0x60
|
||||
#define I8042_STATUS 0x64
|
||||
#define I8042_ACK 0xFA
|
||||
#define I8042_BUFFER_FULL 0x01
|
||||
#define I8042_WHICH_BUFFER 0x20
|
||||
#define I8042_MOUSE_BUFFER 0x20
|
||||
#define I8042_KEYBOARD_BUFFER 0x00
|
||||
#define IRQ_KEYBOARD 1
|
||||
#define I8042_BUFFER 0x60
|
||||
#define I8042_STATUS 0x64
|
||||
#define I8042_ACK 0xFA
|
||||
#define I8042_BUFFER_FULL 0x01
|
||||
#define I8042_WHICH_BUFFER 0x20
|
||||
#define I8042_MOUSE_BUFFER 0x20
|
||||
#define I8042_KEYBOARD_BUFFER 0x00
|
||||
|
||||
static char map[0x80] =
|
||||
{
|
||||
static char map[0x80] = {
|
||||
0, '\033', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08, '\t',
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0,
|
||||
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\',
|
||||
|
@ -26,8 +25,7 @@ static char map[0x80] =
|
|||
0, 0, 0, ' '
|
||||
};
|
||||
|
||||
static char shift_map[0x80] =
|
||||
{
|
||||
static char shift_map[0x80] = {
|
||||
0, '\033', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0x08, '\t',
|
||||
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 0,
|
||||
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|',
|
||||
|
@ -35,24 +33,76 @@ static char shift_map[0x80] =
|
|||
0, 0, 0, ' '
|
||||
};
|
||||
|
||||
static KeyCode unshifted_key_map[0x80] =
|
||||
{
|
||||
Key_Invalid, Key_Escape,
|
||||
Key_1, Key_2, Key_3, Key_4, Key_5, Key_6, Key_7, Key_8, Key_9, Key_0, Key_Minus, Key_Equal, Key_Backspace,
|
||||
static KeyCode unshifted_key_map[0x80] = {
|
||||
Key_Invalid,
|
||||
Key_Escape,
|
||||
Key_1,
|
||||
Key_2,
|
||||
Key_3,
|
||||
Key_4,
|
||||
Key_5,
|
||||
Key_6,
|
||||
Key_7,
|
||||
Key_8,
|
||||
Key_9,
|
||||
Key_0,
|
||||
Key_Minus,
|
||||
Key_Equal,
|
||||
Key_Backspace,
|
||||
Key_Tab, //15
|
||||
Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_LeftBracket, Key_RightBracket,
|
||||
Key_Return, // 28
|
||||
Key_Q,
|
||||
Key_W,
|
||||
Key_E,
|
||||
Key_R,
|
||||
Key_T,
|
||||
Key_Y,
|
||||
Key_U,
|
||||
Key_I,
|
||||
Key_O,
|
||||
Key_P,
|
||||
Key_LeftBracket,
|
||||
Key_RightBracket,
|
||||
Key_Return, // 28
|
||||
Key_Control, // 29
|
||||
Key_A, Key_S, Key_D, Key_F, Key_G, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Apostrophe, Key_Backtick,
|
||||
Key_A,
|
||||
Key_S,
|
||||
Key_D,
|
||||
Key_F,
|
||||
Key_G,
|
||||
Key_H,
|
||||
Key_J,
|
||||
Key_K,
|
||||
Key_L,
|
||||
Key_Semicolon,
|
||||
Key_Apostrophe,
|
||||
Key_Backtick,
|
||||
Key_LeftShift, // 42
|
||||
Key_Backslash,
|
||||
Key_Z, Key_X, Key_C, Key_V, Key_B, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash,
|
||||
Key_Z,
|
||||
Key_X,
|
||||
Key_C,
|
||||
Key_V,
|
||||
Key_B,
|
||||
Key_N,
|
||||
Key_M,
|
||||
Key_Comma,
|
||||
Key_Period,
|
||||
Key_Slash,
|
||||
Key_RightShift, // 54
|
||||
Key_Invalid,
|
||||
Key_Alt, // 56
|
||||
Key_Space, // 57
|
||||
Key_Alt, // 56
|
||||
Key_Space, // 57
|
||||
Key_Invalid, // 58
|
||||
Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10,
|
||||
Key_F1,
|
||||
Key_F2,
|
||||
Key_F3,
|
||||
Key_F4,
|
||||
Key_F5,
|
||||
Key_F6,
|
||||
Key_F7,
|
||||
Key_F8,
|
||||
Key_F9,
|
||||
Key_F10,
|
||||
Key_Invalid,
|
||||
Key_Invalid, // 70
|
||||
Key_Home,
|
||||
|
@ -78,24 +128,76 @@ static KeyCode unshifted_key_map[0x80] =
|
|||
Key_Logo,
|
||||
};
|
||||
|
||||
static KeyCode shifted_key_map[0x100] =
|
||||
{
|
||||
Key_Invalid, Key_Escape,
|
||||
Key_ExclamationPoint, Key_AtSign, Key_Hashtag, Key_Dollar, Key_Percent, Key_Circumflex, Key_Ampersand, Key_Asterisk, Key_LeftParen, Key_RightParen, Key_Underscore, Key_Plus, Key_Backspace,
|
||||
static KeyCode shifted_key_map[0x100] = {
|
||||
Key_Invalid,
|
||||
Key_Escape,
|
||||
Key_ExclamationPoint,
|
||||
Key_AtSign,
|
||||
Key_Hashtag,
|
||||
Key_Dollar,
|
||||
Key_Percent,
|
||||
Key_Circumflex,
|
||||
Key_Ampersand,
|
||||
Key_Asterisk,
|
||||
Key_LeftParen,
|
||||
Key_RightParen,
|
||||
Key_Underscore,
|
||||
Key_Plus,
|
||||
Key_Backspace,
|
||||
Key_Tab,
|
||||
Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_LeftBrace, Key_RightBrace,
|
||||
Key_Q,
|
||||
Key_W,
|
||||
Key_E,
|
||||
Key_R,
|
||||
Key_T,
|
||||
Key_Y,
|
||||
Key_U,
|
||||
Key_I,
|
||||
Key_O,
|
||||
Key_P,
|
||||
Key_LeftBrace,
|
||||
Key_RightBrace,
|
||||
Key_Return,
|
||||
Key_Control,
|
||||
Key_A, Key_S, Key_D, Key_F, Key_G, Key_H, Key_J, Key_K, Key_L, Key_Colon, Key_DoubleQuote, Key_Tilde,
|
||||
Key_A,
|
||||
Key_S,
|
||||
Key_D,
|
||||
Key_F,
|
||||
Key_G,
|
||||
Key_H,
|
||||
Key_J,
|
||||
Key_K,
|
||||
Key_L,
|
||||
Key_Colon,
|
||||
Key_DoubleQuote,
|
||||
Key_Tilde,
|
||||
Key_LeftShift, // 42
|
||||
Key_Pipe,
|
||||
Key_Z, Key_X, Key_C, Key_V, Key_B, Key_N, Key_M, Key_LessThan, Key_GreaterThan, Key_QuestionMark,
|
||||
Key_Z,
|
||||
Key_X,
|
||||
Key_C,
|
||||
Key_V,
|
||||
Key_B,
|
||||
Key_N,
|
||||
Key_M,
|
||||
Key_LessThan,
|
||||
Key_GreaterThan,
|
||||
Key_QuestionMark,
|
||||
Key_RightShift, // 54
|
||||
Key_Invalid,
|
||||
Key_Alt,
|
||||
Key_Space, // 57
|
||||
Key_Space, // 57
|
||||
Key_Invalid, // 58
|
||||
Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10,
|
||||
Key_F1,
|
||||
Key_F2,
|
||||
Key_F3,
|
||||
Key_F4,
|
||||
Key_F5,
|
||||
Key_F6,
|
||||
Key_F7,
|
||||
Key_F8,
|
||||
Key_F9,
|
||||
Key_F10,
|
||||
Key_Invalid,
|
||||
Key_Invalid, // 70
|
||||
Key_Home,
|
||||
|
@ -163,7 +265,8 @@ void KeyboardDevice::handle_irq()
|
|||
break;
|
||||
}
|
||||
switch (ch) {
|
||||
case I8042_ACK: break;
|
||||
case I8042_ACK:
|
||||
break;
|
||||
default:
|
||||
if (m_modifiers & Mod_Alt) {
|
||||
switch (map[ch]) {
|
||||
|
|
|
@ -34,4 +34,3 @@ ssize_t NullDevice::write(FileDescription&, const byte*, ssize_t buffer_size)
|
|||
{
|
||||
return min(PAGE_SIZE, buffer_size);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <Kernel/Devices/PCSpeaker.h>
|
||||
#include <Kernel/i8253.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/i386.h>
|
||||
#include <Kernel/i8253.h>
|
||||
|
||||
void PCSpeaker::tone_on(int frequency)
|
||||
{
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#include "PS2MouseDevice.h"
|
||||
#include "IO.h"
|
||||
|
||||
#define IRQ_MOUSE 1
|
||||
#define I8042_BUFFER 0x60
|
||||
#define I8042_STATUS 0x64
|
||||
#define I8042_ACK 0xFA
|
||||
#define I8042_BUFFER_FULL 0x01
|
||||
#define I8042_WHICH_BUFFER 0x20
|
||||
#define I8042_MOUSE_BUFFER 0x20
|
||||
#define I8042_KEYBOARD_BUFFER 0x00
|
||||
#define IRQ_MOUSE 1
|
||||
#define I8042_BUFFER 0x60
|
||||
#define I8042_STATUS 0x64
|
||||
#define I8042_ACK 0xFA
|
||||
#define I8042_BUFFER_FULL 0x01
|
||||
#define I8042_WHICH_BUFFER 0x20
|
||||
#define I8042_MOUSE_BUFFER 0x20
|
||||
#define I8042_KEYBOARD_BUFFER 0x00
|
||||
|
||||
#define PS2MOUSE_GET_DEVICE_ID 0xF2
|
||||
#define PS2MOUSE_GET_DEVICE_ID 0xF2
|
||||
#define PS2MOUSE_SET_SAMPLE_RATE 0xF3
|
||||
|
||||
#define PS2MOUSE_INTELLIMOUSE_ID 0x03
|
||||
|
@ -54,8 +54,7 @@ void PS2MouseDevice::handle_irq()
|
|||
m_data[2],
|
||||
(m_data[0] & 1) ? "Left" : "",
|
||||
(m_data[0] & 2) ? "Right" : "",
|
||||
m_queue.size()
|
||||
);
|
||||
m_queue.size());
|
||||
#endif
|
||||
parse_data_packet();
|
||||
};
|
||||
|
|
|
@ -47,4 +47,3 @@ ssize_t RandomDevice::write(FileDescription&, const byte*, ssize_t size)
|
|||
// FIXME: Use input for entropy? I guess that could be a neat feature?
|
||||
return min(PAGE_SIZE, size);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,4 +27,3 @@ ssize_t ZeroDevice::write(FileDescription&, const byte*, ssize_t size)
|
|||
{
|
||||
return min(PAGE_SIZE, size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue