summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/PrintfImplementation.h5
-rw-r--r--Applications/FontEditor/FontEditor.cpp2
-rw-r--r--Kernel/Devices/KeyboardDevice.cpp2
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/NetworkTask.cpp4
-rw-r--r--Kernel/PCI/Definitions.h2
-rw-r--r--Kernel/PCI/MMIOAccess.cpp2
-rw-r--r--Kernel/Storage/IDEChannel.cpp6
-rw-r--r--Kernel/Thread.cpp18
-rw-r--r--Kernel/Thread.h4
-rw-r--r--Libraries/LibVT/Terminal.cpp2
-rw-r--r--Userland/printf.cpp4
12 files changed, 27 insertions, 28 deletions
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h
index 0b202a2b79..fa87ddc06f 100644
--- a/AK/PrintfImplementation.h
+++ b/AK/PrintfImplementation.h
@@ -390,10 +390,6 @@ struct PrintfImpl {
{
return print_hex(m_putch, m_bufptr, NextArgument<int>()(ap), false, state.alternate_form, false, true, 4);
}
- ALWAYS_INLINE int format_b(const ModifierState& state, ArgumentListRefT ap) const
- {
- return print_hex(m_putch, m_bufptr, NextArgument<int>()(ap), false, state.alternate_form, false, true, 2);
- }
ALWAYS_INLINE int format_c(const ModifierState& state, ArgumentListRefT ap) const
{
char c = NextArgument<int>()(ap);
@@ -502,7 +498,6 @@ ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fm
PRINTF_IMPL_DELEGATE_TO_IMPL(P);
PRINTF_IMPL_DELEGATE_TO_IMPL(Q);
PRINTF_IMPL_DELEGATE_TO_IMPL(X);
- PRINTF_IMPL_DELEGATE_TO_IMPL(b);
PRINTF_IMPL_DELEGATE_TO_IMPL(c);
PRINTF_IMPL_DELEGATE_TO_IMPL(d);
#ifndef KERNEL
diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp
index 05d72fa5cb..e1371fbb57 100644
--- a/Applications/FontEditor/FontEditor.cpp
+++ b/Applications/FontEditor/FontEditor.cpp
@@ -345,7 +345,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite
m_glyph_editor_widget->set_glyph(glyph);
glyph_width_spinbox.set_value(m_edited_font->glyph_width(m_glyph_map_widget->selected_glyph()));
StringBuilder builder;
- builder.appendf("0x%b (", glyph);
+ builder.appendff("{:#02x} (", glyph);
if (glyph < 128) {
builder.append(glyph);
} else {
diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp
index 7e97cb109f..72c8346e0e 100644
--- a/Kernel/Devices/KeyboardDevice.cpp
+++ b/Kernel/Devices/KeyboardDevice.cpp
@@ -296,7 +296,7 @@ void KeyboardDevice::irq_handle_byte_read(u8 byte)
}
#ifdef KEYBOARD_DEBUG
- dbg() << "Keyboard::irq_handle_byte_read: " << String::format("%b", ch) << " " << (pressed ? "down" : "up");
+ dbgln("Keyboard::irq_handle_byte_read: {:#02x} {}", ch, (pressed ? "down" : "up"));
#endif
switch (ch) {
case 0x38:
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 8664dca130..d5ca9ed9f3 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -217,7 +217,7 @@ E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq)
klog() << "E1000: Has EEPROM? " << m_has_eeprom;
read_mac_address();
const auto& mac = mac_address();
- klog() << "E1000: MAC address: " << String::format("%b", mac[0]) << ":" << String::format("%b", mac[1]) << ":" << String::format("%b", mac[2]) << ":" << String::format("%b", mac[3]) << ":" << String::format("%b", mac[4]) << ":" << String::format("%b", mac[5]);
+ klog() << "E1000: MAC address: " << mac.to_string();
u32 flags = in32(REG_CTRL);
out32(REG_CTRL, flags | ECTRL_SLU);
@@ -458,7 +458,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
m_wait_queue.wait_on(nullptr, "E1000NetworkAdapter");
}
#ifdef E1000_DEBUG
- klog() << "E1000: Sent packet, status is now " << String::format("%b", descriptor.status) << "!";
+ dbgln("E1000: Sent packet, status is now {:#02x}!", descriptor.status);
#endif
}
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index bf1dc0fd92..fee823fd78 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -128,7 +128,7 @@ void NetworkTask_main(void*)
#ifdef ETHERNET_VERY_DEBUG
for (size_t i = 0; i < packet_size; i++) {
- klog() << String::format("%b", buffer[i]);
+ klog() << String::format("%#02x", buffer[i]);
switch (i % 16) {
case 7:
@@ -249,7 +249,7 @@ void handle_icmp(const EthernetFrameHeader& eth, const IPv4Packet& ipv4_packet,
{
auto& icmp_header = *static_cast<const ICMPHeader*>(ipv4_packet.payload());
#ifdef ICMP_DEBUG
- klog() << "handle_icmp: source=" << ipv4_packet.source().to_string().characters() << ", destination=" << ipv4_packet.destination().to_string().characters() << ", type=" << String::format("%b", icmp_header.type()) << ", code=" << String::format("%b", icmp_header.code());
+ dbgln("handle_icmp: source={}, destination={}, type={:#02x}, code={:#02x}", ipv4_packet.source().to_string(), ipv4_packet.destination().to_string(), icmp_header.type(), icmp_header.code());
#endif
{
diff --git a/Kernel/PCI/Definitions.h b/Kernel/PCI/Definitions.h
index 2733cd1c1f..944b41f40c 100644
--- a/Kernel/PCI/Definitions.h
+++ b/Kernel/PCI/Definitions.h
@@ -144,7 +144,7 @@ protected:
inline const LogStream& operator<<(const LogStream& stream, const Address value)
{
- return stream << "PCI [" << String::format("%w", value.seg()) << ":" << String::format("%b", value.bus()) << ":" << String::format("%b", value.slot()) << "." << String::format("%b", value.function()) << "]";
+ return stream << "PCI [" << String::formatted("{:04x}:{:02x}:{:02x}:{:02x}", value.seg(), value.bus(), value.slot(), value.function()) << "]";
}
struct ChangeableAddress : public Address {
diff --git a/Kernel/PCI/MMIOAccess.cpp b/Kernel/PCI/MMIOAccess.cpp
index 793aa20ba2..10e91c89dd 100644
--- a/Kernel/PCI/MMIOAccess.cpp
+++ b/Kernel/PCI/MMIOAccess.cpp
@@ -131,7 +131,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
m_mapped_device_regions.append(make<DeviceConfigurationSpaceMapping>(address, m_segments.get(address.seg()).value()));
m_physical_ids.append({ address, id, get_capabilities(address) });
#ifdef PCI_DEBUG
- dbg() << "PCI: Mapping device @ pci (" << String::format("%w", address.seg()) << ":" << String::format("%b", address.bus()) << ":" << String::format("%b", address.slot()) << "." << String::format("%b", address.function()) << ")"
+ dbg() << "PCI: Mapping device @ pci (" << address << ")"
<< " " << m_mapped_device_regions.last().vaddr() << " " << m_mapped_device_regions.last().paddr();
#endif
});
diff --git a/Kernel/Storage/IDEChannel.cpp b/Kernel/Storage/IDEChannel.cpp
index 6334605c2c..49e4e6dfd5 100644
--- a/Kernel/Storage/IDEChannel.cpp
+++ b/Kernel/Storage/IDEChannel.cpp
@@ -256,7 +256,7 @@ void IDEChannel::handle_irq(const RegisterState&)
if (status & ATA_SR_ERR) {
print_ide_status(status);
m_device_error = m_io_group.io_base().offset(ATA_REG_ERROR).in<u8>();
- klog() << "IDEChannel: Error " << String::format("%b", m_device_error) << "!";
+ dbgln("IDEChannel: Error {:#02x}!", (u8)m_device_error);
complete_current_request(AsyncDeviceRequest::Failure);
return;
}
@@ -557,8 +557,8 @@ void IDEChannel::ata_do_write_sector()
ASSERT(status & ATA_SR_DRQ);
auto in_buffer = request.buffer().offset(m_current_request_block_index * 512);
-#ifdef PATA_DEBUG
- dbg() << "IDEChannel: Writing 512 bytes (part " << m_current_request_block_index << ") (status=" << String::format("%b", status) << ")...";
+#ifndef PATA_DEBUG
+ dbgln("IDEChannel: Writing 512 bytes (part {}) (status={:#02x})...", m_current_request_block_index, status);
#endif
ssize_t nread = request.read_from_buffer_buffered<512>(in_buffer, 512, [&](const u8* buffer, size_t buffer_bytes) {
for (size_t i = 0; i < buffer_bytes; i += sizeof(u16))
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index b89adb4a73..ba8475a833 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -862,7 +862,6 @@ RefPtr<Thread> Thread::clone(Process& process)
clone->m_signal_mask = m_signal_mask;
memcpy(clone->m_fpu_state, m_fpu_state, sizeof(FPUState));
clone->m_thread_specific_data = m_thread_specific_data;
- clone->m_thread_specific_region_size = m_thread_specific_region_size;
return clone;
}
@@ -1037,19 +1036,28 @@ Vector<FlatPtr> Thread::raw_backtrace(FlatPtr ebp, FlatPtr eip) const
return backtrace;
}
+size_t Thread::thread_specific_region_alignment() const
+{
+ return max(process().m_master_tls_alignment, alignof(ThreadSpecificData));
+}
+
+size_t Thread::thread_specific_region_size() const
+{
+ return align_up_to(process().m_master_tls_size, thread_specific_region_alignment()) + sizeof(ThreadSpecificData);
+}
+
KResult Thread::make_thread_specific_region(Badge<Process>)
{
// The process may not require a TLS region
if (!process().m_master_tls_region)
return KSuccess;
- size_t thread_specific_region_alignment = max(process().m_master_tls_alignment, alignof(ThreadSpecificData));
- m_thread_specific_region_size = align_up_to(process().m_master_tls_size, thread_specific_region_alignment) + sizeof(ThreadSpecificData);
- auto* region = process().allocate_region({}, m_thread_specific_region_size, "Thread-specific", PROT_READ | PROT_WRITE, true);
+ auto* region = process().allocate_region({}, thread_specific_region_size(), "Thread-specific", PROT_READ | PROT_WRITE, true);
if (!region)
return KResult(-ENOMEM);
+
SmapDisabler disabler;
- auto* thread_specific_data = (ThreadSpecificData*)region->vaddr().offset(align_up_to(process().m_master_tls_size, thread_specific_region_alignment)).as_ptr();
+ auto* thread_specific_data = (ThreadSpecificData*)region->vaddr().offset(align_up_to(process().m_master_tls_size, thread_specific_region_alignment())).as_ptr();
auto* thread_local_storage = (u8*)((u8*)thread_specific_data) - align_up_to(process().m_master_tls_size, process().m_master_tls_alignment);
m_thread_specific_data = VirtualAddress(thread_specific_data);
thread_specific_data->self = thread_specific_data;
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index c0ef852248..6c44968f94 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -758,7 +758,8 @@ public:
const char* state_string() const;
VirtualAddress thread_specific_data() const { return m_thread_specific_data; }
- size_t thread_specific_region_size() const { return m_thread_specific_region_size; }
+ size_t thread_specific_region_size() const;
+ size_t thread_specific_region_alignment() const;
ALWAYS_INLINE void yield_if_stopped()
{
@@ -1198,7 +1199,6 @@ private:
u32 m_kernel_stack_top { 0 };
OwnPtr<Region> m_kernel_stack_region;
VirtualAddress m_thread_specific_data;
- size_t m_thread_specific_region_size { 0 };
SignalActionData m_signal_action_data[32];
Blocker* m_blocker { nullptr };
diff --git a/Libraries/LibVT/Terminal.cpp b/Libraries/LibVT/Terminal.cpp
index b5b32ef252..afed43f0ad 100644
--- a/Libraries/LibVT/Terminal.cpp
+++ b/Libraries/LibVT/Terminal.cpp
@@ -824,7 +824,7 @@ void Terminal::DSR(const ParamVector& params)
void Terminal::on_input(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);
+ dbgln("Terminal::on_input: {:#02x} ({:c}), fg={}, bg={}\n", ch, ch, m_current_attribute.foreground_color, m_current_attribute.background_color);
#endif
auto fail_utf8_parse = [this] {
diff --git a/Userland/printf.cpp b/Userland/printf.cpp
index 494abb9869..bb434e761c 100644
--- a/Userland/printf.cpp
+++ b/Userland/printf.cpp
@@ -46,10 +46,6 @@ struct PrintfImpl : public PrintfImplementation::PrintfImpl<PutChFunc, ArgumentL
{
}
- ALWAYS_INLINE int format_b(const PrintfImplementation::ModifierState&, ArgumentListRefT&) const
- {
- fail("format specifier 'b' is not supported");
- }
ALWAYS_INLINE int format_q(const PrintfImplementation::ModifierState& state, ArgumentListRefT& ap) const
{
auto state_copy = state;