E1000 - fixed reading/writing device registers
- the pointers must be flagged as volatile because otherwise they might be "optimized" by a compiler. It is a common good practice to access the registers this way, the keyword is in C for a reason. - for instance, in eeprom_eerd() when polling a register the compiler, under certain conditions, may decide upon the first read and if it does not break the loop it assumes that the value is not going to change and thus stays in an infinite loop.
This commit is contained in:
		
							parent
							
								
									170457b73f
								
							
						
					
					
						commit
						d75138be00
					
				@ -878,7 +878,7 @@ uint32_t reg;
 | 
			
		||||
    assert(reg < 0x1ffff);
 | 
			
		||||
 | 
			
		||||
    /* Read from memory mapped register. */
 | 
			
		||||
    value = *(u32_t *)(e->regs + reg);
 | 
			
		||||
    value = *(volatile u32_t *)(e->regs + reg);
 | 
			
		||||
 | 
			
		||||
    /* Return the result. */    
 | 
			
		||||
    return value;
 | 
			
		||||
@ -896,7 +896,7 @@ uint32_t value;
 | 
			
		||||
    assert(reg < 0x1ffff);
 | 
			
		||||
    
 | 
			
		||||
    /* Write to memory mapped register. */
 | 
			
		||||
    *(u32_t *)(e->regs + reg) = value;
 | 
			
		||||
    *(volatile u32_t *)(e->regs + reg) = value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user