Date: Thu, 23 Jul 2009 20:22:51 GMT From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166470 for review Message-ID: <200907232022.n6NKMpKH074697@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=166470 Change 166470 by gonzo@gonzo_figaro on 2009/07/23 20:22:08 - Replace overengineered version of power of 2 calcualtion with shift operator Affected files ... .. //depot/projects/avr32/src/sys/avr32/avr32/cache.c#5 edit Differences ... ==== //depot/projects/avr32/src/sys/avr32/avr32/cache.c#5 (text+ko) ==== @@ -112,21 +112,6 @@ u_int avr32_dcache_line_size; u_int avr32_dcache_ways; -/* XXX: there must be a library function for this? */ -u_int -pow(u_int base, u_int power) -{ - u_int i, result; - - if (power == 0) - return (1); - - result = base; - for (i = 1; i < power; i++) - result *= base; - return (result); -} - /* Set up the cache operations according to config. */ void avr32_config_cache(void) @@ -135,16 +120,16 @@ config = sysreg_read(CONFIG1); /* Read instruction cache parameters. */ - avr32_icache_size = pow(2, bit_value(SYS, CONFIG1, ISET, config)); - avr32_icache_line_size = pow(2, bit_value(SYS, CONFIG1, ILSZ, config) + - 1); - avr32_icache_ways = pow(2, bit_value(SYS, CONFIG1, IASS, config)); + avr32_icache_size = 1 << bit_value(SYS, CONFIG1, ISET, config); + avr32_icache_line_size = 1 << + (bit_value(SYS, CONFIG1, ILSZ, config) + 1); + avr32_icache_ways = 1 << bit_value(SYS, CONFIG1, IASS, config); /* Read data cache parameters. */ - avr32_dcache_size = pow(2, bit_value(SYS, CONFIG1, DSET, config)); - avr32_dcache_line_size = pow(2, bit_value(SYS, CONFIG1, DLSZ, config) + - 1); - avr32_dcache_ways = pow(2, bit_value(SYS, CONFIG1, DASS, config)); + avr32_dcache_size = 1 << bit_value(SYS, CONFIG1, DSET, config); + avr32_dcache_line_size = 1 << + (bit_value(SYS, CONFIG1, DLSZ, config) + 1); + avr32_dcache_ways = 1 << bit_value(SYS, CONFIG1, DASS, config); printf("ICACHE: sz %d lsz %d assoc %d\n", avr32_icache_size, avr32_icache_line_size, avr32_icache_ways); printf("DCACHE: sz %d lsz %d assoc %d\n", avr32_dcache_size,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907232022.n6NKMpKH074697>