mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:32:44 +00:00 
			
		
		
		
	AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it possible to pass a FlatPtr to something that has u32 and u64 overloads.
This commit is contained in:
		
							parent
							
								
									b98d8ad5b0
								
							
						
					
					
						commit
						b1058b33fb
					
				
					 36 changed files with 164 additions and 161 deletions
				
			
		|  | @ -250,14 +250,14 @@ bool E1000NetworkAdapter::link_up() | |||
| 
 | ||||
| void E1000NetworkAdapter::initialize_rx_descriptors() | ||||
| { | ||||
|     auto ptr = (uintptr_t)kmalloc_eternal(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16); | ||||
|     auto ptr = (FlatPtr)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]; | ||||
|         auto addr = (uintptr_t)kmalloc_eternal(8192 + 16); | ||||
|         auto addr = (FlatPtr)kmalloc_eternal(8192 + 16); | ||||
|         if (addr % 16) | ||||
|             addr = (addr + 16) - (addr % 16); | ||||
|         descriptor.addr = addr - 0xc0000000; | ||||
|  | @ -275,14 +275,14 @@ void E1000NetworkAdapter::initialize_rx_descriptors() | |||
| 
 | ||||
| void E1000NetworkAdapter::initialize_tx_descriptors() | ||||
| { | ||||
|     auto ptr = (uintptr_t)kmalloc_eternal(sizeof(e1000_tx_desc) * number_of_tx_descriptors + 16); | ||||
|     auto ptr = (FlatPtr)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]; | ||||
|         auto addr = (uintptr_t)kmalloc_eternal(8192 + 16); | ||||
|         auto addr = (FlatPtr)kmalloc_eternal(8192 + 16); | ||||
|         if (addr % 16) | ||||
|             addr = (addr + 16) - (addr % 16); | ||||
|         descriptor.addr = addr - 0xc0000000; | ||||
|  |  | |||
|  | @ -154,16 +154,16 @@ RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address address, u8 irq) | |||
|     // we add space to account for overhang from the last packet - the rtl8139
 | ||||
|     // can optionally guarantee that packets will be contiguous by
 | ||||
|     // purposefully overrunning the rx buffer
 | ||||
|     m_rx_buffer_addr = (uintptr_t)virtual_to_low_physical(kmalloc_aligned(RX_BUFFER_SIZE + PACKET_SIZE_MAX, 16)); | ||||
|     m_rx_buffer_addr = (FlatPtr)virtual_to_low_physical(kmalloc_aligned(RX_BUFFER_SIZE + PACKET_SIZE_MAX, 16)); | ||||
|     klog() << "RTL8139: RX buffer: " << PhysicalAddress(m_rx_buffer_addr); | ||||
| 
 | ||||
|     auto tx_buffer_addr = (uintptr_t)virtual_to_low_physical(kmalloc_aligned(TX_BUFFER_SIZE * 4, 16)); | ||||
|     auto tx_buffer_addr = (FlatPtr)virtual_to_low_physical(kmalloc_aligned(TX_BUFFER_SIZE * 4, 16)); | ||||
|     for (int i = 0; i < RTL8139_TX_BUFFER_COUNT; i++) { | ||||
|         m_tx_buffer_addr[i] = tx_buffer_addr + TX_BUFFER_SIZE * i; | ||||
|         klog() << "RTL8139: TX buffer " << i << ": "  << PhysicalAddress(m_tx_buffer_addr[i]); | ||||
|     } | ||||
| 
 | ||||
|     m_packet_buffer = (uintptr_t)kmalloc(PACKET_SIZE_MAX); | ||||
|     m_packet_buffer = (FlatPtr)kmalloc(PACKET_SIZE_MAX); | ||||
| 
 | ||||
|     reset(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling