mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:42:44 +00:00 
			
		
		
		
	Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
This commit is contained in:
		
							parent
							
								
									dd727d1fec
								
							
						
					
					
						commit
						c6ebca5b45
					
				
					 8 changed files with 68 additions and 106 deletions
				
			
		
							
								
								
									
										23
									
								
								AK/Debug.h
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								AK/Debug.h
									
										
									
									
									
								
							|  | @ -178,3 +178,26 @@ constexpr bool debug_ipv4_socket = true; | ||||||
| constexpr bool debug_ipv4_socket = false; | constexpr bool debug_ipv4_socket = false; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #ifdef DEBUG_LOCAL_SOCKET | ||||||
|  | constexpr bool debug_local_socket = true; | ||||||
|  | #else | ||||||
|  | constexpr bool debug_local_socket = false; | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef DEBUG_SOCKET | ||||||
|  | constexpr bool debug_socket = true; | ||||||
|  | #else | ||||||
|  | constexpr bool debug_socket = false; | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef TCP_SOCKET_DEBUG | ||||||
|  | constexpr bool debug_tcp_socket = true; | ||||||
|  | #else | ||||||
|  | constexpr bool debug_tcp_socket = false; | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef PCI_DEBUG | ||||||
|  | constexpr bool debug_pci = true; | ||||||
|  | #else | ||||||
|  | constexpr bool debug_pci = false; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | #include <AK/Debug.h> | ||||||
| #include <AK/Singleton.h> | #include <AK/Singleton.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <Kernel/FileSystem/FileDescription.h> | #include <Kernel/FileSystem/FileDescription.h> | ||||||
|  | @ -75,9 +76,7 @@ LocalSocket::LocalSocket(int type) | ||||||
|         evaluate_block_conditions(); |         evaluate_block_conditions(); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG_LOCAL_SOCKET |     dbgln<debug_local_socket>("LocalSocket({}) created with type={}", this, type); | ||||||
|     dbg() << "LocalSocket{" << this << "} created with type=" << type; |  | ||||||
| #endif |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| LocalSocket::~LocalSocket() | LocalSocket::~LocalSocket() | ||||||
|  | @ -113,9 +112,7 @@ KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t add | ||||||
| 
 | 
 | ||||||
|     auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path))); |     auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path))); | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG_LOCAL_SOCKET |     dbgln<debug_local_socket>("LocalSocket({}) bind({})", this, path); | ||||||
|     dbg() << "LocalSocket{" << this << "} bind(" << path << ")"; |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|     mode_t mode = S_IFSOCK | (m_prebind_mode & 04777); |     mode_t mode = S_IFSOCK | (m_prebind_mode & 04777); | ||||||
|     UidAndGid owner { m_prebind_uid, m_prebind_gid }; |     UidAndGid owner { m_prebind_uid, m_prebind_gid }; | ||||||
|  | @ -159,9 +156,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka | ||||||
|         return EFAULT; |         return EFAULT; | ||||||
|     safe_address[sizeof(safe_address) - 1] = '\0'; |     safe_address[sizeof(safe_address) - 1] = '\0'; | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG_LOCAL_SOCKET |     dbgln<debug_local_socket>("LocalSocket({}) connect({})", this, safe_address); | ||||||
|     dbg() << "LocalSocket{" << this << "} connect(" << safe_address << ")"; |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|     auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current()->current_directory()); |     auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current()->current_directory()); | ||||||
|     if (description_or_error.is_error()) |     if (description_or_error.is_error()) | ||||||
|  | @ -197,9 +192,7 @@ KResult LocalSocket::connect(FileDescription& description, Userspace<const socka | ||||||
|         return EINTR; |         return EINTR; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG_LOCAL_SOCKET |     dbgln<debug_local_socket>("LocalSocket({}) connect({}) status is {}", this, safe_address, to_string(setup_state())); | ||||||
|     dbg() << "LocalSocket{" << this << "} connect(" << safe_address << ") status is " << to_string(setup_state()); |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|     if (!((u32)unblock_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Connect)) { |     if (!((u32)unblock_flags & (u32)Thread::FileDescriptionBlocker::BlockFlags::Connect)) { | ||||||
|         set_connect_side_role(Role::None); |         set_connect_side_role(Role::None); | ||||||
|  | @ -218,9 +211,9 @@ KResult LocalSocket::listen(size_t backlog) | ||||||
|     auto previous_role = m_role; |     auto previous_role = m_role; | ||||||
|     m_role = Role::Listener; |     m_role = Role::Listener; | ||||||
|     set_connect_side_role(Role::Listener, previous_role != m_role); |     set_connect_side_role(Role::Listener, previous_role != m_role); | ||||||
| #ifdef DEBUG_LOCAL_SOCKET | 
 | ||||||
|     dbg() << "LocalSocket{" << this << "} listening with backlog=" << backlog; |     dbgln<debug_local_socket>("LocalSocket({}) listening with backlog={}", this, backlog); | ||||||
| #endif | 
 | ||||||
|     return KSuccess; |     return KSuccess; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | #include <AK/Debug.h> | ||||||
| #include <AK/StringBuilder.h> | #include <AK/StringBuilder.h> | ||||||
| #include <AK/StringView.h> | #include <AK/StringView.h> | ||||||
| #include <Kernel/FileSystem/FileDescription.h> | #include <Kernel/FileSystem/FileDescription.h> | ||||||
|  | @ -65,10 +66,7 @@ Socket::~Socket() | ||||||
| 
 | 
 | ||||||
| void Socket::set_setup_state(SetupState new_setup_state) | void Socket::set_setup_state(SetupState new_setup_state) | ||||||
| { | { | ||||||
| #ifdef SOCKET_DEBUG |     dbgln<debug_socket>("Socket({}) setup state moving from {} to {}", this, to_string(m_setup_state), to_string(new_setup_state)); | ||||||
|     dbg() << "Socket{" << this << "} setup state moving from " << to_string(m_setup_state) << " to " << to_string(new_setup_state); |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
|     m_setup_state = new_setup_state; |     m_setup_state = new_setup_state; | ||||||
|     evaluate_block_conditions(); |     evaluate_block_conditions(); | ||||||
| } | } | ||||||
|  | @ -78,9 +76,7 @@ RefPtr<Socket> Socket::accept() | ||||||
|     LOCKER(m_lock); |     LOCKER(m_lock); | ||||||
|     if (m_pending.is_empty()) |     if (m_pending.is_empty()) | ||||||
|         return nullptr; |         return nullptr; | ||||||
| #ifdef SOCKET_DEBUG |     dbgln<debug_socket>("Socket({}) de-queueing connection", this); | ||||||
|     dbg() << "Socket{" << this << "} de-queueing connection"; |  | ||||||
| #endif |  | ||||||
|     auto client = m_pending.take_first(); |     auto client = m_pending.take_first(); | ||||||
|     ASSERT(!client->is_connected()); |     ASSERT(!client->is_connected()); | ||||||
|     auto& process = *Process::current(); |     auto& process = *Process::current(); | ||||||
|  | @ -94,9 +90,7 @@ RefPtr<Socket> Socket::accept() | ||||||
| 
 | 
 | ||||||
| KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer) | KResult Socket::queue_connection_from(NonnullRefPtr<Socket> peer) | ||||||
| { | { | ||||||
| #ifdef SOCKET_DEBUG |     dbgln<debug_socket>("Socket({}) queueing connection", this); | ||||||
|     dbg() << "Socket{" << this << "} queueing connection"; |  | ||||||
| #endif |  | ||||||
|     LOCKER(m_lock); |     LOCKER(m_lock); | ||||||
|     if (m_pending.size() >= m_backlog) |     if (m_pending.size() >= m_backlog) | ||||||
|         return ECONNREFUSED; |         return ECONNREFUSED; | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | #include <AK/Debug.h> | ||||||
| #include <AK/Singleton.h> | #include <AK/Singleton.h> | ||||||
| #include <AK/Time.h> | #include <AK/Time.h> | ||||||
| #include <Kernel/Devices/RandomDevice.h> | #include <Kernel/Devices/RandomDevice.h> | ||||||
|  | @ -48,9 +49,7 @@ void TCPSocket::for_each(Function<void(const TCPSocket&)> callback) | ||||||
| 
 | 
 | ||||||
| void TCPSocket::set_state(State new_state) | void TCPSocket::set_state(State new_state) | ||||||
| { | { | ||||||
| #ifdef TCP_SOCKET_DEBUG |     dbgln<debug_tcp_socket>("TCPSocket({}) state moving from {} to {}", this, to_string(m_state), to_string(new_state)); | ||||||
|     dbg() << "TCPSocket{" << this << "} state moving from " << to_string(m_state) << " to " << to_string(new_state); |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|     auto was_disconnected = protocol_is_disconnected(); |     auto was_disconnected = protocol_is_disconnected(); | ||||||
|     auto previous_role = m_role; |     auto previous_role = m_role; | ||||||
|  | @ -157,9 +156,7 @@ TCPSocket::~TCPSocket() | ||||||
|     LOCKER(sockets_by_tuple().lock()); |     LOCKER(sockets_by_tuple().lock()); | ||||||
|     sockets_by_tuple().resource().remove(tuple()); |     sockets_by_tuple().resource().remove(tuple()); | ||||||
| 
 | 
 | ||||||
| #ifdef TCP_SOCKET_DEBUG |     dbgln<debug_tcp_socket>("~TCPSocket in state {}", to_string(state())); | ||||||
|     dbg() << "~TCPSocket in state " << to_string(state()); |  | ||||||
| #endif |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol) | NonnullRefPtr<TCPSocket> TCPSocket::create(int protocol) | ||||||
|  | @ -278,18 +275,14 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size) | ||||||
|     if (packet.has_ack()) { |     if (packet.has_ack()) { | ||||||
|         u32 ack_number = packet.ack_number(); |         u32 ack_number = packet.ack_number(); | ||||||
| 
 | 
 | ||||||
| #ifdef TCP_SOCKET_DEBUG |         dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet: {}", ack_number); | ||||||
|         dbg() << "TCPSocket: receive_tcp_packet: " << ack_number; |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|         int removed = 0; |         int removed = 0; | ||||||
|         LOCKER(m_not_acked_lock); |         LOCKER(m_not_acked_lock); | ||||||
|         while (!m_not_acked.is_empty()) { |         while (!m_not_acked.is_empty()) { | ||||||
|             auto& packet = m_not_acked.first(); |             auto& packet = m_not_acked.first(); | ||||||
| 
 | 
 | ||||||
| #ifdef TCP_SOCKET_DEBUG |             dbgln<debug_tcp_socket>("TCPSocket: iterate: {}", packet.ack_number); | ||||||
|             dbg() << "TCPSocket: iterate: " << packet.ack_number; |  | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|             if (packet.ack_number <= ack_number) { |             if (packet.ack_number <= ack_number) { | ||||||
|                 m_not_acked.take_first(); |                 m_not_acked.take_first(); | ||||||
|  | @ -299,9 +292,7 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| #ifdef TCP_SOCKET_DEBUG |         dbgln<debug_tcp_socket>("TCPSocket: receive_tcp_packet acknowledged {} packets", removed); | ||||||
|         dbg() << "TCPSocket: receive_tcp_packet acknowledged " << removed << " packets"; |  | ||||||
| #endif |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     m_packets_in++; |     m_packets_in++; | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | #include <AK/Debug.h> | ||||||
| #include <Kernel/IO.h> | #include <Kernel/IO.h> | ||||||
| #include <Kernel/PCI/Access.h> | #include <Kernel/PCI/Access.h> | ||||||
| #include <Kernel/PCI/IOAccess.h> | #include <Kernel/PCI/IOAccess.h> | ||||||
|  | @ -75,44 +76,34 @@ PhysicalID Access::get_physical_id(Address address) const | ||||||
| 
 | 
 | ||||||
| u8 Access::early_read8_field(Address address, u32 field) | u8 Access::early_read8_field(Address address, u32 field) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Early reading 8-bit field {:#08x} for {}", field, address); | ||||||
|     dbg() << "PCI: Early reading 8-bit field 0x" << String::formatted("{:08x}", field) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); |     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); | ||||||
|     return IO::in8(PCI_VALUE_PORT + (field & 3)); |     return IO::in8(PCI_VALUE_PORT + (field & 3)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u16 Access::early_read16_field(Address address, u32 field) | u16 Access::early_read16_field(Address address, u32 field) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Early reading 16-bit field {:#08x} for {}", field, address); | ||||||
|     dbg() << "PCI: Early reading 16-bit field 0x" << String::formatted("{:08x}", field) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); |     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); | ||||||
|     return IO::in16(PCI_VALUE_PORT + (field & 2)); |     return IO::in16(PCI_VALUE_PORT + (field & 2)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 Access::early_read32_field(Address address, u32 field) | u32 Access::early_read32_field(Address address, u32 field) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Early reading 32-bit field {:#08x} for {}", field, address); | ||||||
|     dbg() << "PCI: Early reading 32-bit field 0x" << String::formatted("{:08x}", field) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); |     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); | ||||||
|     return IO::in32(PCI_VALUE_PORT); |     return IO::in32(PCI_VALUE_PORT); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u16 Access::early_read_type(Address address) | u16 Access::early_read_type(Address address) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Early reading type for {}", address); | ||||||
|     dbg() << "PCI: Early reading type for " << address; |  | ||||||
| #endif |  | ||||||
|     return (early_read8_field(address, PCI_CLASS) << 8u) | early_read8_field(address, PCI_SUBCLASS); |     return (early_read8_field(address, PCI_CLASS) << 8u) | early_read8_field(address, PCI_SUBCLASS); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Function<void(Address, ID)>& callback) | void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Function<void(Address, ID)>& callback) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Enumerating function type={}, bus={}, slot={}, function={}", type, bus, slot, function); | ||||||
|     dbg() << "PCI: Enumerating function type=" << type << ", bus=" << bus << ", slot=" << slot << ", function=" << function; |  | ||||||
| #endif |  | ||||||
|     Address address(0, bus, slot, function); |     Address address(0, bus, slot, function); | ||||||
|     if (type == -1 || type == early_read_type(address)) |     if (type == -1 || type == early_read_type(address)) | ||||||
|         callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) }); |         callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) }); | ||||||
|  | @ -128,9 +119,7 @@ void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Functio | ||||||
| 
 | 
 | ||||||
| void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID)>& callback) | void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID)>& callback) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Enumerating slot type={}, bus={}, slot={}", type, bus, slot); | ||||||
|     dbg() << "PCI: Enumerating slot type=" << type << ", bus=" << bus << ", slot=" << slot; |  | ||||||
| #endif |  | ||||||
|     Address address(0, bus, slot, 0); |     Address address(0, bus, slot, 0); | ||||||
|     if (early_read16_field(address, PCI_VENDOR_ID) == PCI_NONE) |     if (early_read16_field(address, PCI_VENDOR_ID) == PCI_NONE) | ||||||
|         return; |         return; | ||||||
|  | @ -146,9 +135,7 @@ void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID | ||||||
| 
 | 
 | ||||||
| void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback) | void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Enumerating bus type={}, bus={}", type, bus); | ||||||
|     dbg() << "PCI: Enumerating bus type=" << type << ", bus=" << bus; |  | ||||||
| #endif |  | ||||||
|     for (u8 slot = 0; slot < 32; ++slot) |     for (u8 slot = 0; slot < 32; ++slot) | ||||||
|         enumerate_slot(type, bus, slot, callback); |         enumerate_slot(type, bus, slot, callback); | ||||||
| } | } | ||||||
|  | @ -167,18 +154,12 @@ void enumerate(Function<void(Address, ID)> callback) | ||||||
| 
 | 
 | ||||||
| Optional<u8> get_capabilities_pointer(Address address) | Optional<u8> get_capabilities_pointer(Address address) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Getting capabilities pointer for {}", address); | ||||||
|     dbg() << "PCI: Getting capabilities pointer for " << address; |  | ||||||
| #endif |  | ||||||
|     if (PCI::read16(address, PCI_STATUS) & (1 << 4)) { |     if (PCI::read16(address, PCI_STATUS) & (1 << 4)) { | ||||||
| #ifdef PCI_DEBUG |         dbgln<debug_pci>("PCI: Found capabilities pointer for {}", address); | ||||||
|         dbg() << "PCI: Found capabilities pointer for " << address; |  | ||||||
| #endif |  | ||||||
|         return PCI::read8(address, PCI_CAPABILITIES_POINTER); |         return PCI::read8(address, PCI_CAPABILITIES_POINTER); | ||||||
|     } |     } | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: No capabilities pointer for {}", address); | ||||||
|     dbg() << "PCI: No capabilities pointer for " << address; |  | ||||||
| #endif |  | ||||||
|     return {}; |     return {}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -189,22 +170,16 @@ PhysicalID get_physical_id(Address address) | ||||||
| 
 | 
 | ||||||
| Vector<Capability> get_capabilities(Address address) | Vector<Capability> get_capabilities(Address address) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: Getting capabilities for {}", address); | ||||||
|     dbg() << "PCI: Getting capabilities for " << address; |  | ||||||
| #endif |  | ||||||
|     auto capabilities_pointer = PCI::get_capabilities_pointer(address); |     auto capabilities_pointer = PCI::get_capabilities_pointer(address); | ||||||
|     if (!capabilities_pointer.has_value()) { |     if (!capabilities_pointer.has_value()) { | ||||||
| #ifdef PCI_DEBUG |         dbgln<debug_pci>("PCI: No capabilities for {}", address); | ||||||
|         dbg() << "PCI: No capabilities for " << address; |  | ||||||
| #endif |  | ||||||
|         return {}; |         return {}; | ||||||
|     } |     } | ||||||
|     Vector<Capability> capabilities; |     Vector<Capability> capabilities; | ||||||
|     auto capability_pointer = capabilities_pointer.value(); |     auto capability_pointer = capabilities_pointer.value(); | ||||||
|     while (capability_pointer != 0) { |     while (capability_pointer != 0) { | ||||||
| #ifdef PCI_DEBUG |         dbgln<debug_pci>("PCI: Reading in capability at {:#02x} for {}", capability_pointer, address); | ||||||
|         dbg() << "PCI: Reading in capability at 0x" << String::formatted("{:02x}", capability_pointer) << " for " << address; |  | ||||||
| #endif |  | ||||||
|         u16 capability_header = PCI::read16(address, capability_pointer); |         u16 capability_header = PCI::read16(address, capability_pointer); | ||||||
|         u8 capability_id = capability_header & 0xff; |         u8 capability_id = capability_header & 0xff; | ||||||
|         capability_pointer = capability_header >> 8; |         capability_pointer = capability_header >> 8; | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <AK/Debug.h> | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
| #include <AK/LogStream.h> | #include <AK/LogStream.h> | ||||||
| #include <AK/String.h> | #include <AK/String.h> | ||||||
|  | @ -195,11 +196,10 @@ public: | ||||||
|         , m_id(id) |         , m_id(id) | ||||||
|         , m_capabilities(capabilities) |         , m_capabilities(capabilities) | ||||||
|     { |     { | ||||||
| #ifdef PCI_DEBUG |         if constexpr (debug_pci) { | ||||||
|         for (auto capability : capabilities) { |             for (auto capability : capabilities) | ||||||
|             dbg() << address << " has capbility " << capability.m_id; |                 dbgln("{} has capability {}", address, capability.m_id); | ||||||
|         } |         } | ||||||
| #endif |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Vector<Capability> capabilities() const { return m_capabilities; } |     Vector<Capability> capabilities() const { return m_capabilities; } | ||||||
|  |  | ||||||
|  | @ -24,11 +24,10 @@ | ||||||
|  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | #include <AK/Debug.h> | ||||||
| #include <Kernel/IO.h> | #include <Kernel/IO.h> | ||||||
| #include <Kernel/PCI/IOAccess.h> | #include <Kernel/PCI/IOAccess.h> | ||||||
| 
 | 
 | ||||||
| //#define PCI_DEBUG
 |  | ||||||
| 
 |  | ||||||
| namespace Kernel { | namespace Kernel { | ||||||
| namespace PCI { | namespace PCI { | ||||||
| 
 | 
 | ||||||
|  | @ -36,9 +35,7 @@ void IOAccess::initialize() | ||||||
| { | { | ||||||
|     if (!Access::is_initialized()) { |     if (!Access::is_initialized()) { | ||||||
|         new IOAccess(); |         new IOAccess(); | ||||||
| #ifdef PCI_DEBUG |         dbgln<debug_pci>("PCI: IO access initialised."); | ||||||
|         dbgln("PCI: IO access initialised."); |  | ||||||
| #endif |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -52,49 +49,37 @@ IOAccess::IOAccess() | ||||||
| 
 | 
 | ||||||
| u8 IOAccess::read8_field(Address address, u32 field) | u8 IOAccess::read8_field(Address address, u32 field) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: IO Reading 8-bit field {:#08x} for {}", field, address); | ||||||
|     dbg() << "PCI: IO Reading 8-bit field 0x" << String::formatted("{:08x}", field) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     return Access::early_read8_field(address, field); |     return Access::early_read8_field(address, field); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u16 IOAccess::read16_field(Address address, u32 field) | u16 IOAccess::read16_field(Address address, u32 field) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: IO Reading 16-bit field {:#08x} for {}", field, address); | ||||||
|     dbg() << "PCI: IO Reading 16-bit field 0x" << String::formatted("{:08x}", field) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     return Access::early_read16_field(address, field); |     return Access::early_read16_field(address, field); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| u32 IOAccess::read32_field(Address address, u32 field) | u32 IOAccess::read32_field(Address address, u32 field) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: IO Reading 32-bit field {:#08x} for {}", field, address); | ||||||
|     dbg() << "PCI: IO Reading 32-bit field 0x" << String::formatted("{:08x}", field) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     return Access::early_read32_field(address, field); |     return Access::early_read32_field(address, field); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IOAccess::write8_field(Address address, u32 field, u8 value) | void IOAccess::write8_field(Address address, u32 field, u8 value) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: IO Writing to 8-bit field {:#08x}, value={:#02x} for {}", field, value, address); | ||||||
|     dbg() << "PCI: IO Writing to 8-bit field 0x" << String::formatted("{:08x}", field) << ", value=0x" << String::formatted("{:02x}", value) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); |     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); | ||||||
|     IO::out8(PCI_VALUE_PORT + (field & 3), value); |     IO::out8(PCI_VALUE_PORT + (field & 3), value); | ||||||
| } | } | ||||||
| void IOAccess::write16_field(Address address, u32 field, u16 value) | void IOAccess::write16_field(Address address, u32 field, u16 value) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: IO Writing to 16-bit field {:#08x}, value={:#02x} for {}", field, value, address); | ||||||
|     dbg() << "PCI: IO Writing to 16-bit field 0x" << String::formatted("{:08x}", field) << ", value=0x" << String::formatted("{:04x}", value) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); |     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); | ||||||
|     IO::out16(PCI_VALUE_PORT + (field & 2), value); |     IO::out16(PCI_VALUE_PORT + (field & 2), value); | ||||||
| } | } | ||||||
| void IOAccess::write32_field(Address address, u32 field, u32 value) | void IOAccess::write32_field(Address address, u32 field, u32 value) | ||||||
| { | { | ||||||
| #ifdef PCI_DEBUG |     dbgln<debug_pci>("PCI: IO Writing to 32-bit field {:#08x}, value={:#02x} for {}", field, value, address); | ||||||
|     dbg() << "PCI: IO Writing to 32-bit field 0x" << String::formatted("{:08x}", field) << ", value=0x" << String::formatted("{:08x}", value) << " for " << address; |  | ||||||
| #endif |  | ||||||
|     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); |     IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field)); | ||||||
|     IO::out32(PCI_VALUE_PORT, value); |     IO::out32(PCI_VALUE_PORT, value); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -167,6 +167,7 @@ add_compile_definitions("WAITQUEUE_DEBUG") | ||||||
| add_compile_definitions("WEAKABLE_DEBUG") | add_compile_definitions("WEAKABLE_DEBUG") | ||||||
| add_compile_definitions("WINDOWMANAGER_DEBUG") | add_compile_definitions("WINDOWMANAGER_DEBUG") | ||||||
| add_compile_definitions("WSMESSAGELOOP_DEBUG") | add_compile_definitions("WSMESSAGELOOP_DEBUG") | ||||||
|  | add_compile_definitions("DEBUG_SOCKET") | ||||||
| add_compile_definitions("WSSCREEN_DEBUG") | add_compile_definitions("WSSCREEN_DEBUG") | ||||||
| # False positive: IF_BMP_DEBUG is not actually a flag. | # False positive: IF_BMP_DEBUG is not actually a flag. | ||||||
| # add_compile_definitions("IF_BMP_DEBUG") | # add_compile_definitions("IF_BMP_DEBUG") | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 asynts
						asynts