summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-03 21:17:35 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-03 21:20:13 +0200
commit27f699ef0c8c2dce0f1dff19eef25f02e3da397e (patch)
tree52f95be1d05ba2a621d3bb8ac9129341f8d9973b
parentc4c4bbc5ba5119e9ccc8ded948b26e7c4851a909 (diff)
downloadserenity-27f699ef0c8c2dce0f1dff19eef25f02e3da397e.zip
AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
-rw-r--r--AK/Bitmap.h18
-rw-r--r--AK/BufferStream.h18
-rw-r--r--AK/ByteBuffer.h40
-rw-r--r--AK/ELF/ELFImage.cpp2
-rw-r--r--AK/ELF/ELFImage.h20
-rw-r--r--AK/ELF/ELFLoader.cpp4
-rw-r--r--AK/ELF/ELFLoader.h6
-rw-r--r--AK/HashFunctions.h4
-rw-r--r--AK/IPv4Address.h18
-rw-r--r--AK/JsonValue.h8
-rw-r--r--AK/PrintfImplementation.h40
-rw-r--r--AK/StdLibExtras.cpp10
-rw-r--r--AK/StdLibExtras.h6
-rw-r--r--AK/String.cpp2
-rw-r--r--AK/StringImpl.h6
-rw-r--r--AK/Traits.h6
-rw-r--r--AK/Types.h44
-rw-r--r--AK/Vector.h2
-rw-r--r--Applications/FontEditor/FontEditor.cpp4
-rw-r--r--Applications/FontEditor/GlyphEditorWidget.cpp2
-rw-r--r--Applications/FontEditor/GlyphEditorWidget.h8
-rw-r--r--Applications/FontEditor/GlyphMapWidget.cpp8
-rw-r--r--Applications/FontEditor/GlyphMapWidget.h12
-rw-r--r--Applications/ProcessManager/MemoryStatsWidget.cpp18
-rw-r--r--Applications/ProcessManager/ProcessModel.cpp14
-rw-r--r--Applications/Terminal/Terminal.cpp44
-rw-r--r--Applications/Terminal/Terminal.h60
-rw-r--r--Demos/Fire/Fire.cpp2
-rw-r--r--Kernel/Arch/i386/CPU.cpp62
-rw-r--r--Kernel/Arch/i386/CPU.h236
-rw-r--r--Kernel/CMOS.cpp4
-rw-r--r--Kernel/CMOS.h4
-rw-r--r--Kernel/Console.cpp4
-rw-r--r--Kernel/Console.h6
-rw-r--r--Kernel/Devices/BXVGADevice.cpp20
-rw-r--r--Kernel/Devices/BXVGADevice.h10
-rw-r--r--Kernel/Devices/DebugLogDevice.cpp2
-rw-r--r--Kernel/Devices/DebugLogDevice.h4
-rw-r--r--Kernel/Devices/DiskDevice.cpp12
-rw-r--r--Kernel/Devices/DiskDevice.h14
-rw-r--r--Kernel/Devices/DiskPartition.cpp8
-rw-r--r--Kernel/Devices/DiskPartition.h8
-rw-r--r--Kernel/Devices/FileBackedDiskDevice.cpp12
-rw-r--r--Kernel/Devices/FileBackedDiskDevice.h8
-rw-r--r--Kernel/Devices/FullDevice.cpp4
-rw-r--r--Kernel/Devices/FullDevice.h4
-rw-r--r--Kernel/Devices/IDEDiskDevice.cpp44
-rw-r--r--Kernel/Devices/IDEDiskDevice.h32
-rw-r--r--Kernel/Devices/KeyboardDevice.cpp12
-rw-r--r--Kernel/Devices/KeyboardDevice.h10
-rw-r--r--Kernel/Devices/MBRPartitionTable.h28
-rw-r--r--Kernel/Devices/NullDevice.cpp4
-rw-r--r--Kernel/Devices/NullDevice.h4
-rw-r--r--Kernel/Devices/PCSpeaker.cpp2
-rw-r--r--Kernel/Devices/PS2MouseDevice.cpp22
-rw-r--r--Kernel/Devices/PS2MouseDevice.h16
-rw-r--r--Kernel/Devices/RandomDevice.cpp12
-rw-r--r--Kernel/Devices/RandomDevice.h6
-rw-r--r--Kernel/Devices/SerialDevice.cpp4
-rw-r--r--Kernel/Devices/SerialDevice.h4
-rw-r--r--Kernel/Devices/ZeroDevice.cpp4
-rw-r--r--Kernel/Devices/ZeroDevice.h4
-rw-r--r--Kernel/DoubleBuffer.cpp4
-rw-r--r--Kernel/DoubleBuffer.h12
-rw-r--r--Kernel/File.h4
-rw-r--r--Kernel/FileSystem/DiskBackedFileSystem.cpp2
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp42
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.h6
-rw-r--r--Kernel/FileSystem/FIFO.cpp6
-rw-r--r--Kernel/FileSystem/FIFO.h8
-rw-r--r--Kernel/FileSystem/FileDescription.cpp14
-rw-r--r--Kernel/FileSystem/FileDescription.h12
-rw-r--r--Kernel/FileSystem/FileSystem.cpp14
-rw-r--r--Kernel/FileSystem/FileSystem.h10
-rw-r--r--Kernel/FileSystem/Inode.cpp4
-rw-r--r--Kernel/FileSystem/Inode.h6
-rw-r--r--Kernel/FileSystem/InodeFile.cpp4
-rw-r--r--Kernel/FileSystem/InodeFile.h4
-rw-r--r--Kernel/FileSystem/InodeIdentifier.h10
-rw-r--r--Kernel/FileSystem/InodeMetadata.h2
-rw-r--r--Kernel/FileSystem/ProcFS.cpp44
-rw-r--r--Kernel/FileSystem/ProcFS.h4
-rw-r--r--Kernel/FileSystem/SyntheticFileSystem.cpp6
-rw-r--r--Kernel/FileSystem/SyntheticFileSystem.h4
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp2
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.h2
-rw-r--r--Kernel/IO.h22
-rw-r--r--Kernel/IRQHandler.cpp2
-rw-r--r--Kernel/IRQHandler.h6
-rw-r--r--Kernel/KSyms.cpp28
-rw-r--r--Kernel/KSyms.h8
-rw-r--r--Kernel/KeyCode.h6
-rw-r--r--Kernel/Lock.h8
-rw-r--r--Kernel/MousePacket.h2
-rw-r--r--Kernel/Multiboot.h94
-rw-r--r--Kernel/Net/ARP.h34
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp68
-rw-r--r--Kernel/Net/E1000NetworkAdapter.h26
-rw-r--r--Kernel/Net/EtherType.h2
-rw-r--r--Kernel/Net/EthernetFrameHeader.h8
-rw-r--r--Kernel/Net/ICMP.h22
-rw-r--r--Kernel/Net/IPv4.h58
-rw-r--r--Kernel/Net/IPv4Socket.cpp14
-rw-r--r--Kernel/Net/IPv4Socket.h22
-rw-r--r--Kernel/Net/LocalSocket.cpp8
-rw-r--r--Kernel/Net/LocalSocket.h4
-rw-r--r--Kernel/Net/LoopbackAdapter.cpp2
-rw-r--r--Kernel/Net/LoopbackAdapter.h2
-rw-r--r--Kernel/Net/MACAddress.h6
-rw-r--r--Kernel/Net/NetworkAdapter.cpp8
-rw-r--r--Kernel/Net/NetworkAdapter.h4
-rw-r--r--Kernel/Net/NetworkTask.cpp4
-rw-r--r--Kernel/Net/Socket.h2
-rw-r--r--Kernel/Net/TCP.h62
-rw-r--r--Kernel/Net/TCPSocket.cpp48
-rw-r--r--Kernel/Net/TCPSocket.h20
-rw-r--r--Kernel/Net/UDP.h24
-rw-r--r--Kernel/Net/UDPSocket.cpp18
-rw-r--r--Kernel/Net/UDPSocket.h4
-rw-r--r--Kernel/PCI.cpp66
-rw-r--r--Kernel/PCI.h34
-rw-r--r--Kernel/PIC.cpp22
-rw-r--r--Kernel/PIC.h14
-rw-r--r--Kernel/PhysicalAddress.h20
-rw-r--r--Kernel/Process.cpp78
-rw-r--r--Kernel/Process.h36
-rw-r--r--Kernel/ProcessTracer.cpp4
-rw-r--r--Kernel/ProcessTracer.h16
-rw-r--r--Kernel/RTC.cpp2
-rw-r--r--Kernel/Scheduler.cpp8
-rw-r--r--Kernel/Scheduler.h2
-rw-r--r--Kernel/SharedMemory.cpp4
-rw-r--r--Kernel/SharedMemory.h4
-rw-r--r--Kernel/StdLib.cpp12
-rw-r--r--Kernel/StdLib.h4
-rw-r--r--Kernel/Syscall.cpp24
-rw-r--r--Kernel/Syscall.h22
-rw-r--r--Kernel/TTY/MasterPTY.cpp6
-rw-r--r--Kernel/TTY/MasterPTY.h6
-rw-r--r--Kernel/TTY/PTYMultiplexer.h4
-rw-r--r--Kernel/TTY/SlavePTY.cpp6
-rw-r--r--Kernel/TTY/SlavePTY.h6
-rw-r--r--Kernel/TTY/TTY.cpp6
-rw-r--r--Kernel/TTY/TTY.h8
-rw-r--r--Kernel/TTY/VirtualConsole.cpp62
-rw-r--r--Kernel/TTY/VirtualConsole.h40
-rw-r--r--Kernel/Thread.cpp48
-rw-r--r--Kernel/Thread.h52
-rw-r--r--Kernel/UnixTypes.h44
-rw-r--r--Kernel/VM/MemoryManager.cpp46
-rw-r--r--Kernel/VM/MemoryManager.h4
-rw-r--r--Kernel/VM/PageDirectory.cpp4
-rw-r--r--Kernel/VM/PageDirectory.h2
-rw-r--r--Kernel/VM/PhysicalPage.h4
-rw-r--r--Kernel/VM/Region.cpp6
-rw-r--r--Kernel/VM/Region.h8
-rw-r--r--Kernel/VM/VMObject.cpp4
-rw-r--r--Kernel/VM/VMObject.h2
-rw-r--r--Kernel/VirtualAddress.h18
-rw-r--r--Kernel/i8253.cpp10
-rw-r--r--Kernel/i8253.h4
-rw-r--r--Kernel/init.cpp2
-rw-r--r--Kernel/kmalloc.cpp18
-rw-r--r--Kernel/kmalloc.h4
-rw-r--r--LibC/dirent.cpp4
-rw-r--r--LibC/fcntl.cpp2
-rw-r--r--LibC/mman.cpp4
-rw-r--r--LibC/netdb.cpp2
-rw-r--r--LibC/stdio.cpp4
-rw-r--r--LibC/string.cpp24
-rw-r--r--LibC/utime.cpp2
-rw-r--r--LibCore/CHttpJob.cpp2
-rw-r--r--LibCore/CIODevice.cpp14
-rw-r--r--LibCore/CIODevice.h8
-rw-r--r--LibCore/CLock.h8
-rw-r--r--LibCore/CProcessStatisticsReader.cpp12
-rw-r--r--LibCore/CSocket.cpp2
-rw-r--r--LibGUI/GClipboard.cpp2
-rw-r--r--LibGUI/GEvent.h8
-rw-r--r--LibGUI/GEventLoop.cpp2
-rw-r--r--LibGUI/GShortcut.h6
-rw-r--r--Servers/LookupServer/DNSPacket.h42
-rw-r--r--Servers/LookupServer/DNSRecord.h20
-rw-r--r--Servers/LookupServer/main.cpp40
-rw-r--r--Servers/WindowServer/WSAPITypes.h6
-rw-r--r--Servers/WindowServer/WSCPUMonitor.cpp4
-rw-r--r--Servers/WindowServer/WSClientConnection.cpp2
-rw-r--r--Servers/WindowServer/WSClipboard.cpp4
-rw-r--r--Servers/WindowServer/WSClipboard.h2
-rw-r--r--Servers/WindowServer/WSCompositor.cpp6
-rw-r--r--Servers/WindowServer/WSEvent.h8
-rw-r--r--Servers/WindowServer/WSEventLoop.cpp2
-rw-r--r--Servers/WindowServer/WSScreen.h2
-rw-r--r--Servers/WindowServer/WSWindowManager.cpp2
-rw-r--r--Servers/WindowServer/WSWindowManager.h2
-rw-r--r--SharedGraphics/Color.cpp6
-rw-r--r--SharedGraphics/Color.h34
-rw-r--r--SharedGraphics/Font.cpp28
-rw-r--r--SharedGraphics/Font.h30
-rw-r--r--SharedGraphics/GraphicsBitmap.cpp2
-rw-r--r--SharedGraphics/GraphicsBitmap.h20
-rw-r--r--SharedGraphics/PNGLoader.cpp80
-rw-r--r--SharedGraphics/Painter.cpp18
-rw-r--r--SharedGraphics/Painter.h2
-rw-r--r--Userland/crash.cpp8
-rw-r--r--Userland/df.cpp8
-rw-r--r--Userland/strace.cpp2
-rw-r--r--Userland/top.cpp18
208 files changed, 1605 insertions, 1623 deletions
diff --git a/AK/Bitmap.h b/AK/Bitmap.h
index 50021cde93..667de7bd13 100644
--- a/AK/Bitmap.h
+++ b/AK/Bitmap.h
@@ -10,7 +10,7 @@ namespace AK {
class Bitmap {
public:
// NOTE: A wrapping Bitmap won't try to free the wrapped data.
- static Bitmap wrap(byte* data, int size)
+ static Bitmap wrap(u8* data, int size)
{
return Bitmap(data, size);
}
@@ -42,13 +42,13 @@ public:
{
ASSERT(index < m_size);
if (value)
- m_data[index / 8] |= static_cast<byte>((1u << (index % 8)));
+ m_data[index / 8] |= static_cast<u8>((1u << (index % 8)));
else
- m_data[index / 8] &= static_cast<byte>(~(1u << (index % 8)));
+ m_data[index / 8] &= static_cast<u8>(~(1u << (index % 8)));
}
- byte* data() { return m_data; }
- const byte* data() const { return m_data; }
+ u8* data() { return m_data; }
+ const u8* data() const { return m_data; }
void grow(int size, bool default_value)
{
@@ -59,7 +59,7 @@ public:
auto previous_data = m_data;
m_size = size;
- m_data = reinterpret_cast<byte*>(kmalloc(size_in_bytes()));
+ m_data = reinterpret_cast<u8*>(kmalloc(size_in_bytes()));
fill(default_value);
@@ -123,11 +123,11 @@ private:
, m_owned(true)
{
ASSERT(m_size != 0);
- m_data = reinterpret_cast<byte*>(kmalloc(size_in_bytes()));
+ m_data = reinterpret_cast<u8*>(kmalloc(size_in_bytes()));
fill(default_value);
}
- Bitmap(byte* data, int size)
+ Bitmap(u8* data, int size)
: m_data(data)
, m_size(size)
, m_owned(false)
@@ -136,7 +136,7 @@ private:
int size_in_bytes() const { return ceil_div(m_size, 8); }
- byte* m_data { nullptr };
+ u8* m_data { nullptr };
int m_size { 0 };
bool m_owned { false };
};
diff --git a/AK/BufferStream.h b/AK/BufferStream.h
index 7edc9f6e65..0b8ad76f15 100644
--- a/AK/BufferStream.h
+++ b/AK/BufferStream.h
@@ -12,28 +12,28 @@ public:
{
}
- void operator<<(byte value)
+ void operator<<(u8 value)
{
m_buffer[m_offset++] = value & 0xffu;
}
void operator<<(char value)
{
- m_buffer[m_offset++] = (byte)value;
+ m_buffer[m_offset++] = (u8)value;
}
- void operator<<(word value)
+ void operator<<(u16 value)
{
m_buffer[m_offset++] = value & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 8) & 0xffu;
+ m_buffer[m_offset++] = (u8)(value >> 8) & 0xffu;
}
- void operator<<(dword value)
+ void operator<<(u32 value)
{
m_buffer[m_offset++] = value & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 8) & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 16) & 0xffu;
- m_buffer[m_offset++] = (byte)(value >> 24) & 0xffu;
+ m_buffer[m_offset++] = (u8)(value >> 8) & 0xffu;
+ m_buffer[m_offset++] = (u8)(value >> 16) & 0xffu;
+ m_buffer[m_offset++] = (u8)(value >> 24) & 0xffu;
}
void operator<<(const StringView& value)
@@ -53,7 +53,7 @@ public:
return m_offset == m_buffer.size();
}
- void fill_to_end(byte ch)
+ void fill_to_end(u8 ch)
{
while (!at_end())
m_buffer[m_offset++] = ch;
diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h
index f62a4c04d6..3946a19440 100644
--- a/AK/ByteBuffer.h
+++ b/AK/ByteBuffer.h
@@ -28,12 +28,12 @@ public:
m_data = nullptr;
}
- byte& operator[](int i)
+ u8& operator[](int i)
{
ASSERT(i < m_size);
return m_data[i];
}
- const byte& operator[](int i) const
+ const u8& operator[](int i) const
{
ASSERT(i < m_size);
return m_data[i];
@@ -41,11 +41,11 @@ public:
bool is_empty() const { return !m_size; }
int size() const { return m_size; }
- byte* pointer() { return m_data; }
- const byte* pointer() const { return m_data; }
+ u8* pointer() { return m_data; }
+ const u8* pointer() const { return m_data; }
- byte* offset_pointer(int offset) { return m_data + offset; }
- const byte* offset_pointer(int offset) const { return m_data + offset; }
+ u8* offset_pointer(int offset) { return m_data + offset; }
+ const u8* offset_pointer(int offset) const { return m_data + offset; }
void* end_pointer() { return m_data + m_size; }
const void* end_pointer() const { return m_data + m_size; }
@@ -71,7 +71,7 @@ private:
ByteBufferImpl(void*, int, ConstructionMode); // For ConstructionMode=Wrap/Adopt
ByteBufferImpl() {}
- byte* m_data { nullptr };
+ u8* m_data { nullptr };
int m_size { 0 };
bool m_owned { false };
};
@@ -114,12 +114,12 @@ public:
bool operator!() const { return is_null(); }
bool is_null() const { return m_impl == nullptr; }
- byte& operator[](int i)
+ u8& operator[](int i)
{
ASSERT(m_impl);
return (*m_impl)[i];
}
- byte operator[](int i) const
+ u8 operator[](int i) const
{
ASSERT(m_impl);
return (*m_impl)[i];
@@ -127,14 +127,14 @@ public:
bool is_empty() const { return !m_impl || m_impl->is_empty(); }
int size() const { return m_impl ? m_impl->size() : 0; }
- byte* data() { return pointer(); }
- const byte* data() const { return pointer(); }
+ u8* data() { return pointer(); }
+ const u8* data() const { return pointer(); }
- byte* pointer() { return m_impl ? m_impl->pointer() : nullptr; }
- const byte* pointer() const { return m_impl ? m_impl->pointer() : nullptr; }
+ u8* pointer() { return m_impl ? m_impl->pointer() : nullptr; }
+ const u8* pointer() const { return m_impl ? m_impl->pointer() : nullptr; }
- byte* offset_pointer(int offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
- const byte* offset_pointer(int offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
+ u8* offset_pointer(int offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
+ const u8* offset_pointer(int offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; }
void* end_pointer() { return m_impl ? m_impl->end_pointer() : nullptr; }
const void* end_pointer() const { return m_impl ? m_impl->end_pointer() : nullptr; }
@@ -191,7 +191,7 @@ private:
inline ByteBufferImpl::ByteBufferImpl(int size)
: m_size(size)
{
- m_data = static_cast<byte*>(kmalloc(size));
+ m_data = static_cast<u8*>(kmalloc(size));
m_owned = true;
}
@@ -199,13 +199,13 @@ inline ByteBufferImpl::ByteBufferImpl(const void* data, int size, ConstructionMo
: m_size(size)
{
ASSERT(mode == Copy);
- m_data = static_cast<byte*>(kmalloc(size));
+ m_data = static_cast<u8*>(kmalloc(size));
memcpy(m_data, data, size);
m_owned = true;
}
inline ByteBufferImpl::ByteBufferImpl(void* data, int size, ConstructionMode mode)
- : m_data(static_cast<byte*>(data))
+ : m_data(static_cast<u8*>(data))
, m_size(size)
{
if (mode == Adopt) {
@@ -219,9 +219,9 @@ inline void ByteBufferImpl::grow(int size)
{
ASSERT(size > m_size);
ASSERT(m_owned);
- byte* new_data = static_cast<byte*>(kmalloc(size));
+ u8* new_data = static_cast<u8*>(kmalloc(size));
memcpy(new_data, m_data, m_size);
- byte* old_data = m_data;
+ u8* old_data = m_data;
m_data = new_data;
m_size = size;
kfree(old_data);
diff --git a/AK/ELF/ELFImage.cpp b/AK/ELF/ELFImage.cpp
index 02a1dba42c..5228bf53f8 100644
--- a/AK/ELF/ELFImage.cpp
+++ b/AK/ELF/ELFImage.cpp
@@ -1,7 +1,7 @@
#include "ELFImage.h"
#include <AK/kstdio.h>
-ELFImage::ELFImage(const byte* buffer)
+ELFImage::ELFImage(const u8* buffer)
: m_buffer(buffer)
{
m_valid = parse();
diff --git a/AK/ELF/ELFImage.h b/AK/ELF/ELFImage.h
index 6f0eee52ec..19238d191d 100644
--- a/AK/ELF/ELFImage.h
+++ b/AK/ELF/ELFImage.h
@@ -7,7 +7,7 @@
class ELFImage {
public:
- explicit ELFImage(const byte*);
+ explicit ELFImage(const u8*);
~ELFImage();
void dump();
bool is_valid() const { return m_valid; }
@@ -54,13 +54,13 @@ public:
~ProgramHeader() {}
unsigned index() const { return m_program_header_index; }
- dword type() const { return m_program_header.p_type; }
- dword flags() const { return m_program_header.p_flags; }
- dword offset() const { return m_program_header.p_offset; }
+ u32 type() const { return m_program_header.p_type; }
+ u32 flags() const { return m_program_header.p_flags; }
+ u32 offset() const { return m_program_header.p_offset; }
VirtualAddress vaddr() const { return VirtualAddress(m_program_header.p_vaddr); }
- dword size_in_memory() const { return m_program_header.p_memsz; }
- dword size_in_image() const { return m_program_header.p_filesz; }
- dword alignment() const { return m_program_header.p_align; }
+ u32 size_in_memory() const { return m_program_header.p_memsz; }
+ u32 size_in_image() const { return m_program_header.p_filesz; }
+ u32 alignment() const { return m_program_header.p_align; }
bool is_readable() const { return flags() & PF_R; }
bool is_writable() const { return flags() & PF_W; }
bool is_executable() const { return flags() & PF_X; }
@@ -88,10 +88,10 @@ public:
unsigned size() const { return m_section_header.sh_size; }
unsigned entry_size() const { return m_section_header.sh_entsize; }
unsigned entry_count() const { return !entry_size() ? 0 : size() / entry_size(); }
- dword address() const { return m_section_header.sh_addr; }
+ u32 address() const { return m_section_header.sh_addr; }
const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); }
bool is_undefined() const { return m_section_index == SHN_UNDEF; }
- dword flags() const { return m_section_header.sh_flags; }
+ u32 flags() const { return m_section_header.sh_flags; }
bool is_writable() const { return flags() & SHF_WRITE; }
bool is_executable() const { return flags() & PF_X; }
@@ -134,7 +134,7 @@ private:
const char* section_header_table_string(unsigned offset) const;
const char* section_index_to_string(unsigned index);
- const byte* m_buffer { nullptr };
+ const u8* m_buffer { nullptr };
bool m_valid { false };
unsigned m_symbol_table_section_index { 0 };
unsigned m_string_table_section_index { 0 };
diff --git a/AK/ELF/ELFLoader.cpp b/AK/ELF/ELFLoader.cpp
index 6bc84f65b4..1891d9f056 100644
--- a/AK/ELF/ELFLoader.cpp
+++ b/AK/ELF/ELFLoader.cpp
@@ -8,7 +8,7 @@
//#define ELFLOADER_DEBUG
-ELFLoader::ELFLoader(const byte* buffer)
+ELFLoader::ELFLoader(const u8* buffer)
: m_image(buffer)
{
}
@@ -81,7 +81,7 @@ char* ELFLoader::symbol_ptr(const char* name)
return found_ptr;
}
-String ELFLoader::symbolicate(dword address) const
+String ELFLoader::symbolicate(u32 address) const
{
SortedSymbol* sorted_symbols = nullptr;
#ifdef KERNEL
diff --git a/AK/ELF/ELFLoader.h b/AK/ELF/ELFLoader.h
index 3803726a29..091e47d6fc 100644
--- a/AK/ELF/ELFLoader.h
+++ b/AK/ELF/ELFLoader.h
@@ -13,7 +13,7 @@ class Region;
class ELFLoader {
public:
- explicit ELFLoader(const byte*);
+ explicit ELFLoader(const u8*);
~ELFLoader();
bool load();
@@ -26,7 +26,7 @@ public:
bool has_symbols() const { return m_image.symbol_count(); }
- String symbolicate(dword address) const;
+ String symbolicate(u32 address) const;
private:
bool layout();
@@ -49,7 +49,7 @@ private:
ELFImage m_image;
struct SortedSymbol {
- dword address;
+ u32 address;
const char* name;
};
#ifdef KERNEL
diff --git a/AK/HashFunctions.h b/AK/HashFunctions.h
index 4155d23c67..ee09fb0cf3 100644
--- a/AK/HashFunctions.h
+++ b/AK/HashFunctions.h
@@ -2,7 +2,7 @@
#include "Types.h"
-inline unsigned int_hash(dword key)
+inline unsigned int_hash(u32 key)
{
key += ~(key << 15);
key ^= (key >> 10);
@@ -13,7 +13,7 @@ inline unsigned int_hash(dword key)
return key;
}
-inline unsigned pair_int_hash(dword key1, dword key2)
+inline unsigned pair_int_hash(u32 key1, u32 key2)
{
return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413)));
}
diff --git a/AK/IPv4Address.h b/AK/IPv4Address.h
index d3d1bf1dfa..36223043b0 100644
--- a/AK/IPv4Address.h
+++ b/AK/IPv4Address.h
@@ -9,26 +9,26 @@ class [[gnu::packed]] IPv4Address
{
public:
IPv4Address() {}
- IPv4Address(const byte data[4])
+ IPv4Address(const u8 data[4])
{
m_data[0] = data[0];
m_data[1] = data[1];
m_data[2] = data[2];
m_data[3] = data[3];
}
- IPv4Address(byte a, byte b, byte c, byte d)
+ IPv4Address(u8 a, u8 b, u8 c, u8 d)
{
m_data[0] = a;
m_data[1] = b;
m_data[2] = c;
m_data[3] = d;
}
- IPv4Address(NetworkOrdered<dword> address)
- : m_data_as_dword(address)
+ IPv4Address(NetworkOrdered<u32> address)
+ : m_data_as_u32(address)
{
}
- byte operator[](int i) const
+ u8 operator[](int i) const
{
ASSERT(i >= 0 && i < 4);
return m_data[i];
@@ -39,13 +39,13 @@ public:
return String::format("%u.%u.%u.%u", m_data[0], m_data[1], m_data[2], m_data[3]);
}
- bool operator==(const IPv4Address& other) const { return m_data_as_dword == other.m_data_as_dword; }
- bool operator!=(const IPv4Address& other) const { return m_data_as_dword != other.m_data_as_dword; }
+ bool operator==(const IPv4Address& other) const { return m_data_as_u32 == other.m_data_as_u32; }
+ bool operator!=(const IPv4Address& other) const { return m_data_as_u32 != other.m_data_as_u32; }
private:
union {
- byte m_data[4];
- dword m_data_as_dword { 0 };
+ u8 m_data[4];
+ u32 m_data_as_u32 { 0 };
};
};
diff --git a/AK/JsonValue.h b/AK/JsonValue.h
index 706c39962b..49eda29aed 100644
--- a/AK/JsonValue.h
+++ b/AK/JsonValue.h
@@ -117,18 +117,18 @@ public:
#endif
}
- dword to_dword(dword default_value = 0) const
+ u32 to_u32(u32 default_value = 0) const
{
if (!is_number())
return default_value;
#ifdef KERNEL
- return (dword)m_value.as_int;
+ return (u32)m_value.as_int;
#else
if (type() == Type::Int)
- return (dword)m_value.as_int;
+ return (u32)m_value.as_int;
if (type() == Type::UnsignedInt)
return m_value.as_uint;
- return (dword)m_value.as_double;
+ return (u32)m_value.as_double;
#endif
}
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h
index c9bde97056..2899fb04ab 100644
--- a/AK/PrintfImplementation.h
+++ b/AK/PrintfImplementation.h
@@ -12,10 +12,10 @@ extern "C" size_t strlen(const char*);
#endif
template<typename PutChFunc, typename T>
-[[gnu::always_inline]] inline int print_hex(PutChFunc putch, char*& bufptr, T number, byte fields)
+[[gnu::always_inline]] inline int print_hex(PutChFunc putch, char*& bufptr, T number, u8 fields)
{
int ret = 0;
- byte shr_count = fields * 4;
+ u8 shr_count = fields * 4;
while (shr_count) {
shr_count -= 4;
putch(bufptr, printf_hex_digits[(number >> shr_count) & 0x0F]);
@@ -25,9 +25,9 @@ template<typename PutChFunc, typename T>
}
template<typename PutChFunc>
-[[gnu::always_inline]] inline int print_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
+[[gnu::always_inline]] inline int print_number(PutChFunc putch, char*& bufptr, u32 number, bool leftPad, bool zeroPad, u32 fieldWidth)
{
- dword divisor = 1000000000;
+ u32 divisor = 1000000000;
char ch;
char padding = 1;
char buf[16];
@@ -66,9 +66,9 @@ template<typename PutChFunc>
}
template<typename PutChFunc>
-[[gnu::always_inline]] inline int print_qword(PutChFunc putch, char*& bufptr, qword number, bool leftPad, bool zeroPad, dword fieldWidth)
+[[gnu::always_inline]] inline int print_u64(PutChFunc putch, char*& bufptr, u64 number, bool leftPad, bool zeroPad, u32 fieldWidth)
{
- qword divisor = 10000000000000000000LLU;
+ u64 divisor = 10000000000000000000LLU;
char ch;
char padding = 1;
char buf[16];
@@ -107,19 +107,19 @@ template<typename PutChFunc>
}
template<typename PutChFunc>
-[[gnu::always_inline]] inline int print_signed_qword(PutChFunc putch, char*& bufptr, signed_qword number, bool leftPad, bool zeroPad, dword fieldWidth)
+[[gnu::always_inline]] inline int print_i64(PutChFunc putch, char*& bufptr, i64 number, bool leftPad, bool zeroPad, u32 fieldWidth)
{
if (number < 0) {
putch(bufptr, '-');
- return print_qword(putch, bufptr, 0 - number, leftPad, zeroPad, fieldWidth) + 1;
+ return print_u64(putch, bufptr, 0 - number, leftPad, zeroPad, fieldWidth) + 1;
}
- return print_qword(putch, bufptr, number, leftPad, zeroPad, fieldWidth);
+ return print_u64(putch, bufptr, number, leftPad, zeroPad, fieldWidth);
}
template<typename PutChFunc>
-[[gnu::always_inline]] inline int print_octal_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
+[[gnu::always_inline]] inline int print_octal_number(PutChFunc putch, char*& bufptr, u32 number, bool leftPad, bool zeroPad, u32 fieldWidth)
{
- dword divisor = 134217728;
+ u32 divisor = 134217728;
char ch;
char padding = 1;
char buf[32];
@@ -158,7 +158,7 @@ template<typename PutChFunc>
}
template<typename PutChFunc>
-[[gnu::always_inline]] inline int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
+[[gnu::always_inline]] inline int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, u32 fieldWidth)
{
size_t len = strlen(str);
if (!fieldWidth || fieldWidth < len)
@@ -178,7 +178,7 @@ template<typename PutChFunc>
}
template<typename PutChFunc>
-[[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth)
+[[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, u32 fieldWidth)
{
if (number < 0) {
putch(bufptr, '-');
@@ -248,22 +248,22 @@ template<typename PutChFunc>
break;
case 'u':
- ret += print_number(putch, bufptr, va_arg(ap, dword), left_pad, zeroPad, fieldWidth);
+ ret += print_number(putch, bufptr, va_arg(ap, u32), left_pad, zeroPad, fieldWidth);
break;
case 'Q':
- ret += print_qword(putch, bufptr, va_arg(ap, qword), left_pad, zeroPad, fieldWidth);
+ ret += print_u64(putch, bufptr, va_arg(ap, u64), left_pad, zeroPad, fieldWidth);
break;
case 'q':
- ret += print_hex(putch, bufptr, va_arg(ap, qword), 16);
+ ret += print_hex(putch, bufptr, va_arg(ap, u64), 16);
break;
#ifndef KERNEL
case 'g':
case 'f':
// FIXME: Print as float!
- ret += print_signed_qword(putch, bufptr, (qword)va_arg(ap, double), left_pad, zeroPad, fieldWidth);
+ ret += print_i64(putch, bufptr, (u64)va_arg(ap, double), left_pad, zeroPad, fieldWidth);
break;
#endif
@@ -272,7 +272,7 @@ template<typename PutChFunc>
putch(bufptr, '0');
++ret;
}
- ret += print_octal_number(putch, bufptr, va_arg(ap, dword), left_pad, zeroPad, fieldWidth);
+ ret += print_octal_number(putch, bufptr, va_arg(ap, u32), left_pad, zeroPad, fieldWidth);
break;
case 'x':
@@ -281,7 +281,7 @@ template<typename PutChFunc>
putch(bufptr, 'x');
ret += 2;
}
- ret += print_hex(putch, bufptr, va_arg(ap, dword), 8);
+ ret += print_hex(putch, bufptr, va_arg(ap, u32), 8);
break;
case 'w':
@@ -306,7 +306,7 @@ template<typename PutChFunc>
putch(bufptr, '0');
putch(bufptr, 'x');
ret += 2;
- ret += print_hex(putch, bufptr, va_arg(ap, dword), 8);
+ ret += print_hex(putch, bufptr, va_arg(ap, u32), 8);
break;
}
} else {
diff --git a/AK/StdLibExtras.cpp b/AK/StdLibExtras.cpp
index 491fe645ed..e0caab308d 100644
--- a/AK/StdLibExtras.cpp
+++ b/AK/StdLibExtras.cpp
@@ -10,11 +10,11 @@ void* mmx_memcpy(void* dest, const void* src, size_t len)
{
ASSERT(len >= 1024);
- auto* dest_ptr = (byte*)dest;
- auto* src_ptr = (const byte*)src;
+ auto* dest_ptr = (u8*)dest;
+ auto* src_ptr = (const u8*)src;
- if ((dword)dest_ptr & 7) {
- dword prologue = 8 - ((dword)dest_ptr & 7);
+ if ((u32)dest_ptr & 7) {
+ u32 prologue = 8 - ((u32)dest_ptr & 7);
len -= prologue;
asm volatile(
"rep movsb\n"
@@ -22,7 +22,7 @@ void* mmx_memcpy(void* dest, const void* src, size_t len)
: "0"(src_ptr), "1"(dest_ptr), "2"(prologue)
: "memory");
}
- for (dword i = len / 64; i; --i) {
+ for (u32 i = len / 64; i; --i) {
asm volatile(
"movq (%0), %%mm0\n"
"movq 8(%0), %%mm1\n"
diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h
index 05c442284f..3c48af6e8f 100644
--- a/AK/StdLibExtras.h
+++ b/AK/StdLibExtras.h
@@ -15,7 +15,7 @@
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
#endif
-[[gnu::always_inline]] inline void fast_dword_copy(dword* dest, const dword* src, size_t count)
+[[gnu::always_inline]] inline void fast_u32_copy(u32* dest, const u32* src, size_t count)
{
#ifndef KERNEL
if (count >= 256) {
@@ -30,7 +30,7 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
: "memory");
}
-[[gnu::always_inline]] inline void fast_dword_fill(dword* dest, dword value, size_t count)
+[[gnu::always_inline]] inline void fast_u32_fill(u32* dest, u32 value, size_t count)
{
asm volatile(
"rep stosl\n"
@@ -39,7 +39,7 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
: "memory");
}
-inline constexpr dword round_up_to_power_of_two(dword value, dword power_of_two)
+inline constexpr u32 round_up_to_power_of_two(u32 value, u32 power_of_two)
{
return ((value - 1) & ~(power_of_two - 1)) + power_of_two;
}
diff --git a/AK/String.cpp b/AK/String.cpp
index b7e8c0cd69..54c7fd742f 100644
--- a/AK/String.cpp
+++ b/AK/String.cpp
@@ -124,7 +124,7 @@ ByteBuffer String::to_byte_buffer() const
{
if (!m_impl)
return nullptr;
- return ByteBuffer::copy(reinterpret_cast<const byte*>(characters()), length());
+ return ByteBuffer::copy(reinterpret_cast<const u8*>(characters()), length());
}
int String::to_int(bool& ok) const
diff --git a/AK/StringImpl.h b/AK/StringImpl.h
index b39e363750..b2b085f81d 100644
--- a/AK/StringImpl.h
+++ b/AK/StringImpl.h
@@ -66,11 +66,11 @@ private:
char m_inline_buffer[0];
};
-inline constexpr dword string_hash(const char* characters, int length)
+inline constexpr u32 string_hash(const char* characters, int length)
{
- dword hash = 0;
+ u32 hash = 0;
for (int i = 0; i < length; ++i) {
- hash += (dword)characters[i];
+ hash += (u32)characters[i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
diff --git a/AK/Traits.h b/AK/Traits.h
index 63080b5883..b651a3f635 100644
--- a/AK/Traits.h
+++ b/AK/Traits.h
@@ -27,9 +27,9 @@ struct Traits<unsigned> : public GenericTraits<unsigned> {
};
template<>
-struct Traits<word> : public GenericTraits<word> {
- static unsigned hash(word u) { return int_hash(u); }
- static void dump(word u) { kprintf("%u", u); }
+struct Traits<u16> : public GenericTraits<u16> {
+ static unsigned hash(u16 u) { return int_hash(u); }
+ static void dump(u16 u) { kprintf("%u", u); }
};
template<typename T>
diff --git a/AK/Types.h b/AK/Types.h
index cf32ebb9b3..7e894f416e 100644
--- a/AK/Types.h
+++ b/AK/Types.h
@@ -21,33 +21,23 @@ static_assert(sizeof(i16) == 2);
static_assert(sizeof(i32) == 4);
static_assert(sizeof(i64) == 8);
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned int dword;
-typedef unsigned long long int qword;
-
-typedef signed char signed_byte;
-typedef signed short signed_word;
-typedef signed int signed_dword;
-typedef signed long long int signed_qword;
-
typedef __SIZE_TYPE__ size_t;
-typedef signed_dword ssize_t;
+typedef i32 ssize_t;
-static_assert(sizeof(size_t) == sizeof(dword));
-static_assert(sizeof(ssize_t) == sizeof(signed_dword));
+static_assert(sizeof(size_t) == sizeof(u32));
+static_assert(sizeof(ssize_t) == sizeof(i32));
typedef __PTRDIFF_TYPE__ ptrdiff_t;
-typedef byte uint8_t;
-typedef word uint16_t;
-typedef dword uint32_t;
-typedef qword uint64_t;
+typedef u8 uint8_t;
+typedef u16 uint16_t;
+typedef u32 uint32_t;
+typedef u64 uint64_t;
-typedef signed_byte int8_t;
-typedef signed_word int16_t;
-typedef signed_dword int32_t;
-typedef signed_qword int64_t;
+typedef i8 int8_t;
+typedef i16 int16_t;
+typedef i32 int32_t;
+typedef i64 int64_t;
#else
# include <stdint.h>
@@ -62,16 +52,6 @@ typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
-
-typedef uint8_t byte;
-typedef uint16_t word;
-typedef uint32_t dword;
-typedef uint64_t qword;
-
-typedef int8_t signed_byte;
-typedef int16_t signed_word;
-typedef int32_t signed_dword;
-typedef int64_t signed_qword;
#endif
constexpr unsigned KB = 1024;
@@ -82,7 +62,7 @@ namespace std {
typedef decltype(nullptr) nullptr_t;
}
-static constexpr dword explode_byte(byte b)
+static constexpr u32 explode_byte(u8 b)
{
return b << 24 | b << 16 | b << 8 | b;
}
diff --git a/AK/Vector.h b/AK/Vector.h
index 176b05d9ff..bb80106cfc 100644
--- a/AK/Vector.h
+++ b/AK/Vector.h
@@ -427,7 +427,7 @@ private:
int m_size { 0 };
int m_capacity { 0 };
- alignas(T) byte m_inline_buffer_storage[sizeof(T) * inline_capacity];
+ alignas(T) u8 m_inline_buffer_storage[sizeof(T) * inline_capacity];
T* m_outline_buffer { nullptr };
};
diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp
index 28dc2e6366..90d9563907 100644
--- a/Applications/FontEditor/FontEditor.cpp
+++ b/Applications/FontEditor/FontEditor.cpp
@@ -91,12 +91,12 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& edited_fon
demo_label_2->update();
};
- m_glyph_editor_widget->on_glyph_altered = [this, update_demo](byte glyph) {
+ m_glyph_editor_widget->on_glyph_altered = [this, update_demo](u8 glyph) {
m_glyph_map_widget->update_glyph(glyph);
update_demo();
};
- m_glyph_map_widget->on_glyph_selected = [this, info_label, width_spinbox](byte glyph) {
+ m_glyph_map_widget->on_glyph_selected = [this, info_label, width_spinbox](u8 glyph) {
m_glyph_editor_widget->set_glyph(glyph);
width_spinbox->set_value(m_edited_font->glyph_width(m_glyph_map_widget->selected_glyph()));
info_label->set_text(String::format("0x%b (%c)", glyph, glyph));
diff --git a/Applications/FontEditor/GlyphEditorWidget.cpp b/Applications/FontEditor/GlyphEditorWidget.cpp
index c8e491dff1..24ff5bc7f7 100644
--- a/Applications/FontEditor/GlyphEditorWidget.cpp
+++ b/Applications/FontEditor/GlyphEditorWidget.cpp
@@ -15,7 +15,7 @@ GlyphEditorWidget::~GlyphEditorWidget()
{
}
-void GlyphEditorWidget::set_glyph(byte glyph)
+void GlyphEditorWidget::set_glyph(u8 glyph)
{
if (m_glyph == glyph)
return;
diff --git a/Applications/FontEditor/GlyphEditorWidget.h b/Applications/FontEditor/GlyphEditorWidget.h
index 9fd05a322e..31b83ed3e5 100644
--- a/Applications/FontEditor/GlyphEditorWidget.h
+++ b/Applications/FontEditor/GlyphEditorWidget.h
@@ -6,8 +6,8 @@ public:
GlyphEditorWidget(Font&, GWidget* parent);
virtual ~GlyphEditorWidget() override;
- byte glyph() const { return m_glyph; }
- void set_glyph(byte);
+ u8 glyph() const { return m_glyph; }
+ void set_glyph(u8);
int preferred_width() const;
int preferred_height() const;
@@ -15,7 +15,7 @@ public:
Font& font() { return *m_font; }
const Font& font() const { return *m_font; }
- Function<void(byte)> on_glyph_altered;
+ Function<void(u8)> on_glyph_altered;
private:
virtual void paint_event(GPaintEvent&) override;
@@ -25,6 +25,6 @@ private:
void draw_at_mouse(const GMouseEvent&);
RefPtr<Font> m_font;
- byte m_glyph { 0 };
+ u8 m_glyph { 0 };
int m_scale { 10 };
};
diff --git a/Applications/FontEditor/GlyphMapWidget.cpp b/Applications/FontEditor/GlyphMapWidget.cpp
index 4d94b2eeaf..1d86a83184 100644
--- a/Applications/FontEditor/GlyphMapWidget.cpp
+++ b/Applications/FontEditor/GlyphMapWidget.cpp
@@ -25,7 +25,7 @@ int GlyphMapWidget::preferred_height() const
return rows() * (font().glyph_height() + m_vertical_spacing) + 2 + frame_thickness() * 2;
}
-void GlyphMapWidget::set_selected_glyph(byte glyph)
+void GlyphMapWidget::set_selected_glyph(u8 glyph)
{
if (m_selected_glyph == glyph)
return;
@@ -35,7 +35,7 @@ void GlyphMapWidget::set_selected_glyph(byte glyph)
update();
}
-Rect GlyphMapWidget::get_outer_rect(byte glyph) const
+Rect GlyphMapWidget::get_outer_rect(u8 glyph) const
{
int row = glyph / columns();
int column = glyph % columns();
@@ -48,7 +48,7 @@ Rect GlyphMapWidget::get_outer_rect(byte glyph) const
.translated(frame_thickness(), frame_thickness());
}
-void GlyphMapWidget::update_glyph(byte glyph)
+void GlyphMapWidget::update_glyph(u8 glyph)
{
update(get_outer_rect(glyph));
}
@@ -63,7 +63,7 @@ void GlyphMapWidget::paint_event(GPaintEvent& event)
painter.set_font(font());
painter.fill_rect(frame_inner_rect(), Color::White);
- byte glyph = 0;
+ u8 glyph = 0;
for (int row = 0; row < rows(); ++row) {
for (int column = 0; column < columns(); ++column, ++glyph) {
diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h
index 521c0f7c2f..944aca6542 100644
--- a/Applications/FontEditor/GlyphMapWidget.h
+++ b/Applications/FontEditor/GlyphMapWidget.h
@@ -8,8 +8,8 @@ public:
GlyphMapWidget(Font&, GWidget* parent);
virtual ~GlyphMapWidget() override;
- byte selected_glyph() const { return m_selected_glyph; }
- void set_selected_glyph(byte);
+ u8 selected_glyph() const { return m_selected_glyph; }
+ void set_selected_glyph(u8);
int rows() const { return m_rows; }
int columns() const { return 256 / m_rows; }
@@ -20,19 +20,19 @@ public:
Font& font() { return *m_font; }
const Font& font() const { return *m_font; }
- void update_glyph(byte);
+ void update_glyph(u8);
- Function<void(byte)> on_glyph_selected;
+ Function<void(u8)> on_glyph_selected;
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
- Rect get_outer_rect(byte glyph) const;
+ Rect get_outer_rect(u8 glyph) const;
RefPtr<Font> m_font;
int m_rows { 8 };
int m_horizontal_spacing { 2 };
int m_vertical_spacing { 2 };
- byte m_selected_glyph { 0 };
+ u8 m_selected_glyph { 0 };
};
diff --git a/Applications/ProcessManager/MemoryStatsWidget.cpp b/Applications/ProcessManager/MemoryStatsWidget.cpp
index d114d937d4..433b0b7c9b 100644
--- a/Applications/ProcessManager/MemoryStatsWidget.cpp
+++ b/Applications/ProcessManager/MemoryStatsWidget.cpp
@@ -64,16 +64,16 @@ void MemoryStatsWidget::refresh()
auto file_contents = m_proc_memstat.read_all();
auto json = JsonValue::from_string(file_contents).as_object();
- unsigned kmalloc_eternal_allocated = json.get("kmalloc_eternal_allocated").to_dword();
+ unsigned kmalloc_eternal_allocated = json.get("kmalloc_eternal_allocated").to_u32();
(void)kmalloc_eternal_allocated;
- unsigned kmalloc_allocated = json.get("kmalloc_allocated").to_dword();
- unsigned kmalloc_available = json.get("kmalloc_available").to_dword();
- unsigned user_physical_allocated = json.get("user_physical_allocated").to_dword();
- unsigned user_physical_available = json.get("user_physical_available").to_dword();
- unsigned super_physical_alloc = json.get("super_physical_allocated").to_dword();
- unsigned super_physical_free = json.get("super_physical_available").to_dword();
- unsigned kmalloc_call_count = json.get("kmalloc_call_count").to_dword();
- unsigned kfree_call_count = json.get("kfree_call_count").to_dword();
+ unsigned kmalloc_allocated = json.get("kmalloc_allocated").to_u32();
+ unsigned kmalloc_available = json.get("kmalloc_available").to_u32();
+ unsigned user_physical_allocated = json.get("user_physical_allocated").to_u32();
+ unsigned user_physical_available = json.get("user_physical_available").to_u32();
+ unsigned super_physical_alloc = json.get("super_physical_allocated").to_u32();
+ unsigned super_physical_free = json.get("super_physical_available").to_u32();
+ unsigned kmalloc_call_count = json.get("kmalloc_call_count").to_u32();
+ unsigned kfree_call_count = json.get("kfree_call_count").to_u32();
size_t kmalloc_sum_available = kmalloc_allocated + kmalloc_available;
size_t user_pages_available = user_physical_allocated + user_physical_available;
diff --git a/Applications/ProcessManager/ProcessModel.cpp b/Applications/ProcessManager/ProcessModel.cpp
index 9c0986d6e3..ac1c872305 100644
--- a/Applications/ProcessManager/ProcessModel.cpp
+++ b/Applications/ProcessManager/ProcessModel.cpp
@@ -198,12 +198,12 @@ void ProcessModel::update()
auto json = JsonValue::from_string({ file_contents.data(), file_contents.size() });
json.as_array().for_each([&](auto& value) {
const JsonObject& process_object = value.as_object();
- pid_t pid = process_object.get("pid").to_dword();
- unsigned nsched = process_object.get("times_scheduled").to_dword();
+ pid_t pid = process_object.get("pid").to_u32();
+ unsigned nsched = process_object.get("times_scheduled").to_u32();
ProcessState state;
state.pid = pid;
state.nsched = nsched;
- unsigned uid = process_object.get("uid").to_dword();
+ unsigned uid = process_object.get("uid").to_u32();
{
auto it = m_usernames.find((uid_t)uid);
if (it != m_usernames.end())
@@ -212,11 +212,11 @@ void ProcessModel::update()
state.user = String::number(uid);
}
state.priority = process_object.get("priority").to_string();
- state.syscalls = process_object.get("syscall_count").to_dword();
+ state.syscalls = process_object.get("syscall_count").to_u32();
state.state = process_object.get("state").to_string();
state.name = process_object.get("name").to_string();
- state.virtual_size = process_object.get("amount_virtual").to_dword();
- state.physical_size = process_object.get("amount_resident").to_dword();
+ state.virtual_size = process_object.get("amount_virtual").to_u32();
+ state.physical_size = process_object.get("amount_resident").to_u32();
sum_nsched += nsched;
{
auto it = m_processes.find(pid);
@@ -240,7 +240,7 @@ void ProcessModel::update()
continue;
}
auto& process = *it.value;
- dword nsched_diff = process.current_state.nsched - process.previous_state.nsched;
+ u32 nsched_diff = process.current_state.nsched - process.previous_state.nsched;
process.current_state.cpu_percent = ((float)nsched_diff * 100) / (float)(sum_nsched - last_sum_nsched);
if (it.key != 0) {
total_cpu_percent += process.current_state.cpu_percent;
diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp
index 85579225b0..9140f81ede 100644
--- a/Applications/Terminal/Terminal.cpp
+++ b/Applications/Terminal/Terminal.cpp
@@ -17,8 +17,8 @@
#include <unistd.h>
//#define TERMINAL_DEBUG
-byte Terminal::Attribute::default_foreground_color = 7;
-byte Terminal::Attribute::default_background_color = 0;
+u8 Terminal::Attribute::default_foreground_color = 7;
+u8 Terminal::Attribute::default_background_color = 0;
Terminal::Terminal(int ptm_fd, RefPtr<CConfigFile> config)
: m_ptm_fd(ptm_fd)
@@ -45,7 +45,7 @@ Terminal::Terminal(int ptm_fd, RefPtr<CConfigFile> config)
set_font(Font::load_from_file(font_entry));
m_notifier.on_ready_to_read = [this] {
- byte buffer[BUFSIZ];
+ u8 buffer[BUFSIZ];
ssize_t nread = read(m_ptm_fd, buffer, sizeof(buffer));
if (nread < 0) {
dbgprintf("Terminal read error: %s\n", strerror(errno));
@@ -69,7 +69,7 @@ Terminal::Terminal(int ptm_fd, RefPtr<CConfigFile> config)
m_config->read_num_entry("Window", "Height", 25));
}
-Terminal::Line::Line(word length)
+Terminal::Line::Line(u16 length)
{
set_length(length);
}
@@ -80,11 +80,11 @@ Terminal::Line::~Line()
delete[] attributes;
}
-void Terminal::Line::set_length(word new_length)
+void Terminal::Line::set_length(u16 new_length)
{
if (m_length == new_length)
return;
- auto* new_characters = new byte[new_length];
+ auto* new_characters = new u8[new_length];
auto* new_attributes = new Attribute[new_length];
memset(new_characters, ' ', new_length);
delete[] characters;
@@ -98,7 +98,7 @@ void Terminal::Line::clear(Attribute attribute)
{
if (dirty) {
memset(characters, ' ', m_length);
- for (word i = 0; i < m_length; ++i)
+ for (u16 i = 0; i < m_length; ++i)
attributes[i] = attribute;
return;
}
@@ -125,17 +125,17 @@ void Terminal::clear()
set_cursor(0, 0);
}
-inline bool is_valid_parameter_character(byte ch)
+inline bool is_valid_parameter_character(u8 ch)
{
return ch >= 0x30 && ch <= 0x3f;
}
-inline bool is_valid_intermediate_character(byte ch)
+inline bool is_valid_intermediate_character(u8 ch)
{
return ch >= 0x20 && ch <= 0x2f;
}
-inline bool is_valid_final_character(byte ch)
+inline bool is_valid_final_character(u8 ch)
{
return ch >= 0x40 && ch <= 0x7e;
}
@@ -481,7 +481,7 @@ void Terminal::escape$S(const ParamVector& params)
if (params.size() >= 1)
count = params[0];
- for (word i = 0; i < count; i++)
+ for (u16 i = 0; i < count; i++)
scroll_up();
}
@@ -491,7 +491,7 @@ void Terminal::escape$T(const ParamVector& params)
if (params.size() >= 1)
count = params[0];
- for (word i = 0; i < count; i++)
+ for (u16 i = 0; i < count; i++)
scroll_down();
}
@@ -577,7 +577,7 @@ void Terminal::execute_xterm_command()
m_xterm_param2.clear_with_capacity();
}
-void Terminal::execute_escape_sequence(byte final)
+void Terminal::execute_escape_sequence(u8 final)
{
bool question_param = false;
m_final = final;
@@ -701,7 +701,7 @@ void Terminal::execute_escape_sequence(byte final)
void Terminal::newline()
{
- word new_row = m_cursor_row;
+ u16 new_row = m_cursor_row;
if (m_cursor_row == m_scroll_region_bottom) {
scroll_up();
} else {
@@ -744,7 +744,7 @@ void Terminal::set_cursor(unsigned a_row, unsigned a_column)
invalidate_cursor();
}
-void Terminal::put_character_at(unsigned row, unsigned column, byte ch)
+void Terminal::put_character_at(unsigned row, unsigned column, u8 ch)
{
ASSERT(row < rows());
ASSERT(column < columns());
@@ -757,7 +757,7 @@ void Terminal::put_character_at(unsigned row, unsigned column, byte ch)
m_last_char = ch;
}
-void Terminal::on_char(byte ch)
+void Terminal::on_char(u8 ch)
{
#ifdef TERMINAL_DEBUG
dbgprintf("Terminal::on_char: %b (%c), fg=%u, bg=%u\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color);
@@ -913,7 +913,7 @@ void Terminal::unimplemented_xterm_escape()
inject_string(message);
}
-void Terminal::set_size(word columns, word rows)
+void Terminal::set_size(u16 columns, u16 rows)
{
if (columns == m_columns && rows == m_rows)
return;
@@ -965,14 +965,14 @@ void Terminal::set_size(word columns, word rows)
ASSERT(rc == 0);
}
-Rect Terminal::glyph_rect(word row, word column)
+Rect Terminal::glyph_rect(u16 row, u16 column)
{
int y = row * m_line_height;
int x = column * font().glyph_width('x');
return { x + frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x'), font().glyph_height() };
}
-Rect Terminal::row_rect(word row)
+Rect Terminal::row_rect(u16 row)
{
int y = row * m_line_height;
Rect rect = { frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x') * m_columns, font().glyph_height() };
@@ -1083,14 +1083,14 @@ void Terminal::paint_event(GPaintEvent& event)
painter.fill_rect(frame_inner_rect(), Color(Color::Black).with_alpha(m_opacity));
invalidate_cursor();
- for (word row = 0; row < m_rows; ++row) {
+ for (u16 row = 0; row < m_rows; ++row) {
auto& line = this->line(row);
bool has_only_one_background_color = line.has_only_one_background_color();
if (m_visual_beep_timer.is_active())
painter.fill_rect(row_rect(row), Color::Red);
else if (has_only_one_background_color)
painter.fill_rect(row_rect(row), lookup_color(line.attributes[0].background_color).with_alpha(m_opacity));
- for (word column = 0; column < m_columns; ++column) {
+ for (u16 column = 0; column < m_columns; ++column) {
char ch = line.characters[column];
bool should_reverse_fill_for_cursor_or_selection = (m_cursor_blink_state && m_in_active_window && row == m_cursor_row && column == m_cursor_column)
|| selection_contains({ row, column });
@@ -1167,7 +1167,7 @@ void Terminal::update_cursor()
flush_dirty_lines();
}
-void Terminal::set_opacity(byte new_opacity)
+void Terminal::set_opacity(u8 new_opacity)
{
if (m_opacity == new_opacity)
return;
diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h
index c0243419ee..b60f924bbe 100644
--- a/Applications/Terminal/Terminal.h
+++ b/Applications/Terminal/Terminal.h
@@ -61,14 +61,14 @@ public:
virtual ~Terminal() override;
void create_window();
- void on_char(byte);
+ void on_char(u8);
void flush_dirty_lines();
void force_repaint();
void apply_size_increments_to_window(GWindow&);
- void set_opacity(byte);
+ void set_opacity(u8);
float opacity() { return m_opacity; };
bool should_beep() { return m_should_beep; }
void set_should_beep(bool sb) { m_should_beep = sb; };
@@ -98,7 +98,7 @@ private:
void scroll_down();
void newline();
void set_cursor(unsigned row, unsigned column);
- void put_character_at(unsigned row, unsigned column, byte ch);
+ void put_character_at(unsigned row, unsigned column, u8 ch);
void invalidate_cursor();
void set_window_title(const String&);
@@ -131,18 +131,18 @@ private:
void clear();
- void set_size(word columns, word rows);
- word columns() const { return m_columns; }
- word rows() const { return m_rows; }
- Rect glyph_rect(word row, word column);
- Rect row_rect(word row);
+ void set_size(u16 columns, u16 rows);
+ u16 columns() const { return m_columns; }
+ u16 rows() const { return m_rows; }
+ Rect glyph_rect(u16 row, u16 column);
+ Rect row_rect(u16 row);
void update_cursor();
struct Attribute {
Attribute() { reset(); }
- static byte default_foreground_color;
- static byte default_background_color;
+ static u8 default_foreground_color;
+ static u8 default_background_color;
void reset()
{
@@ -150,8 +150,8 @@ private:
background_color = default_background_color;
flags = Flags::NoAttributes;
}
- byte foreground_color;
- byte background_color;
+ u8 foreground_color;
+ u8 background_color;
enum Flags {
NoAttributes = 0x00,
@@ -180,15 +180,15 @@ private:
};
struct Line {
- explicit Line(word columns);
+ explicit Line(u16 columns);
~Line();
void clear(Attribute);
bool has_only_one_background_color() const;
- void set_length(word);
- byte* characters { nullptr };
+ void set_length(u16);
+ u8* characters { nullptr };
Attribute* attributes { nullptr };
bool dirty { false };
- word m_length { 0 };
+ u16 m_length { 0 };
};
Line& line(size_t index)
{
@@ -209,20 +209,20 @@ private:
int m_scroll_region_top { 0 };
int m_scroll_region_bottom { 0 };
- word m_columns { 0 };
- word m_rows { 0 };
+ u16 m_columns { 0 };
+ u16 m_rows { 0 };
- byte m_cursor_row { 0 };
- byte m_cursor_column { 0 };
- byte m_saved_cursor_row { 0 };
- byte m_saved_cursor_column { 0 };
+ u8 m_cursor_row { 0 };
+ u8 m_cursor_column { 0 };
+ u8 m_saved_cursor_row { 0 };
+ u8 m_saved_cursor_column { 0 };
bool m_stomp { false };
bool m_should_beep { false };
Attribute m_current_attribute;
- void execute_escape_sequence(byte final);
+ void execute_escape_sequence(u8 final);
void execute_xterm_command();
enum EscapeState {
@@ -237,12 +237,12 @@ private:
ExpectXtermFinal,
};
EscapeState m_escape_state { Normal };
- Vector<byte> m_parameters;
- Vector<byte> m_intermediates;
- Vector<byte> m_xterm_param1;
- Vector<byte> m_xterm_param2;
+ Vector<u8> m_parameters;
+ Vector<u8> m_intermediates;
+ Vector<u8> m_xterm_param1;
+ Vector<u8> m_xterm_param2;
Vector<bool> m_horizontal_tabs;
- byte m_final { 0 };
+ u8 m_final { 0 };
bool m_belling { false };
int m_pixel_width { 0 };
@@ -261,7 +261,7 @@ private:
CNotifier m_notifier;
- byte m_opacity { 255 };
+ u8 m_opacity { 255 };
bool m_needs_background_fill { true };
bool m_cursor_blink_state { true };
@@ -271,5 +271,5 @@ private:
CTimer m_visual_beep_timer;
RefPtr<CConfigFile> m_config;
- byte m_last_char { 0 };
+ u8 m_last_char { 0 };
};
diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp
index f04f4c8d4b..9dc80f300b 100644
--- a/Demos/Fire/Fire.cpp
+++ b/Demos/Fire/Fire.cpp
@@ -146,7 +146,7 @@ void Fire::timer_event(CTimerEvent&)
int rnd = my_rand() % 3;
/* Calculate new pixel value, don't go below 0 */
- byte nv = bitmap->bits(py)[px];
+ u8 nv = bitmap->bits(py)[px];
if (nv > 0)
nv -= (rnd & 1);
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index d7d91ac6d4..5e8721f11b 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -13,7 +13,7 @@
struct [[gnu::packed]] DescriptorTablePointer
{
- word limit;
+ u16 limit;
void* address;
};
@@ -24,18 +24,18 @@ static Descriptor s_gdt[256];
static IRQHandler* s_irq_handler[16];
-static Vector<word>* s_gdt_freelist;
+static Vector<u16>* s_gdt_freelist;
-static word s_gdt_length;
+static u16 s_gdt_length;
-word gdt_alloc_entry()
+u16 gdt_alloc_entry()
{
ASSERT(s_gdt_freelist);
ASSERT(!s_gdt_freelist->is_empty());
return s_gdt_freelist->take_last();
}
-void gdt_free_entry(word entry)
+void gdt_free_entry(u16 entry)
{
s_gdt_freelist->append(entry);
}
@@ -123,8 +123,8 @@ asm(
template<typename DumpType>
static void dump(const DumpType& regs)
{
- word ss;
- dword esp;
+ u16 ss;
+ u32 esp;
if (!current || current->process().is_ring0()) {
ss = regs.ds;
esp = regs.esp;
@@ -144,7 +144,7 @@ static void dump(const DumpType& regs)
kprintf("ebp=%x esp=%x esi=%x edi=%x\n", regs.ebp, esp, regs.esi, regs.edi);
if (current && current->process().validate_read((void*)regs.eip, 8)) {
- byte* codeptr = (byte*)regs.eip;
+ u8* codeptr = (u8*)regs.eip;
kprintf("code: %b %b %b %b %b %b %b %b\n",
codeptr[0],
codeptr[1],
@@ -236,11 +236,11 @@ void exception_14_handler(RegisterDumpWithExceptionCode& regs)
{
ASSERT(current);
- dword fault_address;
+ u32 fault_address;
asm("movl %%cr2, %%eax"
: "=a"(fault_address));
- dword fault_page_directory;
+ u32 fault_page_directory;
asm("movl %%cr3, %%eax"
: "=a"(fault_page_directory));
@@ -269,8 +269,8 @@ void exception_14_handler(RegisterDumpWithExceptionCode& regs)
regs.exception_code & 2 ? "write to" : "read from",
fault_address);
- dword malloc_scrub_pattern = explode_byte(MALLOC_SCRUB_BYTE);
- dword free_scrub_pattern = explode_byte(FREE_SCRUB_BYTE);
+ u32 malloc_scrub_pattern = explode_byte(MALLOC_SCRUB_BYTE);
+ u32 free_scrub_pattern = explode_byte(FREE_SCRUB_BYTE);
if ((fault_address & 0xffff0000) == (malloc_scrub_pattern & 0xffff0000)) {
kprintf("\033[33;1mNote: Address %p looks like it may be uninitialized malloc() memory\033[0m\n", fault_address);
} else if ((fault_address & 0xffff0000) == (free_scrub_pattern & 0xffff0000)) {
@@ -293,7 +293,7 @@ void exception_14_handler(RegisterDumpWithExceptionCode& regs)
static void _exception##i() \
{ \
kprintf(msg "\n"); \
- dword cr0, cr2, cr3, cr4; \
+ u32 cr0, cr2, cr3, cr4; \
asm("movl %%cr0, %%eax" \
: "=a"(cr0)); \
asm("movl %%cr2, %%eax" \
@@ -319,9 +319,9 @@ EH(12, "Stack exception")
EH(15, "Unknown error")
EH(16, "Coprocessor error")
-static void write_raw_gdt_entry(word selector, dword low, dword high)
+static void write_raw_gdt_entry(u16 selector, u32 low, u32 high)
{
- word i = (selector & 0xfffc) >> 3;
+ u16 i = (selector & 0xfffc) >> 3;
s_gdt[i].low = low;
s_gdt[i].high = high;
@@ -329,14 +329,14 @@ static void write_raw_gdt_entry(word selector, dword low, dword high)
s_gdtr.limit = (s_gdt_length + 1) * 8 - 1;
}
-void write_gdt_entry(word selector, Descriptor& descriptor)
+void write_gdt_entry(u16 selector, Descriptor& descriptor)
{
write_raw_gdt_entry(selector, descriptor.low, descriptor.high);
}
-Descriptor& get_gdt_entry(word selector)
+Descriptor& get_gdt_entry(u16 selector)
{
- word i = (selector & 0xfffc) >> 3;
+ u16 i = (selector & 0xfffc) >> 3;
return *(Descriptor*)(&s_gdt[i]);
}
@@ -352,7 +352,7 @@ void gdt_init()
{
s_gdt_length = 5;
- s_gdt_freelist = new Vector<word>();
+ s_gdt_freelist = new Vector<u16>();
s_gdt_freelist->ensure_capacity(256);
for (size_t i = s_gdt_length; i < 256; ++i)
s_gdt_freelist->append(i * 8);
@@ -389,30 +389,30 @@ static void unimp_trap()
hang();
}
-void register_irq_handler(byte irq, IRQHandler& handler)
+void register_irq_handler(u8 irq, IRQHandler& handler)
{
ASSERT(!s_irq_handler[irq]);
s_irq_handler[irq] = &handler;
register_interrupt_handler(IRQ_VECTOR_BASE + irq, asm_irq_entry);
}
-void unregister_irq_handler(byte irq, IRQHandler& handler)
+void unregister_irq_handler(u8 irq, IRQHandler& handler)
{
ASSERT(s_irq_handler[irq] == &handler);
s_irq_handler[irq] = nullptr;
}
-void register_interrupt_handler(byte index, void (*f)())
+void register_interrupt_handler(u8 index, void (*f)())
{
s_idt[index].low = 0x00080000 | LSW((f));
- s_idt[index].high = ((dword)(f)&0xffff0000) | 0x8e00;
+ s_idt[index].high = ((u32)(f)&0xffff0000) | 0x8e00;
flush_idt();
}
-void register_user_callable_interrupt_handler(byte index, void (*f)())
+void register_user_callable_interrupt_handler(u8 index, void (*f)())
{
s_idt[index].low = 0x00080000 | LSW((f));
- s_idt[index].high = ((dword)(f)&0xffff0000) | 0xef00;
+ s_idt[index].high = ((u32)(f)&0xffff0000) | 0xef00;
flush_idt();
}
@@ -437,7 +437,7 @@ void idt_init()
s_idtr.address = s_idt;
s_idtr.limit = 0x100 * 8 - 1;
- for (byte i = 0xff; i > 0x10; --i)
+ for (u8 i = 0xff; i > 0x10; --i)
register_interrupt_handler(i, unimp_trap);
register_interrupt_handler(0x00, exception_0_entry);
@@ -460,28 +460,28 @@ void idt_init()
register_interrupt_handler(0x57, irq7_handler);
- for (byte i = 0; i < 16; ++i) {
+ for (u8 i = 0; i < 16; ++i) {
s_irq_handler[i] = nullptr;
}
flush_idt();
}
-void load_task_register(word selector)
+void load_task_register(u16 selector)
{
asm("ltr %0" ::"r"(selector));
}
void handle_irq()
{
- word isr = PIC::get_isr();
+ u16 isr = PIC::get_isr();
if (!isr) {
kprintf("Spurious IRQ\n");
return;
}
- byte irq = 0;
- for (byte i = 0; i < 16; ++i) {
+ u8 irq = 0;
+ for (u8 i = 0; i < 16; ++i) {
if (i == 2)
continue;
if (isr & (1 << i)) {
diff --git a/Kernel/Arch/i386/CPU.h b/Kernel/Arch/i386/CPU.h
index 4a90bab110..1b979e0b4b 100644
--- a/Kernel/Arch/i386/CPU.h
+++ b/Kernel/Arch/i386/CPU.h
@@ -13,45 +13,45 @@ class PageTableEntry;
struct [[gnu::packed]] TSS32
{
- word backlink, __blh;
- dword esp0;
- word ss0, __ss0h;
- dword esp1;
- word ss1, __ss1h;
- dword esp2;
- word ss2, __ss2h;
- dword cr3, eip, eflags;
- dword eax, ecx, edx, ebx, esp, ebp, esi, edi;
- word es, __esh;
- word cs, __csh;
- word ss, __ssh;
- word ds, __dsh;
- word fs, __fsh;
- word gs, __gsh;
- word ldt, __ldth;
- word trace, iomapbase;
+ u16 backlink, __blh;
+ u32 esp0;
+ u16 ss0, __ss0h;
+ u32 esp1;
+ u16 ss1, __ss1h;
+ u32 esp2;
+ u16 ss2, __ss2h;
+ u32 cr3, eip, eflags;
+ u32 eax, ecx, edx, ebx, esp, ebp, esi, edi;
+ u16 es, __esh;
+ u16 cs, __csh;
+ u16 ss, __ssh;
+ u16 ds, __dsh;
+ u16 fs, __fsh;
+ u16 gs, __gsh;
+ u16 ldt, __ldth;
+ u16 trace, iomapbase;
};
union [[gnu::packed]] Descriptor
{
struct {
- word limit_lo;
- word base_lo;
- byte base_hi;
- byte type : 4;
- byte descriptor_type : 1;
- byte dpl : 2;
- byte segment_present : 1;
- byte limit_hi : 4;
- byte : 1;
- byte zero : 1;
- byte operation_size : 1;
- byte granularity : 1;
- byte base_hi2;
+ u16 limit_lo;
+ u16 base_lo;
+ u8 base_hi;
+ u8 type : 4;
+ u8 descriptor_type : 1;
+ u8 dpl : 2;
+ u8 segment_present : 1;
+ u8 limit_hi : 4;
+ u8 : 1;
+ u8 zero : 1;
+ u8 operation_size : 1;
+ u8 granularity : 1;
+ u8 base_hi2;
};
struct {
- dword low;
- dword high;
+ u32 low;
+ u32 high;
};
enum Type {
@@ -72,15 +72,15 @@ union [[gnu::packed]] Descriptor
void set_base(void* b)
{
- base_lo = (dword)(b)&0xffff;
- base_hi = ((dword)(b) >> 16) & 0xff;
- base_hi2 = ((dword)(b) >> 24) & 0xff;
+ base_lo = (u32)(b)&0xffff;
+ base_hi = ((u32)(b) >> 16) & 0xff;
+ base_hi2 = ((u32)(b) >> 24) & 0xff;
}
- void set_limit(dword l)
+ void set_limit(u32 l)
{
- limit_lo = (dword)l & 0xffff;
- limit_hi = ((dword)l >> 16) & 0xff;
+ limit_lo = (u32)l & 0xffff;
+ limit_hi = ((u32)l >> 16) & 0xff;
}
};
@@ -89,13 +89,13 @@ class PageDirectoryEntry {
public:
PageTableEntry* page_table_base() { return reinterpret_cast<PageTableEntry*>(m_raw & 0xfffff000u); }
- void set_page_table_base(dword value)
+ void set_page_table_base(u32 value)
{
m_raw &= 0xfff;
m_raw |= value & 0xfffff000;
}
- dword raw() const { return m_raw; }
+ u32 raw() const { return m_raw; }
void copy_from(Badge<MemoryManager>, const PageDirectoryEntry& other) { m_raw = other.m_raw; }
enum Flags {
@@ -121,7 +121,7 @@ public:
bool is_cache_disabled() const { return raw() & CacheDisabled; }
void set_cache_disabled(bool b) { set_bit(CacheDisabled, b); }
- void set_bit(byte bit, bool value)
+ void set_bit(u8 bit, bool value)
{
if (value)
m_raw |= bit;
@@ -130,7 +130,7 @@ public:
}
private:
- dword m_raw;
+ u32 m_raw;
};
class PageTableEntry {
@@ -138,13 +138,13 @@ class PageTableEntry {
public:
void* physical_page_base() { return reinterpret_cast<void*>(m_raw & 0xfffff000u); }
- void set_physical_page_base(dword value)
+ void set_physical_page_base(u32 value)
{
m_raw &= 0xfff;
m_raw |= value & 0xfffff000;
}
- dword raw() const { return m_raw; }
+ u32 raw() const { return m_raw; }
enum Flags {
Present = 1 << 0,
@@ -169,7 +169,7 @@ public:
bool is_cache_disabled() const { return raw() & CacheDisabled; }
void set_cache_disabled(bool b) { set_bit(CacheDisabled, b); }
- void set_bit(byte bit, bool value)
+ void set_bit(u8 bit, bool value)
{
if (value)
m_raw |= bit;
@@ -178,7 +178,7 @@ public:
}
private:
- dword m_raw;
+ u32 m_raw;
};
static_assert(sizeof(PageDirectoryEntry) == 4);
@@ -189,17 +189,17 @@ class IRQHandler;
void gdt_init();
void idt_init();
void sse_init();
-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 register_interrupt_handler(u8 number, void (*f)());
+void register_user_callable_interrupt_handler(u8 number, void (*f)());
+void register_irq_handler(u8 number, IRQHandler&);
+void unregister_irq_handler(u8 number, IRQHandler&);
void flush_idt();
void flush_gdt();
-void load_task_register(word selector);
-word gdt_alloc_entry();
-void gdt_free_entry(word);
-Descriptor& get_gdt_entry(word selector);
-void write_gdt_entry(word selector, Descriptor&);
+void load_task_register(u16 selector);
+u16 gdt_alloc_entry();
+void gdt_free_entry(u16);
+Descriptor& get_gdt_entry(u16 selector);
+void write_gdt_entry(u16 selector, Descriptor&);
[[noreturn]] static inline void hang()
{
@@ -208,8 +208,8 @@ void write_gdt_entry(word selector, Descriptor&);
}
}
-#define LSW(x) ((dword)(x)&0xFFFF)
-#define MSW(x) (((dword)(x) >> 16) & 0xFFFF)
+#define LSW(x) ((u32)(x)&0xFFFF)
+#define MSW(x) (((u32)(x) >> 16) & 0xFFFF)
#define LSB(x) ((x)&0xFF)
#define MSB(x) (((x) >> 8) & 0xFF)
@@ -220,17 +220,17 @@ void write_gdt_entry(word selector, Descriptor&);
#define memory_barrier() asm volatile("" :: \
: "memory")
-inline dword cpu_cr3()
+inline u32 cpu_cr3()
{
- dword cr3;
+ u32 cr3;
asm volatile("movl %%cr3, %%eax"
: "=a"(cr3));
return cr3;
}
-inline dword cpu_flags()
+inline u32 cpu_flags()
{
- dword flags;
+ u32 flags;
asm volatile(
"pushf\n"
"pop %0\n"
@@ -259,7 +259,7 @@ public:
}
private:
- dword m_flags;
+ u32 m_flags;
};
class InterruptDisabler {
@@ -277,7 +277,7 @@ public:
}
private:
- dword m_flags;
+ u32 m_flags;
};
/* Map IRQ0-15 @ ISR 0x50-0x5F */
@@ -297,14 +297,14 @@ struct PageFaultFlags {
class PageFault {
public:
- PageFault(word code, VirtualAddress vaddr)
+ PageFault(u16 code, VirtualAddress vaddr)
: m_code(code)
, m_vaddr(vaddr)
{
}
VirtualAddress vaddr() const { return m_vaddr; }
- word code() const { return m_code; }
+ u16 code() const { return m_code; }
bool is_not_present() const { return (m_code & 1) == PageFaultFlags::NotPresent; }
bool is_protection_violation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; }
@@ -315,86 +315,86 @@ public:
bool is_instruction_fetch() const { return (m_code & 8) == PageFaultFlags::InstructionFetch; }
private:
- word m_code;
+ u16 m_code;
VirtualAddress m_vaddr;
};
struct [[gnu::packed]] RegisterDump
{
- word ss;
- word gs;
- word fs;
- word es;
- word ds;
- dword edi;
- dword esi;
- dword ebp;
- dword esp;
- dword ebx;
- dword edx;
- dword ecx;
- dword eax;
- dword eip;
- word cs;
- word __csPadding;
- dword eflags;
- dword esp_if_crossRing;
- word ss_if_crossRing;
+ u16 ss;
+ u16 gs;
+ u16 fs;
+ u16 es;
+ u16 ds;
+ u32 edi;
+ u32 esi;
+ u32 ebp;
+ u32 esp;
+ u32 ebx;
+ u32 edx;
+ u32 ecx;
+ u32 eax;
+ u32 eip;
+ u16 cs;
+ u16 __csPadding;
+ u32 eflags;
+ u32 esp_if_crossRing;
+ u16 ss_if_crossRing;
};
struct [[gnu::packed]] RegisterDumpWithExceptionCode
{
- word ss;
- word gs;
- word fs;
- word es;
- word ds;
- dword edi;
- dword esi;
- dword ebp;
- dword esp;
- dword ebx;
- dword edx;
- dword ecx;
- dword eax;
- word exception_code;
- word __exception_code_padding;
- dword eip;
- word cs;
- word __csPadding;
- dword eflags;
- dword esp_if_crossRing;
- word ss_if_crossRing;
+ u16 ss;
+ u16 gs;
+ u16 fs;
+ u16 es;
+ u16 ds;
+ u32 edi;
+ u32 esi;
+ u32 ebp;
+ u32 esp;
+ u32 ebx;
+ u32 edx;
+ u32 ecx;
+ u32 eax;
+ u16 exception_code;
+ u16 __exception_code_padding;
+ u32 eip;
+ u16 cs;
+ u16 __csPadding;
+ u32 eflags;
+ u32 esp_if_crossRing;
+ u16 ss_if_crossRing;
};
struct [[gnu::aligned(16)]] FPUState
{
- byte buffer[512];
+ u8 buffer[512];
};
-inline constexpr dword page_base_of(dword address)
+inline constexpr u32 page_base_of(u32 address)
{
return address & 0xfffff000;
}
class CPUID {
public:
- CPUID(dword function) { asm volatile("cpuid"
+ CPUID(u32 function) { asm volatile("cpuid"
: "=a"(m_eax), "=b"(m_ebx), "=c"(m_ecx), "=d"(m_edx)
: "a"(function), "c"(0)); }
- dword eax() const { return m_eax; }
- dword ebx() const { return m_ebx; }
- dword ecx() const { return m_ecx; }
- dword edx() const { return m_edx; }
+ u32 eax() const { return m_eax; }
+ u32 ebx() const { return m_ebx; }
+ u32 ecx() const { return m_ecx; }
+ u32 edx() const { return m_edx; }
private:
- dword m_eax { 0xffffffff };
- dword m_ebx { 0xffffffff };
- dword m_ecx { 0xffffffff };
- dword m_edx { 0xffffffff };
+ u32 m_eax { 0xffffffff };
+ u32 m_ebx { 0xffffffff };
+ u32 m_ecx { 0xffffffff };
+ u32 m_edx { 0xffffffff };
};
-inline void read_tsc(dword& lsw, dword& msw)
+inline void read_tsc(u32& lsw, u32& msw)
{
asm volatile("rdtsc"
: "=d"(msw), "=a"(lsw));
diff --git a/Kernel/CMOS.cpp b/Kernel/CMOS.cpp
index 93b261898f..aa9300d311 100644
--- a/Kernel/CMOS.cpp
+++ b/Kernel/CMOS.cpp
@@ -3,13 +3,13 @@
namespace CMOS {
-byte read(byte index)
+u8 read(u8 index)
{
IO::out8(0x70, index);
return IO::in8(0x71);
}
-void write(byte index, byte data)
+void write(u8 index, u8 data)
{
IO::out8(0x70, index);
IO::out8(0x71, data);
diff --git a/Kernel/CMOS.h b/Kernel/CMOS.h
index e173c0b672..9cee4a3d7a 100644
--- a/Kernel/CMOS.h
+++ b/Kernel/CMOS.h
@@ -4,7 +4,7 @@
namespace CMOS {
-byte read(byte index);
-void write(byte index, byte data);
+u8 read(u8 index);
+void write(u8 index, u8 data);
}
diff --git a/Kernel/Console.cpp b/Kernel/Console.cpp
index 5ee1048557..91ddfd56cd 100644
--- a/Kernel/Console.cpp
+++ b/Kernel/Console.cpp
@@ -28,14 +28,14 @@ bool Console::can_read(FileDescription&) const
return false;
}
-ssize_t Console::read(FileDescription&, byte*, ssize_t)
+ssize_t Console::read(FileDescription&, u8*, ssize_t)
{
// FIXME: Implement reading from the console.
// Maybe we could use a ring buffer for this device?
return 0;
}
-ssize_t Console::write(FileDescription&, const byte* data, ssize_t size)
+ssize_t Console::write(FileDescription&, const u8* data, ssize_t size)
{
if (!size)
return 0;
diff --git a/Kernel/Console.h b/Kernel/Console.h
index e1f4e2d2a3..be43380bc8 100644
--- a/Kernel/Console.h
+++ b/Kernel/Console.h
@@ -7,7 +7,7 @@
class ConsoleImplementation {
public:
virtual ~ConsoleImplementation();
- virtual void on_sysconsole_receive(byte) = 0;
+ virtual void on_sysconsole_receive(u8) = 0;
};
class Console final : public CharacterDevice {
@@ -21,8 +21,8 @@ public:
// ^CharacterDevice
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override { return true; }
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual const char* class_name() const override { return "Console"; }
void set_implementation(ConsoleImplementation* implementation) { m_implementation = implementation; }
diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp
index a59587181d..14416fff52 100644
--- a/Kernel/Devices/BXVGADevice.cpp
+++ b/Kernel/Devices/BXVGADevice.cpp
@@ -43,7 +43,7 @@ BXVGADevice::BXVGADevice()
m_framebuffer_address = PhysicalAddress(find_framebuffer_address());
}
-void BXVGADevice::set_register(word index, word data)
+void BXVGADevice::set_register(u16 index, u16 data)
{
IO::out16(VBE_DISPI_IOPORT_INDEX, index);
IO::out16(VBE_DISPI_IOPORT_DATA, data);
@@ -54,10 +54,10 @@ void BXVGADevice::set_resolution(int width, int height)
m_framebuffer_size = { width, height };
set_register(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
- set_register(VBE_DISPI_INDEX_XRES, (word)width);
- set_register(VBE_DISPI_INDEX_YRES, (word)height);
- set_register(VBE_DISPI_INDEX_VIRT_WIDTH, (word)width);
- set_register(VBE_DISPI_INDEX_VIRT_HEIGHT, (word)height * 2);
+ set_register(VBE_DISPI_INDEX_XRES, (u16)width);
+ set_register(VBE_DISPI_INDEX_YRES, (u16)height);
+ set_register(VBE_DISPI_INDEX_VIRT_WIDTH, (u16)width);
+ set_register(VBE_DISPI_INDEX_VIRT_HEIGHT, (u16)height * 2);
set_register(VBE_DISPI_INDEX_BPP, 32);
set_register(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
set_register(VBE_DISPI_INDEX_BANK, 0);
@@ -66,15 +66,15 @@ void BXVGADevice::set_resolution(int width, int height)
void BXVGADevice::set_y_offset(int offset)
{
ASSERT(offset <= m_framebuffer_size.height());
- set_register(VBE_DISPI_INDEX_Y_OFFSET, (word)offset);
+ set_register(VBE_DISPI_INDEX_Y_OFFSET, (u16)offset);
}
-dword BXVGADevice::find_framebuffer_address()
+u32 BXVGADevice::find_framebuffer_address()
{
// NOTE: The QEMU card has the same PCI ID as the Bochs one.
static const PCI::ID bochs_vga_id = { 0x1234, 0x1111 };
static const PCI::ID virtualbox_vga_id = { 0x80ee, 0xbeef };
- dword framebuffer_address = 0;
+ u32 framebuffer_address = 0;
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;
@@ -133,12 +133,12 @@ bool BXVGADevice::can_write(FileDescription&) const
ASSERT_NOT_REACHED();
}
-ssize_t BXVGADevice::read(FileDescription&, byte*, ssize_t)
+ssize_t BXVGADevice::read(FileDescription&, u8*, ssize_t)
{
ASSERT_NOT_REACHED();
}
-ssize_t BXVGADevice::write(FileDescription&, const byte*, ssize_t)
+ssize_t BXVGADevice::write(FileDescription&, const u8*, ssize_t)
{
ASSERT_NOT_REACHED();
}
diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h
index 807113cd85..ddafef6cf2 100644
--- a/Kernel/Devices/BXVGADevice.h
+++ b/Kernel/Devices/BXVGADevice.h
@@ -20,18 +20,18 @@ public:
virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override;
virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t, int prot) override;
- size_t framebuffer_size_in_bytes() const { return m_framebuffer_size.area() * sizeof(dword) * 2; }
+ size_t framebuffer_size_in_bytes() const { return m_framebuffer_size.area() * sizeof(u32) * 2; }
Size framebuffer_size() const { return m_framebuffer_size; }
private:
virtual const char* class_name() const override { return "BXVGA"; }
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
- void set_register(word index, word value);
- dword find_framebuffer_address();
+ void set_register(u16 index, u16 value);
+ u32 find_framebuffer_address();
PhysicalAddress m_framebuffer_address;
Size m_framebuffer_size;
diff --git a/Kernel/Devices/DebugLogDevice.cpp b/Kernel/Devices/DebugLogDevice.cpp
index da6720f139..d4ec0428d8 100644
--- a/Kernel/Devices/DebugLogDevice.cpp
+++ b/Kernel/Devices/DebugLogDevice.cpp
@@ -19,7 +19,7 @@ DebugLogDevice::~DebugLogDevice()
{
}
-ssize_t DebugLogDevice::write(FileDescription&, const byte* data, ssize_t data_size)
+ssize_t DebugLogDevice::write(FileDescription&, const u8* data, ssize_t data_size)
{
for (int i = 0; i < data_size; ++i)
IO::out8(0xe9, data[i]);
diff --git a/Kernel/Devices/DebugLogDevice.h b/Kernel/Devices/DebugLogDevice.h
index 2ef4ade046..1c3296a286 100644
--- a/Kernel/Devices/DebugLogDevice.h
+++ b/Kernel/Devices/DebugLogDevice.h
@@ -9,8 +9,8 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override { return 0; }
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return 0; }
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_write(FileDescription&) const override { return true; }
virtual bool can_read(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "DebugLogDevice"; }
diff --git a/Kernel/Devices/DiskDevice.cpp b/Kernel/Devices/DiskDevice.cpp
index ce131307ca..7541e5f01e 100644
--- a/Kernel/Devices/DiskDevice.cpp
+++ b/Kernel/Devices/DiskDevice.cpp
@@ -8,21 +8,21 @@ DiskDevice::~DiskDevice()
{
}
-bool DiskDevice::read(DiskOffset offset, unsigned length, byte* out) const
+bool DiskDevice::read(DiskOffset offset, unsigned length, u8* out) const
{
ASSERT((offset % block_size()) == 0);
ASSERT((length % block_size()) == 0);
- dword first_block = offset / block_size();
- dword end_block = (offset + length) / block_size();
+ u32 first_block = offset / block_size();
+ u32 end_block = (offset + length) / block_size();
return const_cast<DiskDevice*>(this)->read_blocks(first_block, end_block - first_block, out);
}
-bool DiskDevice::write(DiskOffset offset, unsigned length, const byte* in)
+bool DiskDevice::write(DiskOffset offset, unsigned length, const u8* in)
{
ASSERT((offset % block_size()) == 0);
ASSERT((length % block_size()) == 0);
- dword first_block = offset / block_size();
- dword end_block = (offset + length) / block_size();
+ u32 first_block = offset / block_size();
+ u32 end_block = (offset + length) / block_size();
ASSERT(first_block <= 0xffffffff);
ASSERT(end_block <= 0xffffffff);
return write_blocks(first_block, end_block - first_block, in);
diff --git a/Kernel/Devices/DiskDevice.h b/Kernel/Devices/DiskDevice.h
index 78290cfd3f..9912d80b89 100644
--- a/Kernel/Devices/DiskDevice.h
+++ b/Kernel/Devices/DiskDevice.h
@@ -4,21 +4,21 @@
#include <AK/Types.h>
// FIXME: Support 64-bit DiskOffset
-typedef dword DiskOffset;
+typedef u32 DiskOffset;
class DiskDevice : public RefCounted<DiskDevice> {
public:
virtual ~DiskDevice();
virtual unsigned block_size() const = 0;
- virtual bool read_block(unsigned index, byte*) const = 0;
- virtual bool write_block(unsigned index, const byte*) = 0;
+ virtual bool read_block(unsigned index, u8*) const = 0;
+ virtual bool write_block(unsigned index, const u8*) = 0;
virtual const char* class_name() const = 0;
- bool read(DiskOffset, unsigned length, byte*) const;
- bool write(DiskOffset, unsigned length, const byte*);
+ bool read(DiskOffset, unsigned length, u8*) const;
+ bool write(DiskOffset, unsigned length, const u8*);
- virtual bool read_blocks(unsigned index, word count, byte*) = 0;
- virtual bool write_blocks(unsigned index, word count, const byte*) = 0;
+ virtual bool read_blocks(unsigned index, u16 count, u8*) = 0;
+ virtual bool write_blocks(unsigned index, u16 count, const u8*) = 0;
protected:
DiskDevice();
diff --git a/Kernel/Devices/DiskPartition.cpp b/Kernel/Devices/DiskPartition.cpp
index 7fc60c733d..ec0db9275e 100644
--- a/Kernel/Devices/DiskPartition.cpp
+++ b/Kernel/Devices/DiskPartition.cpp
@@ -22,7 +22,7 @@ unsigned DiskPartition::block_size() const
return m_device->block_size();
}
-bool DiskPartition::read_block(unsigned index, byte* out) const
+bool DiskPartition::read_block(unsigned index, u8* out) const
{
#ifdef OFFD_DEBUG
kprintf("DiskPartition::read_block %u (really: %u)\n", index, m_block_offset + index);
@@ -31,7 +31,7 @@ bool DiskPartition::read_block(unsigned index, byte* out) const
return m_device->read_block(m_block_offset + index, out);
}
-bool DiskPartition::write_block(unsigned index, const byte* data)
+bool DiskPartition::write_block(unsigned index, const u8* data)
{
#ifdef OFFD_DEBUG
kprintf("DiskPartition::write_block %u (really: %u)\n", index, m_block_offset + index);
@@ -40,7 +40,7 @@ bool DiskPartition::write_block(unsigned index, const byte* data)
return m_device->write_block(m_block_offset + index, data);
}
-bool DiskPartition::read_blocks(unsigned index, word count, byte* out)
+bool DiskPartition::read_blocks(unsigned index, u16 count, u8* out)
{
#ifdef OFFD_DEBUG
kprintf("DiskPartition::read_blocks %u (really: %u) count=%u\n", index, m_block_offset + index, count);
@@ -49,7 +49,7 @@ bool DiskPartition::read_blocks(unsigned index, word count, byte* out)
return m_device->read_blocks(m_block_offset + index, count, out);
}
-bool DiskPartition::write_blocks(unsigned index, word count, const byte* data)
+bool DiskPartition::write_blocks(unsigned index, u16 count, const u8* data)
{
#ifdef OFFD_DEBUG
kprintf("DiskPartition::write_blocks %u (really: %u) count=%u\n", index, m_block_offset + index, count);
diff --git a/Kernel/Devices/DiskPartition.h b/Kernel/Devices/DiskPartition.h
index d77eb67a2e..36eea5a7eb 100644
--- a/Kernel/Devices/DiskPartition.h
+++ b/Kernel/Devices/DiskPartition.h
@@ -9,10 +9,10 @@ public:
virtual ~DiskPartition();
virtual unsigned block_size() const override;
- virtual bool read_block(unsigned index, byte* out) const override;
- virtual bool write_block(unsigned index, const byte*) override;
- virtual bool read_blocks(unsigned index, word count, byte*) override;
- virtual bool write_blocks(unsigned index, word count, const byte*) override;
+ virtual bool read_block(unsigned index, u8* out) const override;
+ virtual bool write_block(unsigned index, const u8*) override;
+ virtual bool read_blocks(unsigned index, u16 count, u8*) override;
+ virtual bool write_blocks(unsigned index, u16 count, const u8*) override;
private:
virtual const char* class_name() const override;
diff --git a/Kernel/Devices/FileBackedDiskDevice.cpp b/Kernel/Devices/FileBackedDiskDevice.cpp
index 8b05e6e697..4c10f2e135 100644
--- a/Kernel/Devices/FileBackedDiskDevice.cpp
+++ b/Kernel/Devices/FileBackedDiskDevice.cpp
@@ -32,19 +32,19 @@ unsigned FileBackedDiskDevice::block_size() const
return m_block_size;
}
-bool FileBackedDiskDevice::read_block(unsigned index, byte* out) const
+bool FileBackedDiskDevice::read_block(unsigned index, u8* out) const
{
DiskOffset offset = index * m_block_size;
return read_internal(offset, block_size(), out);
}
-bool FileBackedDiskDevice::write_block(unsigned index, const byte* data)
+bool FileBackedDiskDevice::write_block(unsigned index, const u8* data)
{
DiskOffset offset = index * m_block_size;
return write_internal(offset, block_size(), data);
}
-bool FileBackedDiskDevice::read_internal(DiskOffset offset, unsigned length, byte* out) const
+bool FileBackedDiskDevice::read_internal(DiskOffset offset, unsigned length, u8* out) const
{
#ifndef IGNORE_FILE_LENGTH
if (offset + length >= m_file_length)
@@ -54,12 +54,12 @@ bool FileBackedDiskDevice::read_internal(DiskOffset offset, unsigned length, byt
printf("[FileBackedDiskDevice] Read device @ offset %llx, length %u\n", offset, length);
#endif
fseeko(m_file, offset, SEEK_SET);
- unsigned nread = fread(out, sizeof(byte), length, m_file);
+ unsigned nread = fread(out, sizeof(u8), length, m_file);
ASSERT(nread == length);
return true;
}
-bool FileBackedDiskDevice::write_internal(DiskOffset offset, unsigned length, const byte* data)
+bool FileBackedDiskDevice::write_internal(DiskOffset offset, unsigned length, const u8* data)
{
#ifndef IGNORE_FILE_LENGTH
if (offset + length >= m_file_length)
@@ -70,7 +70,7 @@ bool FileBackedDiskDevice::write_internal(DiskOffset offset, unsigned length, co
#endif
fseeko(m_file, offset, SEEK_SET);
// size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
- unsigned nwritten = fwrite(data, sizeof(byte), length, m_file);
+ unsigned nwritten = fwrite(data, sizeof(u8), length, m_file);
ASSERT(nwritten == length);
return true;
}
diff --git a/Kernel/Devices/FileBackedDiskDevice.h b/Kernel/Devices/FileBackedDiskDevice.h
index 30c61b5776..a630bdfdd2 100644
--- a/Kernel/Devices/FileBackedDiskDevice.h
+++ b/Kernel/Devices/FileBackedDiskDevice.h
@@ -14,14 +14,14 @@ public:
bool is_valid() const { return m_file; }
virtual unsigned block_size() const override;
- virtual bool read_block(unsigned index, byte* out) const override;
- virtual bool write_block(unsigned index, const byte*) override;
+ virtual bool read_block(unsigned index, u8* out) const override;
+ virtual bool write_block(unsigned index, const u8*) override;
private:
virtual const char* class_name() const override;
- bool read_internal(DiskOffset, unsigned length, byte* out) const;
- bool write_internal(DiskOffset, unsigned length, const byte* data);
+ bool read_internal(DiskOffset, unsigned length, u8* out) const;
+ bool write_internal(DiskOffset, unsigned length, const u8* data);
FileBackedDiskDevice(String&& imagePath, unsigned block_size);
diff --git a/Kernel/Devices/FullDevice.cpp b/Kernel/Devices/FullDevice.cpp
index 6198c174a6..b76a79d5bf 100644
--- a/Kernel/Devices/FullDevice.cpp
+++ b/Kernel/Devices/FullDevice.cpp
@@ -17,14 +17,14 @@ bool FullDevice::can_read(FileDescription&) const
return true;
}
-ssize_t FullDevice::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t FullDevice::read(FileDescription&, u8* buffer, ssize_t size)
{
ssize_t count = min(PAGE_SIZE, size);
memset(buffer, 0, (size_t)count);
return count;
}
-ssize_t FullDevice::write(FileDescription&, const byte*, ssize_t size)
+ssize_t FullDevice::write(FileDescription&, const u8*, ssize_t size)
{
if (size == 0)
return 0;
diff --git a/Kernel/Devices/FullDevice.h b/Kernel/Devices/FullDevice.h
index fa4ffcb8bc..9ba58161f1 100644
--- a/Kernel/Devices/FullDevice.h
+++ b/Kernel/Devices/FullDevice.h
@@ -10,8 +10,8 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "FullDevice"; }
diff --git a/Kernel/Devices/IDEDiskDevice.cpp b/Kernel/Devices/IDEDiskDevice.cpp
index 5778805981..186e6f1742 100644
--- a/Kernel/Devices/IDEDiskDevice.cpp
+++ b/Kernel/Devices/IDEDiskDevice.cpp
@@ -106,19 +106,19 @@ unsigned IDEDiskDevice::block_size() const
return 512;
}
-bool IDEDiskDevice::read_blocks(unsigned index, word count, byte* out)
+bool IDEDiskDevice::read_blocks(unsigned index, u16 count, u8* out)
{
if (m_bus_master_base && m_dma_enabled.resource())
return read_sectors_with_dma(index, count, out);
return read_sectors(index, count, out);
}
-bool IDEDiskDevice::read_block(unsigned index, byte* out) const
+bool IDEDiskDevice::read_block(unsigned index, u8* out) const
{
return const_cast<IDEDiskDevice*>(this)->read_blocks(index, 1, out);
}
-bool IDEDiskDevice::write_blocks(unsigned index, word count, const byte* data)
+bool IDEDiskDevice::write_blocks(unsigned index, u16 count, const u8* data)
{
if (m_bus_master_base && m_dma_enabled.resource())
return write_sectors_with_dma(index, count, data);
@@ -129,12 +129,12 @@ bool IDEDiskDevice::write_blocks(unsigned index, word count, const byte* data)
return true;
}
-bool IDEDiskDevice::write_block(unsigned index, const byte* data)
+bool IDEDiskDevice::write_block(unsigned index, const u8* data)
{
return write_blocks(index, 1, data);
}
-static void print_ide_status(byte status)
+static void print_ide_status(u8 status)
{
kprintf("DRQ=%u BSY=%u DRDY=%u DSC=%u DF=%u CORR=%u IDX=%u ERR=%u\n",
(status & ATA_SR_DRQ) != 0,
@@ -166,7 +166,7 @@ bool IDEDiskDevice::wait_for_irq()
void IDEDiskDevice::handle_irq()
{
- byte status = IO::in8(m_io_base + ATA_REG_STATUS);
+ u8 status = IO::in8(m_io_base + ATA_REG_STATUS);
if (status & ATA_SR_ERR) {
print_ide_status(status);
m_device_error = IO::in8(m_io_base + ATA_REG_ERROR);
@@ -192,7 +192,7 @@ void IDEDiskDevice::initialize()
});
#ifdef DISK_DEBUG
- byte status = IO::in8(m_io_base + ATA_REG_STATUS);
+ u8 status = IO::in8(m_io_base + ATA_REG_STATUS);
kprintf("initial status: ");
print_ide_status(status);
#endif
@@ -213,19 +213,19 @@ void IDEDiskDevice::initialize()
ByteBuffer wbuf = ByteBuffer::create_uninitialized(512);
ByteBuffer bbuf = ByteBuffer::create_uninitialized(512);
- byte* b = bbuf.pointer();
- word* w = (word*)wbuf.pointer();
- const word* wbufbase = (word*)wbuf.pointer();
+ u8* b = bbuf.pointer();
+ u16* w = (u16*)wbuf.pointer();
+ const u16* wbufbase = (u16*)wbuf.pointer();
- for (dword i = 0; i < 256; ++i) {
- word data = IO::in16(m_io_base + ATA_REG_DATA);
+ for (u32 i = 0; i < 256; ++i) {
+ u16 data = IO::in16(m_io_base + ATA_REG_DATA);
*(w++) = data;
*(b++) = MSB(data);
*(b++) = LSB(data);
}
// "Unpad" the device name string.
- for (dword i = 93; i > 54 && bbuf[i] == ' '; --i)
+ for (u32 i = 93; i > 54 && bbuf[i] == ' '; --i)
bbuf[i] = 0;
m_cylinders = wbufbase[1];
@@ -249,13 +249,13 @@ void IDEDiskDevice::initialize()
}
}
-static void wait_400ns(word io_base)
+static void wait_400ns(u16 io_base)
{
for (int i = 0; i < 4; ++i)
IO::in8(io_base + ATA_REG_ALTSTATUS);
}
-bool IDEDiskDevice::read_sectors_with_dma(dword lba, word count, byte* outbuf)
+bool IDEDiskDevice::read_sectors_with_dma(u32 lba, u16 count, u8* outbuf)
{
LOCKER(m_lock);
#ifdef DISK_DEBUG
@@ -275,7 +275,7 @@ bool IDEDiskDevice::read_sectors_with_dma(dword lba, word count, byte* outbuf)
IO::out8(m_bus_master_base, 0);
// Write the PRDT location
- IO::out32(m_bus_master_base + 4, (dword)&m_prdt);
+ IO::out32(m_bus_master_base + 4, (u32)&m_prdt);
// Turn on "Interrupt" and "Error" flag. The error flag should be cleared by hardware.
IO::out8(m_bus_master_base + 2, IO::in8(m_bus_master_base + 2) | 0x6);
@@ -332,7 +332,7 @@ bool IDEDiskDevice::read_sectors_with_dma(dword lba, word count, byte* outbuf)
return true;
}
-bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
+bool IDEDiskDevice::read_sectors(u32 start_sector, u16 count, u8* outbuf)
{
ASSERT(count <= 256);
LOCKER(m_lock);
@@ -369,7 +369,7 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
if (m_device_error)
return false;
- byte status = IO::in8(m_io_base + ATA_REG_STATUS);
+ u8 status = IO::in8(m_io_base + ATA_REG_STATUS);
ASSERT(status & ATA_SR_DRQ);
#ifdef DISK_DEBUG
kprintf("Retrieving %u bytes (status=%b), outbuf=%p...\n", count * 512, status, outbuf);
@@ -379,7 +379,7 @@ bool IDEDiskDevice::read_sectors(dword start_sector, word count, byte* outbuf)
return true;
}
-bool IDEDiskDevice::write_sectors_with_dma(dword lba, word count, const byte* inbuf)
+bool IDEDiskDevice::write_sectors_with_dma(u32 lba, u16 count, const u8* inbuf)
{
LOCKER(m_lock);
#ifdef DISK_DEBUG
@@ -401,7 +401,7 @@ bool IDEDiskDevice::write_sectors_with_dma(dword lba, word count, const byte* in
IO::out8(m_bus_master_base, 0);
// Write the PRDT location
- IO::out32(m_bus_master_base + 4, (dword)&m_prdt);
+ IO::out32(m_bus_master_base + 4, (u32)&m_prdt);
// Turn on "Interrupt" and "Error" flag. The error flag should be cleared by hardware.
IO::out8(m_bus_master_base + 2, IO::in8(m_bus_master_base + 2) | 0x6);
@@ -453,7 +453,7 @@ bool IDEDiskDevice::write_sectors_with_dma(dword lba, word count, const byte* in
return true;
}
-bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* data)
+bool IDEDiskDevice::write_sectors(u32 start_sector, u16 count, const u8* data)
{
ASSERT(count <= 256);
LOCKER(m_lock);
@@ -484,7 +484,7 @@ bool IDEDiskDevice::write_sectors(dword start_sector, word count, const byte* da
while (!(IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_DRQ))
;
- byte status = IO::in8(m_io_base + ATA_REG_STATUS);
+ u8 status = IO::in8(m_io_base + ATA_REG_STATUS);
ASSERT(status & ATA_SR_DRQ);
IO::repeated_out16(m_io_base + ATA_REG_DATA, data, count * 256);
diff --git a/Kernel/Devices/IDEDiskDevice.h b/Kernel/Devices/IDEDiskDevice.h
index 93f2f56f22..23a3b53fbb 100644
--- a/Kernel/Devices/IDEDiskDevice.h
+++ b/Kernel/Devices/IDEDiskDevice.h
@@ -10,8 +10,8 @@
struct PhysicalRegionDescriptor {
PhysicalAddress offset;
- word size { 0 };
- word end_of_table { 0 };
+ u16 size { 0 };
+ u16 end_of_table { 0 };
};
class IDEDiskDevice final : public IRQHandler
@@ -23,10 +23,10 @@ public:
// ^DiskDevice
virtual unsigned block_size() const override;
- virtual bool read_block(unsigned index, byte*) const override;
- virtual bool write_block(unsigned index, const byte*) override;
- virtual bool read_blocks(unsigned index, word count, byte*) override;
- virtual bool write_blocks(unsigned index, word count, const byte*) override;
+ virtual bool read_block(unsigned index, u8*) const override;
+ virtual bool write_block(unsigned index, const u8*) override;
+ virtual bool read_blocks(unsigned index, u16 count, u8*) override;
+ virtual bool write_blocks(unsigned index, u16 count, const u8*) override;
protected:
IDEDiskDevice();
@@ -40,22 +40,22 @@ private:
void initialize();
bool wait_for_irq();
- bool read_sectors_with_dma(dword lba, word count, byte*);
- bool write_sectors_with_dma(dword lba, word count, const byte*);
- bool read_sectors(dword lba, word count, byte* buffer);
- bool write_sectors(dword lba, word count, const byte* data);
+ bool read_sectors_with_dma(u32 lba, u16 count, u8*);
+ bool write_sectors_with_dma(u32 lba, u16 count, const u8*);
+ bool read_sectors(u32 lba, u16 count, u8* buffer);
+ bool write_sectors(u32 lba, u16 count, const u8* data);
Lock m_lock { "IDEDiskDevice" };
- word m_cylinders { 0 };
- word m_heads { 0 };
- word m_sectors_per_track { 0 };
- word m_io_base { 0 };
+ u16 m_cylinders { 0 };
+ u16 m_heads { 0 };
+ u16 m_sectors_per_track { 0 };
+ u16 m_io_base { 0 };
volatile bool m_interrupted { false };
- volatile byte m_device_error { 0 };
+ volatile u8 m_device_error { 0 };
PCI::Address m_pci_address;
PhysicalRegionDescriptor m_prdt;
RefPtr<PhysicalPage> m_dma_buffer_page;
- word m_bus_master_base { 0 };
+ u16 m_bus_master_base { 0 };
Lockable<bool> m_dma_enabled;
};
diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp
index d939691a92..523de60205 100644
--- a/Kernel/Devices/KeyboardDevice.cpp
+++ b/Kernel/Devices/KeyboardDevice.cpp
@@ -223,7 +223,7 @@ static KeyCode shifted_key_map[0x100] = {
Key_Logo,
};
-void KeyboardDevice::key_state_changed(byte raw, bool pressed)
+void KeyboardDevice::key_state_changed(u8 raw, bool pressed)
{
Event event;
event.key = (m_modifiers & Mod_Shift) ? shifted_key_map[raw] : unshifted_key_map[raw];
@@ -239,11 +239,11 @@ void KeyboardDevice::key_state_changed(byte raw, bool pressed)
void KeyboardDevice::handle_irq()
{
for (;;) {
- byte status = IO::in8(I8042_STATUS);
+ u8 status = IO::in8(I8042_STATUS);
if (!(((status & I8042_WHICH_BUFFER) == I8042_KEYBOARD_BUFFER) && (status & I8042_BUFFER_FULL)))
return;
- byte raw = IO::in8(I8042_BUFFER);
- byte ch = raw & 0x7f;
+ u8 raw = IO::in8(I8042_BUFFER);
+ u8 ch = raw & 0x7f;
bool pressed = !(raw & 0x80);
#ifdef KEYBOARD_DEBUG
@@ -316,7 +316,7 @@ bool KeyboardDevice::can_read(FileDescription&) const
return !m_queue.is_empty();
}
-ssize_t KeyboardDevice::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t KeyboardDevice::read(FileDescription&, u8* buffer, ssize_t size)
{
ssize_t nread = 0;
while (nread < size) {
@@ -332,7 +332,7 @@ ssize_t KeyboardDevice::read(FileDescription&, byte* buffer, ssize_t size)
return nread;
}
-ssize_t KeyboardDevice::write(FileDescription&, const byte*, ssize_t)
+ssize_t KeyboardDevice::write(FileDescription&, const u8*, ssize_t)
{
return 0;
}
diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h
index 1edffe3869..37472daf4d 100644
--- a/Kernel/Devices/KeyboardDevice.h
+++ b/Kernel/Devices/KeyboardDevice.h
@@ -23,9 +23,9 @@ public:
void set_client(KeyboardClient* client) { m_client = client; }
// ^CharacterDevice
- virtual ssize_t read(FileDescription&, byte* buffer, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8* buffer, ssize_t) override;
virtual bool can_read(FileDescription&) const override;
- virtual ssize_t write(FileDescription&, const byte* buffer, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8* buffer, ssize_t) override;
virtual bool can_write(FileDescription&) const override { return true; }
private:
@@ -35,8 +35,8 @@ private:
// ^CharacterDevice
virtual const char* class_name() const override { return "KeyboardDevice"; }
- void key_state_changed(byte raw, bool pressed);
- void update_modifier(byte modifier, bool state)
+ void key_state_changed(u8 raw, bool pressed);
+ void update_modifier(u8 modifier, bool state)
{
if (state)
m_modifiers |= modifier;
@@ -46,7 +46,7 @@ private:
KeyboardClient* m_client { nullptr };
CircularQueue<Event, 16> m_queue;
- byte m_modifiers { 0 };
+ u8 m_modifiers { 0 };
};
class KeyboardClient {
diff --git a/Kernel/Devices/MBRPartitionTable.h b/Kernel/Devices/MBRPartitionTable.h
index 920bc35284..e6f7962343 100644
--- a/Kernel/Devices/MBRPartitionTable.h
+++ b/Kernel/Devices/MBRPartitionTable.h
@@ -8,23 +8,23 @@
#define MBR_SIGNATURE 0xaa55
struct MBRPartitionEntry {
- byte status;
- byte chs1[3];
- byte type;
- byte chs2[3];
- dword offset;
- dword length;
+ u8 status;
+ u8 chs1[3];
+ u8 type;
+ u8 chs2[3];
+ u32 offset;
+ u32 length;
} __attribute__((packed));
struct MBRPartitionHeader {
- byte code1[218];
- word ts_zero;
- byte ts_drive, ts_seconds, ts_minutes, ts_hours;
- byte code2[216];
- dword disk_signature;
- word disk_signature_zero;
+ u8 code1[218];
+ u16 ts_zero;
+ u8 ts_drive, ts_seconds, ts_minutes, ts_hours;
+ u8 code2[216];
+ u32 disk_signature;
+ u16 disk_signature_zero;
MBRPartitionEntry entry[4];
- word mbr_signature;
+ u16 mbr_signature;
} __attribute__((packed));
class MBRPartitionTable {
@@ -43,5 +43,5 @@ private:
ByteBuffer read_header() const;
const MBRPartitionHeader& header() const;
- byte m_cached_header[512];
+ u8 m_cached_header[512];
};
diff --git a/Kernel/Devices/NullDevice.cpp b/Kernel/Devices/NullDevice.cpp
index 1d4cfcdaf6..b4fa429219 100644
--- a/Kernel/Devices/NullDevice.cpp
+++ b/Kernel/Devices/NullDevice.cpp
@@ -25,12 +25,12 @@ bool NullDevice::can_read(FileDescription&) const
return true;
}
-ssize_t NullDevice::read(FileDescription&, byte*, ssize_t)
+ssize_t NullDevice::read(FileDescription&, u8*, ssize_t)
{
return 0;
}
-ssize_t NullDevice::write(FileDescription&, const byte*, ssize_t buffer_size)
+ssize_t NullDevice::write(FileDescription&, const u8*, ssize_t buffer_size)
{
return min(PAGE_SIZE, buffer_size);
}
diff --git a/Kernel/Devices/NullDevice.h b/Kernel/Devices/NullDevice.h
index 964565c690..822e61508d 100644
--- a/Kernel/Devices/NullDevice.h
+++ b/Kernel/Devices/NullDevice.h
@@ -12,8 +12,8 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_write(FileDescription&) const override { return true; }
virtual bool can_read(FileDescription&) const override;
virtual const char* class_name() const override { return "NullDevice"; }
diff --git a/Kernel/Devices/PCSpeaker.cpp b/Kernel/Devices/PCSpeaker.cpp
index 5fa9bd83e1..853f53bf77 100644
--- a/Kernel/Devices/PCSpeaker.cpp
+++ b/Kernel/Devices/PCSpeaker.cpp
@@ -6,7 +6,7 @@
void PCSpeaker::tone_on(int frequency)
{
IO::out8(PIT_CTL, TIMER2_SELECT | WRITE_WORD | MODE_SQUARE_WAVE);
- word timer_reload = BASE_FREQUENCY / frequency;
+ u16 timer_reload = BASE_FREQUENCY / frequency;
IO::out8(TIMER2_CTL, LSB(timer_reload));
IO::out8(TIMER2_CTL, MSB(timer_reload));
diff --git a/Kernel/Devices/PS2MouseDevice.cpp b/Kernel/Devices/PS2MouseDevice.cpp
index b48b537e8b..26a2083280 100644
--- a/Kernel/Devices/PS2MouseDevice.cpp
+++ b/Kernel/Devices/PS2MouseDevice.cpp
@@ -39,11 +39,11 @@ PS2MouseDevice& PS2MouseDevice::the()
void PS2MouseDevice::handle_irq()
{
for (;;) {
- byte status = IO::in8(I8042_STATUS);
+ u8 status = IO::in8(I8042_STATUS);
if (!(((status & I8042_WHICH_BUFFER) == I8042_MOUSE_BUFFER) && (status & I8042_BUFFER_FULL)))
return;
- byte data = IO::in8(I8042_BUFFER);
+ u8 data = IO::in8(I8042_BUFFER);
m_data[m_data_state] = data;
auto commit_packet = [&] {
@@ -113,13 +113,13 @@ void PS2MouseDevice::parse_data_packet()
m_queue.enqueue(packet);
}
-void PS2MouseDevice::wait_then_write(byte port, byte data)
+void PS2MouseDevice::wait_then_write(u8 port, u8 data)
{
prepare_for_output();
IO::out8(port, data);
}
-byte PS2MouseDevice::wait_then_read(byte port)
+u8 PS2MouseDevice::wait_then_read(u8 port)
{
prepare_for_input();
return IO::in8(port);
@@ -135,7 +135,7 @@ void PS2MouseDevice::initialize()
// Enable the PS/2 mouse IRQ (12).
// NOTE: The keyboard uses IRQ 1 (and is enabled by bit 0 in this register).
- byte status = wait_then_read(0x60) | 2;
+ u8 status = wait_then_read(0x60) | 2;
wait_then_write(0x64, 0x60);
wait_then_write(0x60, status);
@@ -149,7 +149,7 @@ void PS2MouseDevice::initialize()
mouse_write(PS2MOUSE_GET_DEVICE_ID);
expect_ack();
- byte device_id = mouse_read();
+ u8 device_id = mouse_read();
if (device_id != PS2MOUSE_INTELLIMOUSE_ID) {
// Send magical wheel initiation sequence.
@@ -183,7 +183,7 @@ void PS2MouseDevice::initialize()
void PS2MouseDevice::expect_ack()
{
- byte data = mouse_read();
+ u8 data = mouse_read();
ASSERT(data == I8042_ACK);
}
@@ -203,7 +203,7 @@ void PS2MouseDevice::prepare_for_output()
}
}
-void PS2MouseDevice::mouse_write(byte data)
+void PS2MouseDevice::mouse_write(u8 data)
{
prepare_for_output();
IO::out8(0x64, 0xd4);
@@ -211,7 +211,7 @@ void PS2MouseDevice::mouse_write(byte data)
IO::out8(0x60, data);
}
-byte PS2MouseDevice::mouse_read()
+u8 PS2MouseDevice::mouse_read()
{
prepare_for_input();
return IO::in8(0x60);
@@ -222,7 +222,7 @@ bool PS2MouseDevice::can_read(FileDescription&) const
return !m_queue.is_empty();
}
-ssize_t PS2MouseDevice::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t PS2MouseDevice::read(FileDescription&, u8* buffer, ssize_t size)
{
ssize_t nread = 0;
while (nread < size) {
@@ -238,7 +238,7 @@ ssize_t PS2MouseDevice::read(FileDescription&, byte* buffer, ssize_t size)
return nread;
}
-ssize_t PS2MouseDevice::write(FileDescription&, const byte*, ssize_t)
+ssize_t PS2MouseDevice::write(FileDescription&, const u8*, ssize_t)
{
return 0;
}
diff --git a/Kernel/Devices/PS2MouseDevice.h b/Kernel/Devices/PS2MouseDevice.h
index e63db8a998..1a91f556a9 100644
--- a/Kernel/Devices/PS2MouseDevice.h
+++ b/Kernel/Devices/PS2MouseDevice.h
@@ -15,8 +15,8 @@ public:
// ^CharacterDevice
virtual bool can_read(FileDescription&) const override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_write(FileDescription&) const override { return true; }
private:
@@ -29,15 +29,15 @@ private:
void initialize();
void prepare_for_input();
void prepare_for_output();
- void mouse_write(byte);
- byte mouse_read();
- void wait_then_write(byte port, byte data);
- byte wait_then_read(byte port);
+ void mouse_write(u8);
+ u8 mouse_read();
+ void wait_then_write(u8 port, u8 data);
+ u8 wait_then_read(u8 port);
void parse_data_packet();
void expect_ack();
CircularQueue<MousePacket, 100> m_queue;
- byte m_data_state { 0 };
- byte m_data[4];
+ u8 m_data_state { 0 };
+ u8 m_data[4];
bool m_has_wheel { false };
};
diff --git a/Kernel/Devices/RandomDevice.cpp b/Kernel/Devices/RandomDevice.cpp
index c5ff3f2562..5fcd4ace1a 100644
--- a/Kernel/Devices/RandomDevice.cpp
+++ b/Kernel/Devices/RandomDevice.cpp
@@ -10,10 +10,10 @@ RandomDevice::~RandomDevice()
{
}
-static dword next = 1;
+static u32 next = 1;
#define MY_RAND_MAX 4294967295U
-dword RandomDevice::random_value()
+u32 RandomDevice::random_value()
{
next = next * 1103515245 + 12345;
return next;
@@ -31,18 +31,18 @@ bool RandomDevice::can_read(FileDescription&) const
return true;
}
-ssize_t RandomDevice::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t RandomDevice::read(FileDescription&, u8* buffer, ssize_t size)
{
const int range = 'z' - 'a';
ssize_t nread = min(size, PAGE_SIZE);
for (ssize_t i = 0; i < nread; ++i) {
- dword r = random_value() % range;
- buffer[i] = (byte)('a' + r);
+ u32 r = random_value() % range;
+ buffer[i] = (u8)('a' + r);
}
return nread;
}
-ssize_t RandomDevice::write(FileDescription&, const byte*, ssize_t size)
+ssize_t RandomDevice::write(FileDescription&, const u8*, ssize_t size)
{
// FIXME: Use input for entropy? I guess that could be a neat feature?
return min(PAGE_SIZE, size);
diff --git a/Kernel/Devices/RandomDevice.h b/Kernel/Devices/RandomDevice.h
index 4d6dce159e..b1a3e7b0d4 100644
--- a/Kernel/Devices/RandomDevice.h
+++ b/Kernel/Devices/RandomDevice.h
@@ -8,12 +8,12 @@ public:
RandomDevice();
virtual ~RandomDevice() override;
- static dword random_value();
+ static u32 random_value();
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "RandomDevice"; }
diff --git a/Kernel/Devices/SerialDevice.cpp b/Kernel/Devices/SerialDevice.cpp
index d945e4c1d4..7f555ae807 100644
--- a/Kernel/Devices/SerialDevice.cpp
+++ b/Kernel/Devices/SerialDevice.cpp
@@ -17,7 +17,7 @@ bool SerialDevice::can_read(FileDescription&) const
return (get_line_status() & DataReady) != 0;
}
-ssize_t SerialDevice::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t SerialDevice::read(FileDescription&, u8* buffer, ssize_t size)
{
if (!size)
return 0;
@@ -35,7 +35,7 @@ bool SerialDevice::can_write(FileDescription&) const
return (get_line_status() & EmptyTransmitterHoldingRegister) != 0;
}
-ssize_t SerialDevice::write(FileDescription&, const byte* buffer, ssize_t size)
+ssize_t SerialDevice::write(FileDescription&, const u8* buffer, ssize_t size)
{
if (!size)
return 0;
diff --git a/Kernel/Devices/SerialDevice.h b/Kernel/Devices/SerialDevice.h
index 3cccf0c91a..78706e1be8 100644
--- a/Kernel/Devices/SerialDevice.h
+++ b/Kernel/Devices/SerialDevice.h
@@ -13,9 +13,9 @@ public:
// ^CharacterDevice
virtual bool can_read(FileDescription&) const override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
virtual bool can_write(FileDescription&) const override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
enum InterruptEnable {
LowPowerMode = 0x01 << 5,
diff --git a/Kernel/Devices/ZeroDevice.cpp b/Kernel/Devices/ZeroDevice.cpp
index e9eed27af0..cfb3e3b4c3 100644
--- a/Kernel/Devices/ZeroDevice.cpp
+++ b/Kernel/Devices/ZeroDevice.cpp
@@ -16,14 +16,14 @@ bool ZeroDevice::can_read(FileDescription&) const
return true;
}
-ssize_t ZeroDevice::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t ZeroDevice::read(FileDescription&, u8* buffer, ssize_t size)
{
ssize_t count = min(PAGE_SIZE, size);
memset(buffer, 0, (size_t)count);
return count;
}
-ssize_t ZeroDevice::write(FileDescription&, const byte*, ssize_t size)
+ssize_t ZeroDevice::write(FileDescription&, const u8*, ssize_t size)
{
return min(PAGE_SIZE, size);
}
diff --git a/Kernel/Devices/ZeroDevice.h b/Kernel/Devices/ZeroDevice.h
index 631fdd8965..42ceff3abe 100644
--- a/Kernel/Devices/ZeroDevice.h
+++ b/Kernel/Devices/ZeroDevice.h
@@ -10,8 +10,8 @@ public:
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override { return true; }
virtual const char* class_name() const override { return "ZeroDevice"; }
diff --git a/Kernel/DoubleBuffer.cpp b/Kernel/DoubleBuffer.cpp
index 3aed54aef7..d4015f12e5 100644
--- a/Kernel/DoubleBuffer.cpp
+++ b/Kernel/DoubleBuffer.cpp
@@ -17,7 +17,7 @@ void DoubleBuffer::flip()
compute_emptiness();
}
-ssize_t DoubleBuffer::write(const byte* data, ssize_t size)
+ssize_t DoubleBuffer::write(const u8* data, ssize_t size)
{
if (!size)
return 0;
@@ -27,7 +27,7 @@ ssize_t DoubleBuffer::write(const byte* data, ssize_t size)
return size;
}
-ssize_t DoubleBuffer::read(byte* data, ssize_t size)
+ssize_t DoubleBuffer::read(u8* data, ssize_t size)
{
if (!size)
return 0;
diff --git a/Kernel/DoubleBuffer.h b/Kernel/DoubleBuffer.h
index 29b60a07cc..44094829c9 100644
--- a/Kernel/DoubleBuffer.h
+++ b/Kernel/DoubleBuffer.h
@@ -12,8 +12,8 @@ public:
{
}
- ssize_t write(const byte*, ssize_t);
- ssize_t read(byte*, ssize_t);
+ ssize_t write(const u8*, ssize_t);
+ ssize_t read(u8*, ssize_t);
bool is_empty() const { return m_empty; }
@@ -24,10 +24,10 @@ private:
void flip();
void compute_emptiness();
- Vector<byte>* m_write_buffer { nullptr };
- Vector<byte>* m_read_buffer { nullptr };
- Vector<byte> m_buffer1;
- Vector<byte> m_buffer2;
+ Vector<u8>* m_write_buffer { nullptr };
+ Vector<u8>* m_read_buffer { nullptr };
+ Vector<u8> m_buffer1;
+ Vector<u8> m_buffer2;
ssize_t m_read_buffer_index { 0 };
bool m_empty { true };
Lock m_lock { "DoubleBuffer" };
diff --git a/Kernel/File.h b/Kernel/File.h
index 9c160428cb..0f26eb6ec1 100644
--- a/Kernel/File.h
+++ b/Kernel/File.h
@@ -49,8 +49,8 @@ public:
virtual bool can_read(FileDescription&) const = 0;
virtual bool can_write(FileDescription&) const = 0;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) = 0;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) = 0;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) = 0;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) = 0;
virtual int ioctl(FileDescription&, unsigned request, unsigned arg);
virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot);
diff --git a/Kernel/FileSystem/DiskBackedFileSystem.cpp b/Kernel/FileSystem/DiskBackedFileSystem.cpp
index 6a3f8ddc90..b6daa759d4 100644
--- a/Kernel/FileSystem/DiskBackedFileSystem.cpp
+++ b/Kernel/FileSystem/DiskBackedFileSystem.cpp
@@ -126,7 +126,7 @@ ByteBuffer DiskBackedFS::read_blocks(unsigned index, unsigned count) const
if (count == 1)
return read_block(index);
auto blocks = ByteBuffer::create_uninitialized(count * block_size());
- byte* out = blocks.pointer();
+ u8* out = blocks.pointer();
for (unsigned i = 0; i < count; ++i) {
auto block = read_block(index + i);
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index ce7cefcc48..69f57d6e23 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -12,7 +12,7 @@
static const ssize_t max_inline_symlink_length = 60;
-static byte to_ext2_file_type(mode_t mode)
+static u8 to_ext2_file_type(mode_t mode)
{
if (is_regular_file(mode))
return EXT2_FT_REG_FILE;
@@ -59,7 +59,7 @@ ByteBuffer Ext2FS::read_super_block() const
bool Ext2FS::write_super_block(const ext2_super_block& sb)
{
LOCKER(m_lock);
- const byte* raw = (const byte*)&sb;
+ const u8* raw = (const u8*)&sb;
bool success;
success = device().write_block(2, raw);
ASSERT(success);
@@ -479,7 +479,7 @@ RefPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
return new_inode;
}
-ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription*) const
+ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDescription*) const
{
Locker inode_locker(m_lock);
ASSERT(offset >= 0);
@@ -490,7 +490,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileD
// This avoids wasting an entire block on short links. (Most links are short.)
if (is_symlink() && size() < max_inline_symlink_length) {
ssize_t nread = min((off_t)size() - offset, static_cast<off_t>(count));
- memcpy(buffer, ((const byte*)m_raw_inode.i_block) + offset, (size_t)nread);
+ memcpy(buffer, ((const u8*)m_raw_inode.i_block) + offset, (size_t)nread);
return nread;
}
@@ -518,7 +518,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileD
ssize_t nread = 0;
int remaining_count = min((off_t)count, (off_t)size() - offset);
- byte* out = buffer;
+ u8* out = buffer;
#ifdef EXT2_DEBUG
kprintf("Ext2FS: Reading up to %u bytes %d bytes into inode %u:%u to %p\n", count, offset, identifier().fsid(), identifier().index(), buffer);
@@ -543,10 +543,10 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileD
return nread;
}
-bool Ext2FSInode::resize(qword new_size)
+bool Ext2FSInode::resize(u64 new_size)
{
- qword block_size = fs().block_size();
- qword old_size = size();
+ u64 block_size = fs().block_size();
+ u64 old_size = size();
int blocks_needed_before = ceil_div(old_size, block_size);
int blocks_needed_after = ceil_div(new_size, block_size);
@@ -585,7 +585,7 @@ bool Ext2FSInode::resize(qword new_size)
return true;
}
-ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data, FileDescription*)
+ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const u8* data, FileDescription*)
{
ASSERT(offset >= 0);
ASSERT(count >= 0);
@@ -598,7 +598,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data,
#ifdef EXT2_DEBUG
dbgprintf("Ext2FSInode: write_bytes poking into i_block array for inline symlink '%s' (%u bytes)\n", String((const char*)data, count).characters(), count);
#endif
- memcpy(((byte*)m_raw_inode.i_block) + offset, data, (size_t)count);
+ memcpy(((u8*)m_raw_inode.i_block) + offset, data, (size_t)count);
if ((offset + count) > (off_t)m_raw_inode.i_size)
m_raw_inode.i_size = offset + count;
set_metadata_dirty(true);
@@ -607,8 +607,8 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data,
}
const ssize_t block_size = fs().block_size();
- qword old_size = size();
- qword new_size = max(static_cast<qword>(offset) + count, (qword)size());
+ u64 old_size = size();
+ u64 new_size = max(static_cast<u64>(offset) + count, (u64)size());
if (!resize(new_size))
return -EIO;
@@ -624,7 +624,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const byte* data,
ssize_t nwritten = 0;
int remaining_count = min((off_t)count, (off_t)new_size - offset);
- const byte* in = data;
+ const u8* in = data;
#ifdef EXT2_DEBUG
dbgprintf("Ext2FSInode::write_bytes: Writing %u bytes %d bytes into inode %u:%u from %p\n", count, offset, fsid(), index(), data);
@@ -733,20 +733,20 @@ bool Ext2FSInode::write_directory(const Vector<FS::DirectoryEntry>& entries)
record_length += occupied_size - directory_size;
dbgprintf("* inode: %u", entry.inode.index());
- dbgprintf(", name_len: %u", word(entry.name_length));
- dbgprintf(", rec_len: %u", word(record_length));
- dbgprintf(", file_type: %u", byte(entry.file_type));
+ dbgprintf(", name_len: %u", u16(entry.name_length));
+ dbgprintf(", rec_len: %u", u16(record_length));
+ dbgprintf(", file_type: %u", u8(entry.file_type));
dbgprintf(", name: %s\n", entry.name);
- stream << dword(entry.inode.index());
- stream << word(record_length);
- stream << byte(entry.name_length);
- stream << byte(entry.file_type);
+ stream << u32(entry.inode.index());
+ stream << u16(record_length);
+ stream << u8(entry.name_length);
+ stream << u8(entry.file_type);
stream << entry.name;
int padding = record_length - entry.name_length - 8;
for (int j = 0; j < padding; ++j)
- stream << byte(0);
+ stream << u8(0);
}
stream.fill_to_end(0);
diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h
index ac460a2daf..e8a1f48feb 100644
--- a/Kernel/FileSystem/Ext2FileSystem.h
+++ b/Kernel/FileSystem/Ext2FileSystem.h
@@ -25,12 +25,12 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const override;
+ virtual ssize_t read_bytes(off_t, ssize_t, u8* buffer, FileDescription*) const override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const override;
virtual InodeIdentifier lookup(StringView name) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescription*) override;
+ virtual ssize_t write_bytes(off_t, ssize_t, const u8* data, FileDescription*) override;
virtual KResult add_child(InodeIdentifier child_id, const StringView& name, mode_t) override;
virtual KResult remove_child(const StringView& name) override;
virtual int set_atime(time_t) override;
@@ -45,7 +45,7 @@ private:
bool write_directory(const Vector<FS::DirectoryEntry>&);
void populate_lookup_cache() const;
- bool resize(qword);
+ bool resize(u64);
Ext2FS& fs();
const Ext2FS& fs() const;
diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp
index c2d0184377..7f00e4064d 100644
--- a/Kernel/FileSystem/FIFO.cpp
+++ b/Kernel/FileSystem/FIFO.cpp
@@ -16,7 +16,7 @@ Lockable<HashTable<FIFO*>>& all_fifos()
return *s_table;
}
-RefPtr<FIFO> FIFO::from_fifo_id(dword id)
+RefPtr<FIFO> FIFO::from_fifo_id(u32 id)
{
auto* ptr = reinterpret_cast<FIFO*>(id);
LOCKER(all_fifos().lock());
@@ -93,7 +93,7 @@ bool FIFO::can_write(FileDescription&) const
return m_buffer.bytes_in_write_buffer() < 4096 || !m_readers;
}
-ssize_t FIFO::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t FIFO::read(FileDescription&, u8* buffer, ssize_t size)
{
if (!m_writers && m_buffer.is_empty())
return 0;
@@ -107,7 +107,7 @@ ssize_t FIFO::read(FileDescription&, byte* buffer, ssize_t size)
return nread;
}
-ssize_t FIFO::write(FileDescription&, const byte* buffer, ssize_t size)
+ssize_t FIFO::write(FileDescription&, const u8* buffer, ssize_t size)
{
if (!m_readers) {
current->process().send_signal(SIGPIPE, &current->process());
diff --git a/Kernel/FileSystem/FIFO.h b/Kernel/FileSystem/FIFO.h
index 73a3915ba0..bd844dc9f0 100644
--- a/Kernel/FileSystem/FIFO.h
+++ b/Kernel/FileSystem/FIFO.h
@@ -8,13 +8,13 @@ class FileDescription;
class FIFO final : public File {
public:
- enum class Direction : byte {
+ enum class Direction : u8 {
Neither,
Reader,
Writer
};
- static RefPtr<FIFO> from_fifo_id(dword);
+ static RefPtr<FIFO> from_fifo_id(u32);
static NonnullRefPtr<FIFO> create(uid_t);
virtual ~FIFO() override;
@@ -28,8 +28,8 @@ public:
private:
// ^File
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override;
virtual String absolute_path(const FileDescription&) const override;
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index d6c75a8fb6..4d9e3013a1 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -127,7 +127,7 @@ off_t FileDescription::seek(off_t offset, int whence)
return m_current_offset;
}
-ssize_t FileDescription::read(byte* buffer, ssize_t count)
+ssize_t FileDescription::read(u8* buffer, ssize_t count)
{
int nread = m_file->read(*this, buffer, count);
if (m_file->is_seekable())
@@ -135,7 +135,7 @@ ssize_t FileDescription::read(byte* buffer, ssize_t count)
return nread;
}
-ssize_t FileDescription::write(const byte* data, ssize_t size)
+ssize_t FileDescription::write(const u8* data, ssize_t size)
{
int nwritten = m_file->write(*this, data, size);
if (m_file->is_seekable())
@@ -167,7 +167,7 @@ bool FileDescription::is_directory() const
return metadata().is_directory();
}
-ssize_t FileDescription::get_dir_entries(byte* buffer, ssize_t size)
+ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
{
auto metadata = this->metadata();
if (!metadata.is_valid())
@@ -180,9 +180,9 @@ ssize_t FileDescription::get_dir_entries(byte* buffer, ssize_t size)
auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate);
BufferStream stream(temp_buffer);
VFS::the().traverse_directory_inode(*m_inode, [&stream](auto& entry) {
- stream << (dword)entry.inode.index();
- stream << (byte)entry.file_type;
- stream << (dword)entry.name_length;
+ stream << (u32)entry.inode.index();
+ stream << (u8)entry.file_type;
+ stream << (u32)entry.name_length;
stream << entry.name;
return true;
});
@@ -318,7 +318,7 @@ const Socket* FileDescription::socket() const
return static_cast<const Socket*>(m_file.ptr());
}
-void FileDescription::set_file_flags(dword flags)
+void FileDescription::set_file_flags(u32 flags)
{
m_is_blocking = !(flags & O_NONBLOCK);
m_should_append = flags & O_APPEND;
diff --git a/Kernel/FileSystem/FileDescription.h b/Kernel/FileSystem/FileDescription.h
index 3da0b99512..da24fef5f8 100644
--- a/Kernel/FileSystem/FileDescription.h
+++ b/Kernel/FileSystem/FileDescription.h
@@ -30,8 +30,8 @@ public:
int close();
off_t seek(off_t, int whence);
- ssize_t read(byte*, ssize_t);
- ssize_t write(const byte* data, ssize_t);
+ ssize_t read(u8*, ssize_t);
+ ssize_t write(const u8* data, ssize_t);
KResult fstat(stat&);
KResult fchmod(mode_t);
@@ -39,7 +39,7 @@ public:
bool can_read();
bool can_write();
- ssize_t get_dir_entries(byte* buffer, ssize_t);
+ ssize_t get_dir_entries(u8* buffer, ssize_t);
ByteBuffer read_entire_file();
@@ -74,8 +74,8 @@ public:
bool should_append() const { return m_should_append; }
void set_should_append(bool s) { m_should_append = s; }
- dword file_flags() const { return m_file_flags; }
- void set_file_flags(dword);
+ u32 file_flags() const { return m_file_flags; }
+ void set_file_flags(u32);
bool is_socket() const;
Socket* socket();
@@ -116,7 +116,7 @@ private:
ByteBuffer m_generator_cache;
- dword m_file_flags { 0 };
+ u32 m_file_flags { 0 };
bool m_is_blocking { true };
bool m_should_append { false };
diff --git a/Kernel/FileSystem/FileSystem.cpp b/Kernel/FileSystem/FileSystem.cpp
index 1a8753e38a..d67bbb6821 100644
--- a/Kernel/FileSystem/FileSystem.cpp
+++ b/Kernel/FileSystem/FileSystem.cpp
@@ -7,13 +7,13 @@
#include <Kernel/VM/MemoryManager.h>
#include <LibC/errno_numbers.h>
-static dword s_lastFileSystemID;
-static HashMap<dword, FS*>* s_fs_map;
+static u32 s_lastFileSystemID;
+static HashMap<u32, FS*>* s_fs_map;
-static HashMap<dword, FS*>& all_fses()
+static HashMap<u32, FS*>& all_fses()
{
if (!s_fs_map)
- s_fs_map = new HashMap<dword, FS*>();
+ s_fs_map = new HashMap<u32, FS*>();
return *s_fs_map;
}
@@ -28,7 +28,7 @@ FS::~FS()
all_fses().remove(m_fsid);
}
-FS* FS::from_fsid(dword id)
+FS* FS::from_fsid(u32 id)
{
auto it = all_fses().find(id);
if (it != all_fses().end())
@@ -36,7 +36,7 @@ FS* FS::from_fsid(dword id)
return nullptr;
}
-FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byte ft)
+FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, u8 ft)
: name_length(strlen(n))
, inode(i)
, file_type(ft)
@@ -45,7 +45,7 @@ FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byte ft)
name[name_length] = '\0';
}
-FS::DirectoryEntry::DirectoryEntry(const char* n, int nl, InodeIdentifier i, byte ft)
+FS::DirectoryEntry::DirectoryEntry(const char* n, int nl, InodeIdentifier i, u8 ft)
: name_length(nl)
, inode(i)
, file_type(ft)
diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h
index 55d48a4ff8..18470a7fb5 100644
--- a/Kernel/FileSystem/FileSystem.h
+++ b/Kernel/FileSystem/FileSystem.h
@@ -16,7 +16,7 @@
#include <Kernel/KResult.h>
#include <Kernel/Lock.h>
-static const dword mepoch = 476763780;
+static const u32 mepoch = 476763780;
class Inode;
class FileDescription;
@@ -30,7 +30,7 @@ public:
virtual ~FS();
unsigned fsid() const { return m_fsid; }
- static FS* from_fsid(dword);
+ static FS* from_fsid(u32);
static void sync();
static void lock_all();
@@ -46,12 +46,12 @@ public:
virtual unsigned free_inode_count() const { return 0; }
struct DirectoryEntry {
- DirectoryEntry(const char* name, InodeIdentifier, byte file_type);
- DirectoryEntry(const char* name, int name_length, InodeIdentifier, byte file_type);
+ DirectoryEntry(const char* name, InodeIdentifier, u8 file_type);
+ DirectoryEntry(const char* name, int name_length, InodeIdentifier, u8 file_type);
char name[256];
int name_length { 0 };
InodeIdentifier inode;
- byte file_type { 0 };
+ u8 file_type { 0 };
};
virtual RefPtr<Inode> create_inode(InodeIdentifier parentInode, const String& name, mode_t, off_t size, dev_t, int& error) = 0;
diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp
index 19d78684b3..9c953ec78a 100644
--- a/Kernel/FileSystem/Inode.cpp
+++ b/Kernel/FileSystem/Inode.cpp
@@ -35,7 +35,7 @@ ByteBuffer Inode::read_entire(FileDescription* descriptor) const
StringBuilder builder(initial_size);
ssize_t nread;
- byte buffer[4096];
+ u8 buffer[4096];
off_t offset = 0;
for (;;) {
nread = read_bytes(offset, sizeof(buffer), buffer, descriptor);
@@ -76,7 +76,7 @@ void Inode::will_be_destroyed()
flush_metadata();
}
-void Inode::inode_contents_changed(off_t offset, ssize_t size, const byte* data)
+void Inode::inode_contents_changed(off_t offset, ssize_t size, const u8* data)
{
if (m_vmo)
m_vmo->inode_contents_changed({}, offset, size, data);
diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h
index 28696fc311..1caa8c0dbe 100644
--- a/Kernel/FileSystem/Inode.h
+++ b/Kernel/FileSystem/Inode.h
@@ -39,10 +39,10 @@ public:
ByteBuffer read_entire(FileDescription* = nullptr) const;
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const = 0;
+ virtual ssize_t read_bytes(off_t, ssize_t, u8* buffer, FileDescription*) const = 0;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const = 0;
virtual InodeIdentifier lookup(StringView name) = 0;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* data, FileDescription*) = 0;
+ virtual ssize_t write_bytes(off_t, ssize_t, const u8* data, FileDescription*) = 0;
virtual KResult add_child(InodeIdentifier child_id, const StringView& name, mode_t) = 0;
virtual KResult remove_child(const StringView& name) = 0;
virtual size_t directory_entry_count() const = 0;
@@ -76,7 +76,7 @@ public:
protected:
Inode(FS& fs, unsigned index);
void set_metadata_dirty(bool b) { m_metadata_dirty = b; }
- void inode_contents_changed(off_t, ssize_t, const byte*);
+ void inode_contents_changed(off_t, ssize_t, const u8*);
void inode_size_changed(size_t old_size, size_t new_size);
mutable Lock m_lock { "Inode" };
diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp
index 7617636486..36ace74ab8 100644
--- a/Kernel/FileSystem/InodeFile.cpp
+++ b/Kernel/FileSystem/InodeFile.cpp
@@ -13,12 +13,12 @@ InodeFile::~InodeFile()
{
}
-ssize_t InodeFile::read(FileDescription& description, byte* buffer, ssize_t count)
+ssize_t InodeFile::read(FileDescription& description, u8* buffer, ssize_t count)
{
return m_inode->read_bytes(description.offset(), count, buffer, &description);
}
-ssize_t InodeFile::write(FileDescription& description, const byte* data, ssize_t count)
+ssize_t InodeFile::write(FileDescription& description, const u8* data, ssize_t count)
{
return m_inode->write_bytes(description.offset(), count, data, &description);
}
diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h
index f4bbe7b48d..b7101ff753 100644
--- a/Kernel/FileSystem/InodeFile.h
+++ b/Kernel/FileSystem/InodeFile.h
@@ -19,8 +19,8 @@ public:
virtual bool can_read(FileDescription&) const override { return true; }
virtual bool can_write(FileDescription&) const override { return true; }
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot) override;
virtual String absolute_path(const FileDescription&) const override;
diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h
index d6d4c4e881..2a3958aff9 100644
--- a/Kernel/FileSystem/InodeIdentifier.h
+++ b/Kernel/FileSystem/InodeIdentifier.h
@@ -10,7 +10,7 @@ struct InodeMetadata;
class InodeIdentifier {
public:
InodeIdentifier() {}
- InodeIdentifier(dword fsid, dword inode)
+ InodeIdentifier(u32 fsid, u32 inode)
: m_fsid(fsid)
, m_index(inode)
{
@@ -18,8 +18,8 @@ public:
bool is_valid() const { return m_fsid != 0 && m_index != 0; }
- dword fsid() const { return m_fsid; }
- dword index() const { return m_index; }
+ u32 fsid() const { return m_fsid; }
+ u32 index() const { return m_index; }
FS* fs();
const FS* fs() const;
@@ -39,6 +39,6 @@ public:
String to_string() const { return String::format("%u:%u", m_fsid, m_index); }
private:
- dword m_fsid { 0 };
- dword m_index { 0 };
+ u32 m_fsid { 0 };
+ u32 m_index { 0 };
};
diff --git a/Kernel/FileSystem/InodeMetadata.h b/Kernel/FileSystem/InodeMetadata.h
index 97794e5470..7e4ce3230c 100644
--- a/Kernel/FileSystem/InodeMetadata.h
+++ b/Kernel/FileSystem/InodeMetadata.h
@@ -7,7 +7,7 @@
class Process;
-inline constexpr dword encoded_device(unsigned major, unsigned minor)
+inline constexpr u32 encoded_device(unsigned major, unsigned minor)
{
return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
}
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index ef5c8b1d98..5fd6056b96 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -125,7 +125,7 @@ static inline InodeIdentifier to_parent_id(const InodeIdentifier& identifier)
}
#if 0
-static inline byte to_unused_metadata(const InodeIdentifier& identifier)
+static inline u8 to_unused_metadata(const InodeIdentifier& identifier)
{
return (identifier.index() >> 8) & 0xf;
}
@@ -254,7 +254,7 @@ ByteBuffer procfs$pci(InodeIdentifier)
ByteBuffer procfs$uptime(InodeIdentifier)
{
StringBuilder builder;
- builder.appendf("%u\n", (dword)(g_uptime / 1000));
+ builder.appendf("%u\n", (u32)(g_uptime / 1000));
return builder.to_byte_buffer();
}
@@ -317,7 +317,7 @@ ByteBuffer procfs$pid_stack(InodeIdentifier identifier)
auto& process = handle->process();
ProcessPagingScope paging_scope(process);
struct RecognizedSymbol {
- dword address;
+ u32 address;
const KSym* ksym;
};
StringBuilder builder;
@@ -325,8 +325,8 @@ ByteBuffer procfs$pid_stack(InodeIdentifier identifier)
builder.appendf("Thread %d:\n", thread.tid());
Vector<RecognizedSymbol, 64> recognized_symbols;
recognized_symbols.append({ thread.tss().eip, ksymbolicate(thread.tss().eip) });
- for (dword* stack_ptr = (dword*)thread.frame_ptr(); process.validate_read_from_kernel(VirtualAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
- dword retaddr = stack_ptr[1];
+ for (u32* stack_ptr = (u32*)thread.frame_ptr(); process.validate_read_from_kernel(VirtualAddress((u32)stack_ptr)); stack_ptr = (u32*)*stack_ptr) {
+ u32 retaddr = stack_ptr[1];
recognized_symbols.append({ retaddr, ksymbolicate(retaddr) });
}
@@ -397,7 +397,7 @@ ByteBuffer procfs$self(InodeIdentifier)
{
char buffer[16];
ksprintf(buffer, "%u", current->pid());
- return ByteBuffer::copy((const byte*)buffer, strlen(buffer));
+ return ByteBuffer::copy((const u8*)buffer, strlen(buffer));
}
ByteBuffer procfs$mm(InodeIdentifier)
@@ -471,28 +471,28 @@ ByteBuffer procfs$cpuinfo(InodeIdentifier)
{
CPUID cpuid(0);
builder.appendf("cpuid: ");
- auto emit_dword = [&](dword value) {
+ auto emit_u32 = [&](u32 value) {
builder.appendf("%c%c%c%c",
value & 0xff,
(value >> 8) & 0xff,
(value >> 16) & 0xff,
(value >> 24) & 0xff);
};
- emit_dword(cpuid.ebx());
- emit_dword(cpuid.edx());
- emit_dword(cpuid.ecx());
+ emit_u32(cpuid.ebx());
+ emit_u32(cpuid.edx());
+ emit_u32(cpuid.ecx());
builder.appendf("\n");
}
{
CPUID cpuid(1);
- dword stepping = cpuid.eax() & 0xf;
- dword model = (cpuid.eax() >> 4) & 0xf;
- dword family = (cpuid.eax() >> 8) & 0xf;
- dword type = (cpuid.eax() >> 12) & 0x3;
- dword extended_model = (cpuid.eax() >> 16) & 0xf;
- dword extended_family = (cpuid.eax() >> 20) & 0xff;
- dword display_model;
- dword display_family;
+ u32 stepping = cpuid.eax() & 0xf;
+ u32 model = (cpuid.eax() >> 4) & 0xf;
+ u32 family = (cpuid.eax() >> 8) & 0xf;
+ u32 type = (cpuid.eax() >> 12) & 0x3;
+ u32 extended_model = (cpuid.eax() >> 16) & 0xf;
+ u32 extended_family = (cpuid.eax() >> 20) & 0xff;
+ u32 display_model;
+ u32 display_family;
if (family == 15) {
display_family = family + extended_family;
display_model = model + (extended_model << 4);
@@ -512,8 +512,8 @@ ByteBuffer procfs$cpuinfo(InodeIdentifier)
// FIXME: Check first that this is supported by calling CPUID with eax=0x80000000
// and verifying that the returned eax>=0x80000004.
char buffer[48];
- dword* bufptr = reinterpret_cast<dword*>(buffer);
- auto copy_brand_string_part_to_buffer = [&](dword i) {
+ u32* bufptr = reinterpret_cast<u32*>(buffer);
+ auto copy_brand_string_part_to_buffer = [&](u32 i) {
CPUID cpuid(0x80000002 + i);
*bufptr++ = cpuid.eax();
*bufptr++ = cpuid.ebx();
@@ -858,7 +858,7 @@ InodeMetadata ProcFSInode::metadata() const
return metadata;
}
-ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* description) const
+ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDescription* description) const
{
#ifdef PROCFS_DEBUG
dbgprintf("ProcFS: read_bytes %u\n", index());
@@ -1061,7 +1061,7 @@ void ProcFSInode::flush_metadata()
{
}
-ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer, FileDescription*)
+ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const u8* buffer, FileDescription*)
{
auto* directory_entry = fs().get_directory_entry(identifier());
if (!directory_entry || !directory_entry->write_callback)
diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h
index 2976253556..1adf44705c 100644
--- a/Kernel/FileSystem/ProcFS.h
+++ b/Kernel/FileSystem/ProcFS.h
@@ -80,12 +80,12 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const override;
+ virtual ssize_t read_bytes(off_t, ssize_t, u8* buffer, FileDescription*) const override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const override;
virtual InodeIdentifier lookup(StringView name) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescription*) override;
+ virtual ssize_t write_bytes(off_t, ssize_t, const u8* buffer, FileDescription*) override;
virtual KResult add_child(InodeIdentifier child_id, const StringView& name, mode_t) override;
virtual KResult remove_child(const StringView& name) override;
virtual size_t directory_entry_count() const override;
diff --git a/Kernel/FileSystem/SyntheticFileSystem.cpp b/Kernel/FileSystem/SyntheticFileSystem.cpp
index d884fd0e3d..3bc66be0ee 100644
--- a/Kernel/FileSystem/SyntheticFileSystem.cpp
+++ b/Kernel/FileSystem/SyntheticFileSystem.cpp
@@ -185,7 +185,7 @@ InodeMetadata SynthFSInode::metadata() const
return m_metadata;
}
-ssize_t SynthFSInode::read_bytes(off_t offset, ssize_t count, byte* buffer, FileDescription* description) const
+ssize_t SynthFSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDescription* description) const
{
LOCKER(m_lock);
#ifdef SYNTHFS_DEBUG
@@ -227,7 +227,7 @@ bool SynthFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&
callback({ "..", 2, m_parent, 2 });
for (auto& child : m_children)
- callback({ child->m_name.characters(), child->m_name.length(), child->m_metadata.inode, child->m_metadata.is_directory() ? (byte)2 : (byte)1 });
+ callback({ child->m_name.characters(), child->m_name.length(), child->m_metadata.inode, child->m_metadata.is_directory() ? (u8)2 : (u8)1 });
return true;
}
@@ -250,7 +250,7 @@ void SynthFSInode::flush_metadata()
{
}
-ssize_t SynthFSInode::write_bytes(off_t offset, ssize_t size, const byte* buffer, FileDescription*)
+ssize_t SynthFSInode::write_bytes(off_t offset, ssize_t size, const u8* buffer, FileDescription*)
{
LOCKER(m_lock);
if (!m_write_callback)
diff --git a/Kernel/FileSystem/SyntheticFileSystem.h b/Kernel/FileSystem/SyntheticFileSystem.h
index 15e5dc9a21..8582223995 100644
--- a/Kernel/FileSystem/SyntheticFileSystem.h
+++ b/Kernel/FileSystem/SyntheticFileSystem.h
@@ -57,12 +57,12 @@ public:
private:
// ^Inode
- virtual ssize_t read_bytes(off_t, ssize_t, byte* buffer, FileDescription*) const override;
+ virtual ssize_t read_bytes(off_t, ssize_t, u8* buffer, FileDescription*) const override;
virtual InodeMetadata metadata() const override;
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) const override;
virtual InodeIdentifier lookup(StringView name) override;
virtual void flush_metadata() override;
- virtual ssize_t write_bytes(off_t, ssize_t, const byte* buffer, FileDescription*) override;
+ virtual ssize_t write_bytes(off_t, ssize_t, const u8* buffer, FileDescription*) override;
virtual KResult add_child(InodeIdentifier child_id, const StringView& name, mode_t) override;
virtual KResult remove_child(const StringView& name) override;
virtual size_t directory_entry_count() const override;
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index 1392660952..da45f8b861 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.cpp
@@ -516,7 +516,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
auto new_file = parent_inode.fs().create_inode(parent_inode.identifier(), p.basename(), 0120644, 0, 0, error);
if (!new_file)
return KResult(error);
- ssize_t nwritten = new_file->write_bytes(0, target.length(), (const byte*)target.characters(), nullptr);
+ ssize_t nwritten = new_file->write_bytes(0, target.length(), (const u8*)target.characters(), nullptr);
if (nwritten < 0)
return KResult(nwritten);
return KSuccess;
diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h
index 8f7c72fe68..adf82d0b66 100644
--- a/Kernel/FileSystem/VirtualFileSystem.h
+++ b/Kernel/FileSystem/VirtualFileSystem.h
@@ -107,7 +107,7 @@ private:
RefPtr<Inode> m_root_inode;
Vector<OwnPtr<Mount>> m_mounts;
- HashMap<dword, Device*> m_devices;
+ HashMap<u32, Device*> m_devices;
RefPtr<Custody> m_root_custody;
};
diff --git a/Kernel/IO.h b/Kernel/IO.h
index 259911264c..901c7a7726 100644
--- a/Kernel/IO.h
+++ b/Kernel/IO.h
@@ -4,34 +4,34 @@
namespace IO {
-inline byte in8(word port)
+inline u8 in8(u16 port)
{
- byte value;
+ u8 value;
asm volatile("inb %1, %0"
: "=a"(value)
: "Nd"(port));
return value;
}
-inline word in16(word port)
+inline u16 in16(u16 port)
{
- word value;
+ u16 value;
asm volatile("inw %1, %0"
: "=a"(value)
: "Nd"(port));
return value;
}
-inline dword in32(word port)
+inline u32 in32(u16 port)
{
- dword value;
+ u32 value;
asm volatile("inl %1, %0"
: "=a"(value)
: "Nd"(port));
return value;
}
-inline void repeated_in16(word port, byte* buffer, int buffer_size)
+inline void repeated_in16(u16 port, u8* buffer, int buffer_size)
{
asm volatile("rep insw"
: "+D"(buffer), "+c"(buffer_size)
@@ -39,22 +39,22 @@ inline void repeated_in16(word port, byte* buffer, int buffer_size)
: "memory");
}
-inline void out8(word port, byte value)
+inline void out8(u16 port, u8 value)
{
asm volatile("outb %0, %1" ::"a"(value), "Nd"(port));
}
-inline void out16(word port, word value)
+inline void out16(u16 port, u16 value)
{
asm volatile("outw %0, %1" ::"a"(value), "Nd"(port));
}
-inline void out32(word port, dword value)
+inline void out32(u16 port, u32 value)
{
asm volatile("outl %0, %1" ::"a"(value), "Nd"(port));
}
-inline void repeated_out16(word port, const byte* data, int data_size)
+inline void repeated_out16(u16 port, const u8* data, int data_size)
{
asm volatile("rep outsw"
: "+S"(data), "+c"(data_size)
diff --git a/Kernel/IRQHandler.cpp b/Kernel/IRQHandler.cpp
index 400944289c..ea2caa4ebf 100644
--- a/Kernel/IRQHandler.cpp
+++ b/Kernel/IRQHandler.cpp
@@ -2,7 +2,7 @@
#include "PIC.h"
#include <Kernel/Arch/i386/CPU.h>
-IRQHandler::IRQHandler(byte irq)
+IRQHandler::IRQHandler(u8 irq)
: m_irq_number(irq)
{
register_irq_handler(m_irq_number, *this);
diff --git a/Kernel/IRQHandler.h b/Kernel/IRQHandler.h
index 4abadf6b20..d5193b82e0 100644
--- a/Kernel/IRQHandler.h
+++ b/Kernel/IRQHandler.h
@@ -7,14 +7,14 @@ public:
virtual ~IRQHandler();
virtual void handle_irq() = 0;
- byte irq_number() const { return m_irq_number; }
+ u8 irq_number() const { return m_irq_number; }
void enable_irq();
void disable_irq();
protected:
- explicit IRQHandler(byte irq);
+ explicit IRQHandler(u8 irq);
private:
- byte m_irq_number { 0 };
+ u8 m_irq_number { 0 };
};
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index 9e0eddc458..f52b9fbbc5 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -6,12 +6,12 @@
#include <Kernel/FileSystem/FileDescription.h>
static KSym* s_ksyms;
-dword ksym_lowest_address;
-dword ksym_highest_address;
-dword ksym_count;
+u32 ksym_lowest_address;
+u32 ksym_highest_address;
+u32 ksym_count;
bool ksyms_ready;
-static byte parse_hex_digit(char nibble)
+static u8 parse_hex_digit(char nibble)
{
if (nibble >= '0' && nibble <= '9')
return nibble - '0';
@@ -19,7 +19,7 @@ static byte parse_hex_digit(char nibble)
return 10 + (nibble - 'a');
}
-const KSym* ksymbolicate(dword address)
+const KSym* ksymbolicate(u32 address)
{
if (address < ksym_lowest_address || address > ksym_highest_address)
return nullptr;
@@ -36,7 +36,7 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
ksym_highest_address = 0;
auto* bufptr = (const char*)buffer.pointer();
auto* start_of_name = bufptr;
- dword address = 0;
+ u32 address = 0;
for (unsigned i = 0; i < 8; ++i)
ksym_count = (ksym_count << 4) | parse_hex_digit(*(bufptr++));
@@ -76,7 +76,7 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
ksyms_ready = true;
}
-[[gnu::noinline]] void dump_backtrace_impl(dword ebp, bool use_ksyms)
+[[gnu::noinline]] void dump_backtrace_impl(u32 ebp, bool use_ksyms)
{
if (!current) {
//hang();
@@ -87,21 +87,21 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
return;
}
struct RecognizedSymbol {
- dword address;
+ u32 address;
const KSym* ksym;
};
int max_recognized_symbol_count = 256;
RecognizedSymbol recognized_symbols[max_recognized_symbol_count];
int recognized_symbol_count = 0;
if (use_ksyms) {
- for (dword* stack_ptr = (dword*)ebp; current->process().validate_read_from_kernel(VirtualAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
- dword retaddr = stack_ptr[1];
+ for (u32* stack_ptr = (u32*)ebp; current->process().validate_read_from_kernel(VirtualAddress((u32)stack_ptr)); stack_ptr = (u32*)*stack_ptr) {
+ u32 retaddr = stack_ptr[1];
recognized_symbols[recognized_symbol_count++] = { retaddr, ksymbolicate(retaddr) };
}
} else {
- for (dword* stack_ptr = (dword*)ebp; current->process().validate_read_from_kernel(VirtualAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
- dword retaddr = stack_ptr[1];
- dbgprintf("%x (next: %x)\n", retaddr, stack_ptr ? (dword*)*stack_ptr : 0);
+ for (u32* stack_ptr = (u32*)ebp; current->process().validate_read_from_kernel(VirtualAddress((u32)stack_ptr)); stack_ptr = (u32*)*stack_ptr) {
+ u32 retaddr = stack_ptr[1];
+ dbgprintf("%x (next: %x)\n", retaddr, stack_ptr ? (u32*)*stack_ptr : 0);
}
return;
}
@@ -139,7 +139,7 @@ void dump_backtrace()
return;
}
TemporaryChange change(in_dump_backtrace, true);
- dword ebp;
+ u32 ebp;
asm volatile("movl %%ebp, %%eax"
: "=a"(ebp));
dump_backtrace_impl(ebp, ksyms_ready);
diff --git a/Kernel/KSyms.h b/Kernel/KSyms.h
index 3d35dcc75d..dbbec19708 100644
--- a/Kernel/KSyms.h
+++ b/Kernel/KSyms.h
@@ -4,16 +4,16 @@
#include <AK/Vector.h>
struct KSym {
- dword address;
+ u32 address;
const char* name;
};
-const KSym* ksymbolicate(dword address);
+const KSym* ksymbolicate(u32 address);
void load_ksyms();
void init_ksyms();
extern bool ksyms_ready;
-extern dword ksym_lowest_address;
-extern dword ksym_highest_address;
+extern u32 ksym_lowest_address;
+extern u32 ksym_highest_address;
void dump_backtrace();
diff --git a/Kernel/KeyCode.h b/Kernel/KeyCode.h
index 310c950ca9..5765465fc3 100644
--- a/Kernel/KeyCode.h
+++ b/Kernel/KeyCode.h
@@ -2,7 +2,7 @@
#include <AK/Types.h>
-enum KeyCode : byte {
+enum KeyCode : u8 {
Key_Invalid = 0,
Key_Escape,
Key_Tab,
@@ -126,8 +126,8 @@ enum KeyModifier {
struct KeyEvent {
KeyCode key { Key_Invalid };
- byte character { 0 };
- byte flags { 0 };
+ u8 character { 0 };
+ u8 flags { 0 };
bool alt() const { return flags & Mod_Alt; }
bool ctrl() const { return flags & Mod_Ctrl; }
bool shift() const { return flags & Mod_Shift; }
diff --git a/Kernel/Lock.h b/Kernel/Lock.h
index 875dc84ae4..0341ed3f30 100644
--- a/Kernel/Lock.h
+++ b/Kernel/Lock.h
@@ -9,9 +9,9 @@
class Thread;
extern Thread* current;
-static inline dword CAS(volatile dword* mem, dword newval, dword oldval)
+static inline u32 CAS(volatile u32* mem, u32 newval, u32 oldval)
{
- dword ret;
+ u32 ret;
asm volatile(
"cmpxchgl %2, %1"
: "=a"(ret), "+m"(*mem)
@@ -35,8 +35,8 @@ public:
const char* name() const { return m_name; }
private:
- volatile dword m_lock { 0 };
- dword m_level { 0 };
+ volatile u32 m_lock { 0 };
+ u32 m_level { 0 };
Thread* m_holder { nullptr };
const char* m_name { nullptr };
};
diff --git a/Kernel/MousePacket.h b/Kernel/MousePacket.h
index 26d03f4988..c328841c7e 100644
--- a/Kernel/MousePacket.h
+++ b/Kernel/MousePacket.h
@@ -4,5 +4,5 @@ struct MousePacket {
int dx { 0 };
int dy { 0 };
int dz { 0 };
- byte buttons { 0 };
+ unsigned char buttons { 0 };
};
diff --git a/Kernel/Multiboot.h b/Kernel/Multiboot.h
index a74c4feb34..bc55f8f309 100644
--- a/Kernel/Multiboot.h
+++ b/Kernel/Multiboot.h
@@ -3,18 +3,18 @@
#include <AK/Types.h>
struct multiboot_aout_symbol_table {
- dword tabsize;
- dword strsize;
- dword addr;
- dword reserved;
+ u32 tabsize;
+ u32 strsize;
+ u32 addr;
+ u32 reserved;
};
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
struct multiboot_elf_section_header_table {
- dword num;
- dword size;
- dword addr;
- dword shndx;
+ u32 num;
+ u32 size;
+ u32 addr;
+ u32 shndx;
};
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
@@ -25,30 +25,30 @@ typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_t
#define MULTIBOOT_MEMORY_BADRAM 5
struct multiboot_mmap_entry {
- dword size;
- qword addr;
- qword len;
- dword type;
+ u32 size;
+ u64 addr;
+ u64 len;
+ u32 type;
} __attribute__((packed));
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_info {
// Multiboot info version number.
- dword flags;
+ u32 flags;
// Available memory from BIOS.
- dword mem_lower;
- dword mem_upper;
+ u32 mem_lower;
+ u32 mem_upper;
// "root" partition.
- dword boot_device;
+ u32 boot_device;
// Kernel command line.
- dword cmdline;
+ u32 cmdline;
// Boot-Module list.
- dword mods_count;
- dword mods_addr;
+ u32 mods_count;
+ u32 mods_addr;
union {
multiboot_aout_symbol_table_t aout_sym;
@@ -56,53 +56,53 @@ struct multiboot_info {
} u;
// Memory Mapping buffer.
- dword mmap_length;
- dword mmap_addr;
+ u32 mmap_length;
+ u32 mmap_addr;
// Drive Info buffer.
- dword drives_length;
- dword drives_addr;
+ u32 drives_length;
+ u32 drives_addr;
// ROM configuration table.
- dword config_table;
+ u32 config_table;
// Boot Loader Name.
- dword boot_loader_name;
+ u32 boot_loader_name;
// APM table.
- dword apm_table;
+ u32 apm_table;
// Video.
- dword vbe_control_info;
- dword vbe_mode_info;
- word vbe_mode;
- word vbe_interface_seg;
- word vbe_interface_off;
- word vbe_interface_len;
-
- qword framebuffer_addr;
- dword framebuffer_pitch;
- dword framebuffer_width;
- dword framebuffer_height;
- byte framebuffer_bpp;
+ u32 vbe_control_info;
+ u32 vbe_mode_info;
+ u16 vbe_mode;
+ u16 vbe_interface_seg;
+ u16 vbe_interface_off;
+ u16 vbe_interface_len;
+
+ u64 framebuffer_addr;
+ u32 framebuffer_pitch;
+ u32 framebuffer_width;
+ u32 framebuffer_height;
+ u8 framebuffer_bpp;
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
- byte framebuffer_type;
+ u8 framebuffer_type;
union {
struct
{
- dword framebuffer_palette_addr;
- word framebuffer_palette_num_colors;
+ u32 framebuffer_palette_addr;
+ u16 framebuffer_palette_num_colors;
};
struct
{
- byte framebuffer_red_field_position;
- byte framebuffer_red_mask_size;
- byte framebuffer_green_field_position;
- byte framebuffer_green_mask_size;
- byte framebuffer_blue_field_position;
- byte framebuffer_blue_mask_size;
+ u8 framebuffer_red_field_position;
+ u8 framebuffer_red_mask_size;
+ u8 framebuffer_green_field_position;
+ u8 framebuffer_green_mask_size;
+ u8 framebuffer_blue_field_position;
+ u8 framebuffer_blue_mask_size;
};
};
};
diff --git a/Kernel/Net/ARP.h b/Kernel/Net/ARP.h
index 6f3a3cb0ab..da03222e79 100644
--- a/Kernel/Net/ARP.h
+++ b/Kernel/Net/ARP.h
@@ -6,14 +6,14 @@
#include <Kernel/Net/MACAddress.h>
struct ARPOperation {
- enum : word {
+ enum : u16 {
Request = 1,
Response = 2,
};
};
struct ARPHardwareType {
- enum : word {
+ enum : u16 {
Ethernet = 1,
};
};
@@ -21,20 +21,20 @@ struct ARPHardwareType {
class [[gnu::packed]] ARPPacket
{
public:
- word hardware_type() const { return m_hardware_type; }
- void set_hardware_type(word w) { m_hardware_type = w; }
+ u16 hardware_type() const { return m_hardware_type; }
+ void set_hardware_type(u16 w) { m_hardware_type = w; }
- word protocol_type() const { return m_protocol_type; }
- void set_protocol_type(word w) { m_protocol_type = w; }
+ u16 protocol_type() const { return m_protocol_type; }
+ void set_protocol_type(u16 w) { m_protocol_type = w; }
- byte hardware_address_length() const { return m_hardware_address_length; }
- void set_hardware_address_length(byte b) { m_hardware_address_length = b; }
+ u8 hardware_address_length() const { return m_hardware_address_length; }
+ void set_hardware_address_length(u8 b) { m_hardware_address_length = b; }
- byte protocol_address_length() const { return m_protocol_address_length; }
- void set_protocol_address_length(byte b) { m_protocol_address_length = b; }
+ u8 protocol_address_length() const { return m_protocol_address_length; }
+ void set_protocol_address_length(u8 b) { m_protocol_address_length = b; }
- word operation() const { return m_operation; }
- void set_operation(word w) { m_operation = w; }
+ u16 operation() const { return m_operation; }
+ void set_operation(u16 w) { m_operation = w; }
const MACAddress& sender_hardware_address() const { return m_sender_hardware_address; }
void set_sender_hardware_address(const MACAddress& address) { m_sender_hardware_address = address; }
@@ -49,11 +49,11 @@ public:
void set_target_protocol_address(const IPv4Address& address) { m_target_protocol_address = address; }
private:
- NetworkOrdered<word> m_hardware_type { ARPHardwareType::Ethernet };
- NetworkOrdered<word> m_protocol_type { EtherType::IPv4 };
- byte m_hardware_address_length { sizeof(MACAddress) };
- byte m_protocol_address_length { sizeof(IPv4Address) };
- NetworkOrdered<word> m_operation;
+ NetworkOrdered<u16> m_hardware_type { ARPHardwareType::Ethernet };
+ NetworkOrdered<u16> m_protocol_type { EtherType::IPv4 };
+ u8 m_hardware_address_length { sizeof(MACAddress) };
+ u8 m_protocol_address_length { sizeof(IPv4Address) };
+ NetworkOrdered<u16> m_operation;
MACAddress m_sender_hardware_address;
IPv4Address m_sender_protocol_address;
MACAddress m_target_hardware_address;
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 356b1c5f50..3ceb0d7e0e 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -92,7 +92,7 @@ OwnPtr<E1000NetworkAdapter> E1000NetworkAdapter::autodetect()
});
if (found_address.is_null())
return nullptr;
- byte irq = PCI::get_interrupt_line(found_address);
+ u8 irq = PCI::get_interrupt_line(found_address);
return make<E1000NetworkAdapter>(found_address, irq);
}
@@ -102,7 +102,7 @@ E1000NetworkAdapter* E1000NetworkAdapter::the()
return s_the;
}
-E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, byte irq)
+E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, u8 irq)
: IRQHandler(irq)
, m_pci_address(pci_address)
{
@@ -132,7 +132,7 @@ E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, byte irq)
const auto& mac = mac_address();
kprintf("E1000: MAC address: %b:%b:%b:%b:%b:%b\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
- dword flags = in32(REG_CTRL);
+ u32 flags = in32(REG_CTRL);
out32(REG_CTRL, flags | ECTRL_SLU);
initialize_rx_descriptors();
@@ -153,9 +153,9 @@ void E1000NetworkAdapter::handle_irq()
{
out32(REG_IMASK, 0x1);
- dword status = in32(0xc0);
+ u32 status = in32(0xc0);
if (status & 4) {
- dword flags = in32(REG_CTRL);
+ u32 flags = in32(REG_CTRL);
out32(REG_CTRL, flags | ECTRL_SLU);
}
if (status & 0x10) {
@@ -170,7 +170,7 @@ void E1000NetworkAdapter::detect_eeprom()
{
out32(REG_EEPROM, 0x1);
for (volatile int i = 0; i < 999; ++i) {
- dword data = in32(REG_EEPROM);
+ u32 data = in32(REG_EEPROM);
if (data & 0x10) {
m_has_eeprom = true;
return;
@@ -179,16 +179,16 @@ void E1000NetworkAdapter::detect_eeprom()
m_has_eeprom = false;
}
-dword E1000NetworkAdapter::read_eeprom(byte address)
+u32 E1000NetworkAdapter::read_eeprom(u8 address)
{
- word data = 0;
- dword tmp = 0;
+ u16 data = 0;
+ u32 tmp = 0;
if (m_has_eeprom) {
- out32(REG_EEPROM, ((dword)address << 8) | 1);
+ out32(REG_EEPROM, ((u32)address << 8) | 1);
while (!((tmp = in32(REG_EEPROM)) & (1 << 4)))
;
} else {
- out32(REG_EEPROM, ((dword)address << 2) | 1);
+ out32(REG_EEPROM, ((u32)address << 2) | 1);
while (!((tmp = in32(REG_EEPROM)) & (1 << 1)))
;
}
@@ -199,8 +199,8 @@ dword E1000NetworkAdapter::read_eeprom(byte address)
void E1000NetworkAdapter::read_mac_address()
{
if (m_has_eeprom) {
- byte mac[6];
- dword tmp = read_eeprom(0);
+ u8 mac[6];
+ u32 tmp = read_eeprom(0);
mac[0] = tmp & 0xff;
mac[1] = tmp >> 8;
tmp = read_eeprom(1);
@@ -217,14 +217,14 @@ void E1000NetworkAdapter::read_mac_address()
void E1000NetworkAdapter::initialize_rx_descriptors()
{
- auto ptr = (dword)kmalloc_eternal(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16);
+ auto ptr = (u32)kmalloc_eternal(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16);
// Make sure it's 16-byte aligned.
if (ptr % 16)
ptr = (ptr + 16) - (ptr % 16);
m_rx_descriptors = (e1000_rx_desc*)ptr;
for (int i = 0; i < number_of_rx_descriptors; ++i) {
auto& descriptor = m_rx_descriptors[i];
- descriptor.addr = (qword)kmalloc_eternal(8192 + 16);
+ descriptor.addr = (u64)kmalloc_eternal(8192 + 16);
descriptor.status = 0;
}
@@ -239,14 +239,14 @@ void E1000NetworkAdapter::initialize_rx_descriptors()
void E1000NetworkAdapter::initialize_tx_descriptors()
{
- auto ptr = (dword)kmalloc_eternal(sizeof(e1000_tx_desc) * number_of_tx_descriptors + 16);
+ auto ptr = (u32)kmalloc_eternal(sizeof(e1000_tx_desc) * number_of_tx_descriptors + 16);
// Make sure it's 16-byte aligned.
if (ptr % 16)
ptr = (ptr + 16) - (ptr % 16);
m_tx_descriptors = (e1000_tx_desc*)ptr;
for (int i = 0; i < number_of_tx_descriptors; ++i) {
auto& descriptor = m_tx_descriptors[i];
- descriptor.addr = (qword)kmalloc_eternal(8192 + 16);
+ descriptor.addr = (u64)kmalloc_eternal(8192 + 16);
descriptor.cmd = 0;
}
@@ -260,60 +260,60 @@ void E1000NetworkAdapter::initialize_tx_descriptors()
out32(REG_TIPG, 0x0060200A);
}
-void E1000NetworkAdapter::out8(word address, byte data)
+void E1000NetworkAdapter::out8(u16 address, u8 data)
{
if (m_use_mmio) {
- auto* ptr = (volatile byte*)(m_mmio_base.get() + address);
+ auto* ptr = (volatile u8*)(m_mmio_base.get() + address);
*ptr = data;
return;
}
IO::out8(m_io_base + address, data);
}
-void E1000NetworkAdapter::out16(word address, word data)
+void E1000NetworkAdapter::out16(u16 address, u16 data)
{
if (m_use_mmio) {
- auto* ptr = (volatile word*)(m_mmio_base.get() + address);
+ auto* ptr = (volatile u16*)(m_mmio_base.get() + address);
*ptr = data;
return;
}
IO::out16(m_io_base + address, data);
}
-void E1000NetworkAdapter::out32(word address, dword data)
+void E1000NetworkAdapter::out32(u16 address, u32 data)
{
if (m_use_mmio) {
- auto* ptr = (volatile dword*)(m_mmio_base.get() + address);
+ auto* ptr = (volatile u32*)(m_mmio_base.get() + address);
*ptr = data;
return;
}
IO::out32(m_io_base + address, data);
}
-byte E1000NetworkAdapter::in8(word address)
+u8 E1000NetworkAdapter::in8(u16 address)
{
if (m_use_mmio)
- return *(volatile byte*)(m_mmio_base.get() + address);
+ return *(volatile u8*)(m_mmio_base.get() + address);
return IO::in8(m_io_base + address);
}
-word E1000NetworkAdapter::in16(word address)
+u16 E1000NetworkAdapter::in16(u16 address)
{
if (m_use_mmio)
- return *(volatile word*)(m_mmio_base.get() + address);
+ return *(volatile u16*)(m_mmio_base.get() + address);
return IO::in16(m_io_base + address);
}
-dword E1000NetworkAdapter::in32(word address)
+u32 E1000NetworkAdapter::in32(u16 address)
{
if (m_use_mmio)
- return *(volatile dword*)(m_mmio_base.get() + address);
+ return *(volatile u32*)(m_mmio_base.get() + address);
return IO::in32(m_io_base + address);
}
-void E1000NetworkAdapter::send_raw(const byte* data, int length)
+void E1000NetworkAdapter::send_raw(const u8* data, int length)
{
- dword tx_current = in32(REG_TXDESCTAIL);
+ u32 tx_current = in32(REG_TXDESCTAIL);
#ifdef E1000_DEBUG
kprintf("E1000: Sending packet (%d bytes)\n", length);
#endif
@@ -337,7 +337,7 @@ void E1000NetworkAdapter::send_raw(const byte* data, int length)
void E1000NetworkAdapter::receive()
{
- dword rx_current;
+ u32 rx_current;
for (;;) {
rx_current = in32(REG_RXDESCTAIL);
if (rx_current == in32(REG_RXDESCHEAD))
@@ -345,8 +345,8 @@ void E1000NetworkAdapter::receive()
rx_current = (rx_current + 1) % number_of_rx_descriptors;
if (!(m_rx_descriptors[rx_current].status & 1))
break;
- auto* buffer = (byte*)m_rx_descriptors[rx_current].addr;
- word length = m_rx_descriptors[rx_current].length;
+ auto* buffer = (u8*)m_rx_descriptors[rx_current].addr;
+ u16 length = m_rx_descriptors[rx_current].length;
#ifdef E1000_DEBUG
kprintf("E1000: Received 1 packet @ %p (%u) bytes!\n", buffer, length);
#endif
diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h
index e2050853d5..c2eec037b4 100644
--- a/Kernel/Net/E1000NetworkAdapter.h
+++ b/Kernel/Net/E1000NetworkAdapter.h
@@ -13,10 +13,10 @@ public:
static OwnPtr<E1000NetworkAdapter> autodetect();
- E1000NetworkAdapter(PCI::Address, byte irq);
+ E1000NetworkAdapter(PCI::Address, u8 irq);
virtual ~E1000NetworkAdapter() override;
- virtual void send_raw(const byte*, int) override;
+ virtual void send_raw(const u8*, int) override;
private:
virtual void handle_irq() override;
@@ -44,28 +44,28 @@ private:
};
void detect_eeprom();
- dword read_eeprom(byte address);
+ u32 read_eeprom(u8 address);
void read_mac_address();
- void write_command(word address, dword);
- dword read_command(word address);
+ void write_command(u16 address, u32);
+ u32 read_command(u16 address);
void initialize_rx_descriptors();
void initialize_tx_descriptors();
- void out8(word address, byte);
- void out16(word address, word);
- void out32(word address, dword);
- byte in8(word address);
- word in16(word address);
- dword in32(word address);
+ void out8(u16 address, u8);
+ void out16(u16 address, u16);
+ void out32(u16 address, u32);
+ u8 in8(u16 address);
+ u16 in16(u16 address);
+ u32 in32(u16 address);
void receive();
PCI::Address m_pci_address;
- word m_io_base { 0 };
+ u16 m_io_base { 0 };
PhysicalAddress m_mmio_base;
- byte m_interrupt_line { 0 };
+ u8 m_interrupt_line { 0 };
bool m_has_eeprom { false };
bool m_use_mmio { false };
diff --git a/Kernel/Net/EtherType.h b/Kernel/Net/EtherType.h
index ae845d5bf5..9f9c8382bc 100644
--- a/Kernel/Net/EtherType.h
+++ b/Kernel/Net/EtherType.h
@@ -3,7 +3,7 @@
#include <AK/Types.h>
struct EtherType {
- enum : word {
+ enum : u16 {
ARP = 0x0806,
IPv4 = 0x0800,
};
diff --git a/Kernel/Net/EthernetFrameHeader.h b/Kernel/Net/EthernetFrameHeader.h
index 137285230e..c42aee8649 100644
--- a/Kernel/Net/EthernetFrameHeader.h
+++ b/Kernel/Net/EthernetFrameHeader.h
@@ -15,8 +15,8 @@ public:
MACAddress source() const { return m_source; }
void set_source(const MACAddress& address) { m_source = address; }
- word ether_type() const { return m_ether_type; }
- void set_ether_type(word ether_type) { m_ether_type = ether_type; }
+ u16 ether_type() const { return m_ether_type; }
+ void set_ether_type(u16 ether_type) { m_ether_type = ether_type; }
const void* payload() const { return &m_payload[0]; }
void* payload() { return &m_payload[0]; }
@@ -24,8 +24,8 @@ public:
private:
MACAddress m_destination;
MACAddress m_source;
- NetworkOrdered<word> m_ether_type;
- dword m_payload[0];
+ NetworkOrdered<u16> m_ether_type;
+ u32 m_payload[0];
};
static_assert(sizeof(EthernetFrameHeader) == 14);
diff --git a/Kernel/Net/ICMP.h b/Kernel/Net/ICMP.h
index 40bb691181..633c8847d2 100644
--- a/Kernel/Net/ICMP.h
+++ b/Kernel/Net/ICMP.h
@@ -16,22 +16,22 @@ public:
ICMPHeader() {}
~ICMPHeader() {}
- byte type() const { return m_type; }
- void set_type(byte b) { m_type = b; }
+ u8 type() const { return m_type; }
+ void set_type(u8 b) { m_type = b; }
- byte code() const { return m_code; }
- void set_code(byte b) { m_code = b; }
+ u8 code() const { return m_code; }
+ void set_code(u8 b) { m_code = b; }
- word checksum() const { return m_checksum; }
- void set_checksum(word w) { m_checksum = w; }
+ u16 checksum() const { return m_checksum; }
+ void set_checksum(u16 w) { m_checksum = w; }
const void* payload() const { return this + 1; }
void* payload() { return this + 1; }
private:
- byte m_type { 0 };
- byte m_code { 0 };
- NetworkOrdered<word> m_checksum { 0 };
+ u8 m_type { 0 };
+ u8 m_code { 0 };
+ NetworkOrdered<u16> m_checksum { 0 };
// NOTE: The rest of the header is 4 bytes
};
@@ -40,8 +40,8 @@ static_assert(sizeof(ICMPHeader) == 4);
struct [[gnu::packed]] ICMPEchoPacket
{
ICMPHeader header;
- NetworkOrdered<word> identifier;
- NetworkOrdered<word> sequence_number;
+ NetworkOrdered<u16> identifier;
+ NetworkOrdered<u16> sequence_number;
void* payload() { return this + 1; }
const void* payload() const { return this + 1; }
};
diff --git a/Kernel/Net/IPv4.h b/Kernel/Net/IPv4.h
index aa802df6cb..827435e470 100644
--- a/Kernel/Net/IPv4.h
+++ b/Kernel/Net/IPv4.h
@@ -6,37 +6,37 @@
#include <AK/NetworkOrdered.h>
#include <AK/Types.h>
-enum class IPv4Protocol : word {
+enum class IPv4Protocol : u16 {
ICMP = 1,
TCP = 6,
UDP = 17,
};
-NetworkOrdered<word> internet_checksum(const void*, size_t);
+NetworkOrdered<u16> internet_checksum(const void*, size_t);
class [[gnu::packed]] IPv4Packet
{
public:
- byte version() const { return (m_version_and_ihl >> 4) & 0xf; }
- void set_version(byte version) { m_version_and_ihl = (m_version_and_ihl & 0x0f) | (version << 4); }
+ u8 version() const { return (m_version_and_ihl >> 4) & 0xf; }
+ void set_version(u8 version) { m_version_and_ihl = (m_version_and_ihl & 0x0f) | (version << 4); }
- byte internet_header_length() const { return m_version_and_ihl & 0xf; }
- void set_internet_header_length(byte ihl) { m_version_and_ihl = (m_version_and_ihl & 0xf0) | (ihl & 0x0f); }
+ u8 internet_header_length() const { return m_version_and_ihl & 0xf; }
+ void set_internet_header_length(u8 ihl) { m_version_and_ihl = (m_version_and_ihl & 0xf0) | (ihl & 0x0f); }
- word length() const { return m_length; }
- void set_length(word length) { m_length = length; }
+ u16 length() const { return m_length; }
+ void set_length(u16 length) { m_length = length; }
- word ident() const { return m_ident; }
- void set_ident(word ident) { m_ident = ident; }
+ u16 ident() const { return m_ident; }
+ void set_ident(u16 ident) { m_ident = ident; }
- byte ttl() const { return m_ttl; }
- void set_ttl(byte ttl) { m_ttl = ttl; }
+ u8 ttl() const { return m_ttl; }
+ void set_ttl(u8 ttl) { m_ttl = ttl; }
- byte protocol() const { return m_protocol; }
- void set_protocol(byte protocol) { m_protocol = protocol; }
+ u8 protocol() const { return m_protocol; }
+ void set_protocol(u8 protocol) { m_protocol = protocol; }
- word checksum() const { return m_checksum; }
- void set_checksum(word checksum) { m_checksum = checksum; }
+ u16 checksum() const { return m_checksum; }
+ void set_checksum(u16 checksum) { m_checksum = checksum; }
const IPv4Address& source() const { return m_source; }
void set_source(const IPv4Address& address) { m_source = address; }
@@ -47,33 +47,33 @@ public:
void* payload() { return this + 1; }
const void* payload() const { return this + 1; }
- word payload_size() const { return m_length - sizeof(IPv4Packet); }
+ u16 payload_size() const { return m_length - sizeof(IPv4Packet); }
- NetworkOrdered<word> compute_checksum() const
+ NetworkOrdered<u16> compute_checksum() const
{
ASSERT(!m_checksum);
return internet_checksum(this, sizeof(IPv4Packet));
}
private:
- byte m_version_and_ihl { 0 };
- byte m_dscp_and_ecn { 0 };
- NetworkOrdered<word> m_length;
- NetworkOrdered<word> m_ident;
- NetworkOrdered<word> m_flags_and_fragment;
- byte m_ttl { 0 };
- NetworkOrdered<byte> m_protocol;
- NetworkOrdered<word> m_checksum;
+ u8 m_version_and_ihl { 0 };
+ u8 m_dscp_and_ecn { 0 };
+ NetworkOrdered<u16> m_length;
+ NetworkOrdered<u16> m_ident;
+ NetworkOrdered<u16> m_flags_and_fragment;
+ u8 m_ttl { 0 };
+ NetworkOrdered<u8> m_protocol;
+ NetworkOrdered<u16> m_checksum;
IPv4Address m_source;
IPv4Address m_destination;
};
static_assert(sizeof(IPv4Packet) == 20);
-inline NetworkOrdered<word> internet_checksum(const void* ptr, size_t count)
+inline NetworkOrdered<u16> internet_checksum(const void* ptr, size_t count)
{
- dword checksum = 0;
- auto* w = (const word*)ptr;
+ u32 checksum = 0;
+ auto* w = (const u16*)ptr;
while (count > 1) {
checksum += convert_between_host_and_network(*w++);
if (checksum & 0x80000000)
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 1d2ec7a57e..39a85db4cc 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -81,7 +81,7 @@ KResult IPv4Socket::bind(const sockaddr* address, socklen_t address_size)
return KResult(-EINVAL);
auto& ia = *(const sockaddr_in*)address;
- m_local_address = IPv4Address((const byte*)&ia.sin_addr.s_addr);
+ m_local_address = IPv4Address((const u8*)&ia.sin_addr.s_addr);
m_local_port = ntohs(ia.sin_port);
dbgprintf("IPv4Socket::bind %s{%p} to port %u\n", class_name(), this, m_local_port);
@@ -98,7 +98,7 @@ KResult IPv4Socket::connect(FileDescription& description, const sockaddr* addres
return KResult(-EINVAL);
auto& ia = *(const sockaddr_in*)address;
- m_peer_address = IPv4Address((const byte*)&ia.sin_addr.s_addr);
+ m_peer_address = IPv4Address((const u8*)&ia.sin_addr.s_addr);
m_peer_port = ntohs(ia.sin_port);
return protocol_connect(description, should_block);
@@ -123,12 +123,12 @@ bool IPv4Socket::can_read(FileDescription& description) const
return m_can_read;
}
-ssize_t IPv4Socket::read(FileDescription& description, byte* buffer, ssize_t size)
+ssize_t IPv4Socket::read(FileDescription& description, u8* buffer, ssize_t size)
{
return recvfrom(description, buffer, size, 0, nullptr, 0);
}
-ssize_t IPv4Socket::write(FileDescription& description, const byte* data, ssize_t size)
+ssize_t IPv4Socket::write(FileDescription& description, const u8* data, ssize_t size)
{
return sendto(description, data, size, 0, nullptr, 0);
}
@@ -145,7 +145,7 @@ int IPv4Socket::allocate_local_port_if_needed()
int port = protocol_allocate_local_port();
if (port < 0)
return port;
- m_local_port = (word)port;
+ m_local_port = (u16)port;
return port;
}
@@ -162,7 +162,7 @@ ssize_t IPv4Socket::sendto(FileDescription&, const void* data, size_t data_lengt
}
auto& ia = *(const sockaddr_in*)addr;
- m_peer_address = IPv4Address((const byte*)&ia.sin_addr.s_addr);
+ m_peer_address = IPv4Address((const u8*)&ia.sin_addr.s_addr);
m_peer_port = ntohs(ia.sin_port);
}
@@ -249,7 +249,7 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t
return protocol_receive(packet.data, buffer, buffer_length, flags);
}
-void IPv4Socket::did_receive(const IPv4Address& source_address, word source_port, ByteBuffer&& packet)
+void IPv4Socket::did_receive(const IPv4Address& source_address, u16 source_port, ByteBuffer&& packet)
{
LOCKER(lock());
auto packet_size = packet.size();
diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h
index 63f90fe346..d6c52a2bbf 100644
--- a/Kernel/Net/IPv4Socket.h
+++ b/Kernel/Net/IPv4Socket.h
@@ -27,21 +27,21 @@ public:
virtual void attach(FileDescription&) override;
virtual void detach(FileDescription&) override;
virtual bool can_read(FileDescription&) const override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_write(FileDescription&) const override;
virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override;
virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
- void did_receive(const IPv4Address& peer_address, word peer_port, ByteBuffer&&);
+ void did_receive(const IPv4Address& peer_address, u16 peer_port, ByteBuffer&&);
const IPv4Address& local_address() const;
- word local_port() const { return m_local_port; }
- void set_local_port(word port) { m_local_port = port; }
+ u16 local_port() const { return m_local_port; }
+ void set_local_port(u16 port) { m_local_port = port; }
const IPv4Address& peer_address() const { return m_peer_address; }
- word peer_port() const { return m_peer_port; }
- void set_peer_port(word port) { m_peer_port = port; }
+ u16 peer_port() const { return m_peer_port; }
+ void set_peer_port(u16 port) { m_peer_port = port; }
protected:
IPv4Socket(int type, int protocol);
@@ -70,16 +70,16 @@ private:
struct ReceivedPacket {
IPv4Address peer_address;
- word peer_port;
+ u16 peer_port;
ByteBuffer data;
};
SinglyLinkedList<ReceivedPacket> m_receive_queue;
- word m_local_port { 0 };
- word m_peer_port { 0 };
+ u16 m_local_port { 0 };
+ u16 m_peer_port { 0 };
- dword m_bytes_received { 0 };
+ u32 m_bytes_received { 0 };
bool m_can_read { false };
};
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index 57e13a4a3a..16f7edfbde 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -155,7 +155,7 @@ bool LocalSocket::can_read(FileDescription& description) const
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::read(FileDescription& description, byte* buffer, ssize_t size)
+ssize_t LocalSocket::read(FileDescription& description, u8* buffer, ssize_t size)
{
auto role = description.socket_role();
if (role == SocketRole::Accepted) {
@@ -184,7 +184,7 @@ bool LocalSocket::has_attached_peer(const FileDescription& description) const
ASSERT_NOT_REACHED();
}
-ssize_t LocalSocket::write(FileDescription& description, const byte* data, ssize_t size)
+ssize_t LocalSocket::write(FileDescription& description, const u8* data, ssize_t size)
{
if (!has_attached_peer(description))
return -EPIPE;
@@ -206,10 +206,10 @@ bool LocalSocket::can_write(FileDescription& description) const
ssize_t LocalSocket::sendto(FileDescription& description, const void* data, size_t data_size, int, const sockaddr*, socklen_t)
{
- return write(description, (const byte*)data, data_size);
+ return write(description, (const u8*)data, data_size);
}
ssize_t LocalSocket::recvfrom(FileDescription& description, void* buffer, size_t buffer_size, int, sockaddr*, socklen_t*)
{
- return read(description, (byte*)buffer, buffer_size);
+ return read(description, (u8*)buffer, buffer_size);
}
diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h
index 4d348e8435..179f290252 100644
--- a/Kernel/Net/LocalSocket.h
+++ b/Kernel/Net/LocalSocket.h
@@ -17,8 +17,8 @@ public:
virtual void attach(FileDescription&) override;
virtual void detach(FileDescription&) override;
virtual bool can_read(FileDescription&) const override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_write(FileDescription&) const override;
virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override;
virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
diff --git a/Kernel/Net/LoopbackAdapter.cpp b/Kernel/Net/LoopbackAdapter.cpp
index 2f90602e6b..2452d0bfad 100644
--- a/Kernel/Net/LoopbackAdapter.cpp
+++ b/Kernel/Net/LoopbackAdapter.cpp
@@ -18,7 +18,7 @@ LoopbackAdapter::~LoopbackAdapter()
{
}
-void LoopbackAdapter::send_raw(const byte* data, int size)
+void LoopbackAdapter::send_raw(const u8* data, int size)
{
dbgprintf("LoopbackAdapter: Sending %d byte(s) to myself.\n", size);
did_receive(data, size);
diff --git a/Kernel/Net/LoopbackAdapter.h b/Kernel/Net/LoopbackAdapter.h
index e22c146330..0e263c57e0 100644
--- a/Kernel/Net/LoopbackAdapter.h
+++ b/Kernel/Net/LoopbackAdapter.h
@@ -9,7 +9,7 @@ public:
virtual ~LoopbackAdapter() override;
- virtual void send_raw(const byte*, int) override;
+ virtual void send_raw(const u8*, int) override;
virtual const char* class_name() const override { return "LoopbackAdapter"; }
private:
diff --git a/Kernel/Net/MACAddress.h b/Kernel/Net/MACAddress.h
index 72069bdaa5..a5e97f31e3 100644
--- a/Kernel/Net/MACAddress.h
+++ b/Kernel/Net/MACAddress.h
@@ -9,13 +9,13 @@ class [[gnu::packed]] MACAddress
{
public:
MACAddress() {}
- MACAddress(const byte data[6])
+ MACAddress(const u8 data[6])
{
memcpy(m_data, data, 6);
}
~MACAddress() {}
- byte operator[](int i) const
+ u8 operator[](int i) const
{
ASSERT(i >= 0 && i < 6);
return m_data[i];
@@ -32,7 +32,7 @@ public:
}
private:
- byte m_data[6];
+ u8 m_data[6];
};
static_assert(sizeof(MACAddress) == 6);
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp
index 7537e1e224..bb39a869ea 100644
--- a/Kernel/Net/NetworkAdapter.cpp
+++ b/Kernel/Net/NetworkAdapter.cpp
@@ -53,7 +53,7 @@ void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet
eth->set_destination(destination);
eth->set_ether_type(EtherType::ARP);
memcpy(eth->payload(), &packet, sizeof(ARPPacket));
- send_raw((byte*)eth, size_in_bytes);
+ send_raw((u8*)eth, size_in_bytes);
}
void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Address& destination_ipv4, IPv4Protocol protocol, ByteBuffer&& payload)
@@ -69,16 +69,16 @@ void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Addr
ipv4.set_internet_header_length(5);
ipv4.set_source(ipv4_address());
ipv4.set_destination(destination_ipv4);
- ipv4.set_protocol((byte)protocol);
+ ipv4.set_protocol((u8)protocol);
ipv4.set_length(sizeof(IPv4Packet) + payload.size());
ipv4.set_ident(1);
ipv4.set_ttl(64);
ipv4.set_checksum(ipv4.compute_checksum());
memcpy(ipv4.payload(), payload.pointer(), payload.size());
- send_raw((const byte*)&eth, size_in_bytes);
+ send_raw((const u8*)&eth, size_in_bytes);
}
-void NetworkAdapter::did_receive(const byte* data, int length)
+void NetworkAdapter::did_receive(const u8* data, int length)
{
InterruptDisabler disabler;
m_packet_queue.append(ByteBuffer::copy(data, length));
diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h
index 39c2374e0d..118bb13774 100644
--- a/Kernel/Net/NetworkAdapter.h
+++ b/Kernel/Net/NetworkAdapter.h
@@ -52,8 +52,8 @@ protected:
NetworkAdapter();
void set_interface_name(const StringView& basename);
void set_mac_address(const MACAddress& mac_address) { m_mac_address = mac_address; }
- virtual void send_raw(const byte*, int) = 0;
- void did_receive(const byte*, int);
+ virtual void send_raw(const u8*, int) = 0;
+ void did_receive(const u8*, int);
private:
MACAddress m_mac_address;
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index 0a12ffd5b7..c680a66135 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -225,8 +225,8 @@ void handle_icmp(const EthernetFrameHeader& eth, int frame_size)
auto& request = reinterpret_cast<const ICMPEchoPacket&>(icmp_header);
kprintf("handle_icmp: EchoRequest from %s: id=%u, seq=%u\n",
ipv4_packet.source().to_string().characters(),
- (word)request.identifier,
- (word)request.sequence_number);
+ (u16)request.identifier,
+ (u16)request.sequence_number);
size_t icmp_packet_size = ipv4_packet.payload_size();
auto buffer = ByteBuffer::create_zeroed(icmp_packet_size);
auto& response = *(ICMPEchoPacket*)buffer.pointer();
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index 7ff1fe7506..876424b9ce 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -9,7 +9,7 @@
#include <Kernel/Lock.h>
#include <Kernel/UnixTypes.h>
-enum class SocketRole : byte {
+enum class SocketRole : u8 {
None,
Listener,
Accepted,
diff --git a/Kernel/Net/TCP.h b/Kernel/Net/TCP.h
index 611c451105..b994b9d47f 100644
--- a/Kernel/Net/TCP.h
+++ b/Kernel/Net/TCP.h
@@ -3,7 +3,7 @@
#include <Kernel/Net/IPv4.h>
struct TCPFlags {
- enum : word {
+ enum : u16 {
FIN = 0x01,
SYN = 0x02,
RST = 0x04,
@@ -19,52 +19,52 @@ public:
TCPPacket() {}
~TCPPacket() {}
- size_t header_size() const { return data_offset() * sizeof(dword); }
+ size_t header_size() const { return data_offset() * sizeof(u32); }
- word source_port() const { return m_source_port; }
- void set_source_port(word port) { m_source_port = port; }
+ u16 source_port() const { return m_source_port; }
+ void set_source_port(u16 port) { m_source_port = port; }
- word destination_port() const { return m_destination_port; }
- void set_destination_port(word port) { m_destination_port = port; }
+ u16 destination_port() const { return m_destination_port; }
+ void set_destination_port(u16 port) { m_destination_port = port; }
- dword sequence_number() const { return m_sequence_number; }
- void set_sequence_number(dword number) { m_sequence_number = number; }
+ u32 sequence_number() const { return m_sequence_number; }
+ void set_sequence_number(u32 number) { m_sequence_number = number; }
- dword ack_number() const { return m_ack_number; }
- void set_ack_number(dword number) { m_ack_number = number; }
+ u32 ack_number() const { return m_ack_number; }
+ void set_ack_number(u32 number) { m_ack_number = number; }
- word flags() const { return m_flags_and_data_offset & 0x1ff; }
- void set_flags(word flags) { m_flags_and_data_offset = (m_flags_and_data_offset & ~0x1ff) | (flags & 0x1ff); }
+ u16 flags() const { return m_flags_and_data_offset & 0x1ff; }
+ void set_flags(u16 flags) { m_flags_and_data_offset = (m_flags_and_data_offset & ~0x1ff) | (flags & 0x1ff); }
bool has_syn() const { return flags() & TCPFlags::SYN; }
bool has_ack() const { return flags() & TCPFlags::ACK; }
bool has_fin() const { return flags() & TCPFlags::FIN; }
- byte data_offset() const { return (m_flags_and_data_offset & 0xf000) >> 12; }
- void set_data_offset(word data_offset) { m_flags_and_data_offset = (m_flags_and_data_offset & ~0xf000) | data_offset << 12; }
+ u8 data_offset() const { return (m_flags_and_data_offset & 0xf000) >> 12; }
+ void set_data_offset(u16 data_offset) { m_flags_and_data_offset = (m_flags_and_data_offset & ~0xf000) | data_offset << 12; }
- word window_size() const { return m_window_size; }
- void set_window_size(word window_size) { m_window_size = window_size; }
+ u16 window_size() const { return m_window_size; }
+ void set_window_size(u16 window_size) { m_window_size = window_size; }
- word checksum() const { return m_checksum; }
- void set_checksum(word checksum) { m_checksum = checksum; }
+ u16 checksum() const { return m_checksum; }
+ void set_checksum(u16 checksum) { m_checksum = checksum; }
- word urgent() const { return m_urgent; }
- void set_urgent(word urgent) { m_urgent = urgent; }
+ u16 urgent() const { return m_urgent; }
+ void set_urgent(u16 urgent) { m_urgent = urgent; }
- const void* payload() const { return ((const byte*)this) + header_size(); }
- void* payload() { return ((byte*)this) + header_size(); }
+ const void* payload() const { return ((const u8*)this) + header_size(); }
+ void* payload() { return ((u8*)this) + header_size(); }
private:
- NetworkOrdered<word> m_source_port;
- NetworkOrdered<word> m_destination_port;
- NetworkOrdered<dword> m_sequence_number;
- NetworkOrdered<dword> m_ack_number;
-
- NetworkOrdered<word> m_flags_and_data_offset;
- NetworkOrdered<word> m_window_size;
- NetworkOrdered<word> m_checksum;
- NetworkOrdered<word> m_urgent;
+ NetworkOrdered<u16> m_source_port;
+ NetworkOrdered<u16> m_destination_port;
+ NetworkOrdered<u32> m_sequence_number;
+ NetworkOrdered<u32> m_ack_number;
+
+ NetworkOrdered<u16> m_flags_and_data_offset;
+ NetworkOrdered<u16> m_window_size;
+ NetworkOrdered<u16> m_checksum;
+ NetworkOrdered<u16> m_urgent;
};
static_assert(sizeof(TCPPacket) == 20);
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index f9d1c1281d..ad2f688495 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -5,15 +5,15 @@
#include <Kernel/Net/TCPSocket.h>
#include <Kernel/Process.h>
-Lockable<HashMap<word, TCPSocket*>>& TCPSocket::sockets_by_port()
+Lockable<HashMap<u16, TCPSocket*>>& TCPSocket::sockets_by_port()
{
- static Lockable<HashMap<word, TCPSocket*>>* s_map;
+ static Lockable<HashMap<u16, TCPSocket*>>* s_map;
if (!s_map)
- s_map = new Lockable<HashMap<word, TCPSocket*>>;
+ s_map = new Lockable<HashMap<u16, TCPSocket*>>;
return *s_map;
}
-TCPSocketHandle TCPSocket::from_port(word port)
+TCPSocketHandle TCPSocket::from_port(u16 port)
{
RefPtr<TCPSocket> socket;
{
@@ -65,7 +65,7 @@ int TCPSocket::protocol_send(const void* data, int data_length)
return data_length;
}
-void TCPSocket::send_tcp_packet(word flags, const void* payload, int payload_size)
+void TCPSocket::send_tcp_packet(u16 flags, const void* payload, int payload_size)
{
// FIXME: Maybe the socket should be bound to an adapter instead of looking it up every time?
auto* adapter = adapter_for_route_to(peer_address());
@@ -78,7 +78,7 @@ void TCPSocket::send_tcp_packet(word flags, const void* payload, int payload_siz
tcp_packet.set_destination_port(peer_port());
tcp_packet.set_window_size(1024);
tcp_packet.set_sequence_number(m_sequence_number);
- tcp_packet.set_data_offset(sizeof(TCPPacket) / sizeof(dword));
+ tcp_packet.set_data_offset(sizeof(TCPPacket) / sizeof(u32));
tcp_packet.set_flags(flags);
if (flags & TCPFlags::ACK)
@@ -104,41 +104,41 @@ void TCPSocket::send_tcp_packet(word flags, const void* payload, int payload_siz
adapter->send_ipv4(MACAddress(), peer_address(), IPv4Protocol::TCP, move(buffer));
}
-NetworkOrdered<word> TCPSocket::compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket& packet, word payload_size)
+NetworkOrdered<u16> TCPSocket::compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket& packet, u16 payload_size)
{
struct [[gnu::packed]] PseudoHeader
{
IPv4Address source;
IPv4Address destination;
- byte zero;
- byte protocol;
- NetworkOrdered<word> payload_size;
+ u8 zero;
+ u8 protocol;
+ NetworkOrdered<u16> payload_size;
};
- PseudoHeader pseudo_header { source, destination, 0, (byte)IPv4Protocol::TCP, sizeof(TCPPacket) + payload_size };
+ PseudoHeader pseudo_header { source, destination, 0, (u8)IPv4Protocol::TCP, sizeof(TCPPacket) + payload_size };
- dword checksum = 0;
- auto* w = (const NetworkOrdered<word>*)&pseudo_header;
- for (size_t i = 0; i < sizeof(pseudo_header) / sizeof(word); ++i) {
+ u32 checksum = 0;
+ auto* w = (const NetworkOrdered<u16>*)&pseudo_header;
+ for (size_t i = 0; i < sizeof(pseudo_header) / sizeof(u16); ++i) {
checksum += w[i];
if (checksum > 0xffff)
checksum = (checksum >> 16) + (checksum & 0xffff);
}
- w = (const NetworkOrdered<word>*)&packet;
- for (size_t i = 0; i < sizeof(packet) / sizeof(word); ++i) {
+ w = (const NetworkOrdered<u16>*)&packet;
+ for (size_t i = 0; i < sizeof(packet) / sizeof(u16); ++i) {
checksum += w[i];
if (checksum > 0xffff)
checksum = (checksum >> 16) + (checksum & 0xffff);
}
ASSERT(packet.data_offset() * 4 == sizeof(TCPPacket));
- w = (const NetworkOrdered<word>*)packet.payload();
- for (size_t i = 0; i < payload_size / sizeof(word); ++i) {
+ w = (const NetworkOrdered<u16>*)packet.payload();
+ for (size_t i = 0; i < payload_size / sizeof(u16); ++i) {
checksum += w[i];
if (checksum > 0xffff)
checksum = (checksum >> 16) + (checksum & 0xffff);
}
if (payload_size & 1) {
- word expanded_byte = ((const byte*)packet.payload())[payload_size - 1] << 8;
+ u16 expanded_byte = ((const u8*)packet.payload())[payload_size - 1] << 8;
checksum += expanded_byte;
if (checksum > 0xffff)
checksum = (checksum >> 16) + (checksum & 0xffff);
@@ -171,13 +171,13 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
int TCPSocket::protocol_allocate_local_port()
{
- static const word first_ephemeral_port = 32768;
- static const word last_ephemeral_port = 60999;
- static const word ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port;
- word first_scan_port = first_ephemeral_port + RandomDevice::random_value() % ephemeral_port_range_size;
+ static const u16 first_ephemeral_port = 32768;
+ static const u16 last_ephemeral_port = 60999;
+ static const u16 ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port;
+ u16 first_scan_port = first_ephemeral_port + RandomDevice::random_value() % ephemeral_port_range_size;
LOCKER(sockets_by_port().lock());
- for (word port = first_scan_port;;) {
+ for (u16 port = first_scan_port;;) {
auto it = sockets_by_port().resource().find(port);
if (it == sockets_by_port().resource().end()) {
set_local_port(port);
diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h
index 4c71a9be8d..8161eca234 100644
--- a/Kernel/Net/TCPSocket.h
+++ b/Kernel/Net/TCPSocket.h
@@ -17,21 +17,21 @@ public:
State state() const { return m_state; }
void set_state(State state) { m_state = state; }
- void set_ack_number(dword n) { m_ack_number = n; }
- void set_sequence_number(dword n) { m_sequence_number = n; }
- dword ack_number() const { return m_ack_number; }
- dword sequence_number() const { return m_sequence_number; }
+ void set_ack_number(u32 n) { m_ack_number = n; }
+ void set_sequence_number(u32 n) { m_sequence_number = n; }
+ u32 ack_number() const { return m_ack_number; }
+ u32 sequence_number() const { return m_sequence_number; }
- void send_tcp_packet(word flags, const void* = nullptr, int = 0);
+ void send_tcp_packet(u16 flags, const void* = nullptr, int = 0);
- static Lockable<HashMap<word, TCPSocket*>>& sockets_by_port();
- static TCPSocketHandle from_port(word);
+ static Lockable<HashMap<u16, TCPSocket*>>& sockets_by_port();
+ static TCPSocketHandle from_port(u16);
private:
explicit TCPSocket(int protocol);
virtual const char* class_name() const override { return "TCPSocket"; }
- static NetworkOrdered<word> compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket&, word payload_size);
+ static NetworkOrdered<u16> compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket&, u16 payload_size);
virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags) override;
virtual int protocol_send(const void*, int) override;
@@ -40,8 +40,8 @@ private:
virtual bool protocol_is_disconnected() const override;
virtual KResult protocol_bind() override;
- dword m_sequence_number { 0 };
- dword m_ack_number { 0 };
+ u32 m_sequence_number { 0 };
+ u32 m_ack_number { 0 };
State m_state { State::Disconnected };
};
diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h
index 7ec39719cd..61718a8f06 100644
--- a/Kernel/Net/UDP.h
+++ b/Kernel/Net/UDP.h
@@ -8,26 +8,26 @@ public:
UDPPacket() {}
~UDPPacket() {}
- word source_port() const { return m_source_port; }
- void set_source_port(word port) { m_source_port = port; }
+ u16 source_port() const { return m_source_port; }
+ void set_source_port(u16 port) { m_source_port = port; }
- word destination_port() const { return m_destination_port; }
- void set_destination_port(word port) { m_destination_port = port; }
+ u16 destination_port() const { return m_destination_port; }
+ void set_destination_port(u16 port) { m_destination_port = port; }
- word length() const { return m_length; }
- void set_length(word length) { m_length = length; }
+ u16 length() const { return m_length; }
+ void set_length(u16 length) { m_length = length; }
- word checksum() const { return m_checksum; }
- void set_checksum(word checksum) { m_checksum = checksum; }
+ u16 checksum() const { return m_checksum; }
+ void set_checksum(u16 checksum) { m_checksum = checksum; }
const void* payload() const { return this + 1; }
void* payload() { return this + 1; }
private:
- NetworkOrdered<word> m_source_port;
- NetworkOrdered<word> m_destination_port;
- NetworkOrdered<word> m_length;
- NetworkOrdered<word> m_checksum;
+ NetworkOrdered<u16> m_source_port;
+ NetworkOrdered<u16> m_destination_port;
+ NetworkOrdered<u16> m_length;
+ NetworkOrdered<u16> m_checksum;
};
static_assert(sizeof(UDPPacket) == 8);
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index c36f09c4bf..9658346642 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -5,15 +5,15 @@
#include <Kernel/Net/UDPSocket.h>
#include <Kernel/Process.h>
-Lockable<HashMap<word, UDPSocket*>>& UDPSocket::sockets_by_port()
+Lockable<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port()
{
- static Lockable<HashMap<word, UDPSocket*>>* s_map;
+ static Lockable<HashMap<u16, UDPSocket*>>* s_map;
if (!s_map)
- s_map = new Lockable<HashMap<word, UDPSocket*>>;
+ s_map = new Lockable<HashMap<u16, UDPSocket*>>;
return *s_map;
}
-UDPSocketHandle UDPSocket::from_port(word port)
+UDPSocketHandle UDPSocket::from_port(u16 port)
{
RefPtr<UDPSocket> socket;
{
@@ -77,13 +77,13 @@ int UDPSocket::protocol_send(const void* data, int data_length)
int UDPSocket::protocol_allocate_local_port()
{
- static const word first_ephemeral_port = 32768;
- static const word last_ephemeral_port = 60999;
- static const word ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port;
- word first_scan_port = first_ephemeral_port + RandomDevice::random_value() % ephemeral_port_range_size;
+ static const u16 first_ephemeral_port = 32768;
+ static const u16 last_ephemeral_port = 60999;
+ static const u16 ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port;
+ u16 first_scan_port = first_ephemeral_port + RandomDevice::random_value() % ephemeral_port_range_size;
LOCKER(sockets_by_port().lock());
- for (word port = first_scan_port;;) {
+ for (u16 port = first_scan_port;;) {
auto it = sockets_by_port().resource().find(port);
if (it == sockets_by_port().resource().end()) {
set_local_port(port);
diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h
index fbfce367b2..2f60b0452d 100644
--- a/Kernel/Net/UDPSocket.h
+++ b/Kernel/Net/UDPSocket.h
@@ -9,12 +9,12 @@ public:
static NonnullRefPtr<UDPSocket> create(int protocol);
virtual ~UDPSocket() override;
- static UDPSocketHandle from_port(word);
+ static UDPSocketHandle from_port(u16);
private:
explicit UDPSocket(int protocol);
virtual const char* class_name() const override { return "UDPSocket"; }
- static Lockable<HashMap<word, UDPSocket*>>& sockets_by_port();
+ static Lockable<HashMap<u16, UDPSocket*>>& sockets_by_port();
virtual int protocol_receive(const ByteBuffer&, void* buffer, size_t buffer_size, int flags) override;
virtual int protocol_send(const void*, int) override;
diff --git a/Kernel/PCI.cpp b/Kernel/PCI.cpp
index 2b7e66aab7..6621d20f97 100644
--- a/Kernel/PCI.cpp
+++ b/Kernel/PCI.cpp
@@ -13,12 +13,12 @@
#define PCI_LATENCY_TIMER 0x0d // byte
#define PCI_HEADER_TYPE 0x0e // byte
#define PCI_BIST 0x0f // byte
-#define PCI_BAR0 0x10 // dword
-#define PCI_BAR1 0x14 // dword
-#define PCI_BAR2 0x18 // dword
-#define PCI_BAR3 0x1C // dword
-#define PCI_BAR4 0x20 // dword
-#define PCI_BAR5 0x24 // dword
+#define PCI_BAR0 0x10 // u32
+#define PCI_BAR1 0x14 // u32
+#define PCI_BAR2 0x18 // u32
+#define PCI_BAR3 0x1C // u32
+#define PCI_BAR4 0x20 // u32
+#define PCI_BAR5 0x24 // u32
#define PCI_INTERRUPT_LINE 0x3C // byte
#define PCI_SECONDARY_BUS 0x19 // byte
#define PCI_HEADER_TYPE_DEVICE 0
@@ -31,7 +31,7 @@
namespace PCI {
template<typename T>
-T read_field(Address address, dword field)
+T read_field(Address address, u32 field)
{
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
if constexpr (sizeof(T) == 4)
@@ -43,7 +43,7 @@ T read_field(Address address, dword field)
}
template<typename T>
-void write_field(Address address, dword field, T value)
+void write_field(Address address, u32 field, T value)
{
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
if constexpr (sizeof(T) == 4)
@@ -54,74 +54,74 @@ void write_field(Address address, dword field, T value)
IO::out8(PCI_VALUE_PORT + (field & 3), value);
}
-word read_type(Address address)
+u16 read_type(Address address)
{
- return (read_field<byte>(address, PCI_CLASS) << 8u) | read_field<byte>(address, PCI_SUBCLASS);
+ return (read_field<u8>(address, PCI_CLASS) << 8u) | read_field<u8>(address, PCI_SUBCLASS);
}
-void enumerate_bus(int type, byte bus, Function<void(Address, ID)>&);
+void enumerate_bus(int type, u8 bus, Function<void(Address, ID)>&);
-void enumerate_functions(int type, byte bus, byte slot, byte function, Function<void(Address, ID)>& callback)
+void enumerate_functions(int type, u8 bus, u8 slot, u8 function, Function<void(Address, ID)>& callback)
{
Address address(bus, slot, function);
if (type == -1 || type == read_type(address))
- callback(address, { read_field<word>(address, PCI_VENDOR_ID), read_field<word>(address, PCI_DEVICE_ID) });
+ callback(address, { read_field<u16>(address, PCI_VENDOR_ID), read_field<u16>(address, PCI_DEVICE_ID) });
if (read_type(address) == PCI_TYPE_BRIDGE) {
- byte secondary_bus = read_field<byte>(address, PCI_SECONDARY_BUS);
+ u8 secondary_bus = read_field<u8>(address, PCI_SECONDARY_BUS);
kprintf("PCI: Found secondary bus: %u\n", secondary_bus);
ASSERT(secondary_bus != bus);
enumerate_bus(type, secondary_bus, callback);
}
}
-void enumerate_slot(int type, byte bus, byte slot, Function<void(Address, ID)>& callback)
+void enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID)>& callback)
{
Address address(bus, slot, 0);
- if (read_field<word>(address, PCI_VENDOR_ID) == PCI_NONE)
+ if (read_field<u16>(address, PCI_VENDOR_ID) == PCI_NONE)
return;
enumerate_functions(type, bus, slot, 0, callback);
- if (!(read_field<byte>(address, PCI_HEADER_TYPE) & 0x80))
+ if (!(read_field<u8>(address, PCI_HEADER_TYPE) & 0x80))
return;
- for (byte function = 1; function < 8; ++function) {
+ for (u8 function = 1; function < 8; ++function) {
Address address(bus, slot, function);
- if (read_field<word>(address, PCI_VENDOR_ID) != PCI_NONE)
+ if (read_field<u16>(address, PCI_VENDOR_ID) != PCI_NONE)
enumerate_functions(type, bus, slot, function, callback);
}
}
-void enumerate_bus(int type, byte bus, Function<void(Address, ID)>& callback)
+void enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback)
{
- for (byte slot = 0; slot < 32; ++slot)
+ for (u8 slot = 0; slot < 32; ++slot)
enumerate_slot(type, bus, slot, callback);
}
-byte get_interrupt_line(Address address) { return read_field<byte>(address, PCI_INTERRUPT_LINE); }
-dword get_BAR0(Address address) { return read_field<dword>(address, PCI_BAR0); }
-dword get_BAR1(Address address) { return read_field<dword>(address, PCI_BAR1); }
-dword get_BAR2(Address address) { return read_field<dword>(address, PCI_BAR2); }
-dword get_BAR3(Address address) { return read_field<dword>(address, PCI_BAR3); }
-dword get_BAR4(Address address) { return read_field<dword>(address, PCI_BAR4); }
-dword get_BAR5(Address address) { return read_field<dword>(address, PCI_BAR5); }
+u8 get_interrupt_line(Address address) { return read_field<u8>(address, PCI_INTERRUPT_LINE); }
+u32 get_BAR0(Address address) { return read_field<u32>(address, PCI_BAR0); }
+u32 get_BAR1(Address address) { return read_field<u32>(address, PCI_BAR1); }
+u32 get_BAR2(Address address) { return read_field<u32>(address, PCI_BAR2); }
+u32 get_BAR3(Address address) { return read_field<u32>(address, PCI_BAR3); }
+u32 get_BAR4(Address address) { return read_field<u32>(address, PCI_BAR4); }
+u32 get_BAR5(Address address) { return read_field<u32>(address, PCI_BAR5); }
void enable_bus_mastering(Address address)
{
- auto value = read_field<word>(address, PCI_COMMAND);
+ auto value = read_field<u16>(address, PCI_COMMAND);
value |= (1 << 2);
value |= (1 << 0);
- write_field<word>(address, PCI_COMMAND, value);
+ write_field<u16>(address, PCI_COMMAND, value);
}
void enumerate_all(Function<void(Address, ID)> callback)
{
// Single PCI host controller.
- if ((read_field<byte>(Address(), PCI_HEADER_TYPE) & 0x80) == 0) {
+ if ((read_field<u8>(Address(), PCI_HEADER_TYPE) & 0x80) == 0) {
enumerate_bus(-1, 0, callback);
return;
}
// Multiple PCI host controllers.
- for (byte function = 0; function < 8; ++function) {
- if (read_field<word>(Address(0, 0, function), PCI_VENDOR_ID) == PCI_NONE)
+ for (u8 function = 0; function < 8; ++function) {
+ if (read_field<u16>(Address(0, 0, function), PCI_VENDOR_ID) == PCI_NONE)
break;
enumerate_bus(-1, function, callback);
}
diff --git a/Kernel/PCI.h b/Kernel/PCI.h
index f295fb8f4d..8a51f7d041 100644
--- a/Kernel/PCI.h
+++ b/Kernel/PCI.h
@@ -6,8 +6,8 @@
namespace PCI {
struct ID {
- word vendor_id { 0 };
- word device_id { 0 };
+ u16 vendor_id { 0 };
+ u16 device_id { 0 };
bool is_null() const { return !vendor_id && !device_id; }
@@ -19,7 +19,7 @@ struct ID {
struct Address {
Address() {}
- Address(byte bus, byte slot, byte function)
+ Address(u8 bus, u8 slot, u8 function)
: m_bus(bus)
, m_slot(slot)
, m_function(function)
@@ -29,29 +29,29 @@ struct Address {
bool is_null() const { return !m_bus && !m_slot && !m_function; }
operator bool() const { return !is_null(); }
- byte bus() const { return m_bus; }
- byte slot() const { return m_slot; }
- byte function() const { return m_function; }
+ u8 bus() const { return m_bus; }
+ u8 slot() const { return m_slot; }
+ u8 function() const { return m_function; }
- dword io_address_for_field(byte field) const
+ u32 io_address_for_field(u8 field) const
{
return 0x80000000u | (m_bus << 16u) | (m_slot << 11u) | (m_function << 8u) | (field & 0xfc);
}
private:
- byte m_bus { 0 };
- byte m_slot { 0 };
- byte m_function { 0 };
+ u8 m_bus { 0 };
+ u8 m_slot { 0 };
+ u8 m_function { 0 };
};
void enumerate_all(Function<void(Address, ID)>);
-byte get_interrupt_line(Address);
-dword get_BAR0(Address);
-dword get_BAR1(Address);
-dword get_BAR2(Address);
-dword get_BAR3(Address);
-dword get_BAR4(Address);
-dword get_BAR5(Address);
+u8 get_interrupt_line(Address);
+u32 get_BAR0(Address);
+u32 get_BAR1(Address);
+u32 get_BAR2(Address);
+u32 get_BAR3(Address);
+u32 get_BAR4(Address);
+u32 get_BAR5(Address);
void enable_bus_mastering(Address);
}
diff --git a/Kernel/PIC.cpp b/Kernel/PIC.cpp
index 3ce2a0bfe5..124ca24974 100644
--- a/Kernel/PIC.cpp
+++ b/Kernel/PIC.cpp
@@ -19,9 +19,9 @@ static bool initialized;
namespace PIC {
-void disable(byte irq)
+void disable(u8 irq)
{
- byte imr;
+ u8 imr;
if (irq & 8) {
imr = IO::in8(PIC1_CMD);
imr |= 1 << (irq - 8);
@@ -33,9 +33,9 @@ void disable(byte irq)
}
}
-void enable(byte irq)
+void enable(u8 irq)
{
- byte imr;
+ u8 imr;
if (irq & 8) {
imr = IO::in8(PIC1_CMD);
imr &= ~(1 << (irq - 8));
@@ -47,7 +47,7 @@ void enable(byte irq)
}
}
-void eoi(byte irq)
+void eoi(u8 irq)
{
if (irq & 8)
IO::out8(PIC1_CTL, 0x20);
@@ -90,21 +90,21 @@ void initialize()
#endif
}
-word get_isr()
+u16 get_isr()
{
IO::out8(PIC0_CTL, 0x0b);
IO::out8(PIC1_CTL, 0x0b);
- byte isr0 = IO::in8(PIC0_CTL);
- byte isr1 = IO::in8(PIC1_CTL);
+ u8 isr0 = IO::in8(PIC0_CTL);
+ u8 isr1 = IO::in8(PIC1_CTL);
return (isr1 << 8) | isr0;
}
-word get_irr()
+u16 get_irr()
{
IO::out8(PIC0_CTL, 0x0a);
IO::out8(PIC1_CTL, 0x0a);
- byte irr0 = IO::in8(PIC0_CTL);
- byte irr1 = IO::in8(PIC1_CTL);
+ u8 irr0 = IO::in8(PIC0_CTL);
+ u8 irr1 = IO::in8(PIC1_CTL);
return (irr1 << 8) | irr0;
}
diff --git a/Kernel/PIC.h b/Kernel/PIC.h
index 7b0dcbe6a5..c8265d9f7e 100644
--- a/Kernel/PIC.h
+++ b/Kernel/PIC.h
@@ -4,23 +4,23 @@
namespace PIC {
-void enable(byte number);
-void disable(byte number);
-void eoi(byte number);
+void enable(u8 number);
+void disable(u8 number);
+void eoi(u8 number);
void initialize();
-word get_isr();
-word get_irr();
+u16 get_isr();
+u16 get_irr();
}
class IRQHandlerScope {
public:
- explicit IRQHandlerScope(byte irq)
+ explicit IRQHandlerScope(u8 irq)
: m_irq(irq)
{
}
~IRQHandlerScope() { PIC::eoi(m_irq); }
private:
- byte m_irq { 0 };
+ u8 m_irq { 0 };
};
diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h
index 8457006aba..974db05592 100644
--- a/Kernel/PhysicalAddress.h
+++ b/Kernel/PhysicalAddress.h
@@ -1,24 +1,26 @@
#pragma once
+#include <AK/Types.h>
+
class PhysicalAddress {
public:
PhysicalAddress() {}
- explicit PhysicalAddress(dword address)
+ explicit PhysicalAddress(u32 address)
: m_address(address)
{
}
- PhysicalAddress offset(dword o) const { return PhysicalAddress(m_address + o); }
- dword get() const { return m_address; }
- void set(dword address) { m_address = address; }
- void mask(dword m) { m_address &= m; }
+ PhysicalAddress offset(u32 o) const { return PhysicalAddress(m_address + o); }
+ u32 get() const { return m_address; }
+ void set(u32 address) { m_address = address; }
+ void mask(u32 m) { m_address &= m; }
bool is_null() const { return m_address == 0; }
- byte* as_ptr() { return reinterpret_cast<byte*>(m_address); }
- const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); }
+ u8* as_ptr() { return reinterpret_cast<u8*>(m_address); }
+ const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); }
- dword page_base() const { return m_address & 0xfffff000; }
+ u32 page_base() const { return m_address & 0xfffff000; }
bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; }
bool operator!=(const PhysicalAddress& other) const { return m_address != other.m_address; }
@@ -28,5 +30,5 @@ public:
bool operator<=(const PhysicalAddress& other) const { return m_address <= other.m_address; }
private:
- dword m_address { 0 };
+ u32 m_address { 0 };
};
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index c5f3a22483..8802cf784a 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -154,7 +154,7 @@ int Process::sys$set_mmap_name(void* addr, size_t size, const char* name)
{
if (!validate_read_str(name))
return -EFAULT;
- auto* region = region_from_range(VirtualAddress((dword)addr), size);
+ auto* region = region_from_range(VirtualAddress((u32)addr), size);
if (!region)
return -EINVAL;
region->set_name(String(name));
@@ -176,10 +176,10 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params)
const char* name = params->name;
if (size == 0)
return (void*)-EINVAL;
- if ((dword)addr & ~PAGE_MASK)
+ if ((u32)addr & ~PAGE_MASK)
return (void*)-EINVAL;
if (flags & MAP_ANONYMOUS) {
- auto* region = allocate_region(VirtualAddress((dword)addr), size, "mmap", prot, false);
+ auto* region = allocate_region(VirtualAddress((u32)addr), size, "mmap", prot, false);
if (!region)
return (void*)-ENOMEM;
if (flags & MAP_SHARED)
@@ -193,7 +193,7 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params)
auto* description = file_description(fd);
if (!description)
return (void*)-EBADF;
- auto region_or_error = description->mmap(*this, VirtualAddress((dword)addr), offset, size, prot);
+ auto region_or_error = description->mmap(*this, VirtualAddress((u32)addr), offset, size, prot);
if (region_or_error.is_error())
return (void*)(int)region_or_error.error();
auto region = region_or_error.value();
@@ -206,7 +206,7 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params)
int Process::sys$munmap(void* addr, size_t size)
{
- auto* region = region_from_range(VirtualAddress((dword)addr), size);
+ auto* region = region_from_range(VirtualAddress((u32)addr), size);
if (!region)
return -EINVAL;
if (!deallocate_region(*region))
@@ -323,7 +323,7 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
if (!metadata.size)
return -ENOTIMPL;
- dword entry_eip = 0;
+ u32 entry_eip = 0;
// FIXME: Is there a race here?
auto old_page_directory = move(m_page_directory);
m_page_directory = PageDirectory::create_for_userspace();
@@ -420,7 +420,7 @@ int Process::do_exec(String path, Vector<String> arguments, Vector<String> envir
m_name = parts.take_last();
// ss0 sp!!!!!!!!!
- dword old_esp0 = main_thread().m_tss.esp0;
+ u32 old_esp0 = main_thread().m_tss.esp0;
memset(&main_thread().m_tss, 0, sizeof(main_thread().m_tss));
main_thread().m_tss.eflags = 0x0202;
@@ -548,7 +548,7 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid,
Process* Process::create_kernel_process(String&& name, void (*e)())
{
auto* process = new Process(move(name), (uid_t)0, (gid_t)0, (pid_t)0, Ring0);
- process->main_thread().tss().eip = (dword)e;
+ process->main_thread().tss().eip = (u32)e;
if (process->pid() != 0) {
InterruptDisabler disabler;
@@ -679,18 +679,18 @@ void Process::create_signal_trampolines_if_needed()
// FIXME: Remap as read-only after setup.
auto* region = allocate_region(VirtualAddress(), PAGE_SIZE, "Signal trampolines", PROT_READ | PROT_WRITE | PROT_EXEC);
m_return_to_ring3_from_signal_trampoline = region->vaddr();
- byte* code_ptr = m_return_to_ring3_from_signal_trampoline.as_ptr();
+ u8* code_ptr = m_return_to_ring3_from_signal_trampoline.as_ptr();
*code_ptr++ = 0x58; // pop eax (Argument to signal handler (ignored here))
*code_ptr++ = 0x5a; // pop edx (Original signal mask to restore)
- *code_ptr++ = 0xb8; // mov eax, <dword>
- *(dword*)code_ptr = Syscall::SC_restore_signal_mask;
- code_ptr += sizeof(dword);
+ *code_ptr++ = 0xb8; // mov eax, <u32>
+ *(u32*)code_ptr = Syscall::SC_restore_signal_mask;
+ code_ptr += sizeof(u32);
*code_ptr++ = 0xcd; // int 0x82
*code_ptr++ = 0x82;
*code_ptr++ = 0x83; // add esp, (stack alignment padding)
*code_ptr++ = 0xc4;
- *code_ptr++ = sizeof(dword) * 3;
+ *code_ptr++ = sizeof(u32) * 3;
*code_ptr++ = 0x61; // popa
*code_ptr++ = 0x9d; // popf
@@ -698,26 +698,26 @@ void Process::create_signal_trampolines_if_needed()
*code_ptr++ = 0x0f; // ud2
*code_ptr++ = 0x0b;
- m_return_to_ring0_from_signal_trampoline = VirtualAddress((dword)code_ptr);
+ m_return_to_ring0_from_signal_trampoline = VirtualAddress((u32)code_ptr);
*code_ptr++ = 0x58; // pop eax (Argument to signal handler (ignored here))
*code_ptr++ = 0x5a; // pop edx (Original signal mask to restore)
- *code_ptr++ = 0xb8; // mov eax, <dword>
- *(dword*)code_ptr = Syscall::SC_restore_signal_mask;
- code_ptr += sizeof(dword);
+ *code_ptr++ = 0xb8; // mov eax, <u32>
+ *(u32*)code_ptr = Syscall::SC_restore_signal_mask;
+ code_ptr += sizeof(u32);
*code_ptr++ = 0xcd; // int 0x82
// NOTE: Stack alignment padding doesn't matter when returning to ring0.
// Nothing matters really, as we're returning by replacing the entire TSS.
*code_ptr++ = 0x82;
- *code_ptr++ = 0xb8; // mov eax, <dword>
- *(dword*)code_ptr = Syscall::SC_sigreturn;
- code_ptr += sizeof(dword);
+ *code_ptr++ = 0xb8; // mov eax, <u32>
+ *(u32*)code_ptr = Syscall::SC_sigreturn;
+ code_ptr += sizeof(u32);
*code_ptr++ = 0xcd; // int 0x82
*code_ptr++ = 0x82;
*code_ptr++ = 0x0f; // ud2
*code_ptr++ = 0x0b;
}
-int Process::sys$restore_signal_mask(dword mask)
+int Process::sys$restore_signal_mask(u32 mask)
{
current->m_signal_mask = mask;
return 0;
@@ -740,7 +740,7 @@ void Process::sys$sigreturn()
ASSERT_NOT_REACHED();
}
-void Process::crash(int signal, dword eip)
+void Process::crash(int signal, u32 eip)
{
ASSERT_INTERRUPTS_DISABLED();
ASSERT(!is_dead());
@@ -793,7 +793,7 @@ ssize_t Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size)
auto* description = file_description(fd);
if (!description)
return -EBADF;
- return description->get_dir_entries((byte*)buffer, size);
+ return description->get_dir_entries((u8*)buffer, size);
}
int Process::sys$lseek(int fd, off_t offset, int whence)
@@ -857,7 +857,7 @@ ssize_t Process::sys$writev(int fd, const struct iovec* iov, int iov_count)
int nwritten = 0;
for (int i = 0; i < iov_count; ++i) {
- int rc = do_write(*description, (const byte*)iov[i].iov_base, iov[i].iov_len);
+ int rc = do_write(*description, (const u8*)iov[i].iov_base, iov[i].iov_len);
if (rc < 0) {
if (nwritten == 0)
return rc;
@@ -875,7 +875,7 @@ ssize_t Process::sys$writev(int fd, const struct iovec* iov, int iov_count)
return nwritten;
}
-ssize_t Process::do_write(FileDescription& description, const byte* data, int data_size)
+ssize_t Process::do_write(FileDescription& description, const u8* data, int data_size)
{
ssize_t nwritten = 0;
if (!description.is_blocking()) {
@@ -921,7 +921,7 @@ ssize_t Process::do_write(FileDescription& description, const byte* data, int da
return nwritten;
}
-ssize_t Process::sys$write(int fd, const byte* data, ssize_t size)
+ssize_t Process::sys$write(int fd, const u8* data, ssize_t size)
{
if (size < 0)
return -EINVAL;
@@ -944,7 +944,7 @@ ssize_t Process::sys$write(int fd, const byte* data, ssize_t size)
return nwritten;
}
-ssize_t Process::sys$read(int fd, byte* buffer, ssize_t size)
+ssize_t Process::sys$read(int fd, u8* buffer, ssize_t size)
{
if (size < 0)
return -EINVAL;
@@ -1005,7 +1005,7 @@ int Process::sys$access(const char* pathname, int mode)
return VFS::the().access(StringView(pathname), mode, current_directory());
}
-int Process::sys$fcntl(int fd, int cmd, dword arg)
+int Process::sys$fcntl(int fd, int cmd, u32 arg)
{
(void)cmd;
(void)arg;
@@ -1144,7 +1144,7 @@ int Process::sys$open(const char* path, int options, mode_t mode)
if (options & O_DIRECTORY && !description->is_directory())
return -ENOTDIR; // FIXME: This should be handled by VFS::open.
description->set_file_flags(options);
- dword fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
+ u32 fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
m_fds[fd].set(move(description), fd_flags);
return fd;
}
@@ -1284,7 +1284,7 @@ int Process::sys$usleep(useconds_t usec)
current->sleep(usec / 1000);
if (current->m_wakeup_time > g_uptime) {
ASSERT(current->m_was_interrupted_while_blocked);
- dword ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
+ u32 ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
return ticks_left_until_original_wakeup_time / TICKS_PER_SECOND;
}
return 0;
@@ -1297,7 +1297,7 @@ int Process::sys$sleep(unsigned seconds)
current->sleep(seconds * TICKS_PER_SECOND);
if (current->m_wakeup_time > g_uptime) {
ASSERT(current->m_was_interrupted_while_blocked);
- dword ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
+ u32 ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
return ticks_left_until_original_wakeup_time / TICKS_PER_SECOND;
}
return 0;
@@ -1495,7 +1495,7 @@ bool Process::validate_read_str(const char* str)
bool Process::validate_read(const void* address, ssize_t size) const
{
ASSERT(size >= 0);
- VirtualAddress first_address((dword)address);
+ VirtualAddress first_address((u32)address);
VirtualAddress last_address = first_address.offset(size - 1);
if (is_ring0()) {
auto kmc_result = check_kernel_memory_access(first_address, false);
@@ -1519,7 +1519,7 @@ bool Process::validate_read(const void* address, ssize_t size) const
bool Process::validate_write(void* address, ssize_t size) const
{
ASSERT(size >= 0);
- VirtualAddress first_address((dword)address);
+ VirtualAddress first_address((u32)address);
VirtualAddress last_address = first_address.offset(size - 1);
if (is_ring0()) {
if (is_kmalloc_address(address))
@@ -1699,7 +1699,7 @@ int Process::sys$sigaction(int signum, const sigaction* act, sigaction* old_act)
old_act->sa_sigaction = (decltype(old_act->sa_sigaction))action.handler_or_sigaction.get();
}
action.flags = act->sa_flags;
- action.handler_or_sigaction = VirtualAddress((dword)act->sa_sigaction);
+ action.handler_or_sigaction = VirtualAddress((u32)act->sa_sigaction);
return 0;
}
@@ -1923,7 +1923,7 @@ int Process::sys$rmdir(const char* pathname)
return VFS::the().rmdir(StringView(pathname), current_directory());
}
-int Process::sys$read_tsc(dword* lsw, dword* msw)
+int Process::sys$read_tsc(u32* lsw, u32* msw)
{
if (!validate_write_typed(lsw))
return -EFAULT;
@@ -2587,7 +2587,7 @@ const char* to_string(Process::Priority priority)
return nullptr;
}
-void Process::terminate_due_to_signal(byte signal)
+void Process::terminate_due_to_signal(u8 signal)
{
ASSERT_INTERRUPTS_DISABLED();
ASSERT(signal < 32);
@@ -2597,7 +2597,7 @@ void Process::terminate_due_to_signal(byte signal)
die();
}
-void Process::send_signal(byte signal, Process* sender)
+void Process::send_signal(u8 signal, Process* sender)
{
// FIXME(Thread): Find the appropriate thread to deliver the signal to.
main_thread().send_signal(signal, sender);
@@ -2619,7 +2619,7 @@ int Process::sys$create_thread(int (*entry)(void*), void* argument)
return -EFAULT;
auto* thread = new Thread(*this);
auto& tss = thread->tss();
- tss.eip = (dword)entry;
+ tss.eip = (u32)entry;
tss.eflags = 0x0202;
tss.cr3 = page_directory().cr3();
thread->make_userspace_stack_for_secondary_thread(argument);
@@ -2734,7 +2734,7 @@ void Process::FileDescriptionAndFlags::clear()
flags = 0;
}
-void Process::FileDescriptionAndFlags::set(NonnullRefPtr<FileDescription>&& d, dword f)
+void Process::FileDescriptionAndFlags::set(NonnullRefPtr<FileDescription>&& d, u32 f)
{
description = move(d);
flags = f;
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 86946af79e..04068068bc 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -120,8 +120,8 @@ public:
mode_t sys$umask(mode_t);
int sys$open(const char* path, int options, mode_t mode = 0);
int sys$close(int fd);
- ssize_t sys$read(int fd, byte*, ssize_t);
- ssize_t sys$write(int fd, const byte*, ssize_t);
+ ssize_t sys$read(int fd, u8*, ssize_t);
+ ssize_t sys$write(int fd, const u8*, ssize_t);
ssize_t sys$writev(int fd, const struct iovec* iov, int iov_count);
int sys$fstat(int fd, stat*);
int sys$lstat(const char*, stat*);
@@ -164,7 +164,7 @@ public:
int sys$setuid(uid_t);
unsigned sys$alarm(unsigned seconds);
int sys$access(const char* pathname, int mode);
- int sys$fcntl(int fd, int cmd, dword extra_arg);
+ int sys$fcntl(int fd, int cmd, u32 extra_arg);
int sys$ioctl(int fd, unsigned request, unsigned arg);
int sys$mkdir(const char* pathname, mode_t mode);
clock_t sys$times(tms*);
@@ -173,7 +173,7 @@ public:
int sys$unlink(const char* pathname);
int sys$symlink(const char* target, const char* linkpath);
int sys$rmdir(const char* pathname);
- int sys$read_tsc(dword* lsw, dword* msw);
+ int sys$read_tsc(u32* lsw, u32* msw);
int sys$chmod(const char* pathname, mode_t);
int sys$fchmod(int fd, mode_t);
int sys$chown(const char* pathname, uid_t, gid_t);
@@ -191,7 +191,7 @@ public:
int sys$getpeername(int sockfd, sockaddr* addr, socklen_t* addrlen);
int sys$sched_setparam(pid_t pid, const struct sched_param* param);
int sys$sched_getparam(pid_t pid, struct sched_param* param);
- int sys$restore_signal_mask(dword mask);
+ int sys$restore_signal_mask(u32 mask);
int sys$create_thread(int (*)(void*), void*);
void sys$exit_thread(int code);
int sys$rename(const char* oldpath, const char* newpath);
@@ -205,7 +205,7 @@ public:
static void initialize();
- [[noreturn]] void crash(int signal, dword eip);
+ [[noreturn]] void crash(int signal, u32 eip);
[[nodiscard]] static int reap(Process&);
const TTY* tty() const { return m_tty; }
@@ -218,11 +218,11 @@ public:
ProcessTracer* tracer() { return m_tracer.ptr(); }
ProcessTracer& ensure_tracer();
- dword m_ticks_in_user { 0 };
- dword m_ticks_in_kernel { 0 };
+ u32 m_ticks_in_user { 0 };
+ u32 m_ticks_in_kernel { 0 };
- dword m_ticks_in_user_for_dead_children { 0 };
- dword m_ticks_in_kernel_for_dead_children { 0 };
+ u32 m_ticks_in_user_for_dead_children { 0 };
+ u32 m_ticks_in_kernel_for_dead_children { 0 };
bool validate_read_from_kernel(VirtualAddress) const;
@@ -257,8 +257,8 @@ public:
void set_being_inspected(bool b) { m_being_inspected = b; }
bool is_being_inspected() const { return m_being_inspected; }
- void terminate_due_to_signal(byte signal);
- void send_signal(byte, Process* sender);
+ void terminate_due_to_signal(u8 signal);
+ void send_signal(u8, Process* sender);
int thread_count() const;
@@ -279,7 +279,7 @@ private:
Range allocate_range(VirtualAddress, size_t);
int do_exec(String path, Vector<String> arguments, Vector<String> environment);
- ssize_t do_write(FileDescription&, const byte*, int data_size);
+ ssize_t do_write(FileDescription&, const u8*, int data_size);
int alloc_fd(int first_candidate_fd = 0);
void disown_all_shared_buffers();
@@ -308,17 +308,17 @@ private:
struct FileDescriptionAndFlags {
operator bool() const { return !!description; }
void clear();
- void set(NonnullRefPtr<FileDescription>&& d, dword f = 0);
+ void set(NonnullRefPtr<FileDescription>&& d, u32 f = 0);
RefPtr<FileDescription> description;
- dword flags { 0 };
+ u32 flags { 0 };
};
Vector<FileDescriptionAndFlags> m_fds;
RingLevel m_ring { Ring0 };
static const int m_max_open_file_descriptors { FD_SETSIZE };
- byte m_termination_status { 0 };
- byte m_termination_signal { 0 };
+ u8 m_termination_status { 0 };
+ u8 m_termination_signal { 0 };
RefPtr<Custody> m_executable;
RefPtr<Custody> m_cwd;
@@ -351,7 +351,7 @@ private:
Lock m_big_lock { "Process" };
- qword m_alarm_deadline { 0 };
+ u64 m_alarm_deadline { 0 };
};
class ProcessInspectionHandle {
diff --git a/Kernel/ProcessTracer.cpp b/Kernel/ProcessTracer.cpp
index 33cbf79966..6fa58748ce 100644
--- a/Kernel/ProcessTracer.cpp
+++ b/Kernel/ProcessTracer.cpp
@@ -10,13 +10,13 @@ ProcessTracer::~ProcessTracer()
{
}
-void ProcessTracer::did_syscall(dword function, dword arg1, dword arg2, dword arg3, dword result)
+void ProcessTracer::did_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3, u32 result)
{
CallData data = { function, arg1, arg2, arg3, result };
m_calls.enqueue(data);
}
-int ProcessTracer::read(FileDescription&, byte* buffer, int buffer_size)
+int ProcessTracer::read(FileDescription&, u8* buffer, int buffer_size)
{
if (m_calls.is_empty())
return 0;
diff --git a/Kernel/ProcessTracer.h b/Kernel/ProcessTracer.h
index 8733c0a813..2a064625f5 100644
--- a/Kernel/ProcessTracer.h
+++ b/Kernel/ProcessTracer.h
@@ -13,14 +13,14 @@ public:
void set_dead() { m_dead = true; }
virtual bool can_read(FileDescription&) const override { return !m_calls.is_empty() || m_dead; }
- virtual int read(FileDescription&, byte*, int) override;
+ virtual int read(FileDescription&, u8*, int) override;
virtual bool can_write(FileDescription&) const override { return true; }
- virtual int write(FileDescription&, const byte*, int) override { return -EIO; }
+ virtual int write(FileDescription&, const u8*, int) override { return -EIO; }
virtual String absolute_path(const FileDescription&) const override;
- void did_syscall(dword function, dword arg1, dword arg2, dword arg3, dword result);
+ void did_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3, u32 result);
pid_t pid() const { return m_pid; }
private:
@@ -28,11 +28,11 @@ private:
explicit ProcessTracer(pid_t);
struct CallData {
- dword function;
- dword arg1;
- dword arg2;
- dword arg3;
- dword result;
+ u32 function;
+ u32 arg1;
+ u32 arg2;
+ u32 arg3;
+ u32 result;
};
pid_t m_pid;
diff --git a/Kernel/RTC.cpp b/Kernel/RTC.cpp
index ac5ba4acd5..9e50d5a7c4 100644
--- a/Kernel/RTC.cpp
+++ b/Kernel/RTC.cpp
@@ -8,7 +8,7 @@ static time_t s_boot_time;
void initialize()
{
- byte cmos_mode = CMOS::read(0x0b);
+ u8 cmos_mode = CMOS::read(0x0b);
cmos_mode |= 2; // 24 hour mode
cmos_mode |= 4; // No BCD mode
CMOS::write(0x0b, cmos_mode);
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index 41438ab66f..8f06e76c55 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -10,7 +10,7 @@
//#define LOG_EVERY_CONTEXT_SWITCH
//#define SCHEDULER_DEBUG
-static dword time_slice_for(Process::Priority priority)
+static u32 time_slice_for(Process::Priority priority)
{
// One time slice unit == 1ms
switch (priority) {
@@ -30,11 +30,11 @@ Thread* current;
Thread* g_last_fpu_thread;
Thread* g_finalizer;
static Process* s_colonel_process;
-qword g_uptime;
-static qword s_beep_timeout;
+u64 g_uptime;
+static u64 s_beep_timeout;
struct TaskRedirectionData {
- word selector;
+ u16 selector;
TSS32 tss;
};
static TaskRedirectionData s_redirection;
diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h
index 76b4a8d070..5cdb2c3b64 100644
--- a/Kernel/Scheduler.h
+++ b/Kernel/Scheduler.h
@@ -10,7 +10,7 @@ struct RegisterDump;
extern Thread* current;
extern Thread* g_last_fpu_thread;
extern Thread* g_finalizer;
-extern qword g_uptime;
+extern u64 g_uptime;
class Scheduler {
public:
diff --git a/Kernel/SharedMemory.cpp b/Kernel/SharedMemory.cpp
index fec48ce082..52805a165a 100644
--- a/Kernel/SharedMemory.cpp
+++ b/Kernel/SharedMemory.cpp
@@ -73,7 +73,7 @@ String SharedMemory::absolute_path(const FileDescription&) const
return String::format("shm:%u", this);
}
-int SharedMemory::read(FileDescription&, byte* buffer, int buffer_size)
+int SharedMemory::read(FileDescription&, u8* buffer, int buffer_size)
{
UNUSED_PARAM(buffer);
UNUSED_PARAM(buffer_size);
@@ -81,7 +81,7 @@ int SharedMemory::read(FileDescription&, byte* buffer, int buffer_size)
ASSERT_NOT_REACHED();
}
-int SharedMemory::write(FileDescription&, const byte* data, int data_size)
+int SharedMemory::write(FileDescription&, const u8* data, int data_size)
{
UNUSED_PARAM(data);
UNUSED_PARAM(data_size);
diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h
index 7cc36e1f00..ef77bb0c12 100644
--- a/Kernel/SharedMemory.h
+++ b/Kernel/SharedMemory.h
@@ -26,8 +26,8 @@ private:
// ^File
virtual bool can_read(FileDescription&) const override { return true; }
virtual bool can_write(FileDescription&) const override { return true; }
- virtual int read(FileDescription&, byte*, int) override;
- virtual int write(FileDescription&, const byte*, int) override;
+ virtual int read(FileDescription&, u8*, int) override;
+ virtual int write(FileDescription&, const u8*, int) override;
virtual String absolute_path(const FileDescription&) const override;
virtual const char* class_name() const override { return "SharedMemory"; }
virtual bool is_shared_memory() const override { return true; }
diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp
index e146d643ee..8f31691b6a 100644
--- a/Kernel/StdLib.cpp
+++ b/Kernel/StdLib.cpp
@@ -31,8 +31,8 @@ void* memmove(void* dest, const void* src, size_t n)
if (dest < src)
return memcpy(dest, src, n);
- byte* pd = (byte*)dest;
- const byte* ps = (const byte*)src;
+ u8* pd = (u8*)dest;
+ const u8* ps = (const u8*)src;
for (pd += n, ps += n; n--;)
*--pd = *--ps;
return dest;
@@ -63,7 +63,7 @@ void* memset(void* dest_ptr, int c, size_t n)
// FIXME: Support starting at an unaligned address.
if (!(dest & 0x3) && n >= 12) {
size_t size_ts = n / sizeof(size_t);
- size_t expanded_c = (byte)c;
+ size_t expanded_c = (u8)c;
expanded_c |= expanded_c << 8;
expanded_c |= expanded_c << 16;
asm volatile(
@@ -108,7 +108,7 @@ int strcmp(const char* s1, const char* s2)
if (*s1 == 0)
return 0;
}
- return *(const byte*)s1 < *(const byte*)s2 ? -1 : 1;
+ return *(const u8*)s1 < *(const u8*)s2 ? -1 : 1;
}
char* strdup(const char* str)
@@ -121,8 +121,8 @@ char* strdup(const char* str)
int memcmp(const void* v1, const void* v2, size_t n)
{
- auto* s1 = (const byte*)v1;
- auto* s2 = (const byte*)v2;
+ auto* s1 = (const u8*)v1;
+ auto* s2 = (const u8*)v2;
while (n-- > 0) {
if (*s1++ != *s2++)
return s1[-1] < s2[-1] ? -1 : 1;
diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h
index 6fa43e3563..2273b4e631 100644
--- a/Kernel/StdLib.h
+++ b/Kernel/StdLib.h
@@ -17,6 +17,6 @@ int memcmp(const void*, const void*, size_t);
char* strrchr(const char* str, int ch);
void* memmove(void* dest, const void* src, size_t n);
-inline word ntohs(word w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
-inline word htons(word w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
+inline u16 ntohs(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
+inline u16 htons(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
}
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index 0f6fb51404..df301686cf 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -51,7 +51,7 @@ int sync()
return 0;
}
-static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2, dword arg3)
+static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
{
current->process().did_syscall();
@@ -87,11 +87,11 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_open:
return current->process().sys$open((const char*)arg1, (int)arg2, (mode_t)arg3);
case Syscall::SC_write:
- return current->process().sys$write((int)arg1, (const byte*)arg2, (ssize_t)arg3);
+ return current->process().sys$write((int)arg1, (const u8*)arg2, (ssize_t)arg3);
case Syscall::SC_close:
return current->process().sys$close((int)arg1);
case Syscall::SC_read:
- return current->process().sys$read((int)arg1, (byte*)arg2, (ssize_t)arg3);
+ return current->process().sys$read((int)arg1, (u8*)arg2, (ssize_t)arg3);
case Syscall::SC_lseek:
return current->process().sys$lseek((int)arg1, (off_t)arg2, (int)arg3);
case Syscall::SC_kill:
@@ -107,7 +107,7 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_waitpid:
return current->process().sys$waitpid((pid_t)arg1, (int*)arg2, (int)arg3);
case Syscall::SC_mmap:
- return (dword)current->process().sys$mmap((const SC_mmap_params*)arg1);
+ return (u32)current->process().sys$mmap((const SC_mmap_params*)arg1);
case Syscall::SC_select:
return current->process().sys$select((const SC_select_params*)arg1);
case Syscall::SC_poll:
@@ -197,7 +197,7 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_access:
return current->process().sys$access((const char*)arg1, (int)arg2);
case Syscall::SC_fcntl:
- return current->process().sys$fcntl((int)arg1, (int)arg2, (dword)arg3);
+ return current->process().sys$fcntl((int)arg1, (int)arg2, (u32)arg3);
case Syscall::SC_ioctl:
return current->process().sys$ioctl((int)arg1, (unsigned)arg2, (unsigned)arg3);
case Syscall::SC_fstat:
@@ -217,7 +217,7 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_symlink:
return current->process().sys$symlink((const char*)arg1, (const char*)arg2);
case Syscall::SC_read_tsc:
- return current->process().sys$read_tsc((dword*)arg1, (dword*)arg2);
+ return current->process().sys$read_tsc((u32*)arg1, (u32*)arg2);
case Syscall::SC_rmdir:
return current->process().sys$rmdir((const char*)arg1);
case Syscall::SC_chmod:
@@ -237,7 +237,7 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_create_shared_buffer:
return current->process().sys$create_shared_buffer((pid_t)arg1, (size_t)arg2, (void**)arg3);
case Syscall::SC_get_shared_buffer:
- return (dword)current->process().sys$get_shared_buffer((int)arg1);
+ return (u32)current->process().sys$get_shared_buffer((int)arg1);
case Syscall::SC_release_shared_buffer:
return current->process().sys$release_shared_buffer((int)arg1);
case Syscall::SC_chown:
@@ -245,7 +245,7 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
case Syscall::SC_fchown:
return current->process().sys$fchown((int)arg1, (uid_t)arg2, (gid_t)arg3);
case Syscall::SC_restore_signal_mask:
- return current->process().sys$restore_signal_mask((dword)arg1);
+ return current->process().sys$restore_signal_mask((u32)arg1);
case Syscall::SC_seal_shared_buffer:
return current->process().sys$seal_shared_buffer((int)arg1);
case Syscall::SC_get_shared_buffer_size:
@@ -303,10 +303,10 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
void syscall_trap_entry(RegisterDump& regs)
{
current->process().big_lock().lock();
- dword function = regs.eax;
- dword arg1 = regs.edx;
- dword arg2 = regs.ecx;
- dword arg3 = regs.ebx;
+ u32 function = regs.eax;
+ u32 arg1 = regs.edx;
+ u32 arg2 = regs.ecx;
+ u32 arg3 = regs.ebx;
regs.eax = Syscall::handle(regs, function, arg1, arg2, arg3);
if (auto* tracer = current->process().tracer())
tracer->did_syscall(function, arg1, arg2, arg3, regs.eax);
diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h
index 033148a76f..51e3dce753 100644
--- a/Kernel/Syscall.h
+++ b/Kernel/Syscall.h
@@ -193,9 +193,9 @@ struct SC_setsockopt_params {
void initialize();
int sync();
-inline dword invoke(Function function)
+inline u32 invoke(Function function)
{
- dword result;
+ u32 result;
asm volatile("int $0x82"
: "=a"(result)
: "a"(function)
@@ -204,34 +204,34 @@ inline dword invoke(Function function)
}
template<typename T1>
-inline dword invoke(Function function, T1 arg1)
+inline u32 invoke(Function function, T1 arg1)
{
- dword result;
+ u32 result;
asm volatile("int $0x82"
: "=a"(result)
- : "a"(function), "d"((dword)arg1)
+ : "a"(function), "d"((u32)arg1)
: "memory");
return result;
}
template<typename T1, typename T2>
-inline dword invoke(Function function, T1 arg1, T2 arg2)
+inline u32 invoke(Function function, T1 arg1, T2 arg2)
{
- dword result;
+ u32 result;
asm volatile("int $0x82"
: "=a"(result)
- : "a"(function), "d"((dword)arg1), "c"((dword)arg2)
+ : "a"(function), "d"((u32)arg1), "c"((u32)arg2)
: "memory");
return result;
}
template<typename T1, typename T2, typename T3>
-inline dword invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
+inline u32 invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
{
- dword result;
+ u32 result;
asm volatile("int $0x82"
: "=a"(result)
- : "a"(function), "d"((dword)arg1), "c"((dword)arg2), "b"((dword)arg3)
+ : "a"(function), "d"((u32)arg1), "c"((u32)arg2), "b"((u32)arg3)
: "memory");
return result;
}
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp
index fa339786c9..897314f3b1 100644
--- a/Kernel/TTY/MasterPTY.cpp
+++ b/Kernel/TTY/MasterPTY.cpp
@@ -31,14 +31,14 @@ String MasterPTY::pts_name() const
return m_pts_name;
}
-ssize_t MasterPTY::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t MasterPTY::read(FileDescription&, u8* buffer, ssize_t size)
{
if (!m_slave && m_buffer.is_empty())
return 0;
return m_buffer.read(buffer, size);
}
-ssize_t MasterPTY::write(FileDescription&, const byte* buffer, ssize_t size)
+ssize_t MasterPTY::write(FileDescription&, const u8* buffer, ssize_t size)
{
if (!m_slave)
return -EIO;
@@ -69,7 +69,7 @@ void MasterPTY::notify_slave_closed(Badge<SlavePTY>)
m_slave = nullptr;
}
-ssize_t MasterPTY::on_slave_write(const byte* data, ssize_t size)
+ssize_t MasterPTY::on_slave_write(const u8* data, ssize_t size)
{
if (m_closed)
return -EIO;
diff --git a/Kernel/TTY/MasterPTY.h b/Kernel/TTY/MasterPTY.h
index d4965cd76a..cb97f8f609 100644
--- a/Kernel/TTY/MasterPTY.h
+++ b/Kernel/TTY/MasterPTY.h
@@ -13,15 +13,15 @@ public:
unsigned index() const { return m_index; }
String pts_name() const;
- ssize_t on_slave_write(const byte*, ssize_t);
+ ssize_t on_slave_write(const u8*, ssize_t);
bool can_write_from_slave() const;
void notify_slave_closed(Badge<SlavePTY>);
bool is_closed() const { return m_closed; }
private:
// ^CharacterDevice
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override;
virtual void close() override;
diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h
index 5a5e8f51b5..a51520298b 100644
--- a/Kernel/TTY/PTYMultiplexer.h
+++ b/Kernel/TTY/PTYMultiplexer.h
@@ -16,8 +16,8 @@ public:
// ^CharacterDevice
virtual KResultOr<NonnullRefPtr<FileDescription>> open(int options) override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override { return 0; }
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override { return 0; }
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return 0; }
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return 0; }
virtual bool can_read(FileDescription&) const override { return true; }
virtual bool can_write(FileDescription&) const override { return true; }
diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp
index 2773db17a8..5f227b50da 100644
--- a/Kernel/TTY/SlavePTY.cpp
+++ b/Kernel/TTY/SlavePTY.cpp
@@ -30,13 +30,13 @@ String SlavePTY::tty_name() const
return m_tty_name;
}
-void SlavePTY::on_master_write(const byte* buffer, ssize_t size)
+void SlavePTY::on_master_write(const u8* buffer, ssize_t size)
{
for (ssize_t i = 0; i < size; ++i)
emit(buffer[i]);
}
-ssize_t SlavePTY::on_tty_write(const byte* data, ssize_t size)
+ssize_t SlavePTY::on_tty_write(const u8* data, ssize_t size)
{
return m_master->on_slave_write(data, size);
}
@@ -53,7 +53,7 @@ bool SlavePTY::can_read(FileDescription& description) const
return TTY::can_read(description);
}
-ssize_t SlavePTY::read(FileDescription& description, byte* buffer, ssize_t size)
+ssize_t SlavePTY::read(FileDescription& description, u8* buffer, ssize_t size)
{
if (m_master->is_closed())
return 0;
diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h
index 71c79371fc..5cb0b7ed80 100644
--- a/Kernel/TTY/SlavePTY.h
+++ b/Kernel/TTY/SlavePTY.h
@@ -9,7 +9,7 @@ class SlavePTY final : public TTY {
public:
virtual ~SlavePTY() override;
- void on_master_write(const byte*, ssize_t);
+ void on_master_write(const u8*, ssize_t);
unsigned index() const { return m_index; }
InodeIdentifier devpts_inode_id() const { return m_devpts_inode_id; }
@@ -18,11 +18,11 @@ public:
private:
// ^TTY
virtual String tty_name() const override;
- virtual ssize_t on_tty_write(const byte*, ssize_t) override;
+ virtual ssize_t on_tty_write(const u8*, ssize_t) override;
// ^CharacterDevice
virtual bool can_read(FileDescription&) const override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
virtual bool can_write(FileDescription&) const override;
virtual const char* class_name() const override { return "SlavePTY"; }
virtual void close() override;
diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp
index 7f5b892d7f..f2062b6303 100644
--- a/Kernel/TTY/TTY.cpp
+++ b/Kernel/TTY/TTY.cpp
@@ -24,12 +24,12 @@ void TTY::set_default_termios()
memcpy(m_termios.c_cc, default_cc, sizeof(default_cc));
}
-ssize_t TTY::read(FileDescription&, byte* buffer, ssize_t size)
+ssize_t TTY::read(FileDescription&, u8* buffer, ssize_t size)
{
return m_buffer.read(buffer, size);
}
-ssize_t TTY::write(FileDescription&, const byte* buffer, ssize_t size)
+ssize_t TTY::write(FileDescription&, const u8* buffer, ssize_t size)
{
#ifdef TTY_DEBUG
dbgprintf("TTY::write {%u} ", size);
@@ -52,7 +52,7 @@ bool TTY::can_write(FileDescription&) const
return true;
}
-void TTY::emit(byte ch)
+void TTY::emit(u8 ch)
{
if (should_generate_signals()) {
if (ch == m_termios.c_cc[VINTR]) {
diff --git a/Kernel/TTY/TTY.h b/Kernel/TTY/TTY.h
index 78c7762829..97fd9900c8 100644
--- a/Kernel/TTY/TTY.h
+++ b/Kernel/TTY/TTY.h
@@ -10,8 +10,8 @@ class TTY : public CharacterDevice {
public:
virtual ~TTY() override;
- virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
virtual bool can_read(FileDescription&) const override;
virtual bool can_write(FileDescription&) const override;
virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override final;
@@ -34,11 +34,11 @@ public:
void hang_up();
protected:
- virtual ssize_t on_tty_write(const byte*, ssize_t) = 0;
+ virtual ssize_t on_tty_write(const u8*, ssize_t) = 0;
void set_size(unsigned short columns, unsigned short rows);
TTY(unsigned major, unsigned minor);
- void emit(byte);
+ void emit(u8);
void generate_signal(int signal);
diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp
index 84ee4c58bf..2a65f9ddfd 100644
--- a/Kernel/TTY/VirtualConsole.cpp
+++ b/Kernel/TTY/VirtualConsole.cpp
@@ -5,13 +5,13 @@
#include <AK/AKString.h>
#include <Kernel/Arch/i386/CPU.h>
-static byte* s_vga_buffer;
+static u8* s_vga_buffer;
static VirtualConsole* s_consoles[6];
static int s_active_console;
-void VirtualConsole::get_vga_cursor(byte& row, byte& column)
+void VirtualConsole::get_vga_cursor(u8& row, u8& column)
{
- word value;
+ u16 value;
IO::out8(0x3d4, 0x0e);
value = IO::in8(0x3d5) << 8;
IO::out8(0x3d4, 0x0f);
@@ -22,7 +22,7 @@ void VirtualConsole::get_vga_cursor(byte& row, byte& column)
void VirtualConsole::flush_vga_cursor()
{
- word value = m_current_vga_start_address + (m_cursor_row * columns() + m_cursor_column);
+ u16 value = m_current_vga_start_address + (m_cursor_row * columns() + m_cursor_column);
IO::out8(0x3d4, 0x0e);
IO::out8(0x3d5, MSB(value));
IO::out8(0x3d4, 0x0f);
@@ -31,7 +31,7 @@ void VirtualConsole::flush_vga_cursor()
void VirtualConsole::initialize()
{
- s_vga_buffer = (byte*)0xb8000;
+ s_vga_buffer = (u8*)0xb8000;
memset(s_consoles, 0, sizeof(s_consoles));
s_active_console = -1;
}
@@ -42,20 +42,20 @@ VirtualConsole::VirtualConsole(unsigned index, InitialContents initial_contents)
{
m_tty_name = String::format("/dev/tty%u", m_index);
set_size(80, 25);
- m_horizontal_tabs = static_cast<byte*>(kmalloc(columns()));
+ m_horizontal_tabs = static_cast<u8*>(kmalloc(columns()));
for (unsigned i = 0; i < columns(); ++i)
m_horizontal_tabs[i] = (i % 8) == 0;
// Rightmost column is always last tab on line.
m_horizontal_tabs[columns() - 1] = 1;
s_consoles[index] = this;
- m_buffer = (byte*)kmalloc_eternal(rows() * columns() * 2);
+ m_buffer = (u8*)kmalloc_eternal(rows() * columns() * 2);
if (initial_contents == AdoptCurrentVGABuffer) {
memcpy(m_buffer, s_vga_buffer, rows() * columns() * 2);
get_vga_cursor(m_cursor_row, m_cursor_column);
} else {
- word* line_mem = reinterpret_cast<word*>(m_buffer);
- for (word i = 0; i < rows() * columns(); ++i)
+ u16* line_mem = reinterpret_cast<u16*>(m_buffer);
+ for (u16 i = 0; i < rows() * columns(); ++i)
line_mem[i] = 0x0720;
}
}
@@ -68,8 +68,8 @@ VirtualConsole::~VirtualConsole()
void VirtualConsole::clear()
{
- word* linemem = m_active ? (word*)s_vga_buffer : (word*)m_buffer;
- for (word i = 0; i < rows() * columns(); ++i)
+ u16* linemem = m_active ? (u16*)s_vga_buffer : (u16*)m_buffer;
+ for (u16 i = 0; i < rows() * columns(); ++i)
linemem[i] = 0x0720;
if (m_active)
set_vga_start_row(0);
@@ -113,22 +113,22 @@ void VirtualConsole::set_active(bool b)
#endif
}
-inline bool is_valid_parameter_character(byte ch)
+inline bool is_valid_parameter_character(u8 ch)
{
return ch >= 0x30 && ch <= 0x3f;
}
-inline bool is_valid_intermediate_character(byte ch)
+inline bool is_valid_intermediate_character(u8 ch)
{
return ch >= 0x20 && ch <= 0x2f;
}
-inline bool is_valid_final_character(byte ch)
+inline bool is_valid_final_character(u8 ch)
{
return ch >= 0x40 && ch <= 0x7e;
}
-enum class VGAColor : byte {
+enum class VGAColor : u8 {
Black = 0,
Blue,
Green,
@@ -147,7 +147,7 @@ enum class VGAColor : byte {
White,
};
-enum class ANSIColor : byte {
+enum class ANSIColor : u8 {
Black = 0,
Red,
Green,
@@ -206,9 +206,9 @@ static inline VGAColor ansi_color_to_vga(ANSIColor color)
return VGAColor::LightGray;
}
-static inline byte ansi_color_to_vga(byte color)
+static inline u8 ansi_color_to_vga(u8 color)
{
- return (byte)ansi_color_to_vga((ANSIColor)color);
+ return (u8)ansi_color_to_vga((ANSIColor)color);
}
void VirtualConsole::escape$m(const Vector<unsigned>& params)
@@ -319,7 +319,7 @@ void VirtualConsole::escape$J(const Vector<unsigned>& params)
}
}
-void VirtualConsole::execute_escape_sequence(byte final)
+void VirtualConsole::execute_escape_sequence(u8 final)
{
auto paramparts = String::copy(m_parameters).split(';');
Vector<unsigned> params;
@@ -362,10 +362,10 @@ void VirtualConsole::execute_escape_sequence(byte final)
m_intermediates.clear();
}
-void VirtualConsole::clear_vga_row(word row)
+void VirtualConsole::clear_vga_row(u16 row)
{
- word* linemem = (word*)&m_current_vga_window[row * 160];
- for (word i = 0; i < columns(); ++i)
+ u16* linemem = (u16*)&m_current_vga_window[row * 160];
+ for (u16 i = 0; i < columns(); ++i)
linemem[i] = 0x0720;
}
@@ -383,8 +383,8 @@ void VirtualConsole::scroll_up()
}
} else {
memcpy(m_buffer, m_buffer + 160, 160 * 24);
- word* linemem = (word*)&m_buffer[24 * 160];
- for (word i = 0; i < columns(); ++i)
+ u16* linemem = (u16*)&m_buffer[24 * 160];
+ for (u16 i = 0; i < columns(); ++i)
linemem[i] = 0x0720;
}
} else {
@@ -403,13 +403,13 @@ void VirtualConsole::set_cursor(unsigned row, unsigned column)
flush_vga_cursor();
}
-void VirtualConsole::put_character_at(unsigned row, unsigned column, byte ch)
+void VirtualConsole::put_character_at(unsigned row, unsigned column, u8 ch)
{
ASSERT(row < rows());
ASSERT(column < columns());
- word cur = (row * 160) + (column * 2);
+ u16 cur = (row * 160) + (column * 2);
if (m_active) {
- word cur = (row * 160) + (column * 2);
+ u16 cur = (row * 160) + (column * 2);
m_current_vga_window[cur] = ch;
m_current_vga_window[cur + 1] = m_current_attribute;
} else {
@@ -418,7 +418,7 @@ void VirtualConsole::put_character_at(unsigned row, unsigned column, byte ch)
}
}
-void VirtualConsole::on_char(byte ch)
+void VirtualConsole::on_char(u8 ch)
{
switch (m_escape_state) {
case ExpectBracket:
@@ -506,7 +506,7 @@ void VirtualConsole::on_key_pressed(KeyboardDevice::Event key)
emit(key.character);
}
-void VirtualConsole::on_sysconsole_receive(byte ch)
+void VirtualConsole::on_sysconsole_receive(u8 ch)
{
InterruptDisabler disabler;
auto old_attribute = m_current_attribute;
@@ -515,7 +515,7 @@ void VirtualConsole::on_sysconsole_receive(byte ch)
m_current_attribute = old_attribute;
}
-ssize_t VirtualConsole::on_tty_write(const byte* data, ssize_t size)
+ssize_t VirtualConsole::on_tty_write(const u8* data, ssize_t size)
{
InterruptDisabler disabler;
for (ssize_t i = 0; i < size; ++i)
@@ -528,7 +528,7 @@ String VirtualConsole::tty_name() const
return m_tty_name;
}
-void VirtualConsole::set_vga_start_row(word row)
+void VirtualConsole::set_vga_start_row(u16 row)
{
m_vga_start_row = row;
m_current_vga_start_address = row * columns();
diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h
index 7d9bb850da..383fe1d0af 100644
--- a/Kernel/TTY/VirtualConsole.h
+++ b/Kernel/TTY/VirtualConsole.h
@@ -25,28 +25,28 @@ private:
virtual void on_key_pressed(KeyboardDevice::Event) override;
// ^ConsoleImplementation
- virtual void on_sysconsole_receive(byte) override;
+ virtual void on_sysconsole_receive(u8) override;
// ^TTY
- virtual ssize_t on_tty_write(const byte*, ssize_t) override;
+ virtual ssize_t on_tty_write(const u8*, ssize_t) override;
virtual String tty_name() const override;
// ^CharacterDevice
virtual const char* class_name() const override { return "VirtualConsole"; }
void set_active(bool);
- void on_char(byte);
+ void on_char(u8);
- void get_vga_cursor(byte& row, byte& column);
+ void get_vga_cursor(u8& row, u8& column);
void flush_vga_cursor();
- byte* m_buffer;
+ u8* m_buffer;
unsigned m_index;
bool m_active { false };
void scroll_up();
void set_cursor(unsigned row, unsigned column);
- void put_character_at(unsigned row, unsigned column, byte ch);
+ void put_character_at(unsigned row, unsigned column, u8 ch);
void escape$A(const Vector<unsigned>&);
void escape$D(const Vector<unsigned>&);
@@ -58,19 +58,19 @@ private:
void clear();
- byte m_cursor_row { 0 };
- byte m_cursor_column { 0 };
- byte m_saved_cursor_row { 0 };
- byte m_saved_cursor_column { 0 };
- byte m_current_attribute { 0x07 };
+ u8 m_cursor_row { 0 };
+ u8 m_cursor_column { 0 };
+ u8 m_saved_cursor_row { 0 };
+ u8 m_saved_cursor_column { 0 };
+ u8 m_current_attribute { 0x07 };
- void clear_vga_row(word row);
- void set_vga_start_row(word row);
- word m_vga_start_row { 0 };
- word m_current_vga_start_address { 0 };
- byte* m_current_vga_window { nullptr };
+ void clear_vga_row(u16 row);
+ void set_vga_start_row(u16 row);
+ u16 m_vga_start_row { 0 };
+ u16 m_current_vga_start_address { 0 };
+ u8* m_current_vga_window { nullptr };
- void execute_escape_sequence(byte final);
+ void execute_escape_sequence(u8 final);
enum EscapeState {
Normal,
@@ -80,8 +80,8 @@ private:
ExpectFinal,
};
EscapeState m_escape_state { Normal };
- Vector<byte> m_parameters;
- Vector<byte> m_intermediates;
- byte* m_horizontal_tabs { nullptr };
+ Vector<u8> m_parameters;
+ Vector<u8> m_intermediates;
+ u8* m_horizontal_tabs { nullptr };
String m_tty_name;
};
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index a0d26b378d..3176331796 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -19,8 +19,8 @@ HashTable<Thread*>& thread_table()
InlineLinkedList<Thread>* g_runnable_threads;
InlineLinkedList<Thread>* g_nonrunnable_threads;
-static const dword default_kernel_stack_size = 65536;
-static const dword default_userspace_stack_size = 65536;
+static const u32 default_kernel_stack_size = 65536;
+static const u32 default_userspace_stack_size = 65536;
Thread::Thread(Process& process)
: m_process(process)
@@ -33,7 +33,7 @@ Thread::Thread(Process& process)
// Only IF is set when a process boots.
m_tss.eflags = 0x0202;
- word cs, ds, ss;
+ u16 cs, ds, ss;
if (m_process.is_ring0()) {
cs = 0x08;
@@ -57,7 +57,7 @@ Thread::Thread(Process& process)
if (m_process.is_ring0()) {
// FIXME: This memory is leaked.
// But uh, there's also no kernel process termination, so I guess it's not technically leaked...
- m_kernel_stack_base = (dword)kmalloc_eternal(default_kernel_stack_size);
+ m_kernel_stack_base = (u32)kmalloc_eternal(default_kernel_stack_size);
m_tss.esp = (m_kernel_stack_base + default_kernel_stack_size) & 0xfffffff8u;
} else {
@@ -135,7 +135,7 @@ void Thread::block(Thread::State new_state, FileDescription& description)
block(new_state);
}
-void Thread::sleep(dword ticks)
+void Thread::sleep(u32 ticks)
{
ASSERT(state() == Thread::Running);
current->set_wakeup_time(g_uptime + ticks);
@@ -221,7 +221,7 @@ bool Thread::tick()
return --m_ticks_left;
}
-void Thread::send_signal(byte signal, Process* sender)
+void Thread::send_signal(u8 signal, Process* sender)
{
ASSERT(signal < 32);
@@ -242,10 +242,10 @@ bool Thread::has_unmasked_pending_signals() const
ShouldUnblockThread Thread::dispatch_one_pending_signal()
{
ASSERT_INTERRUPTS_DISABLED();
- dword signal_candidates = m_pending_signals & ~m_signal_mask;
+ u32 signal_candidates = m_pending_signals & ~m_signal_mask;
ASSERT(signal_candidates);
- byte signal = 0;
+ u8 signal = 0;
for (; signal < 32; ++signal) {
if (signal_candidates & (1 << signal)) {
break;
@@ -262,7 +262,7 @@ enum class DefaultSignalAction {
Continue,
};
-DefaultSignalAction default_signal_action(byte signal)
+DefaultSignalAction default_signal_action(u8 signal)
{
ASSERT(signal && signal < NSIG);
@@ -307,7 +307,7 @@ DefaultSignalAction default_signal_action(byte signal)
ASSERT_NOT_REACHED();
}
-ShouldUnblockThread Thread::dispatch_signal(byte signal)
+ShouldUnblockThread Thread::dispatch_signal(u8 signal)
{
ASSERT_INTERRUPTS_DISABLED();
ASSERT(signal < 32);
@@ -358,8 +358,8 @@ ShouldUnblockThread Thread::dispatch_signal(byte signal)
return ShouldUnblockThread::Yes;
}
- dword old_signal_mask = m_signal_mask;
- dword new_signal_mask = action.mask;
+ u32 old_signal_mask = m_signal_mask;
+ u32 new_signal_mask = action.mask;
if (action.flags & SA_NODEFER)
new_signal_mask &= ~(1 << signal);
else
@@ -369,9 +369,9 @@ ShouldUnblockThread Thread::dispatch_signal(byte signal)
Scheduler::prepare_to_modify_tss(*this);
- word ret_cs = m_tss.cs;
- dword ret_eip = m_tss.eip;
- dword ret_eflags = m_tss.eflags;
+ u16 ret_cs = m_tss.cs;
+ u32 ret_eip = m_tss.eip;
+ u32 ret_eflags = m_tss.eflags;
bool interrupting_in_kernel = (ret_cs & 3) == 0;
ProcessPagingScope paging_scope(m_process);
@@ -404,7 +404,7 @@ ShouldUnblockThread Thread::dispatch_signal(byte signal)
push_value_on_stack(ret_eflags);
// PUSHA
- dword old_esp = m_tss.esp;
+ u32 old_esp = m_tss.esp;
push_value_on_stack(m_tss.eax);
push_value_on_stack(m_tss.ecx);
push_value_on_stack(m_tss.edx);
@@ -451,14 +451,14 @@ void Thread::set_default_signal_dispositions()
{
// FIXME: Set up all the right default actions. See signal(7).
memset(&m_signal_action_data, 0, sizeof(m_signal_action_data));
- m_signal_action_data[SIGCHLD].handler_or_sigaction = VirtualAddress((dword)SIG_IGN);
- m_signal_action_data[SIGWINCH].handler_or_sigaction = VirtualAddress((dword)SIG_IGN);
+ m_signal_action_data[SIGCHLD].handler_or_sigaction = VirtualAddress((u32)SIG_IGN);
+ m_signal_action_data[SIGWINCH].handler_or_sigaction = VirtualAddress((u32)SIG_IGN);
}
-void Thread::push_value_on_stack(dword value)
+void Thread::push_value_on_stack(u32 value)
{
m_tss.esp -= 4;
- dword* stack_ptr = (dword*)m_tss.esp;
+ u32* stack_ptr = (u32*)m_tss.esp;
*stack_ptr = value;
}
@@ -502,9 +502,9 @@ void Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vect
env[environment.size()] = nullptr;
// NOTE: The stack needs to be 16-byte aligned.
- push_value_on_stack((dword)env);
- push_value_on_stack((dword)argv);
- push_value_on_stack((dword)argc);
+ push_value_on_stack((u32)env);
+ push_value_on_stack((u32)argv);
+ push_value_on_stack((u32)argc);
push_value_on_stack(0);
}
@@ -515,7 +515,7 @@ void Thread::make_userspace_stack_for_secondary_thread(void* argument)
m_tss.esp = region->vaddr().offset(default_userspace_stack_size).get();
// NOTE: The stack needs to be 16-byte aligned.
- push_value_on_stack((dword)argument);
+ push_value_on_stack((u32)argument);
push_value_on_stack(0);
}
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 7b8d070f36..54aee2b4ff 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -24,7 +24,7 @@ enum class ShouldUnblockThread {
struct SignalActionData {
VirtualAddress handler_or_sigaction;
- dword mask { 0 };
+ u32 mask { 0 };
int flags { 0 };
};
@@ -53,7 +53,7 @@ public:
void finalize();
- enum State : byte {
+ enum State : u8 {
Invalid = 0,
Runnable,
Running,
@@ -75,7 +75,7 @@ public:
};
void did_schedule() { ++m_times_scheduled; }
- dword times_scheduled() const { return m_times_scheduled; }
+ u32 times_scheduled() const { return m_times_scheduled; }
bool is_stopped() const { return m_state == Stopped; }
bool is_blocked() const
@@ -84,50 +84,50 @@ public:
}
bool in_kernel() const { return (m_tss.cs & 0x03) == 0; }
- dword frame_ptr() const { return m_tss.ebp; }
- dword stack_ptr() const { return m_tss.esp; }
+ u32 frame_ptr() const { return m_tss.ebp; }
+ u32 stack_ptr() const { return m_tss.esp; }
- word selector() const { return m_far_ptr.selector; }
+ u16 selector() const { return m_far_ptr.selector; }
TSS32& tss() { return m_tss; }
State state() const { return m_state; }
- dword ticks() const { return m_ticks; }
+ u32 ticks() const { return m_ticks; }
pid_t waitee_pid() const { return m_waitee_pid; }
- void sleep(dword ticks);
+ void sleep(u32 ticks);
void block(Thread::State);
void block(Thread::State, FileDescription&);
void unblock();
- void set_wakeup_time(qword t) { m_wakeup_time = t; }
- qword wakeup_time() const { return m_wakeup_time; }
+ void set_wakeup_time(u64 t) { m_wakeup_time = t; }
+ u64 wakeup_time() const { return m_wakeup_time; }
void snooze_until(Alarm&);
KResult wait_for_connect(FileDescription&);
const FarPtr& far_ptr() const { return m_far_ptr; }
bool tick();
- void set_ticks_left(dword t) { m_ticks_left = t; }
- dword ticks_left() const { return m_ticks_left; }
+ void set_ticks_left(u32 t) { m_ticks_left = t; }
+ u32 ticks_left() const { return m_ticks_left; }
- dword kernel_stack_base() const { return m_kernel_stack_base; }
- dword kernel_stack_for_signal_handler_base() const { return m_kernel_stack_for_signal_handler_region ? m_kernel_stack_for_signal_handler_region->vaddr().get() : 0; }
+ u32 kernel_stack_base() const { return m_kernel_stack_base; }
+ u32 kernel_stack_for_signal_handler_base() const { return m_kernel_stack_for_signal_handler_region ? m_kernel_stack_for_signal_handler_region->vaddr().get() : 0; }
- void set_selector(word s) { m_far_ptr.selector = s; }
+ void set_selector(u16 s) { m_far_ptr.selector = s; }
void set_state(State);
- void send_signal(byte signal, Process* sender);
+ void send_signal(u8 signal, Process* sender);
ShouldUnblockThread dispatch_one_pending_signal();
- ShouldUnblockThread dispatch_signal(byte signal);
+ ShouldUnblockThread dispatch_signal(u8 signal);
bool has_unmasked_pending_signals() const;
- void terminate_due_to_signal(byte signal);
+ void terminate_due_to_signal(u8 signal);
FPUState& fpu_state() { return *m_fpu_state; }
bool has_used_fpu() const { return m_has_used_fpu; }
void set_has_used_fpu(bool b) { m_has_used_fpu = b; }
void set_default_signal_dispositions();
- void push_value_on_stack(dword);
+ void push_value_on_stack(u32);
void make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment);
void make_userspace_stack_for_secondary_thread(void* argument);
@@ -169,13 +169,13 @@ private:
TSS32 m_tss;
OwnPtr<TSS32> m_tss_to_resume_kernel;
FarPtr m_far_ptr;
- dword m_ticks { 0 };
- dword m_ticks_left { 0 };
- qword m_wakeup_time { 0 };
- dword m_times_scheduled { 0 };
- dword m_pending_signals { 0 };
- dword m_signal_mask { 0 };
- dword m_kernel_stack_base { 0 };
+ u32 m_ticks { 0 };
+ u32 m_ticks_left { 0 };
+ u64 m_wakeup_time { 0 };
+ u32 m_times_scheduled { 0 };
+ u32 m_pending_signals { 0 };
+ u32 m_signal_mask { 0 };
+ u32 m_kernel_stack_base { 0 };
RefPtr<Region> m_kernel_stack_region;
RefPtr<Region> m_kernel_stack_for_signal_handler_region;
pid_t m_waitee_pid { -1 };
diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h
index c79f7b0a82..063ee96b36 100644
--- a/Kernel/UnixTypes.h
+++ b/Kernel/UnixTypes.h
@@ -216,14 +216,14 @@ struct winsize {
unsigned short ws_col;
};
-typedef dword dev_t;
-typedef dword ino_t;
-typedef word mode_t;
-typedef dword nlink_t;
-typedef dword uid_t;
-typedef dword gid_t;
-typedef dword clock_t;
-typedef dword socklen_t;
+typedef u32 dev_t;
+typedef u32 ino_t;
+typedef u16 mode_t;
+typedef u32 nlink_t;
+typedef u32 uid_t;
+typedef u32 gid_t;
+typedef u32 clock_t;
+typedef u32 socklen_t;
typedef int pid_t;
struct tms {
@@ -236,7 +236,7 @@ struct tms {
typedef void (*__sighandler_t)(int);
typedef __sighandler_t sighandler_t;
-typedef dword sigset_t;
+typedef u32 sigset_t;
typedef void siginfo_t;
struct sigaction {
@@ -259,16 +259,16 @@ struct sigaction {
#define OFF_T_MAX 2147483647
-typedef signed_dword off_t;
-typedef dword time_t;
+typedef i32 off_t;
+typedef u32 time_t;
struct utimbuf {
time_t actime;
time_t modtime;
};
-typedef dword blksize_t;
-typedef dword blkcnt_t;
+typedef u32 blksize_t;
+typedef u32 blkcnt_t;
#define NCCS 32
@@ -343,7 +343,7 @@ struct pollfd {
#define IPPROTO_UDP 17
struct sockaddr {
- word sa_family;
+ u16 sa_family;
char sa_data[14];
};
@@ -351,7 +351,7 @@ struct sockaddr {
#define UNIX_PATH_MAX 108
struct sockaddr_un {
- word sun_family;
+ u16 sun_family;
char sun_path[UNIX_PATH_MAX];
};
@@ -366,14 +366,14 @@ struct sockaddr_in {
char sin_zero[8];
};
-typedef dword __u32;
-typedef word __u16;
-typedef byte __u8;
+typedef u32 __u32;
+typedef u16 __u16;
+typedef u8 __u8;
typedef int __s32;
typedef short __s16;
-typedef dword useconds_t;
-typedef signed_dword suseconds_t;
+typedef u32 useconds_t;
+typedef i32 suseconds_t;
struct timeval {
time_t tv_sec;
@@ -392,8 +392,8 @@ struct utsname {
struct [[gnu::packed]] FarPtr
{
- dword offset { 0 };
- word selector { 0 };
+ u32 offset { 0 };
+ u16 selector { 0 };
};
struct iovec {
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index f49a438923..954bb871d1 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -84,11 +84,11 @@ void MemoryManager::initialize_paging()
for (auto* mmap = (multiboot_memory_map_t*)multiboot_info_ptr->mmap_addr; (unsigned long)mmap < multiboot_info_ptr->mmap_addr + multiboot_info_ptr->mmap_length; mmap = (multiboot_memory_map_t*)((unsigned long)mmap + mmap->size + sizeof(mmap->size))) {
kprintf("MM: Multiboot mmap: base_addr = 0x%x%08x, length = 0x%x%08x, type = 0x%x\n",
- (dword)(mmap->addr >> 32),
- (dword)(mmap->addr & 0xffffffff),
- (dword)(mmap->len >> 32),
- (dword)(mmap->len & 0xffffffff),
- (dword)mmap->type);
+ (u32)(mmap->addr >> 32),
+ (u32)(mmap->addr & 0xffffffff),
+ (u32)(mmap->len >> 32),
+ (u32)(mmap->len & 0xffffffff),
+ (u32)mmap->type);
if (mmap->type != MULTIBOOT_MEMORY_AVAILABLE)
continue;
@@ -99,7 +99,7 @@ void MemoryManager::initialize_paging()
#ifdef MM_DEBUG
kprintf("MM: considering memory at %p - %p\n",
- (dword)mmap->addr, (dword)(mmap->addr + mmap->len));
+ (u32)mmap->addr, (u32)(mmap->addr + mmap->len));
#endif
for (size_t page_base = mmap->addr; page_base < (mmap->addr + mmap->len); page_base += PAGE_SIZE) {
@@ -163,7 +163,7 @@ void MemoryManager::remove_identity_mapping(PageDirectory& page_directory, Virtu
{
InterruptDisabler disabler;
// FIXME: ASSERT(vaddr is 4KB aligned);
- for (dword offset = 0; offset < size; offset += PAGE_SIZE) {
+ for (u32 offset = 0; offset < size; offset += PAGE_SIZE) {
auto pte_address = vaddr.offset(offset);
auto& pte = ensure_pte(page_directory, pte_address);
pte.set_physical_page_base(0);
@@ -177,8 +177,8 @@ void MemoryManager::remove_identity_mapping(PageDirectory& page_directory, Virtu
PageTableEntry& MemoryManager::ensure_pte(PageDirectory& page_directory, VirtualAddress vaddr)
{
ASSERT_INTERRUPTS_DISABLED();
- dword page_directory_index = (vaddr.get() >> 22) & 0x3ff;
- dword page_table_index = (vaddr.get() >> 12) & 0x3ff;
+ u32 page_directory_index = (vaddr.get() >> 22) & 0x3ff;
+ u32 page_table_index = (vaddr.get() >> 12) & 0x3ff;
PageDirectoryEntry& pde = page_directory.entries()[page_directory_index];
if (!pde.is_present()) {
@@ -187,13 +187,13 @@ PageTableEntry& MemoryManager::ensure_pte(PageDirectory& page_directory, Virtual
#endif
if (page_directory_index == 0) {
ASSERT(&page_directory == m_kernel_page_directory);
- pde.set_page_table_base((dword)m_page_table_zero);
+ pde.set_page_table_base((u32)m_page_table_zero);
pde.set_user_allowed(false);
pde.set_present(true);
pde.set_writable(true);
} else if (page_directory_index == 1) {
ASSERT(&page_directory == m_kernel_page_directory);
- pde.set_page_table_base((dword)m_page_table_one);
+ pde.set_page_table_base((u32)m_page_table_one);
pde.set_user_allowed(false);
pde.set_present(true);
pde.set_writable(true);
@@ -224,7 +224,7 @@ void MemoryManager::map_protected(VirtualAddress vaddr, size_t length)
{
InterruptDisabler disabler;
ASSERT(vaddr.is_page_aligned());
- for (dword offset = 0; offset < length; offset += PAGE_SIZE) {
+ for (u32 offset = 0; offset < length; offset += PAGE_SIZE) {
auto pte_address = vaddr.offset(offset);
auto& pte = ensure_pte(kernel_page_directory(), pte_address);
pte.set_physical_page_base(pte_address.get());
@@ -239,7 +239,7 @@ void MemoryManager::create_identity_mapping(PageDirectory& page_directory, Virtu
{
InterruptDisabler disabler;
ASSERT((vaddr.get() & ~PAGE_MASK) == 0);
- for (dword offset = 0; offset < size; offset += PAGE_SIZE) {
+ for (u32 offset = 0; offset < size; offset += PAGE_SIZE) {
auto pte_address = vaddr.offset(offset);
auto& pte = ensure_pte(page_directory, pte_address);
pte.set_physical_page_base(pte_address.get());
@@ -336,8 +336,8 @@ bool MemoryManager::copy_on_write(Region& region, unsigned page_index_in_region)
#endif
auto physical_page_to_copy = move(vmo.physical_pages()[page_index_in_region]);
auto physical_page = allocate_user_physical_page(ShouldZeroFill::No);
- byte* dest_ptr = quickmap_page(*physical_page);
- const byte* src_ptr = region.vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr();
+ u8* dest_ptr = quickmap_page(*physical_page);
+ const u8* src_ptr = region.vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr();
#ifdef PAGE_FAULT_DEBUG
dbgprintf(" >> COW P%x <- P%x\n", physical_page->paddr().get(), physical_page_to_copy->paddr().get());
#endif
@@ -374,7 +374,7 @@ bool MemoryManager::page_in_from_inode(Region& region, unsigned page_index_in_re
dbgprintf("MM: page_in_from_inode ready to read from inode\n");
#endif
sti();
- byte page_buffer[PAGE_SIZE];
+ u8 page_buffer[PAGE_SIZE];
auto& inode = *vmo.inode();
auto nread = inode.read_bytes(vmo.inode_offset() + ((region.first_page_index() + page_index_in_region) * PAGE_SIZE), PAGE_SIZE, page_buffer, nullptr);
if (nread < 0) {
@@ -392,7 +392,7 @@ bool MemoryManager::page_in_from_inode(Region& region, unsigned page_index_in_re
return false;
}
remap_region_page(region, page_index_in_region, true);
- byte* dest_ptr = region.vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr();
+ u8* dest_ptr = region.vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr();
memcpy(dest_ptr, page_buffer, PAGE_SIZE);
return true;
}
@@ -406,7 +406,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
#endif
ASSERT(fault.vaddr() != m_quickmap_addr);
if (fault.is_not_present() && fault.vaddr().get() >= 0xc0000000) {
- dword page_directory_index = (fault.vaddr().get() >> 22) & 0x3ff;
+ u32 page_directory_index = (fault.vaddr().get() >> 22) & 0x3ff;
if (kernel_page_directory().entries()[page_directory_index].is_present()) {
current->process().page_directory().entries()[page_directory_index].copy_from({}, kernel_page_directory().entries()[page_directory_index]);
dbgprintf("NP(kernel): copying new kernel mapping for L%x into process\n", fault.vaddr().get());
@@ -510,8 +510,8 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s
#endif
if (should_zero_fill == ShouldZeroFill::Yes) {
- auto* ptr = (dword*)quickmap_page(*page);
- fast_dword_fill(ptr, 0, PAGE_SIZE / sizeof(dword));
+ auto* ptr = (u32*)quickmap_page(*page);
+ fast_u32_fill(ptr, 0, PAGE_SIZE / sizeof(u32));
unquickmap_page();
}
@@ -563,7 +563,7 @@ RefPtr<PhysicalPage> MemoryManager::allocate_supervisor_physical_page()
dbgprintf("MM: allocate_supervisor_physical_page vending P%p\n", page->paddr().get());
#endif
- fast_dword_fill((dword*)page->paddr().as_ptr(), 0, PAGE_SIZE / sizeof(dword));
+ fast_u32_fill((u32*)page->paddr().as_ptr(), 0, PAGE_SIZE / sizeof(u32));
++m_super_physical_pages_used;
return page;
}
@@ -603,7 +603,7 @@ void MemoryManager::map_for_kernel(VirtualAddress vaddr, PhysicalAddress paddr)
flush_tlb(vaddr);
}
-byte* MemoryManager::quickmap_page(PhysicalPage& physical_page)
+u8* MemoryManager::quickmap_page(PhysicalPage& physical_page)
{
ASSERT_INTERRUPTS_DISABLED();
ASSERT(!m_quickmap_in_use);
@@ -615,7 +615,7 @@ byte* MemoryManager::quickmap_page(PhysicalPage& physical_page)
pte.set_writable(true);
pte.set_user_allowed(false);
flush_tlb(page_vaddr);
- ASSERT((dword)pte.physical_page_base() == physical_page.paddr().get());
+ ASSERT((u32)pte.physical_page_base() == physical_page.paddr().get());
#ifdef MM_DEBUG
dbgprintf("MM: >> quickmap_page L%x => P%x @ PTE=%p\n", page_vaddr, physical_page.paddr().get(), pte.ptr());
#endif
diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h
index 2a758f12dd..67ac2dddb6 100644
--- a/Kernel/VM/MemoryManager.h
+++ b/Kernel/VM/MemoryManager.h
@@ -19,7 +19,7 @@
#include <Kernel/VM/VMObject.h>
#include <Kernel/VirtualAddress.h>
-#define PAGE_ROUND_UP(x) ((((dword)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1)))
+#define PAGE_ROUND_UP(x) ((((u32)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1)))
class SynthFSInode;
@@ -108,7 +108,7 @@ private:
bool page_in_from_inode(Region&, unsigned page_index_in_region);
bool zero_page(Region& region, unsigned page_index_in_region);
- byte* quickmap_page(PhysicalPage&);
+ u8* quickmap_page(PhysicalPage&);
void unquickmap_page();
PageDirectory& kernel_page_directory() { return *m_kernel_page_directory; }
diff --git a/Kernel/VM/PageDirectory.cpp b/Kernel/VM/PageDirectory.cpp
index 7bc5ff3932..f6d401a38f 100644
--- a/Kernel/VM/PageDirectory.cpp
+++ b/Kernel/VM/PageDirectory.cpp
@@ -3,8 +3,8 @@
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PageDirectory.h>
-static const dword userspace_range_base = 0x01000000;
-static const dword kernelspace_range_base = 0xc0000000;
+static const u32 userspace_range_base = 0x01000000;
+static const u32 kernelspace_range_base = 0xc0000000;
PageDirectory::PageDirectory(PhysicalAddress paddr)
: m_range_allocator(VirtualAddress(0xc0000000), 0x3f000000)
diff --git a/Kernel/VM/PageDirectory.h b/Kernel/VM/PageDirectory.h
index b7917aa9f1..7eecd07d16 100644
--- a/Kernel/VM/PageDirectory.h
+++ b/Kernel/VM/PageDirectory.h
@@ -14,7 +14,7 @@ public:
static NonnullRefPtr<PageDirectory> create_at_fixed_address(PhysicalAddress paddr) { return adopt(*new PageDirectory(paddr)); }
~PageDirectory();
- dword cr3() const { return m_directory_page->paddr().get(); }
+ u32 cr3() const { return m_directory_page->paddr().get(); }
PageDirectoryEntry* entries() { return reinterpret_cast<PageDirectoryEntry*>(cr3()); }
void flush(VirtualAddress);
diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h
index d6cfe2e371..0f080e97cc 100644
--- a/Kernel/VM/PhysicalPage.h
+++ b/Kernel/VM/PhysicalPage.h
@@ -30,7 +30,7 @@ public:
static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);
- word ref_count() const { return m_retain_count; }
+ u16 ref_count() const { return m_retain_count; }
private:
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
@@ -38,7 +38,7 @@ private:
void return_to_freelist() &&;
- word m_retain_count { 1 };
+ u16 m_retain_count { 1 };
bool m_may_return_to_freelist { true };
bool m_supervisor { false };
PhysicalAddress m_paddr;
diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp
index e191ce2e25..b18aa639cd 100644
--- a/Kernel/VM/Region.cpp
+++ b/Kernel/VM/Region.cpp
@@ -4,7 +4,7 @@
#include <Kernel/VM/Region.h>
#include <Kernel/VM/VMObject.h>
-Region::Region(const Range& range, const String& name, byte access, bool cow)
+Region::Region(const Range& range, const String& name, u8 access, bool cow)
: m_range(range)
, m_vmo(VMObject::create_anonymous(size()))
, m_name(name)
@@ -15,7 +15,7 @@ Region::Region(const Range& range, const String& name, byte access, bool cow)
MM.register_region(*this);
}
-Region::Region(const Range& range, RefPtr<Inode>&& inode, const String& name, byte access)
+Region::Region(const Range& range, RefPtr<Inode>&& inode, const String& name, u8 access)
: m_range(range)
, m_vmo(VMObject::create_file_backed(move(inode)))
, m_name(name)
@@ -25,7 +25,7 @@ Region::Region(const Range& range, RefPtr<Inode>&& inode, const String& name, by
MM.register_region(*this);
}
-Region::Region(const Range& range, NonnullRefPtr<VMObject>&& vmo, size_t offset_in_vmo, const String& name, byte access, bool cow)
+Region::Region(const Range& range, NonnullRefPtr<VMObject>&& vmo, size_t offset_in_vmo, const String& name, u8 access, bool cow)
: m_range(range)
, m_offset_in_vmo(offset_in_vmo)
, m_vmo(move(vmo))
diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h
index 9079280d2f..3e9f02a490 100644
--- a/Kernel/VM/Region.h
+++ b/Kernel/VM/Region.h
@@ -18,9 +18,9 @@ public:
Execute = 4,
};
- Region(const Range&, const String&, byte access, bool cow = false);
- Region(const Range&, NonnullRefPtr<VMObject>&&, size_t offset_in_vmo, const String&, byte access, bool cow = false);
- Region(const Range&, RefPtr<Inode>&&, const String&, byte access);
+ Region(const Range&, const String&, u8 access, bool cow = false);
+ Region(const Range&, NonnullRefPtr<VMObject>&&, size_t offset_in_vmo, const String&, u8 access, bool cow = false);
+ Region(const Range&, RefPtr<Inode>&&, const String&, u8 access);
~Region();
VirtualAddress vaddr() const { return m_range.base(); }
@@ -102,7 +102,7 @@ private:
size_t m_offset_in_vmo { 0 };
NonnullRefPtr<VMObject> m_vmo;
String m_name;
- byte m_access { 0 };
+ u8 m_access { 0 };
bool m_shared { false };
Bitmap m_cow_map;
};
diff --git a/Kernel/VM/VMObject.cpp b/Kernel/VM/VMObject.cpp
index 0d7bfa65ff..417ee2f7e3 100644
--- a/Kernel/VM/VMObject.cpp
+++ b/Kernel/VM/VMObject.cpp
@@ -118,7 +118,7 @@ void VMObject::inode_size_changed(Badge<Inode>, size_t old_size, size_t new_size
});
}
-void VMObject::inode_contents_changed(Badge<Inode>, off_t offset, ssize_t size, const byte* data)
+void VMObject::inode_contents_changed(Badge<Inode>, off_t offset, ssize_t size, const u8* data)
{
(void)size;
(void)data;
@@ -132,7 +132,7 @@ void VMObject::inode_contents_changed(Badge<Inode>, off_t offset, ssize_t size,
#if 0
size_t current_offset = offset;
size_t remaining_bytes = size;
- const byte* data_ptr = data;
+ const u8* data_ptr = data;
auto to_page_index = [] (size_t offset) -> size_t {
return offset / PAGE_SIZE;
diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h
index c96179201c..46b51e950f 100644
--- a/Kernel/VM/VMObject.h
+++ b/Kernel/VM/VMObject.h
@@ -37,7 +37,7 @@ public:
const Vector<RefPtr<PhysicalPage>>& physical_pages() const { return m_physical_pages; }
Vector<RefPtr<PhysicalPage>>& physical_pages() { return m_physical_pages; }
- void inode_contents_changed(Badge<Inode>, off_t, ssize_t, const byte*);
+ void inode_contents_changed(Badge<Inode>, off_t, ssize_t, const u8*);
void inode_size_changed(Badge<Inode>, size_t old_size, size_t new_size);
size_t size() const { return m_size; }
diff --git a/Kernel/VirtualAddress.h b/Kernel/VirtualAddress.h
index 5f9e7d546b..9bfe838c5e 100644
--- a/Kernel/VirtualAddress.h
+++ b/Kernel/VirtualAddress.h
@@ -5,7 +5,7 @@
class VirtualAddress {
public:
VirtualAddress() {}
- explicit VirtualAddress(dword address)
+ explicit VirtualAddress(u32 address)
: m_address(address)
{
}
@@ -13,10 +13,10 @@ public:
bool is_null() const { return m_address == 0; }
bool is_page_aligned() const { return (m_address & 0xfff) == 0; }
- VirtualAddress offset(dword o) const { return VirtualAddress(m_address + o); }
- dword get() const { return m_address; }
- void set(dword address) { m_address = address; }
- void mask(dword m) { m_address &= m; }
+ VirtualAddress offset(u32 o) const { return VirtualAddress(m_address + o); }
+ u32 get() const { return m_address; }
+ void set(u32 address) { m_address = address; }
+ void mask(u32 m) { m_address &= m; }
bool operator<=(const VirtualAddress& other) const { return m_address <= other.m_address; }
bool operator>=(const VirtualAddress& other) const { return m_address >= other.m_address; }
@@ -25,13 +25,13 @@ public:
bool operator==(const VirtualAddress& other) const { return m_address == other.m_address; }
bool operator!=(const VirtualAddress& other) const { return m_address != other.m_address; }
- byte* as_ptr() { return reinterpret_cast<byte*>(m_address); }
- const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); }
+ u8* as_ptr() { return reinterpret_cast<u8*>(m_address); }
+ const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); }
- dword page_base() const { return m_address & 0xfffff000; }
+ u32 page_base() const { return m_address & 0xfffff000; }
private:
- dword m_address { 0 };
+ u32 m_address { 0 };
};
inline VirtualAddress operator-(const VirtualAddress& a, const VirtualAddress& b)
diff --git a/Kernel/i8253.cpp b/Kernel/i8253.cpp
index 49818a3063..38a401a7cd 100644
--- a/Kernel/i8253.cpp
+++ b/Kernel/i8253.cpp
@@ -36,8 +36,8 @@ asm(
" popa\n"
" iret\n");
-static dword s_ticks_this_second;
-static dword s_seconds_since_boot;
+static u32 s_ticks_this_second;
+static u32 s_seconds_since_boot;
void timer_interrupt_handler(RegisterDump& regs)
{
@@ -52,19 +52,19 @@ void timer_interrupt_handler(RegisterDump& regs)
namespace PIT {
-dword ticks_this_second()
+u32 ticks_this_second()
{
return s_ticks_this_second;
}
-dword seconds_since_boot()
+u32 seconds_since_boot()
{
return s_seconds_since_boot;
}
void initialize()
{
- word timer_reload;
+ u16 timer_reload;
IO::out8(PIT_CTL, TIMER0_SELECT | WRITE_WORD | MODE_SQUARE_WAVE);
diff --git a/Kernel/i8253.h b/Kernel/i8253.h
index 573399d1a1..0421025339 100644
--- a/Kernel/i8253.h
+++ b/Kernel/i8253.h
@@ -26,7 +26,7 @@
namespace PIT {
void initialize();
-dword ticks_this_second();
-dword seconds_since_boot();
+u32 ticks_this_second();
+u32 seconds_since_boot();
}
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index d1b9e381f8..d2bc73e870 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -50,7 +50,7 @@ VFS* vfs;
#ifdef STRESS_TEST_SPAWNING
[[noreturn]] static void spawn_stress()
{
- dword last_sum_alloc = sum_alloc;
+ u32 last_sum_alloc = sum_alloc;
for (unsigned i = 0; i < 10000; ++i) {
int error;
diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp
index 48d18cb98b..4985f84647 100644
--- a/Kernel/kmalloc.cpp
+++ b/Kernel/kmalloc.cpp
@@ -29,22 +29,22 @@ struct [[gnu::packed]] allocation_t
#define BASE_PHYSICAL (3 * MB)
#define RANGE_SIZE (1 * MB)
-static byte alloc_map[POOL_SIZE / CHUNK_SIZE / 8];
+static u8 alloc_map[POOL_SIZE / CHUNK_SIZE / 8];
volatile size_t sum_alloc = 0;
volatile size_t sum_free = POOL_SIZE;
volatile size_t kmalloc_sum_eternal = 0;
-dword g_kmalloc_call_count;
-dword g_kfree_call_count;
+u32 g_kmalloc_call_count;
+u32 g_kfree_call_count;
bool g_dump_kmalloc_stacks;
-static byte* s_next_eternal_ptr;
-static byte* s_end_of_eternal_range;
+static u8* s_next_eternal_ptr;
+static u8* s_end_of_eternal_range;
bool is_kmalloc_address(const void* ptr)
{
- if (ptr >= (byte*)ETERNAL_BASE_PHYSICAL && ptr < s_next_eternal_ptr)
+ if (ptr >= (u8*)ETERNAL_BASE_PHYSICAL && ptr < s_next_eternal_ptr)
return true;
return (size_t)ptr >= BASE_PHYSICAL && (size_t)ptr <= (BASE_PHYSICAL + POOL_SIZE);
}
@@ -58,7 +58,7 @@ void kmalloc_init()
sum_alloc = 0;
sum_free = POOL_SIZE;
- s_next_eternal_ptr = (byte*)ETERNAL_BASE_PHYSICAL;
+ s_next_eternal_ptr = (u8*)ETERNAL_BASE_PHYSICAL;
s_end_of_eternal_range = s_next_eternal_ptr + ETERNAL_RANGE_SIZE;
}
@@ -137,7 +137,7 @@ void* kmalloc_impl(size_t size)
if (chunks_here == chunks_needed) {
auto* a = (allocation_t*)(BASE_PHYSICAL + (first_chunk * CHUNK_SIZE));
- byte* ptr = (byte*)a;
+ u8* ptr = (u8*)a;
ptr += sizeof(allocation_t);
a->nchunk = chunks_needed;
a->start = first_chunk;
@@ -173,7 +173,7 @@ void kfree(void* ptr)
InterruptDisabler disabler;
++g_kfree_call_count;
- auto* a = (allocation_t*)((((byte*)ptr) - sizeof(allocation_t)));
+ auto* a = (allocation_t*)((((u8*)ptr) - sizeof(allocation_t)));
for (size_t k = a->start; k < (a->start + a->nchunk); ++k)
alloc_map[k / 8] &= ~(1 << (k % 8));
diff --git a/Kernel/kmalloc.h b/Kernel/kmalloc.h
index d490e28ce4..172f5cb508 100644
--- a/Kernel/kmalloc.h
+++ b/Kernel/kmalloc.h
@@ -18,8 +18,8 @@ extern volatile size_t sum_alloc;
extern volatile size_t sum_free;
extern volatile size_t kmalloc_sum_eternal;
extern volatile size_t kmalloc_sum_page_aligned;
-extern dword g_kmalloc_call_count;
-extern dword g_kfree_call_count;
+extern u32 g_kmalloc_call_count;
+extern u32 g_kfree_call_count;
extern bool g_dump_kmalloc_stacks;
inline void* operator new(size_t, void* p) { return p; }
diff --git a/LibC/dirent.cpp b/LibC/dirent.cpp
index 07a9ef22ff..1d6f82b733 100644
--- a/LibC/dirent.cpp
+++ b/LibC/dirent.cpp
@@ -41,12 +41,12 @@ int closedir(DIR* dirp)
struct [[gnu::packed]] sys_dirent
{
ino_t ino;
- byte file_type;
+ u8 file_type;
size_t namelen;
char name[];
size_t total_size()
{
- return sizeof(ino_t) + sizeof(byte) + sizeof(size_t) + sizeof(char) * namelen;
+ return sizeof(ino_t) + sizeof(u8) + sizeof(size_t) + sizeof(char) * namelen;
}
};
diff --git a/LibC/fcntl.cpp b/LibC/fcntl.cpp
index ba4e425e1c..582c339710 100644
--- a/LibC/fcntl.cpp
+++ b/LibC/fcntl.cpp
@@ -10,7 +10,7 @@ int fcntl(int fd, int cmd, ...)
{
va_list ap;
va_start(ap, cmd);
- dword extra_arg = va_arg(ap, dword);
+ u32 extra_arg = va_arg(ap, u32);
int rc = syscall(SC_fcntl, fd, cmd, extra_arg);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
diff --git a/LibC/mman.cpp b/LibC/mman.cpp
index 0e89a4ead0..38c08b6825 100644
--- a/LibC/mman.cpp
+++ b/LibC/mman.cpp
@@ -7,7 +7,7 @@ extern "C" {
void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset)
{
- Syscall::SC_mmap_params params { (dword)addr, size, prot, flags, fd, offset, nullptr };
+ Syscall::SC_mmap_params params { (u32)addr, size, prot, flags, fd, offset, nullptr };
int rc = syscall(SC_mmap, &params);
if (rc < 0 && -rc < EMAXERRNO) {
errno = -rc;
@@ -18,7 +18,7 @@ void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset)
void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t offset, const char* name)
{
- Syscall::SC_mmap_params params { (dword)addr, size, prot, flags, fd, offset, name };
+ Syscall::SC_mmap_params params { (u32)addr, size, prot, flags, fd, offset, name };
int rc = syscall(SC_mmap, &params);
if (rc < 0 && -rc < EMAXERRNO) {
errno = -rc;
diff --git a/LibC/netdb.cpp b/LibC/netdb.cpp
index 3376269223..697627a11c 100644
--- a/LibC/netdb.cpp
+++ b/LibC/netdb.cpp
@@ -136,7 +136,7 @@ hostent* gethostbyaddr(const void* addr, socklen_t addr_size, int type)
close(fd);
});
- IPv4Address ipv4_address((const byte*)&((const in_addr*)addr)->s_addr);
+ IPv4Address ipv4_address((const u8*)&((const in_addr*)addr)->s_addr);
auto line = String::format("R%d.%d.%d.%d.in-addr.arpa\n",
ipv4_address[3],
diff --git a/LibC/stdio.cpp b/LibC/stdio.cpp
index e017e98adf..82217fc990 100644
--- a/LibC/stdio.cpp
+++ b/LibC/stdio.cpp
@@ -221,7 +221,7 @@ int fputc(int ch, FILE* stream)
fflush(stream);
if (stream->eof || stream->error)
return EOF;
- return (byte)ch;
+ return (u8)ch;
}
int putc(int ch, FILE* stream)
@@ -298,7 +298,7 @@ size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream)
size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream)
{
assert(stream);
- auto* bytes = (const byte*)ptr;
+ auto* bytes = (const u8*)ptr;
ssize_t nwritten = 0;
for (size_t i = 0; i < (size * nmemb); ++i) {
int rc = fputc(bytes[i], stream);
diff --git a/LibC/string.cpp b/LibC/string.cpp
index dcd795fd30..905e967d51 100644
--- a/LibC/string.cpp
+++ b/LibC/string.cpp
@@ -137,17 +137,17 @@ void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
if (n >= 1024)
return mmx_memcpy(dest_ptr, src_ptr, n);
- dword dest = (dword)dest_ptr;
- dword src = (dword)src_ptr;
+ u32 dest = (u32)dest_ptr;
+ u32 src = (u32)src_ptr;
// FIXME: Support starting at an unaligned address.
if (!(dest & 0x3) && !(src & 0x3) && n >= 12) {
- size_t dwords = n / sizeof(dword);
+ size_t u32s = n / sizeof(u32);
asm volatile(
"rep movsl\n"
: "=S"(src), "=D"(dest)
- : "S"(src), "D"(dest), "c"(dwords)
+ : "S"(src), "D"(dest), "c"(u32s)
: "memory");
- n -= dwords * sizeof(dword);
+ n -= u32s * sizeof(u32);
if (n == 0)
return dest_ptr;
}
@@ -159,19 +159,19 @@ void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
void* memset(void* dest_ptr, int c, size_t n)
{
- dword dest = (dword)dest_ptr;
+ u32 dest = (u32)dest_ptr;
// FIXME: Support starting at an unaligned address.
if (!(dest & 0x3) && n >= 12) {
- size_t dwords = n / sizeof(dword);
- dword expanded_c = (byte)c;
+ size_t u32s = n / sizeof(u32);
+ u32 expanded_c = (u8)c;
expanded_c |= expanded_c << 8;
expanded_c |= expanded_c << 16;
asm volatile(
"rep stosl\n"
: "=D"(dest)
- : "D"(dest), "c"(dwords), "a"(expanded_c)
+ : "D"(dest), "c"(u32s), "a"(expanded_c)
: "memory");
- n -= dwords * sizeof(dword);
+ n -= u32s * sizeof(u32);
if (n == 0)
return dest_ptr;
}
@@ -188,8 +188,8 @@ void* memmove(void* dest, const void* src, size_t n)
if (dest < src)
return memcpy(dest, src, n);
- byte* pd = (byte*)dest;
- const byte* ps = (const byte*)src;
+ u8* pd = (u8*)dest;
+ const u8* ps = (const u8*)src;
for (pd += n, ps += n; n--;)
*--pd = *--ps;
return dest;
diff --git a/LibC/utime.cpp b/LibC/utime.cpp
index e8517ab4df..761d2e60da 100644
--- a/LibC/utime.cpp
+++ b/LibC/utime.cpp
@@ -6,7 +6,7 @@ extern "C" {
int utime(const char* pathname, const struct utimbuf* buf)
{
- int rc = syscall(SC_utime, (dword)pathname, (dword)buf);
+ int rc = syscall(SC_utime, (u32)pathname, (u32)buf);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}
diff --git a/LibCore/CHttpJob.cpp b/LibCore/CHttpJob.cpp
index 5787dbebfc..a3b00b9175 100644
--- a/LibCore/CHttpJob.cpp
+++ b/LibCore/CHttpJob.cpp
@@ -24,7 +24,7 @@ void CHttpJob::on_socket_connected()
if (!success)
return deferred_invoke([this](auto&) { did_fail(CNetworkJob::Error::TransmissionFailed); });
- Vector<byte> buffer;
+ Vector<u8> buffer;
while (m_socket->is_connected()) {
if (m_state == State::InStatus) {
while (!m_socket->can_read_line())
diff --git a/LibCore/CIODevice.cpp b/LibCore/CIODevice.cpp
index 18eba4f811..86393f6888 100644
--- a/LibCore/CIODevice.cpp
+++ b/LibCore/CIODevice.cpp
@@ -33,7 +33,7 @@ ByteBuffer CIODevice::read(int max_size)
if (!m_buffered_data.is_empty()) {
taken_from_buffered = min(remaining_buffer_space, m_buffered_data.size());
memcpy(buffer_ptr, m_buffered_data.data(), taken_from_buffered);
- Vector<byte> new_buffered_data;
+ Vector<u8> new_buffered_data;
new_buffered_data.append(m_buffered_data.data() + taken_from_buffered, m_buffered_data.size() - taken_from_buffered);
m_buffered_data = move(new_buffered_data);
remaining_buffer_space -= taken_from_buffered;
@@ -141,10 +141,10 @@ ByteBuffer CIODevice::read_line(int max_size)
auto line = ByteBuffer::create_uninitialized(max_size + 1);
int line_index = 0;
while (line_index < max_size) {
- byte ch = m_buffered_data[line_index];
+ u8 ch = m_buffered_data[line_index];
line[line_index++] = ch;
if (ch == '\n') {
- Vector<byte> new_buffered_data;
+ Vector<u8> new_buffered_data;
new_buffered_data.append(m_buffered_data.data() + line_index, m_buffered_data.size() - line_index);
m_buffered_data = move(new_buffered_data);
line[line_index] = '\0';
@@ -159,7 +159,7 @@ bool CIODevice::populate_read_buffer()
{
if (m_fd < 0)
return false;
- byte buffer[1024];
+ u8 buffer[1024];
int nread = ::read(m_fd, buffer, sizeof(buffer));
if (nread < 0) {
set_error(errno);
@@ -187,7 +187,7 @@ bool CIODevice::close()
return true;
}
-bool CIODevice::seek(signed_qword offset, SeekMode mode, off_t* pos)
+bool CIODevice::seek(i64 offset, SeekMode mode, off_t* pos)
{
int m = SEEK_SET;
switch (mode) {
@@ -215,7 +215,7 @@ bool CIODevice::seek(signed_qword offset, SeekMode mode, off_t* pos)
return true;
}
-bool CIODevice::write(const byte* data, int size)
+bool CIODevice::write(const u8* data, int size)
{
int rc = ::write(m_fd, data, size);
if (rc < 0) {
@@ -232,7 +232,7 @@ int CIODevice::printf(const char* format, ...)
va_start(ap, format);
// FIXME: We're not propagating write() failures to client here!
int ret = printf_internal([this](char*&, char ch) {
- int rc = write((const byte*)&ch, 1);
+ int rc = write((const u8*)&ch, 1);
if (rc < 0)
dbgprintf("CIODevice::printf: write: %s\n", strerror(errno));
},
diff --git a/LibCore/CIODevice.h b/LibCore/CIODevice.h
index 36cbd0e0fd..e6de17b46d 100644
--- a/LibCore/CIODevice.h
+++ b/LibCore/CIODevice.h
@@ -31,8 +31,8 @@ public:
ByteBuffer read_line(int max_size);
ByteBuffer read_all();
- bool write(const byte*, int size);
- bool write(const AK::StringView& v) { return write((const byte*)v.characters(), v.length()); }
+ bool write(const u8*, int size);
+ bool write(const AK::StringView& v) { return write((const u8*)v.characters(), v.length()); }
// FIXME: I would like this to be const but currently it needs to call populate_read_buffer().
bool can_read_line();
@@ -45,7 +45,7 @@ public:
FromEndPosition,
};
- bool seek(signed_qword, SeekMode = SeekMode::SetPosition, off_t* = nullptr);
+ bool seek(i64, SeekMode = SeekMode::SetPosition, off_t* = nullptr);
virtual bool open(CIODevice::OpenMode) = 0;
virtual bool close();
@@ -70,5 +70,5 @@ private:
int m_error { 0 };
bool m_eof { false };
OpenMode m_mode { NotOpen };
- Vector<byte> m_buffered_data;
+ Vector<u8> m_buffered_data;
};
diff --git a/LibCore/CLock.h b/LibCore/CLock.h
index add591037f..2c31751f92 100644
--- a/LibCore/CLock.h
+++ b/LibCore/CLock.h
@@ -9,9 +9,9 @@
#define memory_barrier() asm volatile("" :: \
: "memory")
-static inline dword CAS(volatile dword* mem, dword newval, dword oldval)
+static inline u32 CAS(volatile u32* mem, u32 newval, u32 oldval)
{
- dword ret;
+ u32 ret;
asm volatile(
"cmpxchgl %2, %1"
: "=a"(ret), "+m"(*mem)
@@ -29,8 +29,8 @@ public:
void unlock();
private:
- volatile dword m_lock { 0 };
- dword m_level { 0 };
+ volatile u32 m_lock { 0 };
+ u32 m_level { 0 };
int m_holder { -1 };
};
diff --git a/LibCore/CProcessStatisticsReader.cpp b/LibCore/CProcessStatisticsReader.cpp
index 67c81386a3..7f0456d53e 100644
--- a/LibCore/CProcessStatisticsReader.cpp
+++ b/LibCore/CProcessStatisticsReader.cpp
@@ -34,16 +34,16 @@ void CProcessStatisticsReader::update_map(HashMap<pid_t, CProcessStatistics>& ma
json.as_array().for_each([&](auto& value) {
const JsonObject& process_object = value.as_object();
CProcessStatistics process;
- process.pid = process_object.get("pid").to_dword();
- process.nsched = process_object.get("times_scheduled").to_dword();
- process.uid = process_object.get("uid").to_dword();
+ process.pid = process_object.get("pid").to_u32();
+ process.nsched = process_object.get("times_scheduled").to_u32();
+ process.uid = process_object.get("uid").to_u32();
process.username = get_username_from_uid(process.uid);
process.priority = process_object.get("priority").to_string();
- process.syscalls = process_object.get("syscall_count").to_dword();
+ process.syscalls = process_object.get("syscall_count").to_u32();
process.state = process_object.get("state").to_string();
process.name = process_object.get("name").to_string();
- process.virtual_size = process_object.get("amount_virtual").to_dword();
- process.physical_size = process_object.get("amount_resident").to_dword();
+ process.virtual_size = process_object.get("amount_virtual").to_u32();
+ process.physical_size = process_object.get("amount_resident").to_u32();
map.set(process.pid, process);
});
}
diff --git a/LibCore/CSocket.cpp b/LibCore/CSocket.cpp
index ea9a7135ec..4479969c40 100644
--- a/LibCore/CSocket.cpp
+++ b/LibCore/CSocket.cpp
@@ -26,7 +26,7 @@ bool CSocket::connect(const String& hostname, int port)
return false;
}
- IPv4Address host_address((const byte*)hostent->h_addr_list[0]);
+ IPv4Address host_address((const u8*)hostent->h_addr_list[0]);
dbgprintf("CSocket::connect: Resolved '%s' to %s\n", hostname.characters(), host_address.to_string().characters());
return connect(host_address, port);
}
diff --git a/LibGUI/GClipboard.cpp b/LibGUI/GClipboard.cpp
index fc02b3b623..45875e78dd 100644
--- a/LibGUI/GClipboard.cpp
+++ b/LibGUI/GClipboard.cpp
@@ -46,7 +46,7 @@ void GClipboard::set_data(const StringView& data)
if (!data.is_empty())
memcpy(shared_buffer->data(), data.characters(), data.length() + 1);
else
- ((byte*)shared_buffer->data())[0] = '\0';
+ ((u8*)shared_buffer->data())[0] = '\0';
shared_buffer->seal();
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
request.clipboard.contents_size = data.length();
diff --git a/LibGUI/GEvent.h b/LibGUI/GEvent.h
index f55f68b5a6..ac5fc719b7 100644
--- a/LibGUI/GEvent.h
+++ b/LibGUI/GEvent.h
@@ -217,7 +217,7 @@ public:
}
};
-enum GMouseButton : byte {
+enum GMouseButton : u8 {
None = 0,
Left = 1,
Right = 2,
@@ -226,7 +226,7 @@ enum GMouseButton : byte {
class GKeyEvent final : public GEvent {
public:
- GKeyEvent(Type type, int key, byte modifiers)
+ GKeyEvent(Type type, int key, u8 modifiers)
: GEvent(type)
, m_key(key)
, m_modifiers(modifiers)
@@ -238,13 +238,13 @@ public:
bool alt() const { return m_modifiers & Mod_Alt; }
bool shift() const { return m_modifiers & Mod_Shift; }
bool logo() const { return m_modifiers & Mod_Logo; }
- byte modifiers() const { return m_modifiers; }
+ u8 modifiers() const { return m_modifiers; }
String text() const { return m_text; }
private:
friend class GEventLoop;
int m_key { 0 };
- byte m_modifiers { 0 };
+ u8 m_modifiers { 0 };
String m_text;
};
diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp
index 4debe6e442..589bc4ca34 100644
--- a/LibGUI/GEventLoop.cpp
+++ b/LibGUI/GEventLoop.cpp
@@ -388,7 +388,7 @@ bool GEventLoop::post_message_to_server(const WSAPI_ClientMessage& message, cons
iov[0].iov_len = sizeof(message);
if (!extra_data.is_empty()) {
- iov[1].iov_base = const_cast<byte*>(extra_data.data());
+ iov[1].iov_base = const_cast<u8*>(extra_data.data());
iov[1].iov_len = extra_data.size();
++iov_count;
}
diff --git a/LibGUI/GShortcut.h b/LibGUI/GShortcut.h
index 808fca4136..77bc77102b 100644
--- a/LibGUI/GShortcut.h
+++ b/LibGUI/GShortcut.h
@@ -7,14 +7,14 @@
class GShortcut {
public:
GShortcut() {}
- GShortcut(byte modifiers, KeyCode key)
+ GShortcut(u8 modifiers, KeyCode key)
: m_modifiers(modifiers)
, m_key(key)
{
}
bool is_valid() const { return m_key != KeyCode::Key_Invalid; }
- byte modifiers() const { return m_modifiers; }
+ u8 modifiers() const { return m_modifiers; }
KeyCode key() const { return m_key; }
String to_string() const;
@@ -25,7 +25,7 @@ public:
}
private:
- byte m_modifiers { 0 };
+ u8 m_modifiers { 0 };
KeyCode m_key { KeyCode::Key_Invalid };
};
diff --git a/Servers/LookupServer/DNSPacket.h b/Servers/LookupServer/DNSPacket.h
index fddf35a5b1..869c760a3a 100644
--- a/Servers/LookupServer/DNSPacket.h
+++ b/Servers/LookupServer/DNSPacket.h
@@ -20,8 +20,8 @@ public:
{
}
- word id() const { return m_id; }
- void set_id(word w) { m_id = w; }
+ u16 id() const { return m_id; }
+ void set_id(u16 w) { m_id = w; }
bool recursion_desired() const { return m_recursion_desired; }
void set_recursion_desired(bool b) { m_recursion_desired = b; }
@@ -32,16 +32,16 @@ public:
bool is_authoritative_answer() const { return m_authoritative_answer; }
void set_authoritative_answer(bool b) { m_authoritative_answer = b; }
- byte opcode() const { return m_opcode; }
- void set_opcode(byte b) { m_opcode = b; }
+ u8 opcode() const { return m_opcode; }
+ void set_opcode(u8 b) { m_opcode = b; }
bool is_query() const { return !m_query_or_response; }
bool is_response() const { return m_query_or_response; }
void set_is_query() { m_query_or_response = false; }
void set_is_response() { m_query_or_response = true; }
- byte response_code() const { return m_response_code; }
- void set_response_code(byte b) { m_response_code = b; }
+ u8 response_code() const { return m_response_code; }
+ void set_response_code(u8 b) { m_response_code = b; }
bool checking_disabled() const { return m_checking_disabled; }
void set_checking_disabled(bool b) { m_checking_disabled = b; }
@@ -52,39 +52,39 @@ public:
bool is_recursion_available() const { return m_recursion_available; }
void set_recursion_available(bool b) { m_recursion_available = b; }
- word question_count() const { return m_question_count; }
- void set_question_count(word w) { m_question_count = w; }
+ u16 question_count() const { return m_question_count; }
+ void set_question_count(u16 w) { m_question_count = w; }
- word answer_count() const { return m_answer_count; }
- void set_answer_count(word w) { m_answer_count = w; }
+ u16 answer_count() const { return m_answer_count; }
+ void set_answer_count(u16 w) { m_answer_count = w; }
- word authority_count() const { return m_authority_count; }
- void set_authority_count(word w) { m_authority_count = w; }
+ u16 authority_count() const { return m_authority_count; }
+ void set_authority_count(u16 w) { m_authority_count = w; }
- word additional_count() const { return m_additional_count; }
- void set_additional_count(word w) { m_additional_count = w; }
+ u16 additional_count() const { return m_additional_count; }
+ void set_additional_count(u16 w) { m_additional_count = w; }
void* payload() { return this + 1; }
const void* payload() const { return this + 1; }
private:
- NetworkOrdered<word> m_id;
+ NetworkOrdered<u16> m_id;
bool m_recursion_desired : 1;
bool m_truncated : 1;
bool m_authoritative_answer : 1;
- byte m_opcode : 4;
+ u8 m_opcode : 4;
bool m_query_or_response : 1;
- byte m_response_code : 4;
+ u8 m_response_code : 4;
bool m_checking_disabled : 1;
bool m_authenticated_data : 1;
bool m_zero : 1;
bool m_recursion_available : 1;
- NetworkOrdered<word> m_question_count;
- NetworkOrdered<word> m_answer_count;
- NetworkOrdered<word> m_authority_count;
- NetworkOrdered<word> m_additional_count;
+ NetworkOrdered<u16> m_question_count;
+ NetworkOrdered<u16> m_answer_count;
+ NetworkOrdered<u16> m_authority_count;
+ NetworkOrdered<u16> m_additional_count;
};
static_assert(sizeof(DNSPacket) == 12);
diff --git a/Servers/LookupServer/DNSRecord.h b/Servers/LookupServer/DNSRecord.h
index 5989f8c99a..258aeadba5 100644
--- a/Servers/LookupServer/DNSRecord.h
+++ b/Servers/LookupServer/DNSRecord.h
@@ -8,21 +8,21 @@ class [[gnu::packed]] DNSRecord
public:
DNSRecord() {}
- word name() const { return m_name; }
- word type() const { return m_type; }
- word record_class() const { return m_class; }
- dword ttl() const { return m_ttl; }
- word data_length() const { return m_data_length; }
+ u16 name() const { return m_name; }
+ u16 type() const { return m_type; }
+ u16 record_class() const { return m_class; }
+ u32 ttl() const { return m_ttl; }
+ u16 data_length() const { return m_data_length; }
void* data() { return this + 1; }
const void* data() const { return this + 1; }
private:
- NetworkOrdered<word> m_name;
- NetworkOrdered<word> m_type;
- NetworkOrdered<word> m_class;
- NetworkOrdered<dword> m_ttl;
- NetworkOrdered<word> m_data_length;
+ NetworkOrdered<u16> m_name;
+ NetworkOrdered<u16> m_type;
+ NetworkOrdered<u16> m_class;
+ NetworkOrdered<u32> m_ttl;
+ NetworkOrdered<u16> m_data_length;
};
static_assert(sizeof(DNSRecord) == 12);
diff --git a/Servers/LookupServer/main.cpp b/Servers/LookupServer/main.cpp
index 14fa33af38..1bf9e75539 100644
--- a/Servers/LookupServer/main.cpp
+++ b/Servers/LookupServer/main.cpp
@@ -29,7 +29,7 @@
static HashMap<String, String> dns_custom_hostnames;
static Vector<String> lookup(const String& hostname, bool& did_timeout, const String& DNS_IP, unsigned short record_type);
-static String parse_dns_name(const byte*, int& offset, int max_offset);
+static String parse_dns_name(const u8*, int& offset, int max_offset);
static void load_etc_hosts()
{
@@ -46,20 +46,20 @@ static void load_etc_hosts()
auto sections = fields[0].split('.');
IPv4Address addr {
- (byte)atoi(sections[0].characters()),
- (byte)atoi(sections[1].characters()),
- (byte)atoi(sections[2].characters()),
- (byte)atoi(sections[3].characters()),
+ (u8)atoi(sections[0].characters()),
+ (u8)atoi(sections[1].characters()),
+ (u8)atoi(sections[2].characters()),
+ (u8)atoi(sections[3].characters()),
};
auto name = fields[1];
dns_custom_hostnames.set(name, addr.to_string());
IPv4Address reverse_addr {
- (byte)atoi(sections[3].characters()),
- (byte)atoi(sections[2].characters()),
- (byte)atoi(sections[1].characters()),
- (byte)atoi(sections[0].characters()),
+ (u8)atoi(sections[3].characters()),
+ (u8)atoi(sections[2].characters()),
+ (u8)atoi(sections[1].characters()),
+ (u8)atoi(sections[0].characters()),
};
StringBuilder builder;
builder.append(reverse_addr.to_string());
@@ -198,9 +198,9 @@ int main(int argc, char** argv)
return 0;
}
-static word get_next_id()
+static u16 get_next_id()
{
- static word s_next_id = 0;
+ static u16 s_next_id = 0;
return ++s_next_id;
}
@@ -221,7 +221,7 @@ Vector<String> lookup(const String& hostname, bool& did_timeout, const String& D
stream << ByteBuffer::wrap(&request_header, sizeof(request_header));
auto parts = hostname.split('.');
for (auto& part : parts) {
- stream << (byte)part.length();
+ stream << (u8)part.length();
stream << part;
}
stream << '\0';
@@ -262,7 +262,7 @@ Vector<String> lookup(const String& hostname, bool& did_timeout, const String& D
struct sockaddr_in src_addr;
socklen_t src_addr_len = sizeof(src_addr);
- byte response_buffer[4096];
+ u8 response_buffer[4096];
ssize_t nrecv = recvfrom(fd, response_buffer, sizeof(response_buffer) - 1, 0, (struct sockaddr*)&src_addr, &src_addr_len);
if (nrecv < 0) {
if (errno == EAGAIN) {
@@ -303,13 +303,13 @@ Vector<String> lookup(const String& hostname, bool& did_timeout, const String& D
}
int offset = 0;
- auto question = parse_dns_name((const byte*)response_header.payload(), offset, nrecv);
+ auto question = parse_dns_name((const u8*)response_header.payload(), offset, nrecv);
offset += 4;
Vector<String> addresses;
- for (word i = 0; i < response_header.answer_count(); ++i) {
- auto& record = *(const DNSRecord*)(&((const byte*)response_header.payload())[offset]);
+ for (u16 i = 0; i < response_header.answer_count(); ++i) {
+ auto& record = *(const DNSRecord*)(&((const u8*)response_header.payload())[offset]);
dbgprintf("LookupServer: Answer #%u: (question: %s), type=%u, ttl=%u, length=%u, data=",
i,
question.characters(),
@@ -320,11 +320,11 @@ Vector<String> lookup(const String& hostname, bool& did_timeout, const String& D
offset += sizeof(DNSRecord) + record.data_length();
if (record.type() == T_PTR) {
int dummy = 0;
- auto name = parse_dns_name((const byte*)record.data(), dummy, record.data_length());
+ auto name = parse_dns_name((const u8*)record.data(), dummy, record.data_length());
dbgprintf("%s\n", name.characters());
addresses.append(name);
} else if (record.type() == T_A) {
- auto ipv4_address = IPv4Address((const byte*)record.data());
+ auto ipv4_address = IPv4Address((const u8*)record.data());
dbgprintf("%s\n", ipv4_address.to_string().characters());
addresses.append(ipv4_address.to_string());
} else {
@@ -337,11 +337,11 @@ Vector<String> lookup(const String& hostname, bool& did_timeout, const String& D
return addresses;
}
-static String parse_dns_name(const byte* data, int& offset, int max_offset)
+static String parse_dns_name(const u8* data, int& offset, int max_offset)
{
Vector<char, 128> buf;
while (offset < max_offset) {
- byte ch = data[offset];
+ u8 ch = data[offset];
if (ch == '\0') {
++offset;
break;
diff --git a/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h
index 0ecc11b0b0..412c18c607 100644
--- a/Servers/WindowServer/WSAPITypes.h
+++ b/Servers/WindowServer/WSAPITypes.h
@@ -159,13 +159,13 @@ struct WSAPI_ServerMessage {
WSAPI_Point position;
WSAPI_MouseButton button;
unsigned buttons;
- byte modifiers;
+ u8 modifiers;
int wheel_delta;
} mouse;
struct {
char character;
- byte key;
- byte modifiers;
+ u8 key;
+ u8 modifiers;
bool ctrl : 1;
bool alt : 1;
bool shift : 1;
diff --git a/Servers/WindowServer/WSCPUMonitor.cpp b/Servers/WindowServer/WSCPUMonitor.cpp
index 3dccde4f2e..1c6783897b 100644
--- a/Servers/WindowServer/WSCPUMonitor.cpp
+++ b/Servers/WindowServer/WSCPUMonitor.cpp
@@ -44,8 +44,8 @@ void WSCPUMonitor::get_cpu_usage(unsigned& busy, unsigned& idle)
auto json = JsonValue::from_string({ file_contents.data(), file_contents.size() });
json.as_array().for_each([&](auto& value) {
const JsonObject& process_object = value.as_object();
- pid_t pid = process_object.get("pid").to_dword();
- unsigned nsched = process_object.get("times_scheduled").to_dword();
+ pid_t pid = process_object.get("pid").to_u32();
+ unsigned nsched = process_object.get("times_scheduled").to_u32();
if (pid == 0)
idle += nsched;
else
diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp
index 5ac8867d29..510be0647c 100644
--- a/Servers/WindowServer/WSClientConnection.cpp
+++ b/Servers/WindowServer/WSClientConnection.cpp
@@ -86,7 +86,7 @@ void WSClientConnection::post_message(const WSAPI_ServerMessage& message, const
iov[0].iov_len = sizeof(message);
if (!extra_data.is_empty()) {
- iov[1].iov_base = const_cast<byte*>(extra_data.data());
+ iov[1].iov_base = const_cast<u8*>(extra_data.data());
iov[1].iov_len = extra_data.size();
++iov_count;
}
diff --git a/Servers/WindowServer/WSClipboard.cpp b/Servers/WindowServer/WSClipboard.cpp
index 113a3dd692..6ffd245d99 100644
--- a/Servers/WindowServer/WSClipboard.cpp
+++ b/Servers/WindowServer/WSClipboard.cpp
@@ -16,11 +16,11 @@ WSClipboard::~WSClipboard()
{
}
-const byte* WSClipboard::data() const
+const u8* WSClipboard::data() const
{
if (!m_shared_buffer)
return nullptr;
- return (const byte*)m_shared_buffer->data();
+ return (const u8*)m_shared_buffer->data();
}
int WSClipboard::size() const
diff --git a/Servers/WindowServer/WSClipboard.h b/Servers/WindowServer/WSClipboard.h
index 1f53137ba5..7887fbb3c5 100644
--- a/Servers/WindowServer/WSClipboard.h
+++ b/Servers/WindowServer/WSClipboard.h
@@ -13,7 +13,7 @@ public:
return m_shared_buffer;
}
- const byte* data() const;
+ const u8* data() const;
int size() const;
void clear();
diff --git a/Servers/WindowServer/WSCompositor.cpp b/Servers/WindowServer/WSCompositor.cpp
index 61ae9a2457..115b5cea44 100644
--- a/Servers/WindowServer/WSCompositor.cpp
+++ b/Servers/WindowServer/WSCompositor.cpp
@@ -186,9 +186,9 @@ void WSCompositor::flush(const Rect& a_rect)
size_t pitch = m_back_bitmap->pitch();
for (int y = 0; y < rect.height(); ++y) {
- fast_dword_copy(back_ptr, front_ptr, rect.width());
- front_ptr = (const RGBA32*)((const byte*)front_ptr + pitch);
- back_ptr = (RGBA32*)((byte*)back_ptr + pitch);
+ fast_u32_copy(back_ptr, front_ptr, rect.width());
+ front_ptr = (const RGBA32*)((const u8*)front_ptr + pitch);
+ back_ptr = (RGBA32*)((u8*)back_ptr + pitch);
}
}
diff --git a/Servers/WindowServer/WSEvent.h b/Servers/WindowServer/WSEvent.h
index ec2a96f5f6..706facdd3f 100644
--- a/Servers/WindowServer/WSEvent.h
+++ b/Servers/WindowServer/WSEvent.h
@@ -726,7 +726,7 @@ private:
Vector<Rect, 32> m_rects;
};
-enum class MouseButton : byte {
+enum class MouseButton : u8 {
None = 0,
Left = 1,
Right = 2,
@@ -735,7 +735,7 @@ enum class MouseButton : byte {
class WSKeyEvent final : public WSEvent {
public:
- WSKeyEvent(Type type, int key, char character, byte modifiers)
+ WSKeyEvent(Type type, int key, char character, u8 modifiers)
: WSEvent(type)
, m_key(key)
, m_character(character)
@@ -748,7 +748,7 @@ public:
bool alt() const { return m_modifiers & Mod_Alt; }
bool shift() const { return m_modifiers & Mod_Shift; }
bool logo() const { return m_modifiers & Mod_Logo; }
- byte modifiers() const { return m_modifiers; }
+ u8 modifiers() const { return m_modifiers; }
char character() const { return m_character; }
private:
@@ -756,7 +756,7 @@ private:
friend class WSScreen;
int m_key { 0 };
char m_character { 0 };
- byte m_modifiers { 0 };
+ u8 m_modifiers { 0 };
};
class WSMouseEvent final : public WSEvent {
diff --git a/Servers/WindowServer/WSEventLoop.cpp b/Servers/WindowServer/WSEventLoop.cpp
index 2758aaf213..781695af91 100644
--- a/Servers/WindowServer/WSEventLoop.cpp
+++ b/Servers/WindowServer/WSEventLoop.cpp
@@ -92,7 +92,7 @@ void WSEventLoop::drain_keyboard()
auto& screen = WSScreen::the();
for (;;) {
KeyEvent event;
- ssize_t nread = read(m_keyboard_fd, (byte*)&event, sizeof(KeyEvent));
+ ssize_t nread = read(m_keyboard_fd, (u8*)&event, sizeof(KeyEvent));
if (nread == 0)
break;
ASSERT(nread == sizeof(KeyEvent));
diff --git a/Servers/WindowServer/WSScreen.h b/Servers/WindowServer/WSScreen.h
index 77fb5880a2..6a9d492821 100644
--- a/Servers/WindowServer/WSScreen.h
+++ b/Servers/WindowServer/WSScreen.h
@@ -44,5 +44,5 @@ private:
inline RGBA32* WSScreen::scanline(int y)
{
size_t pitch = sizeof(RGBA32) * width();
- return reinterpret_cast<RGBA32*>(((byte*)m_framebuffer) + (y * pitch));
+ return reinterpret_cast<RGBA32*>(((u8*)m_framebuffer) + (y * pitch));
}
diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp
index a942b3a5dd..6c839aa17a 100644
--- a/Servers/WindowServer/WSWindowManager.cpp
+++ b/Servers/WindowServer/WSWindowManager.cpp
@@ -51,7 +51,7 @@ WSWindowManager::WSWindowManager()
{ "/bin/ProcessManager", "Open ProcessManager..." }
};
- byte system_menu_name[] = { 0xf8, 0 };
+ u8 system_menu_name[] = { 0xf8, 0 };
m_system_menu = make<WSMenu>(nullptr, -1, String((const char*)system_menu_name));
int appIndex = 1;
diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h
index 6bd77b3eea..7349cf6075 100644
--- a/Servers/WindowServer/WSWindowManager.h
+++ b/Servers/WindowServer/WSWindowManager.h
@@ -232,7 +232,7 @@ private:
Point m_resize_origin;
ResizeDirection m_resize_direction { ResizeDirection::None };
- byte m_keyboard_modifiers { 0 };
+ u8 m_keyboard_modifiers { 0 };
OwnPtr<WSMenu> m_system_menu;
Color m_menu_selection_color;
diff --git a/SharedGraphics/Color.cpp b/SharedGraphics/Color.cpp
index 51ad268ab1..00a312b7bb 100644
--- a/SharedGraphics/Color.cpp
+++ b/SharedGraphics/Color.cpp
@@ -4,9 +4,9 @@
Color::Color(NamedColor named)
{
struct {
- byte r;
- byte g;
- byte b;
+ u8 r;
+ u8 g;
+ u8 b;
} rgb;
switch (named) {
diff --git a/SharedGraphics/Color.h b/SharedGraphics/Color.h
index 06f8a07110..ff2090ff04 100644
--- a/SharedGraphics/Color.h
+++ b/SharedGraphics/Color.h
@@ -3,9 +3,9 @@
#include <AK/AKString.h>
#include <AK/Types.h>
-typedef dword RGBA32;
+typedef u32 RGBA32;
-inline constexpr dword make_rgb(byte r, byte g, byte b)
+inline constexpr u32 make_rgb(u8 r, u8 g, u8 b)
{
return ((r << 16) | (g << 8) | b);
}
@@ -36,11 +36,11 @@ public:
Color() {}
Color(NamedColor);
- Color(byte r, byte g, byte b)
+ Color(u8 r, u8 g, u8 b)
: m_value(0xff000000 | (r << 16) | (g << 8) | b)
{
}
- Color(byte r, byte g, byte b, byte a)
+ Color(u8 r, u8 g, u8 b, u8 a)
: m_value((a << 24) | (r << 16) | (g << 8) | b)
{
}
@@ -48,36 +48,36 @@ public:
static Color from_rgb(unsigned rgb) { return Color(rgb | 0xff000000); }
static Color from_rgba(unsigned rgba) { return Color(rgba); }
- byte red() const { return (m_value >> 16) & 0xff; }
- byte green() const { return (m_value >> 8) & 0xff; }
- byte blue() const { return m_value & 0xff; }
- byte alpha() const { return (m_value >> 24) & 0xff; }
+ u8 red() const { return (m_value >> 16) & 0xff; }
+ u8 green() const { return (m_value >> 8) & 0xff; }
+ u8 blue() const { return m_value & 0xff; }
+ u8 alpha() const { return (m_value >> 24) & 0xff; }
- void set_alpha(byte value)
+ void set_alpha(u8 value)
{
m_value &= 0x00ffffff;
m_value |= value << 24;
}
- void set_red(byte value)
+ void set_red(u8 value)
{
m_value &= 0xff00ffff;
m_value |= value << 16;
}
- void set_green(byte value)
+ void set_green(u8 value)
{
m_value &= 0xffff00ff;
m_value |= value << 8;
}
- void set_blue(byte value)
+ void set_blue(u8 value)
{
m_value &= 0xffffff00;
m_value |= value;
}
- Color with_alpha(byte alpha)
+ Color with_alpha(u8 alpha)
{
return Color((m_value & 0x00ffffff) | alpha << 24);
}
@@ -91,10 +91,10 @@ public:
return *this;
int d = 255 * (alpha() + source.alpha()) - alpha() * source.alpha();
- byte r = (red() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.red()) / d;
- byte g = (green() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.green()) / d;
- byte b = (blue() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.blue()) / d;
- byte a = d / 255;
+ u8 r = (red() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.red()) / d;
+ u8 g = (green() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.green()) / d;
+ u8 b = (blue() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.blue()) / d;
+ u8 a = d / 255;
return Color(r, g, b, a);
}
diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp
index 9b27d33093..9c3c66a84a 100644
--- a/SharedGraphics/Font.cpp
+++ b/SharedGraphics/Font.cpp
@@ -12,11 +12,11 @@
struct [[gnu::packed]] FontFileHeader
{
char magic[4];
- byte glyph_width;
- byte glyph_height;
- byte type;
- byte is_variable_width;
- byte unused[6];
+ u8 glyph_width;
+ u8 glyph_height;
+ u8 type;
+ u8 is_variable_width;
+ u8 unused[6];
char name[64];
};
@@ -55,11 +55,11 @@ Font& Font::default_bold_font()
RefPtr<Font> Font::clone() const
{
- size_t bytes_per_glyph = sizeof(dword) * glyph_height();
+ size_t bytes_per_glyph = sizeof(u32) * glyph_height();
// FIXME: This is leaked!
auto* new_rows = static_cast<unsigned*>(kmalloc(bytes_per_glyph * 256));
memcpy(new_rows, m_rows, bytes_per_glyph * 256);
- auto* new_widths = static_cast<byte*>(kmalloc(256));
+ auto* new_widths = static_cast<u8*>(kmalloc(256));
if (m_glyph_widths)
memcpy(new_widths, m_glyph_widths, 256);
else
@@ -67,7 +67,7 @@ RefPtr<Font> Font::clone() const
return adopt(*new Font(m_name, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height));
}
-Font::Font(const StringView& name, unsigned* rows, byte* widths, bool is_fixed_width, byte glyph_width, byte glyph_height)
+Font::Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height)
: m_name(name)
, m_rows(rows)
, m_glyph_widths(widths)
@@ -78,8 +78,8 @@ Font::Font(const StringView& name, unsigned* rows, byte* widths, bool is_fixed_w
, m_fixed_width(is_fixed_width)
{
if (!m_fixed_width) {
- byte maximum = 0;
- byte minimum = 255;
+ u8 maximum = 0;
+ u8 minimum = 255;
for (int i = 0; i < 256; ++i) {
minimum = min(minimum, m_glyph_widths[i]);
maximum = max(maximum, m_glyph_widths[i]);
@@ -93,7 +93,7 @@ Font::~Font()
{
}
-RefPtr<Font> Font::load_from_memory(const byte* data)
+RefPtr<Font> Font::load_from_memory(const u8* data)
{
auto& header = *reinterpret_cast<const FontFileHeader*>(data);
if (memcmp(header.magic, "!Fnt", 4)) {
@@ -108,9 +108,9 @@ RefPtr<Font> Font::load_from_memory(const byte* data)
size_t bytes_per_glyph = sizeof(unsigned) * header.glyph_height;
auto* rows = const_cast<unsigned*>((const unsigned*)(data + sizeof(FontFileHeader)));
- byte* widths = nullptr;
+ u8* widths = nullptr;
if (header.is_variable_width)
- widths = (byte*)(rows) + 256 * bytes_per_glyph;
+ widths = (u8*)(rows) + 256 * bytes_per_glyph;
return adopt(*new Font(String(header.name), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height));
}
@@ -120,7 +120,7 @@ RefPtr<Font> Font::load_from_file(const StringView& path)
if (!mapped_file.is_valid())
return nullptr;
- auto font = load_from_memory((const byte*)mapped_file.pointer());
+ auto font = load_from_memory((const u8*)mapped_file.pointer());
font->m_mapped_file = move(mapped_file);
return font;
}
diff --git a/SharedGraphics/Font.h b/SharedGraphics/Font.h
index a63b035b8b..83ae396dcb 100644
--- a/SharedGraphics/Font.h
+++ b/SharedGraphics/Font.h
@@ -54,13 +54,13 @@ public:
~Font();
- GlyphBitmap glyph_bitmap(char ch) const { return GlyphBitmap(&m_rows[(byte)ch * m_glyph_height], { glyph_width(ch), m_glyph_height }); }
+ GlyphBitmap glyph_bitmap(char ch) const { return GlyphBitmap(&m_rows[(u8)ch * m_glyph_height], { glyph_width(ch), m_glyph_height }); }
- byte glyph_width(char ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[(byte)ch]; }
- byte glyph_height() const { return m_glyph_height; }
- byte min_glyph_width() const { return m_min_glyph_width; }
- byte max_glyph_width() const { return m_max_glyph_width; }
- byte glyph_spacing() const { return m_fixed_width ? 0 : 1; }
+ u8 glyph_width(char ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[(u8)ch]; }
+ u8 glyph_height() const { return m_glyph_height; }
+ u8 min_glyph_width() const { return m_min_glyph_width; }
+ u8 max_glyph_width() const { return m_max_glyph_width; }
+ u8 glyph_spacing() const { return m_fixed_width ? 0 : 1; }
int width(const StringView& string) const;
String name() const { return m_name; }
@@ -69,27 +69,27 @@ public:
bool is_fixed_width() const { return m_fixed_width; }
void set_fixed_width(bool b) { m_fixed_width = b; }
- void set_glyph_width(char ch, byte width)
+ void set_glyph_width(char ch, u8 width)
{
ASSERT(m_glyph_widths);
- m_glyph_widths[(byte)ch] = width;
+ m_glyph_widths[(u8)ch] = width;
}
private:
- Font(const StringView& name, unsigned* rows, byte* widths, bool is_fixed_width, byte glyph_width, byte glyph_height);
+ Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height);
- static RefPtr<Font> load_from_memory(const byte*);
+ static RefPtr<Font> load_from_memory(const u8*);
String m_name;
unsigned* m_rows { nullptr };
- byte* m_glyph_widths { nullptr };
+ u8* m_glyph_widths { nullptr };
MappedFile m_mapped_file;
- byte m_glyph_width { 0 };
- byte m_glyph_height { 0 };
- byte m_min_glyph_width { 0 };
- byte m_max_glyph_width { 0 };
+ u8 m_glyph_width { 0 };
+ u8 m_glyph_height { 0 };
+ u8 m_min_glyph_width { 0 };
+ u8 m_max_glyph_width { 0 };
bool m_fixed_width { false };
};
diff --git a/SharedGraphics/GraphicsBitmap.cpp b/SharedGraphics/GraphicsBitmap.cpp
index 7b87555ee0..16fdb73b12 100644
--- a/SharedGraphics/GraphicsBitmap.cpp
+++ b/SharedGraphics/GraphicsBitmap.cpp
@@ -97,6 +97,6 @@ void GraphicsBitmap::fill(Color color)
ASSERT(m_format == GraphicsBitmap::Format::RGB32 || m_format == GraphicsBitmap::Format::RGBA32);
for (int y = 0; y < height(); ++y) {
auto* scanline = this->scanline(y);
- fast_dword_fill(scanline, color.value(), width());
+ fast_u32_fill(scanline, color.value(), width());
}
}
diff --git a/SharedGraphics/GraphicsBitmap.h b/SharedGraphics/GraphicsBitmap.h
index 149338fe9d..cfd056390a 100644
--- a/SharedGraphics/GraphicsBitmap.h
+++ b/SharedGraphics/GraphicsBitmap.h
@@ -29,8 +29,8 @@ public:
RGBA32* scanline(int y);
const RGBA32* scanline(int y) const;
- byte* bits(int y);
- const byte* bits(int y) const;
+ u8* bits(int y);
+ const u8* bits(int y) const;
Rect rect() const { return { {}, m_size }; }
Size size() const { return m_size; }
@@ -63,8 +63,8 @@ public:
size_t size_in_bytes() const { return m_pitch * m_size.height(); }
- Color palette_color(byte index) const { return Color::from_rgba(m_palette[index]); }
- void set_palette_color(byte index, Color color) { m_palette[index] = color.value(); }
+ Color palette_color(u8 index) const { return Color::from_rgba(m_palette[index]); }
+ void set_palette_color(u8 index, Color color) { m_palette[index] = color.value(); }
template<Format>
Color get_pixel(int x, int y) const
@@ -110,22 +110,22 @@ private:
inline RGBA32* GraphicsBitmap::scanline(int y)
{
- return reinterpret_cast<RGBA32*>((((byte*)m_data) + (y * m_pitch)));
+ return reinterpret_cast<RGBA32*>((((u8*)m_data) + (y * m_pitch)));
}
inline const RGBA32* GraphicsBitmap::scanline(int y) const
{
- return reinterpret_cast<const RGBA32*>((((const byte*)m_data) + (y * m_pitch)));
+ return reinterpret_cast<const RGBA32*>((((const u8*)m_data) + (y * m_pitch)));
}
-inline const byte* GraphicsBitmap::bits(int y) const
+inline const u8* GraphicsBitmap::bits(int y) const
{
- return reinterpret_cast<const byte*>(scanline(y));
+ return reinterpret_cast<const u8*>(scanline(y));
}
-inline byte* GraphicsBitmap::bits(int y)
+inline u8* GraphicsBitmap::bits(int y)
{
- return reinterpret_cast<byte*>(scanline(y));
+ return reinterpret_cast<u8*>(scanline(y));
}
template<>
diff --git a/SharedGraphics/PNGLoader.cpp b/SharedGraphics/PNGLoader.cpp
index 23d09879e5..08e02e1d00 100644
--- a/SharedGraphics/PNGLoader.cpp
+++ b/SharedGraphics/PNGLoader.cpp
@@ -14,43 +14,43 @@
//#define PNG_STOPWATCH_DEBUG
struct PNG_IHDR {
- NetworkOrdered<dword> width;
- NetworkOrdered<dword> height;
- byte bit_depth { 0 };
- byte color_type { 0 };
- byte compression_method { 0 };
- byte filter_method { 0 };
- byte interlace_method { 0 };
+ NetworkOrdered<u32> width;
+ NetworkOrdered<u32> height;
+ u8 bit_depth { 0 };
+ u8 color_type { 0 };
+ u8 compression_method { 0 };
+ u8 filter_method { 0 };
+ u8 interlace_method { 0 };
};
static_assert(sizeof(PNG_IHDR) == 13);
struct Scanline {
- byte filter { 0 };
+ u8 filter { 0 };
ByteBuffer data { };
};
struct PNGLoadingContext {
int width { -1 };
int height { -1 };
- byte bit_depth { 0 };
- byte color_type { 0 };
- byte compression_method { 0 };
- byte filter_method { 0 };
- byte interlace_method { 0 };
- byte bytes_per_pixel { 0 };
+ u8 bit_depth { 0 };
+ u8 color_type { 0 };
+ u8 compression_method { 0 };
+ u8 filter_method { 0 };
+ u8 interlace_method { 0 };
+ u8 bytes_per_pixel { 0 };
bool has_seen_zlib_header { false };
bool has_alpha() const { return color_type & 4; }
Vector<Scanline> scanlines;
RefPtr<GraphicsBitmap> bitmap;
- byte* decompression_buffer { nullptr };
+ u8* decompression_buffer { nullptr };
int decompression_buffer_size { 0 };
- Vector<byte> compressed_data;
+ Vector<u8> compressed_data;
};
class Streamer {
public:
- Streamer(const byte* data, int size)
+ Streamer(const u8* data, int size)
: m_original_data(data)
, m_original_size(size)
, m_data_ptr(data)
@@ -69,7 +69,7 @@ public:
return true;
}
- bool read_bytes(byte* buffer, int count)
+ bool read_bytes(u8* buffer, int count)
{
if (m_size_remaining < count)
return false;
@@ -92,13 +92,13 @@ public:
bool at_end() const { return !m_size_remaining; }
private:
- const byte* m_original_data;
+ const u8* m_original_data;
int m_original_size;
- const byte* m_data_ptr;
+ const u8* m_data_ptr;
int m_size_remaining;
};
-static RefPtr<GraphicsBitmap> load_png_impl(const byte*, int);
+static RefPtr<GraphicsBitmap> load_png_impl(const u8*, int);
static bool process_chunk(Streamer&, PNGLoadingContext& context);
RefPtr<GraphicsBitmap> load_png(const StringView& path)
@@ -106,13 +106,13 @@ RefPtr<GraphicsBitmap> load_png(const StringView& path)
MappedFile mapped_file(path);
if (!mapped_file.is_valid())
return nullptr;
- auto bitmap = load_png_impl((const byte*)mapped_file.pointer(), mapped_file.size());
+ auto bitmap = load_png_impl((const u8*)mapped_file.pointer(), mapped_file.size());
if (bitmap)
bitmap->set_mmap_name(String::format("GraphicsBitmap [%dx%d] - Decoded PNG: %s", bitmap->width(), bitmap->height(), FileSystemPath(path).string().characters()));
return bitmap;
}
-[[gnu::always_inline]] static inline byte paeth_predictor(int a, int b, int c)
+[[gnu::always_inline]] static inline u8 paeth_predictor(int a, int b, int c)
{
int p = a + b - c;
int pa = abs(p - a);
@@ -128,17 +128,17 @@ RefPtr<GraphicsBitmap> load_png(const StringView& path)
union [[gnu::packed]] Pixel
{
RGBA32 rgba { 0 };
- byte v[4];
+ u8 v[4];
struct {
- byte r;
- byte g;
- byte b;
- byte a;
+ u8 r;
+ u8 g;
+ u8 b;
+ u8 a;
};
};
static_assert(sizeof(Pixel) == 4);
-template<bool has_alpha, byte filter_type>
+template<bool has_alpha, u8 filter_type>
[[gnu::always_inline]] static inline void unfilter_impl(GraphicsBitmap& bitmap, int y, const void* dummy_scanline_data)
{
auto* dummy_scanline = (const Pixel*)dummy_scanline_data;
@@ -232,9 +232,9 @@ template<bool has_alpha, byte filter_type>
for (int y = 0; y < context.height; ++y) {
struct [[gnu::packed]] Triplet
{
- byte r;
- byte g;
- byte b;
+ u8 r;
+ u8 g;
+ u8 b;
};
auto* triplets = (Triplet*)context.scanlines[y].data.pointer();
for (int i = 0; i < context.width; ++i) {
@@ -302,15 +302,15 @@ template<bool has_alpha, byte filter_type>
}
}
-static RefPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size)
+static RefPtr<GraphicsBitmap> load_png_impl(const u8* data, int data_size)
{
#ifdef PNG_STOPWATCH_DEBUG
Stopwatch sw("load_png_impl: total");
#endif
- const byte* data_ptr = data;
+ const u8* data_ptr = data;
int data_remaining = data_size;
- const byte png_header[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 };
+ const u8 png_header[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 };
if (memcmp(data, png_header, sizeof(png_header))) {
dbgprintf("Invalid PNG header\n");
return nullptr;
@@ -354,7 +354,7 @@ static RefPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size)
context.scanlines.ensure_capacity(context.height);
Streamer streamer(context.decompression_buffer, context.decompression_buffer_size);
for (int y = 0; y < context.height; ++y) {
- byte filter;
+ u8 filter;
if (!streamer.read(filter))
return nullptr;
@@ -412,7 +412,7 @@ static bool process_IHDR(const ByteBuffer& data, PNGLoadingContext& context)
#endif
context.decompression_buffer_size = (context.width * context.height * context.bytes_per_pixel + context.height);
- context.decompression_buffer = (byte*)mmap_with_name(nullptr, context.decompression_buffer_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, "PNG decompression buffer");
+ context.decompression_buffer = (u8*)mmap_with_name(nullptr, context.decompression_buffer_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, "PNG decompression buffer");
return true;
}
@@ -424,12 +424,12 @@ static bool process_IDAT(const ByteBuffer& data, PNGLoadingContext& context)
static bool process_chunk(Streamer& streamer, PNGLoadingContext& context)
{
- dword chunk_size;
+ u32 chunk_size;
if (!streamer.read(chunk_size)) {
printf("Bail at chunk_size\n");
return false;
}
- byte chunk_type[5];
+ u8 chunk_type[5];
chunk_type[4] = '\0';
if (!streamer.read_bytes(chunk_type, 4)) {
printf("Bail at chunk_type\n");
@@ -440,7 +440,7 @@ static bool process_chunk(Streamer& streamer, PNGLoadingContext& context)
printf("Bail at chunk_data\n");
return false;
}
- dword chunk_crc;
+ u32 chunk_crc;
if (!streamer.read(chunk_crc)) {
printf("Bail at chunk_crc\n");
return false;
diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp
index 5f73a72083..a52c6b04ea 100644
--- a/SharedGraphics/Painter.cpp
+++ b/SharedGraphics/Painter.cpp
@@ -69,7 +69,7 @@ void Painter::fill_rect(const Rect& a_rect, Color color)
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
for (int i = rect.height() - 1; i >= 0; --i) {
- fast_dword_fill(dst, color.value(), rect.width());
+ fast_u32_fill(dst, color.value(), rect.width());
dst += dst_skip;
}
}
@@ -125,13 +125,13 @@ void Painter::draw_rect(const Rect& a_rect, Color color, bool rough)
if (rect.top() >= clipped_rect.top() && rect.top() <= clipped_rect.bottom()) {
int start_x = rough ? max(rect.x() + 1, clipped_rect.x()) : clipped_rect.x();
int width = rough ? min(rect.width() - 2, clipped_rect.width()) : clipped_rect.width();
- fast_dword_fill(m_target->scanline(rect.top()) + start_x, color.value(), width);
+ fast_u32_fill(m_target->scanline(rect.top()) + start_x, color.value(), width);
++min_y;
}
if (rect.bottom() >= clipped_rect.top() && rect.bottom() <= clipped_rect.bottom()) {
int start_x = rough ? max(rect.x() + 1, clipped_rect.x()) : clipped_rect.x();
int width = rough ? min(rect.width() - 2, clipped_rect.width()) : clipped_rect.width();
- fast_dword_fill(m_target->scanline(rect.bottom()) + start_x, color.value(), width);
+ fast_u32_fill(m_target->scanline(rect.bottom()) + start_x, color.value(), width);
--max_y;
}
@@ -243,7 +243,7 @@ void Painter::blit_with_opacity(const Point& position, const GraphicsBitmap& sou
if (opacity >= 1.0f)
return blit(position, source, src_rect);
- byte alpha = 255 * opacity;
+ u8 alpha = 255 * opacity;
Rect safe_src_rect = Rect::intersection(src_rect, source.rect());
Rect dst_rect(position, safe_src_rect.size());
@@ -290,7 +290,7 @@ void Painter::blit_dimmed(const Point& position, const GraphicsBitmap& source, c
for (int row = first_row; row <= last_row; ++row) {
for (int x = 0; x <= (last_column - first_column); ++x) {
- byte alpha = Color::from_rgba(src[x]).alpha();
+ u8 alpha = Color::from_rgba(src[x]).alpha();
if (alpha == 0xff)
dst[x] = Color::from_rgba(src[x]).to_grayscale().lightened().value();
else if (!alpha)
@@ -387,7 +387,7 @@ void Painter::blit_with_alpha(const Point& position, const GraphicsBitmap& sourc
for (int row = first_row; row <= last_row; ++row) {
for (int x = 0; x <= (last_column - first_column); ++x) {
- byte alpha = Color::from_rgba(src[x]).alpha();
+ u8 alpha = Color::from_rgba(src[x]).alpha();
if (alpha == 0xff)
dst[x] = src[x];
else if (!alpha)
@@ -422,7 +422,7 @@ void Painter::blit(const Point& position, const GraphicsBitmap& source, const Re
const RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column;
const size_t src_skip = source.pitch() / sizeof(RGBA32);
for (int row = first_row; row <= last_row; ++row) {
- fast_dword_copy(dst, src, clipped_rect.width());
+ fast_u32_copy(dst, src, clipped_rect.width());
dst += dst_skip;
src += src_skip;
}
@@ -430,7 +430,7 @@ void Painter::blit(const Point& position, const GraphicsBitmap& source, const Re
}
if (source.format() == GraphicsBitmap::Format::Indexed8) {
- const byte* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column;
+ const u8* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column;
const size_t src_skip = source.pitch();
for (int row = first_row; row <= last_row; ++row) {
for (int i = 0; i < clipped_rect.width(); ++i)
@@ -628,7 +628,7 @@ void Painter::set_pixel(const Point& p, Color color)
m_target->scanline(point.y())[point.x()] = color.value();
}
-[[gnu::always_inline]] inline void Painter::set_pixel_with_draw_op(dword& pixel, const Color& color)
+[[gnu::always_inline]] inline void Painter::set_pixel_with_draw_op(u32& pixel, const Color& color)
{
if (draw_op() == DrawOp::Copy)
pixel = color.value();
diff --git a/SharedGraphics/Painter.h b/SharedGraphics/Painter.h
index 31c27e7b20..2f64c83d88 100644
--- a/SharedGraphics/Painter.h
+++ b/SharedGraphics/Painter.h
@@ -64,7 +64,7 @@ public:
}
protected:
- void set_pixel_with_draw_op(dword& pixel, const Color&);
+ void set_pixel_with_draw_op(u32& pixel, const Color&);
void fill_rect_with_draw_op(const Rect&, Color);
void blit_with_alpha(const Point&, const GraphicsBitmap&, const Rect& src_rect);
void blit_with_opacity(const Point&, const GraphicsBitmap&, const Rect& src_rect, float opacity);
diff --git a/Userland/crash.cpp b/Userland/crash.cpp
index 65cbb406b0..3d702bc3b3 100644
--- a/Userland/crash.cpp
+++ b/Userland/crash.cpp
@@ -70,14 +70,14 @@ int main(int argc, char** argv)
}
if (mode == ReadFromUninitializedMallocMemory) {
- auto* uninitialized_memory = (volatile dword**)malloc(1024);
+ auto* uninitialized_memory = (volatile u32**)malloc(1024);
volatile auto x = uninitialized_memory[0][0];
(void)x;
ASSERT_NOT_REACHED();
}
if (mode == ReadFromFreedMemory) {
- auto* uninitialized_memory = (volatile dword**)malloc(1024);
+ auto* uninitialized_memory = (volatile u32**)malloc(1024);
free(uninitialized_memory);
volatile auto x = uninitialized_memory[4][0];
(void)x;
@@ -85,13 +85,13 @@ int main(int argc, char** argv)
}
if (mode == WriteToUninitializedMallocMemory) {
- auto* uninitialized_memory = (volatile dword**)malloc(1024);
+ auto* uninitialized_memory = (volatile u32**)malloc(1024);
uninitialized_memory[4][0] = 1;
ASSERT_NOT_REACHED();
}
if (mode == WriteToFreedMemory) {
- auto* uninitialized_memory = (volatile dword**)malloc(1024);
+ auto* uninitialized_memory = (volatile u32**)malloc(1024);
free(uninitialized_memory);
uninitialized_memory[4][0] = 1;
ASSERT_NOT_REACHED();
diff --git a/Userland/df.cpp b/Userland/df.cpp
index 0013274e8b..19a80b2328 100644
--- a/Userland/df.cpp
+++ b/Userland/df.cpp
@@ -31,10 +31,10 @@ int main(int, char**)
json.for_each([](auto& value) {
auto fs_object = value.as_object();
auto fs = fs_object.get("class_name").to_string();
- auto total_block_count = fs_object.get("total_block_count").to_dword();
- auto free_block_count = fs_object.get("free_block_count").to_dword();
- auto total_inode_count = fs_object.get("total_inode_count").to_dword();
- auto free_inode_count = fs_object.get("free_inode_count").to_dword();
+ auto total_block_count = fs_object.get("total_block_count").to_u32();
+ auto free_block_count = fs_object.get("free_block_count").to_u32();
+ auto total_inode_count = fs_object.get("total_inode_count").to_u32();
+ auto free_inode_count = fs_object.get("free_inode_count").to_u32();
auto mount_point = fs_object.get("mount_point").to_string();
(void)total_inode_count;
diff --git a/Userland/strace.cpp b/Userland/strace.cpp
index 786479aade..5d744705b7 100644
--- a/Userland/strace.cpp
+++ b/Userland/strace.cpp
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
}
for (;;) {
- dword call[5];
+ u32 call[5];
int nread = read(fd, &call, sizeof(call));
if (nread == 0)
break;
diff --git a/Userland/top.cpp b/Userland/top.cpp
index defa0efa8e..5ddfa7edbf 100644
--- a/Userland/top.cpp
+++ b/Userland/top.cpp
@@ -30,7 +30,7 @@ struct Process {
struct Snapshot {
HashMap<unsigned, Process> map;
- dword sum_nsched { 0 };
+ u32 sum_nsched { 0 };
};
static Snapshot get_snapshot()
@@ -47,19 +47,19 @@ static Snapshot get_snapshot()
auto json = JsonValue::from_string({ file_contents.data(), file_contents.size() });
json.as_array().for_each([&](auto& value) {
const JsonObject& process_object = value.as_object();
- pid_t pid = process_object.get("pid").to_dword();
- unsigned nsched = process_object.get("times_scheduled").to_dword();
+ pid_t pid = process_object.get("pid").to_u32();
+ unsigned nsched = process_object.get("times_scheduled").to_u32();
snapshot.sum_nsched += nsched;
Process process;
process.pid = pid;
process.nsched = nsched;
- unsigned uid = process_object.get("uid").to_dword();
+ unsigned uid = process_object.get("uid").to_u32();
process.user = s_usernames->get(uid);
process.priority = process_object.get("priority").to_string();
process.state = process_object.get("state").to_string();
process.name = process_object.get("name").to_string();
- process.virtual_size = process_object.get("amount_virtual").to_dword();
- process.physical_size = process_object.get("amount_resident").to_dword();
+ process.virtual_size = process_object.get("amount_virtual").to_u32();
+ process.physical_size = process_object.get("amount_resident").to_u32();
snapshot.map.set(pid, move(process));
});
return snapshot;
@@ -94,12 +94,12 @@ int main(int, char**)
pid_t pid = it.key;
if (pid == 0)
continue;
- dword nsched_now = it.value.nsched;
+ u32 nsched_now = it.value.nsched;
auto jt = prev.map.find(pid);
if (jt == prev.map.end())
continue;
- dword nsched_before = (*jt).value.nsched;
- dword nsched_diff = nsched_now - nsched_before;
+ u32 nsched_before = (*jt).value.nsched;
+ u32 nsched_diff = nsched_now - nsched_before;
it.value.nsched_since_prev = nsched_diff;
it.value.cpu_percent = ((nsched_diff * 100) / sum_diff);
it.value.cpu_percent_decimal = (((nsched_diff * 1000) / sum_diff) % 10);